Commit bc33fa4d authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Refactor DeviceScaleEnsuresTextQuality() in render_widget.cc

- Inline the function into the caller. The condition for Android and
  ChromeOS should not be in DeviceScaleEnsuresTextQuality() becuase
  we can't ensure text quality but just accept to sacrifice text
  quality for better compositing.

- Add a comment about keeping sync about the DSF threshold in
  cc/metrics/lcd_text_metrics_reporter.cc.

Bug: 642885
Change-Id: Idb58ebc21db32ded979b24c444497abff37c4a2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2155279Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761089}
parent 204ed1bf
...@@ -347,20 +347,6 @@ ui::TextInputMode ConvertWebTextInputMode(blink::WebTextInputMode mode) { ...@@ -347,20 +347,6 @@ ui::TextInputMode ConvertWebTextInputMode(blink::WebTextInputMode mode) {
return static_cast<ui::TextInputMode>(mode); return static_cast<ui::TextInputMode>(mode);
} }
// Returns true if the device scale is high enough that losing subpixel
// antialiasing won't have a noticeable effect on text quality.
static bool DeviceScaleEnsuresTextQuality(float device_scale_factor) {
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
// On Android, we never have subpixel antialiasing. On Chrome OS we prefer to
// composite all scrollers so that we get animated overlay scrollbars.
return true;
#else
// 1.5 is a common touchscreen tablet device scale factor. For such
// devices main thread antialiasing is a heavy burden.
return device_scale_factor >= 1.5f;
#endif
}
static bool ComputePreferCompositingToLCDText( static bool ComputePreferCompositingToLCDText(
CompositorDependencies* compositor_deps, CompositorDependencies* compositor_deps,
float device_scale_factor) { float device_scale_factor) {
...@@ -368,13 +354,25 @@ static bool ComputePreferCompositingToLCDText( ...@@ -368,13 +354,25 @@ static bool ComputePreferCompositingToLCDText(
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText))
return false; return false;
#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
// On Android, we never have subpixel antialiasing. On Chrome OS we prefer to
// composite all scrollers for better scrolling performance.
return true;
#else
// Prefer compositing if the device scale is high enough that losing subpixel
// antialiasing won't have a noticeable effect on text quality.
// Note: We should keep kHighDPIDeviceScaleFactorThreshold in
// cc/metrics/lcd_text_metrics_reporter.cc the same as the value below.
if (device_scale_factor >= 1.5f)
return true;
if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText))
return true; return true;
if (!compositor_deps->IsLcdTextEnabled()) if (!compositor_deps->IsLcdTextEnabled())
return true; return true;
if (base::FeatureList::IsEnabled(features::kPreferCompositingToLCDText)) if (base::FeatureList::IsEnabled(features::kPreferCompositingToLCDText))
return true; return true;
return DeviceScaleEnsuresTextQuality(device_scale_factor); return false;
#endif
} }
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment