Chromium Code Reviews| Index: ui/gfx/font_render_params_linux.cc |
| diff --git a/ui/gfx/font_render_params_linux.cc b/ui/gfx/font_render_params_linux.cc |
| index f02636e8050c2da9466648995aada7952e1f09f6..a198358ecff6e279277157ba31cfa3d3a1ed7304 100644 |
| --- a/ui/gfx/font_render_params_linux.cc |
| +++ b/ui/gfx/font_render_params_linux.cc |
| @@ -23,6 +23,12 @@ namespace gfx { |
| namespace { |
| +#if defined(OS_CHROMEOS) |
| +// A device scale factor for an internal display (if any) |
| +// that is used to determine if subpixel positioning should be used. |
| +float device_scale_factor_for_internal_display = 1.0f; |
|
Alexei Svitkine (slow)
2014/08/21 15:36:38
Nit: add g_ prefix
|
| +#endif |
| + |
| // Keyed by hashes of FontRenderParamQuery structs from |
| // HashFontRenderParamsQuery(). |
| typedef base::MRUCache<uint32, FontRenderParams> Cache; |
| @@ -43,6 +49,14 @@ struct SynchronizedCache { |
| base::LazyInstance<SynchronizedCache>::Leaky g_synchronized_cache = |
| LAZY_INSTANCE_INITIALIZER; |
| +bool IsBrowserTextSubpixelPositioningEnabled() { |
| +#if defined(OS_CHROMEOS) |
| + return device_scale_factor_for_internal_display > 1.0f; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| // Converts Fontconfig FC_HINT_STYLE to FontRenderParams::Hinting. |
| FontRenderParams::Hinting ConvertFontconfigHintStyle(int hint_style) { |
| switch (hint_style) { |
| @@ -176,7 +190,6 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query, |
| if (delegate) |
| params = delegate->GetDefaultFontRenderParams(); |
| QueryFontconfig(query, ¶ms, family_out); |
| - |
| if (!params.antialiasing) { |
| // Cairo forces full hinting when antialiasing is disabled, since anything |
| // less than that looks awful; do the same here. Requesting subpixel |
| @@ -187,10 +200,11 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query, |
| } else { |
| // Fontconfig doesn't support configuring subpixel positioning; check a |
| // flag. |
| - params.subpixel_positioning = CommandLine::ForCurrentProcess()->HasSwitch( |
| + params.subpixel_positioning = |
| query.for_web_contents ? |
| - switches::kEnableWebkitTextSubpixelPositioning : |
| - switches::kEnableBrowserTextSubpixelPositioning); |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableWebkitTextSubpixelPositioning) : |
| + IsBrowserTextSubpixelPositioningEnabled(); |
| // To enable subpixel positioning, we need to disable hinting. |
| if (params.subpixel_positioning) |
| @@ -217,4 +231,10 @@ void ClearFontRenderParamsCacheForTest() { |
| synchronized_cache->cache.Clear(); |
| } |
| +#if defined(OS_CHROMEOS) |
| +void SetFontRenderParamsDeviceScaleFactor(float device_scale_factor) { |
| + device_scale_factor_for_internal_display = device_scale_factor; |
| +} |
| +#endif |
| + |
| } // namespace gfx |