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

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

Issue 2263453002: Use enclosing rect to find WindowTreeHost size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit test Created 4 years, 4 months 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/BUILD.gn ('k') | ui/aura/window_tree_host_unittest.cc » ('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"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_event_dispatcher.h" 13 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/aura/window_targeter.h" 14 #include "ui/aura/window_targeter.h"
15 #include "ui/aura/window_tree_host_observer.h" 15 #include "ui/aura/window_tree_host_observer.h"
16 #include "ui/base/ime/input_method.h" 16 #include "ui/base/ime/input_method.h"
17 #include "ui/base/ime/input_method_factory.h" 17 #include "ui/base/ime/input_method_factory.h"
18 #include "ui/base/view_prop.h" 18 #include "ui/base/view_prop.h"
19 #include "ui/compositor/dip_util.h" 19 #include "ui/compositor/dip_util.h"
20 #include "ui/compositor/layer.h" 20 #include "ui/compositor/layer.h"
21 #include "ui/display/display.h" 21 #include "ui/display/display.h"
22 #include "ui/display/screen.h" 22 #include "ui/display/screen.h"
23 #include "ui/gfx/geometry/insets.h" 23 #include "ui/gfx/geometry/insets.h"
24 #include "ui/gfx/geometry/point.h" 24 #include "ui/gfx/geometry/point.h"
25 #include "ui/gfx/geometry/point3_f.h" 25 #include "ui/gfx/geometry/point3_f.h"
26 #include "ui/gfx/geometry/point_conversions.h" 26 #include "ui/gfx/geometry/point_conversions.h"
27 #include "ui/gfx/geometry/rect_conversions.h"
27 #include "ui/gfx/geometry/size_conversions.h" 28 #include "ui/gfx/geometry/size_conversions.h"
28 29
29 namespace aura { 30 namespace aura {
30 31
31 const char kWindowTreeHostForAcceleratedWidget[] = 32 const char kWindowTreeHostForAcceleratedWidget[] =
32 "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__"; 33 "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__";
33 34
34 float GetDeviceScaleFactorFromDisplay(Window* window) { 35 float GetDeviceScaleFactorFromDisplay(Window* window) {
35 display::Display display = 36 display::Display display =
36 display::Screen::GetScreen()->GetDisplayNearestWindow(window); 37 display::Screen::GetScreen()->GetDisplayNearestWindow(window);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return; 108 return;
108 109
109 output_surface_padding_ = padding; 110 output_surface_padding_ = padding;
110 OnHostResized(GetBounds().size()); 111 OnHostResized(GetBounds().size());
111 } 112 }
112 113
113 void WindowTreeHost::UpdateRootWindowSize(const gfx::Size& host_size) { 114 void WindowTreeHost::UpdateRootWindowSize(const gfx::Size& host_size) {
114 gfx::Rect bounds(output_surface_padding_.left(), 115 gfx::Rect bounds(output_surface_padding_.left(),
115 output_surface_padding_.top(), host_size.width(), 116 output_surface_padding_.top(), host_size.width(),
116 host_size.height()); 117 host_size.height());
117 gfx::RectF new_bounds(ui::ConvertRectToDIP(window()->layer(), bounds)); 118 float scale_factor = ui::GetDeviceScaleFactor(window()->layer());
119 gfx::RectF new_bounds =
120 gfx::ScaleRect(gfx::RectF(bounds), 1.0f / scale_factor);
118 window()->layer()->transform().TransformRect(&new_bounds); 121 window()->layer()->transform().TransformRect(&new_bounds);
119 window()->SetBounds(gfx::Rect(gfx::ToFlooredPoint(new_bounds.origin()), 122 window()->SetBounds(gfx::ToEnclosingRect(new_bounds));
120 gfx::ToFlooredSize(new_bounds.size())));
121 } 123 }
122 124
123 void WindowTreeHost::ConvertPointToNativeScreen(gfx::Point* point) const { 125 void WindowTreeHost::ConvertPointToNativeScreen(gfx::Point* point) const {
124 ConvertPointToHost(point); 126 ConvertPointToHost(point);
125 gfx::Point location = GetLocationOnNativeScreen(); 127 gfx::Point location = GetLocationOnNativeScreen();
126 point->Offset(location.x(), location.y()); 128 point->Offset(location.x(), location.y());
127 } 129 }
128 130
129 void WindowTreeHost::ConvertPointFromNativeScreen(gfx::Point* point) const { 131 void WindowTreeHost::ConvertPointFromNativeScreen(gfx::Point* point) const {
130 gfx::Point location = GetLocationOnNativeScreen(); 132 gfx::Point location = GetLocationOnNativeScreen();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 client::CursorClient* cursor_client = client::GetCursorClient(window()); 321 client::CursorClient* cursor_client = client::GetCursorClient(window());
320 if (cursor_client) { 322 if (cursor_client) {
321 const display::Display& display = 323 const display::Display& display =
322 display::Screen::GetScreen()->GetDisplayNearestWindow(window()); 324 display::Screen::GetScreen()->GetDisplayNearestWindow(window());
323 cursor_client->SetDisplay(display); 325 cursor_client->SetDisplay(display);
324 } 326 }
325 dispatcher()->OnCursorMovedToRootLocation(root_location); 327 dispatcher()->OnCursorMovedToRootLocation(root_location);
326 } 328 }
327 329
328 } // namespace aura 330 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/BUILD.gn ('k') | ui/aura/window_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698