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..af31b3af5e4c8ca69cfb1364f7af1f130362bd07 100644 |
| --- a/ui/gfx/font_render_params_linux.cc |
| +++ b/ui/gfx/font_render_params_linux.cc |
| @@ -23,6 +23,13 @@ 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 |
| +// instead of hinting. |
|
Daniel Erat
2014/08/20 04:21:00
i'd remove "instead of hinting" here; i don't thin
oshima
2014/08/20 18:36:21
Done.
|
| +float device_scale_factor_for_internal_display = 1.0f; |
| +#endif |
| + |
| // Keyed by hashes of FontRenderParamQuery structs from |
| // HashFontRenderParamsQuery(). |
| typedef base::MRUCache<uint32, FontRenderParams> Cache; |
| @@ -43,6 +50,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 +191,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 +201,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 +232,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 |