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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window_tree_host.h" 5 #include "ui/aura/window_tree_host.h"
6 6
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "ui/aura/client/capture_client.h" 9 #include "ui/aura/client/capture_client.h"
10 #include "ui/aura/client/cursor_client.h" 10 #include "ui/aura/client/cursor_client.h"
(...skipping 16 matching lines...) Expand all
27 #include "ui/gfx/geometry/point_conversions.h" 27 #include "ui/gfx/geometry/point_conversions.h"
28 #include "ui/gfx/geometry/rect_conversions.h" 28 #include "ui/gfx/geometry/rect_conversions.h"
29 #include "ui/gfx/geometry/size_conversions.h" 29 #include "ui/gfx/geometry/size_conversions.h"
30 #include "ui/gfx/icc_profile.h" 30 #include "ui/gfx/icc_profile.h"
31 31
32 namespace aura { 32 namespace aura {
33 33
34 const char kWindowTreeHostForAcceleratedWidget[] = 34 const char kWindowTreeHostForAcceleratedWidget[] =
35 "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__"; 35 "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__";
36 36
37 float GetDeviceScaleFactorFromDisplay(Window* window) { 37 float GetDeviceScaleFactorFromScreen(Window* window) {
38 display::Display display = 38 return display::Screen::GetScreen()->GetScaleFactorForWindow(window);
39 display::Screen::GetScreen()->GetDisplayNearestWindow(window);
40 DCHECK(display.is_valid());
41 return display.device_scale_factor();
42 } 39 }
43 40
44 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
45 // WindowTreeHost, public: 42 // WindowTreeHost, public:
46 43
47 WindowTreeHost::~WindowTreeHost() { 44 WindowTreeHost::~WindowTreeHost() {
48 DCHECK(!compositor_) << "compositor must be destroyed before root window"; 45 DCHECK(!compositor_) << "compositor must be destroyed before root window";
49 if (owned_input_method_) { 46 if (owned_input_method_) {
50 delete input_method_; 47 delete input_method_;
51 input_method_ = nullptr; 48 input_method_ = nullptr;
52 } 49 }
53 } 50 }
54 51
55 // static 52 // static
56 WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget( 53 WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget(
57 gfx::AcceleratedWidget widget) { 54 gfx::AcceleratedWidget widget) {
58 return reinterpret_cast<WindowTreeHost*>( 55 return reinterpret_cast<WindowTreeHost*>(
59 ui::ViewProp::GetValue(widget, kWindowTreeHostForAcceleratedWidget)); 56 ui::ViewProp::GetValue(widget, kWindowTreeHostForAcceleratedWidget));
60 } 57 }
61 58
62 void WindowTreeHost::InitHost() { 59 void WindowTreeHost::InitHost() {
63 InitCompositor(); 60 InitCompositor();
64 UpdateRootWindowSize(GetBounds().size()); 61 UpdateRootWindowSize(GetBounds().size());
65 Env::GetInstance()->NotifyHostInitialized(this); 62 Env::GetInstance()->NotifyHostInitialized(this);
66 window()->Show(); 63 window()->Show();
67 } 64 }
68 65
69 void WindowTreeHost::InitCompositor() { 66 void WindowTreeHost::InitCompositor() {
70 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), 67 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromScreen(window()),
71 GetBounds().size()); 68 GetBounds().size());
72 compositor_->SetRootLayer(window()->layer()); 69 compositor_->SetRootLayer(window()->layer());
73 compositor_->SetDisplayColorSpace( 70 compositor_->SetDisplayColorSpace(
74 GetICCProfileForCurrentDisplay().GetColorSpace()); 71 GetICCProfileForCurrentDisplay().GetColorSpace());
75 } 72 }
76 73
77 void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) { 74 void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) {
78 observers_.AddObserver(observer); 75 observers_.AddObserver(observer);
79 } 76 }
80 77
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 267
271 void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) { 268 void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) {
272 TRACE_EVENT1("ui", "WindowTreeHost::OnHostMoved", 269 TRACE_EVENT1("ui", "WindowTreeHost::OnHostMoved",
273 "origin", new_location.ToString()); 270 "origin", new_location.ToString());
274 271
275 for (WindowTreeHostObserver& observer : observers_) 272 for (WindowTreeHostObserver& observer : observers_)
276 observer.OnHostMoved(this, new_location); 273 observer.OnHostMoved(this, new_location);
277 } 274 }
278 275
279 void WindowTreeHost::OnHostResized(const gfx::Size& new_size) { 276 void WindowTreeHost::OnHostResized(const gfx::Size& new_size) {
277 LOG(ERROR) << "WindowTreeHost::OnHostResized(" << new_size.ToString()
278 << ", DPI = " << GetDeviceScaleFactorFromScreen(window()) << ")";
279
280 gfx::Size adjusted_size(new_size); 280 gfx::Size adjusted_size(new_size);
281 adjusted_size.Enlarge(output_surface_padding_.width(), 281 adjusted_size.Enlarge(output_surface_padding_.width(),
282 output_surface_padding_.height()); 282 output_surface_padding_.height());
283 // The compositor should have the same size as the native root window host. 283 // The compositor should have the same size as the native root window host.
284 // Get the latest scale from display because it might have been changed. 284 // Get the latest scale from display because it might have been changed.
285 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), 285 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromScreen(window()),
286 adjusted_size); 286 adjusted_size);
287 287
288 gfx::Size layer_size = GetBounds().size(); 288 gfx::Size layer_size = GetBounds().size();
289 // The layer, and the observers should be notified of the 289 // The layer, and the observers should be notified of the
290 // transformed size of the root window. 290 // transformed size of the root window.
291 UpdateRootWindowSize(layer_size); 291 UpdateRootWindowSize(layer_size);
292 for (WindowTreeHostObserver& observer : observers_) 292 for (WindowTreeHostObserver& observer : observers_)
293 observer.OnHostResized(this); 293 observer.OnHostResized(this);
294 } 294 }
295 295
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 client::CursorClient* cursor_client = client::GetCursorClient(window()); 333 client::CursorClient* cursor_client = client::GetCursorClient(window());
334 if (cursor_client) { 334 if (cursor_client) {
335 const display::Display& display = 335 const display::Display& display =
336 display::Screen::GetScreen()->GetDisplayNearestWindow(window()); 336 display::Screen::GetScreen()->GetDisplayNearestWindow(window());
337 cursor_client->SetDisplay(display); 337 cursor_client->SetDisplay(display);
338 } 338 }
339 dispatcher()->OnCursorMovedToRootLocation(root_location); 339 dispatcher()->OnCursorMovedToRootLocation(root_location);
340 } 340 }
341 341
342 } // namespace aura 342 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698