OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/wm/core/coordinate_conversion.h" | 5 #include "ui/wm/core/coordinate_conversion.h" |
6 | 6 |
7 #include "ui/aura/client/screen_position_client.h" | 7 #include "ui/aura/client/screen_position_client.h" |
8 #include "ui/gfx/geometry/point.h" | 8 #include "ui/gfx/geometry/point.h" |
| 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/gfx/geometry/rect_conversions.h" |
| 11 #include "ui/gfx/geometry/rect_f.h" |
| 12 #include "ui/gfx/transform.h" |
9 | 13 |
10 namespace wm { | 14 namespace wm { |
11 | 15 |
12 void ConvertPointToScreen(const aura::Window* window, gfx::Point* point) { | 16 void ConvertPointToScreen(const aura::Window* window, gfx::Point* point) { |
13 DCHECK(window); | 17 DCHECK(window); |
14 DCHECK(window->GetRootWindow()); | 18 DCHECK(window->GetRootWindow()); |
15 DCHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); | 19 DCHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); |
16 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | 20 aura::client::GetScreenPositionClient(window->GetRootWindow())-> |
17 ConvertPointToScreen(window, point); | 21 ConvertPointToScreen(window, point); |
18 } | 22 } |
19 | 23 |
20 void ConvertPointFromScreen(const aura::Window* window, | 24 void ConvertPointFromScreen(const aura::Window* window, |
21 gfx::Point* point_in_screen) { | 25 gfx::Point* point_in_screen) { |
22 DCHECK(window); | 26 DCHECK(window); |
23 DCHECK(window->GetRootWindow()); | 27 DCHECK(window->GetRootWindow()); |
24 DCHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); | 28 DCHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); |
25 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | 29 aura::client::GetScreenPositionClient(window->GetRootWindow())-> |
26 ConvertPointFromScreen(window, point_in_screen); | 30 ConvertPointFromScreen(window, point_in_screen); |
27 } | 31 } |
28 | 32 |
| 33 void ConvertRectToScreen(const aura::Window* window, gfx::Rect* rect) { |
| 34 gfx::Point origin = rect->origin(); |
| 35 ConvertPointToScreen(window, &origin); |
| 36 rect->set_origin(origin); |
| 37 } |
| 38 |
| 39 void ConvertRectFromScreen(const aura::Window* window, |
| 40 gfx::Rect* rect_in_screen) { |
| 41 gfx::Point origin = rect_in_screen->origin(); |
| 42 ConvertPointFromScreen(window, &origin); |
| 43 rect_in_screen->set_origin(origin); |
| 44 } |
| 45 |
29 } // namespace wm | 46 } // namespace wm |
OLD | NEW |