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