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

Side by Side Diff: ui/aura/window_tree_host.cc

Issue 2524873002: Rename WindowTreeHost G|SetBounds to indicate they are in pixels. (Closed)
Patch Set: rebase Created 4 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 unified diff | Download patch
« no previous file with comments | « ui/aura/window_tree_host.h ('k') | ui/aura/window_tree_host_platform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // static 55 // static
56 WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget( 56 WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget(
57 gfx::AcceleratedWidget widget) { 57 gfx::AcceleratedWidget widget) {
58 return reinterpret_cast<WindowTreeHost*>( 58 return reinterpret_cast<WindowTreeHost*>(
59 ui::ViewProp::GetValue(widget, kWindowTreeHostForAcceleratedWidget)); 59 ui::ViewProp::GetValue(widget, kWindowTreeHostForAcceleratedWidget));
60 } 60 }
61 61
62 void WindowTreeHost::InitHost() { 62 void WindowTreeHost::InitHost() {
63 InitCompositor(); 63 InitCompositor();
64 UpdateRootWindowSize(GetBounds().size()); 64 UpdateRootWindowSize(GetBoundsInPixels().size());
65 Env::GetInstance()->NotifyHostInitialized(this); 65 Env::GetInstance()->NotifyHostInitialized(this);
66 window()->Show(); 66 window()->Show();
67 } 67 }
68 68
69 void WindowTreeHost::InitCompositor() { 69 void WindowTreeHost::InitCompositor() {
70 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), 70 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
71 GetBounds().size()); 71 GetBoundsInPixels().size());
72 compositor_->SetRootLayer(window()->layer()); 72 compositor_->SetRootLayer(window()->layer());
73 compositor_->SetDisplayColorSpace( 73 compositor_->SetDisplayColorSpace(
74 GetICCProfileForCurrentDisplay().GetColorSpace()); 74 GetICCProfileForCurrentDisplay().GetColorSpace());
75 } 75 }
76 76
77 void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) { 77 void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) {
78 observers_.AddObserver(observer); 78 observers_.AddObserver(observer);
79 } 79 }
80 80
81 void WindowTreeHost::RemoveObserver(WindowTreeHostObserver* observer) { 81 void WindowTreeHost::RemoveObserver(WindowTreeHostObserver* observer) {
82 observers_.RemoveObserver(observer); 82 observers_.RemoveObserver(observer);
83 } 83 }
84 84
85 ui::EventProcessor* WindowTreeHost::event_processor() { 85 ui::EventProcessor* WindowTreeHost::event_processor() {
86 return dispatcher(); 86 return dispatcher();
87 } 87 }
88 88
89 gfx::Transform WindowTreeHost::GetRootTransform() const { 89 gfx::Transform WindowTreeHost::GetRootTransform() const {
90 float scale = ui::GetDeviceScaleFactor(window()->layer()); 90 float scale = ui::GetDeviceScaleFactor(window()->layer());
91 gfx::Transform transform; 91 gfx::Transform transform;
92 transform.Scale(scale, scale); 92 transform.Scale(scale, scale);
93 transform *= window()->layer()->transform(); 93 transform *= window()->layer()->transform();
94 return transform; 94 return transform;
95 } 95 }
96 96
97 void WindowTreeHost::SetRootTransform(const gfx::Transform& transform) { 97 void WindowTreeHost::SetRootTransform(const gfx::Transform& transform) {
98 window()->SetTransform(transform); 98 window()->SetTransform(transform);
99 UpdateRootWindowSize(GetBounds().size()); 99 UpdateRootWindowSize(GetBoundsInPixels().size());
100 } 100 }
101 101
102 gfx::Transform WindowTreeHost::GetInverseRootTransform() const { 102 gfx::Transform WindowTreeHost::GetInverseRootTransform() const {
103 gfx::Transform invert; 103 gfx::Transform invert;
104 gfx::Transform transform = GetRootTransform(); 104 gfx::Transform transform = GetRootTransform();
105 if (!transform.GetInverse(&invert)) 105 if (!transform.GetInverse(&invert))
106 return transform; 106 return transform;
107 return invert; 107 return invert;
108 } 108 }
109 109
110 void WindowTreeHost::SetOutputSurfacePadding(const gfx::Insets& padding) { 110 void WindowTreeHost::SetOutputSurfacePadding(const gfx::Insets& padding) {
111 if (output_surface_padding_ == padding) 111 if (output_surface_padding_ == padding)
112 return; 112 return;
113 113
114 output_surface_padding_ = padding; 114 output_surface_padding_ = padding;
115 OnHostResized(GetBounds().size()); 115 OnHostResized(GetBoundsInPixels().size());
116 } 116 }
117 117
118 void WindowTreeHost::UpdateRootWindowSize(const gfx::Size& host_size) { 118 void WindowTreeHost::UpdateRootWindowSize(const gfx::Size& host_size) {
119 gfx::Rect bounds(output_surface_padding_.left(), 119 gfx::Rect bounds(output_surface_padding_.left(),
120 output_surface_padding_.top(), host_size.width(), 120 output_surface_padding_.top(), host_size.width(),
121 host_size.height()); 121 host_size.height());
122 float scale_factor = ui::GetDeviceScaleFactor(window()->layer()); 122 float scale_factor = ui::GetDeviceScaleFactor(window()->layer());
123 gfx::RectF new_bounds = 123 gfx::RectF new_bounds =
124 gfx::ScaleRect(gfx::RectF(bounds), 1.0f / scale_factor); 124 gfx::ScaleRect(gfx::RectF(bounds), 1.0f / scale_factor);
125 window()->layer()->transform().TransformRect(&new_bounds); 125 window()->layer()->transform().TransformRect(&new_bounds);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 void WindowTreeHost::OnHostResized(const gfx::Size& new_size) { 279 void WindowTreeHost::OnHostResized(const gfx::Size& new_size) {
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(GetDeviceScaleFactorFromDisplay(window()),
286 adjusted_size); 286 adjusted_size);
287 287
288 gfx::Size layer_size = GetBounds().size(); 288 gfx::Size layer_size = GetBoundsInPixels().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
296 void WindowTreeHost::OnHostWorkspaceChanged() { 296 void WindowTreeHost::OnHostWorkspaceChanged() {
297 for (WindowTreeHostObserver& observer : observers_) 297 for (WindowTreeHostObserver& observer : observers_)
298 observer.OnHostWorkspaceChanged(this); 298 observer.OnHostWorkspaceChanged(this);
(...skipping 34 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
« no previous file with comments | « ui/aura/window_tree_host.h ('k') | ui/aura/window_tree_host_platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698