OLD | NEW |
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 "ash/display/root_window_transformers.h" | 5 #include "ash/display/root_window_transformers.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
11 #include "ash/magnifier/magnification_controller.h" | 11 #include "ash/magnifier/magnification_controller.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/host/root_window_transformer.h" |
13 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "third_party/skia/include/utils/SkMatrix44.h" | 16 #include "third_party/skia/include/utils/SkMatrix44.h" |
16 #include "ui/aura/root_window_transformer.h" | |
17 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
18 #include "ui/aura/window_property.h" | 18 #include "ui/aura/window_property.h" |
19 #include "ui/compositor/dip_util.h" | 19 #include "ui/compositor/dip_util.h" |
20 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
21 #include "ui/gfx/insets.h" | 21 #include "ui/gfx/insets.h" |
22 #include "ui/gfx/size_conversions.h" | 22 #include "ui/gfx/size_conversions.h" |
23 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
24 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
25 | 25 |
26 DECLARE_WINDOW_PROPERTY_TYPE(gfx::Display::Rotation); | 26 DECLARE_WINDOW_PROPERTY_TYPE(gfx::Display::Rotation); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 float x_offset = insets.left() / device_scale_factor; | 117 float x_offset = insets.left() / device_scale_factor; |
118 float y_offset = insets.top() / device_scale_factor; | 118 float y_offset = insets.top() / device_scale_factor; |
119 transform.Translate(x_offset, y_offset); | 119 transform.Translate(x_offset, y_offset); |
120 } | 120 } |
121 float inverted_scale = 1.0f / ui_scale; | 121 float inverted_scale = 1.0f / ui_scale; |
122 transform.Scale(inverted_scale, inverted_scale); | 122 transform.Scale(inverted_scale, inverted_scale); |
123 return transform; | 123 return transform; |
124 } | 124 } |
125 | 125 |
126 // RootWindowTransformer for ash environment. | 126 // RootWindowTransformer for ash environment. |
127 class AshRootWindowTransformer : public aura::RootWindowTransformer { | 127 class AshRootWindowTransformer : public RootWindowTransformer { |
128 public: | 128 public: |
129 AshRootWindowTransformer(aura::Window* root, | 129 AshRootWindowTransformer(aura::Window* root, |
130 const gfx::Display& display) | 130 const gfx::Display& display) |
131 : root_window_(root) { | 131 : root_window_(root) { |
132 DisplayInfo info = Shell::GetInstance()->display_manager()-> | 132 DisplayInfo info = Shell::GetInstance()->display_manager()-> |
133 GetDisplayInfo(display.id()); | 133 GetDisplayInfo(display.id()); |
134 host_insets_ = info.GetOverscanInsetsInPixel(); | 134 host_insets_ = info.GetOverscanInsetsInPixel(); |
135 root_window_ui_scale_ = info.GetEffectiveUIScale(); | 135 root_window_ui_scale_ = info.GetEffectiveUIScale(); |
136 root_window_bounds_transform_ = | 136 root_window_bounds_transform_ = |
137 CreateInsetsAndScaleTransform(host_insets_, | 137 CreateInsetsAndScaleTransform(host_insets_, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 gfx::Insets host_insets_; | 196 gfx::Insets host_insets_; |
197 | 197 |
198 DISALLOW_COPY_AND_ASSIGN(AshRootWindowTransformer); | 198 DISALLOW_COPY_AND_ASSIGN(AshRootWindowTransformer); |
199 }; | 199 }; |
200 | 200 |
201 // RootWindowTransformer for mirror root window. We simply copy the | 201 // RootWindowTransformer for mirror root window. We simply copy the |
202 // texture (bitmap) of the source display into the mirror window, so | 202 // texture (bitmap) of the source display into the mirror window, so |
203 // the root window bounds is the same as the source display's | 203 // the root window bounds is the same as the source display's |
204 // pixel size (excluding overscan insets). | 204 // pixel size (excluding overscan insets). |
205 class MirrorRootWindowTransformer : public aura::RootWindowTransformer { | 205 class MirrorRootWindowTransformer : public RootWindowTransformer { |
206 public: | 206 public: |
207 MirrorRootWindowTransformer(const DisplayInfo& source_display_info, | 207 MirrorRootWindowTransformer(const DisplayInfo& source_display_info, |
208 const DisplayInfo& mirror_display_info) { | 208 const DisplayInfo& mirror_display_info) { |
209 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); | 209 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); |
210 gfx::Rect mirror_display_rect = | 210 gfx::Rect mirror_display_rect = |
211 gfx::Rect(mirror_display_info.bounds_in_native().size()); | 211 gfx::Rect(mirror_display_info.bounds_in_native().size()); |
212 | 212 |
213 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > | 213 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > |
214 root_bounds_.height() * mirror_display_rect.width(); | 214 root_bounds_.height() * mirror_display_rect.width(); |
215 if (letterbox) { | 215 if (letterbox) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 261 |
262 gfx::Transform transform_; | 262 gfx::Transform transform_; |
263 gfx::Rect root_bounds_; | 263 gfx::Rect root_bounds_; |
264 gfx::Insets insets_; | 264 gfx::Insets insets_; |
265 | 265 |
266 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); | 266 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); |
267 }; | 267 }; |
268 | 268 |
269 } // namespace | 269 } // namespace |
270 | 270 |
271 aura::RootWindowTransformer* CreateRootWindowTransformerForDisplay( | 271 RootWindowTransformer* CreateRootWindowTransformerForDisplay( |
272 aura::Window* root, | 272 aura::Window* root, |
273 const gfx::Display& display) { | 273 const gfx::Display& display) { |
274 return new AshRootWindowTransformer(root, display); | 274 return new AshRootWindowTransformer(root, display); |
275 } | 275 } |
276 | 276 |
277 aura::RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( | 277 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( |
278 const DisplayInfo& source_display_info, | 278 const DisplayInfo& source_display_info, |
279 const DisplayInfo& mirror_display_info) { | 279 const DisplayInfo& mirror_display_info) { |
280 return new MirrorRootWindowTransformer(source_display_info, | 280 return new MirrorRootWindowTransformer(source_display_info, |
281 mirror_display_info); | 281 mirror_display_info); |
282 } | 282 } |
283 | 283 |
284 } // namespace internal | 284 } // namespace internal |
285 } // namespace ash | 285 } // namespace ash |
OLD | NEW |