Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: content/renderer/render_view_linux.cc

Issue 10544103: Chromium change of sharing some WebKit API between Android/Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "content/renderer/render_view_impl.h"
6
7 #include "content/public/common/renderer_preferences.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderin g.h"
10
11 using WebKit::WebFontInfo;
12 using WebKit::WebFontRendering;
13
14 static SkPaint::Hinting RendererPreferencesToSkiaHinting(
15 const content::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 content::RENDERER_PREFERENCES_HINTING_NONE:
22 return SkPaint::kNo_Hinting;
23 case content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT:
24 case content::RENDERER_PREFERENCES_HINTING_SLIGHT:
25 case content::RENDERER_PREFERENCES_HINTING_MEDIUM:
26 case content::RENDERER_PREFERENCES_HINTING_FULL:
27 return SkPaint::kNormal_Hinting;
28 default:
29 NOTREACHED();
30 return SkPaint::kNormal_Hinting;
31 }
32 }
33
34 switch (prefs.hinting) {
35 case content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT:
36 return SkPaint::kNormal_Hinting;
37 case content::RENDERER_PREFERENCES_HINTING_NONE:
38 return SkPaint::kNo_Hinting;
39 case content::RENDERER_PREFERENCES_HINTING_SLIGHT:
40 return SkPaint::kSlight_Hinting;
41 case content::RENDERER_PREFERENCES_HINTING_MEDIUM:
42 return SkPaint::kNormal_Hinting;
43 case content::RENDERER_PREFERENCES_HINTING_FULL:
44 return SkPaint::kFull_Hinting;
45 default:
46 NOTREACHED();
47 return SkPaint::kNormal_Hinting;
48 }
49 }
50
51 static SkFontHost::LCDOrder RendererPreferencesToSkiaLCDOrder(
52 content::RendererPreferencesSubpixelRenderingEnum subpixel) {
53 switch (subpixel) {
54 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT:
55 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE:
56 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB:
57 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB:
58 return SkFontHost::kRGB_LCDOrder;
59 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR:
60 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR:
61 return SkFontHost::kBGR_LCDOrder;
62 default:
63 NOTREACHED();
64 return SkFontHost::kRGB_LCDOrder;
65 }
66 }
67
68 static SkFontHost::LCDOrientation
69 RendererPreferencesToSkiaLCDOrientation(
70 content::RendererPreferencesSubpixelRenderingEnum subpixel) {
71 switch (subpixel) {
72 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT:
73 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE:
74 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB:
75 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR:
76 return SkFontHost::kHorizontal_LCDOrientation;
77 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB:
78 case content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR:
79 return SkFontHost::kVertical_LCDOrientation;
80 default:
81 NOTREACHED();
82 return SkFontHost::kHorizontal_LCDOrientation;
83 }
84 }
85
86 static bool RendererPreferencesToAntiAliasFlag(
87 const content::RendererPreferences& prefs) {
88 return prefs.should_antialias_text;
89 }
90
91 static bool RendererPreferencesToSubpixelRenderingFlag(
92 const content::RendererPreferences& prefs) {
93 if (prefs.subpixel_rendering !=
94 content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT &&
95 prefs.subpixel_rendering !=
96 content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE) {
97 return true;
98 }
99 return false;
100 }
101
102 void RenderViewImpl::UpdateFontRenderingFromRendererPrefs() {
103 const content::RendererPreferences& prefs = renderer_preferences_;
104 WebFontRendering::setHinting(RendererPreferencesToSkiaHinting(prefs));
105 WebFontRendering::setLCDOrder(
106 RendererPreferencesToSkiaLCDOrder(prefs.subpixel_rendering));
107 WebFontRendering::setLCDOrientation(
108 RendererPreferencesToSkiaLCDOrientation(prefs.subpixel_rendering));
109 WebFontRendering::setAntiAlias(RendererPreferencesToAntiAliasFlag(prefs));
110 WebFontRendering::setSubpixelRendering(
111 RendererPreferencesToSubpixelRenderingFlag(prefs));
112 WebFontRendering::setSubpixelPositioning(prefs.use_subpixel_positioning);
113 WebFontInfo::setSubpixelPositioning(prefs.use_subpixel_positioning);
114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698