| 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, ¶ms, family_out);
|
| + QueryFontconfig(actual_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
|
| @@ -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;
|
| }
|
|
|