Fix build break
[chromium-blink-merge.git] / content / renderer / render_view_linux.cc
blob43d8b43bf2e90cd911bb27c8f1f67bc2f76b9154
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/renderer/render_view_impl.h"
7 #include "content/public/common/renderer_preferences.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRendering.h"
10 using WebKit::WebFontRendering;
12 namespace content {
14 static SkPaint::Hinting RendererPreferencesToSkiaHinting(
15 const RendererPreferences& prefs) {
16 if (!prefs.should_antialias_text) {
17 // When anti-aliasing is off, GTK maps all non-zero hinting settings to
18 // 'Normal' hinting so we do the same. Otherwise, folks who have 'Slight'
19 // hinting selected will see readable text in everything expect Chromium.
20 switch (prefs.hinting) {
21 case RENDERER_PREFERENCES_HINTING_NONE:
22 return SkPaint::kNo_Hinting;
23 case RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT:
24 case RENDERER_PREFERENCES_HINTING_SLIGHT:
25 case RENDERER_PREFERENCES_HINTING_MEDIUM:
26 case RENDERER_PREFERENCES_HINTING_FULL:
27 return SkPaint::kNormal_Hinting;
28 default:
29 NOTREACHED();
30 return SkPaint::kNormal_Hinting;
34 switch (prefs.hinting) {
35 case RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT:
36 return SkPaint::kNormal_Hinting;
37 case RENDERER_PREFERENCES_HINTING_NONE:
38 return SkPaint::kNo_Hinting;
39 case RENDERER_PREFERENCES_HINTING_SLIGHT:
40 return SkPaint::kSlight_Hinting;
41 case RENDERER_PREFERENCES_HINTING_MEDIUM:
42 return SkPaint::kNormal_Hinting;
43 case RENDERER_PREFERENCES_HINTING_FULL:
44 return SkPaint::kFull_Hinting;
45 default:
46 NOTREACHED();
47 return SkPaint::kNormal_Hinting;
51 static SkFontHost::LCDOrder RendererPreferencesToSkiaLCDOrder(
52 RendererPreferencesSubpixelRenderingEnum subpixel) {
53 switch (subpixel) {
54 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT:
55 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE:
56 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB:
57 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB:
58 return SkFontHost::kRGB_LCDOrder;
59 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR:
60 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR:
61 return SkFontHost::kBGR_LCDOrder;
62 default:
63 NOTREACHED();
64 return SkFontHost::kRGB_LCDOrder;
68 static SkFontHost::LCDOrientation
69 RendererPreferencesToSkiaLCDOrientation(
70 RendererPreferencesSubpixelRenderingEnum subpixel) {
71 switch (subpixel) {
72 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT:
73 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE:
74 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB:
75 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR:
76 return SkFontHost::kHorizontal_LCDOrientation;
77 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB:
78 case RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR:
79 return SkFontHost::kVertical_LCDOrientation;
80 default:
81 NOTREACHED();
82 return SkFontHost::kHorizontal_LCDOrientation;
86 static bool RendererPreferencesToAntiAliasFlag(
87 const RendererPreferences& prefs) {
88 return prefs.should_antialias_text;
91 static bool RendererPreferencesToSubpixelRenderingFlag(
92 const RendererPreferences& prefs) {
93 if (prefs.subpixel_rendering !=
94 RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT &&
95 prefs.subpixel_rendering !=
96 RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE) {
97 return true;
99 return false;
102 void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
103 const RendererPreferences& prefs = renderer_preferences_;
104 WebFontRendering::setHinting(RendererPreferencesToSkiaHinting(prefs));
105 WebFontRendering::setAutoHint(prefs.use_autohinter);
106 WebFontRendering::setUseBitmaps(prefs.use_bitmaps);
107 WebFontRendering::setLCDOrder(
108 RendererPreferencesToSkiaLCDOrder(prefs.subpixel_rendering));
109 WebFontRendering::setLCDOrientation(
110 RendererPreferencesToSkiaLCDOrientation(prefs.subpixel_rendering));
111 WebFontRendering::setAntiAlias(RendererPreferencesToAntiAliasFlag(prefs));
112 WebFontRendering::setSubpixelRendering(
113 RendererPreferencesToSubpixelRenderingFlag(prefs));
114 WebFontRendering::setSubpixelPositioning(prefs.use_subpixel_positioning);
117 } // namespace content