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

Unified Diff: ui/gfx/font_render_params_linux.cc

Issue 485873002: Enable subpixel positioning for internal display with dsf larger than 1.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/font_render_params.h ('k') | ui/gfx/font_render_params_linux_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+#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, &params, 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
« no previous file with comments | « ui/gfx/font_render_params.h ('k') | ui/gfx/font_render_params_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698