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

Unified Diff: ui/gfx/font_render_params_linux.cc

Issue 789583002: Updates subpixel positioning and hinting when DSF is changed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: linux fix Created 6 years 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.cc ('k') | ui/gfx/platform_font.h » ('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 34afe6fb3ade7ee4527acfd37aabb8d19626d96d..f4cd346e80fb8427a36bf5580e7361c00a705be8 100644
--- a/ui/gfx/font_render_params_linux.cc
+++ b/ui/gfx/font_render_params_linux.cc
@@ -61,9 +61,10 @@ struct SynchronizedCache {
base::LazyInstance<SynchronizedCache>::Leaky g_synchronized_cache =
LAZY_INSTANCE_INITIALIZER;
-bool IsBrowserTextSubpixelPositioningEnabled() {
+bool IsBrowserTextSubpixelPositioningEnabled(
+ const FontRenderParamsQuery& query) {
#if defined(OS_CHROMEOS)
- return device_scale_factor_for_internal_display > 1.0f;
+ return query.device_scale_factor > 1.0f;
#else
return false;
#endif
@@ -179,16 +180,22 @@ bool QueryFontconfig(const FontRenderParamsQuery& query,
// Serialize |query| into a string and hash it to a value suitable for use as a
// cache key.
uint32 HashFontRenderParamsQuery(const FontRenderParamsQuery& query) {
- return base::Hash(base::StringPrintf("%d|%d|%d|%d|%s",
- query.for_web_contents, query.pixel_size, query.point_size, query.style,
- JoinString(query.families, ',').c_str()));
+ return base::Hash(base::StringPrintf(
+ "%d|%d|%d|%d|%s|%f", query.for_web_contents, query.pixel_size,
+ query.point_size, query.style, JoinString(query.families, ',').c_str(),
+ query.device_scale_factor));
}
} // namespace
FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
std::string* family_out) {
- const uint32 hash = HashFontRenderParamsQuery(query);
+ FontRenderParamsQuery actual_query(query);
+#if defined(OS_CHROMEOS)
+ if (actual_query.device_scale_factor == 0)
+ actual_query.device_scale_factor = device_scale_factor_for_internal_display;
+#endif
+ const uint32 hash = HashFontRenderParamsQuery(actual_query);
SynchronizedCache* synchronized_cache = g_synchronized_cache.Pointer();
{
@@ -213,7 +220,7 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
const LinuxFontDelegate* delegate = LinuxFontDelegate::instance();
if (delegate)
params = delegate->GetDefaultFontRenderParams();
- QueryFontconfig(query, &params, family_out);
+ QueryFontconfig(actual_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
@@ -225,10 +232,10 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
// Fontconfig doesn't support configuring subpixel positioning; check a
// flag.
params.subpixel_positioning =
- query.for_web_contents ?
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableWebkitTextSubpixelPositioning) :
- IsBrowserTextSubpixelPositioningEnabled();
+ actual_query.for_web_contents
+ ? CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableWebkitTextSubpixelPositioning)
+ : IsBrowserTextSubpixelPositioningEnabled(actual_query);
// To enable subpixel positioning, we need to disable hinting.
if (params.subpixel_positioning)
@@ -236,8 +243,8 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
}
// Use the first family from the list if Fontconfig didn't suggest a family.
- if (family_out && family_out->empty() && !query.families.empty())
- *family_out = query.families[0];
+ if (family_out && family_out->empty() && !actual_query.families.empty())
+ *family_out = actual_query.families[0];
{
// Store the result. It's fine if this overwrites a result that was cached
@@ -257,6 +264,10 @@ void ClearFontRenderParamsCacheForTest() {
}
#if defined(OS_CHROMEOS)
+float GetFontRenderParamsDeviceScaleFactor() {
+ return device_scale_factor_for_internal_display;
+}
+
void SetFontRenderParamsDeviceScaleFactor(float device_scale_factor) {
device_scale_factor_for_internal_display = device_scale_factor;
}
« no previous file with comments | « ui/gfx/font_render_params.cc ('k') | ui/gfx/platform_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698