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..77f8ba4b6521da1bca6d830fb167b3050844622d 100644 |
--- a/ui/gfx/font_render_params_linux.cc |
+++ b/ui/gfx/font_render_params_linux.cc |
@@ -23,6 +23,17 @@ 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. |
+float device_scale_factor_for_internal_display = 1.0f; |
+ |
+// Minimum device scale factor to enable text subpixel positioining |
+// for internal display. |
+const float kMinDsfToEnableSubpixelPositioning = 1.2f; |
Daniel Erat
2014/08/19 22:32:25
forget if i sent my previous comment asking this:
oshima
2014/08/20 01:41:12
Done. I just removed const and use 1.0f as it's mo
|
+#endif |
+ |
// Keyed by hashes of FontRenderParamQuery structs from |
// HashFontRenderParamsQuery(). |
typedef base::MRUCache<uint32, FontRenderParams> Cache; |
@@ -43,6 +54,15 @@ 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 >= |
+ kMinDsfToEnableSubpixelPositioning; |
+#else |
+ return false; |
+#endif |
+} |
+ |
// Converts Fontconfig FC_HINT_STYLE to FontRenderParams::Hinting. |
FontRenderParams::Hinting ConvertFontconfigHintStyle(int hint_style) { |
switch (hint_style) { |
@@ -187,10 +207,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 +238,19 @@ void ClearFontRenderParamsCacheForTest() { |
synchronized_cache->cache.Clear(); |
} |
+#if defined(OS_CHROMEOS) |
+void SetDeviceScaleFactorForInternalDisplay(float device_scale_factor) { |
+ device_scale_factor_for_internal_display = device_scale_factor; |
+} |
+ |
+namespace test { |
+ |
+bool GetBrowserTextSubpixelPoisitioningEnabled() { |
+ return IsBrowserTextSubpixelPositioningEnabled(); |
+} |
+ |
+} // namespace test |
+ |
+#endif |
+ |
} // namespace gfx |