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

Unified Diff: ui/aura/window_tree_host.cc

Issue 2510793002: Use actual value of display scale factor from GetMonitorScaleFactor().
Patch Set: Created 4 years, 1 month 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
Index: ui/aura/window_tree_host.cc
diff --git a/ui/aura/window_tree_host.cc b/ui/aura/window_tree_host.cc
index ef626257d735d2d0a96387217a894573dfe41d8b..048a9758709fe277ebb46eb9ff6cabda3e24491f 100644
--- a/ui/aura/window_tree_host.cc
+++ b/ui/aura/window_tree_host.cc
@@ -34,11 +34,8 @@ namespace aura {
const char kWindowTreeHostForAcceleratedWidget[] =
"__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__";
-float GetDeviceScaleFactorFromDisplay(Window* window) {
- display::Display display =
- display::Screen::GetScreen()->GetDisplayNearestWindow(window);
- DCHECK(display.is_valid());
- return display.device_scale_factor();
+float GetDeviceScaleFactorFromScreen(Window* window) {
+ return display::Screen::GetScreen()->GetScaleFactorForWindow(window);
}
////////////////////////////////////////////////////////////////////////////////
@@ -67,7 +64,7 @@ void WindowTreeHost::InitHost() {
}
void WindowTreeHost::InitCompositor() {
- compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
+ compositor_->SetScaleAndSize(GetDeviceScaleFactorFromScreen(window()),
GetBounds().size());
compositor_->SetRootLayer(window()->layer());
compositor_->SetDisplayColorSpace(
@@ -277,12 +274,15 @@ void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) {
}
void WindowTreeHost::OnHostResized(const gfx::Size& new_size) {
+ LOG(ERROR) << "WindowTreeHost::OnHostResized(" << new_size.ToString()
+ << ", DPI = " << GetDeviceScaleFactorFromScreen(window()) << ")";
+
gfx::Size adjusted_size(new_size);
adjusted_size.Enlarge(output_surface_padding_.width(),
output_surface_padding_.height());
// The compositor should have the same size as the native root window host.
// Get the latest scale from display because it might have been changed.
- compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
+ compositor_->SetScaleAndSize(GetDeviceScaleFactorFromScreen(window()),
adjusted_size);
gfx::Size layer_size = GetBounds().size();

Powered by Google App Engine
This is Rietveld 408576698