| 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/host/root_window_transformer.h" |
| 11 #include "ash/magnifier/magnification_controller.h" | 12 #include "ash/magnifier/magnification_controller.h" |
| 12 #include "ash/shell.h" | 13 #include "ash/shell.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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 float x_offset = insets.left() / device_scale_factor; | 116 float x_offset = insets.left() / device_scale_factor; |
| 117 float y_offset = insets.top() / device_scale_factor; | 117 float y_offset = insets.top() / device_scale_factor; |
| 118 transform.Translate(x_offset, y_offset); | 118 transform.Translate(x_offset, y_offset); |
| 119 } | 119 } |
| 120 float inverted_scale = 1.0f / ui_scale; | 120 float inverted_scale = 1.0f / ui_scale; |
| 121 transform.Scale(inverted_scale, inverted_scale); | 121 transform.Scale(inverted_scale, inverted_scale); |
| 122 return transform; | 122 return transform; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // RootWindowTransformer for ash environment. | 125 // RootWindowTransformer for ash environment. |
| 126 class AshRootWindowTransformer : public aura::RootWindowTransformer { | 126 class AshRootWindowTransformer : public RootWindowTransformer { |
| 127 public: | 127 public: |
| 128 AshRootWindowTransformer(aura::Window* root, | 128 AshRootWindowTransformer(aura::Window* root, |
| 129 const gfx::Display& display) | 129 const gfx::Display& display) |
| 130 : root_window_(root) { | 130 : root_window_(root) { |
| 131 DisplayInfo info = Shell::GetInstance()->display_manager()-> | 131 DisplayInfo info = Shell::GetInstance()->display_manager()-> |
| 132 GetDisplayInfo(display.id()); | 132 GetDisplayInfo(display.id()); |
| 133 host_insets_ = info.GetOverscanInsetsInPixel(); | 133 host_insets_ = info.GetOverscanInsetsInPixel(); |
| 134 root_window_ui_scale_ = info.GetEffectiveUIScale(); | 134 root_window_ui_scale_ = info.GetEffectiveUIScale(); |
| 135 root_window_bounds_transform_ = | 135 root_window_bounds_transform_ = |
| 136 CreateInsetsAndScaleTransform(host_insets_, | 136 CreateInsetsAndScaleTransform(host_insets_, |
| 137 display.device_scale_factor(), | 137 display.device_scale_factor(), |
| 138 root_window_ui_scale_) * | 138 root_window_ui_scale_) * |
| 139 CreateRotationTransform(root, display); | 139 CreateRotationTransform(root, display); |
| 140 transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root); | 140 transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root); |
| 141 CHECK(transform_.GetInverse(&invert_transform_)); | 141 CHECK(transform_.GetInverse(&invert_transform_)); |
| 142 | |
| 143 } | 142 } |
| 144 | 143 |
| 145 // aura::RootWindowTransformer overrides: | 144 // aura::RootWindowTransformer overrides: |
| 146 virtual gfx::Transform GetTransform() const OVERRIDE { | 145 virtual gfx::Transform GetTransform() const OVERRIDE { |
| 147 return transform_; | 146 return transform_; |
| 148 } | 147 } |
| 149 virtual gfx::Transform GetInverseTransform() const OVERRIDE { | 148 virtual gfx::Transform GetInverseTransform() const OVERRIDE { |
| 150 return invert_transform_; | 149 return invert_transform_; |
| 151 } | 150 } |
| 152 virtual gfx::Rect GetRootWindowBounds( | 151 virtual gfx::Rect GetRootWindowBounds( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 193 |
| 195 gfx::Insets host_insets_; | 194 gfx::Insets host_insets_; |
| 196 | 195 |
| 197 DISALLOW_COPY_AND_ASSIGN(AshRootWindowTransformer); | 196 DISALLOW_COPY_AND_ASSIGN(AshRootWindowTransformer); |
| 198 }; | 197 }; |
| 199 | 198 |
| 200 // RootWindowTransformer for mirror root window. We simply copy the | 199 // RootWindowTransformer for mirror root window. We simply copy the |
| 201 // texture (bitmap) of the source display into the mirror window, so | 200 // texture (bitmap) of the source display into the mirror window, so |
| 202 // the root window bounds is the same as the source display's | 201 // the root window bounds is the same as the source display's |
| 203 // pixel size (excluding overscan insets). | 202 // pixel size (excluding overscan insets). |
| 204 class MirrorRootWindowTransformer : public aura::RootWindowTransformer { | 203 class MirrorRootWindowTransformer : public RootWindowTransformer { |
| 205 public: | 204 public: |
| 206 MirrorRootWindowTransformer(const DisplayInfo& source_display_info, | 205 MirrorRootWindowTransformer(const DisplayInfo& source_display_info, |
| 207 const DisplayInfo& mirror_display_info) { | 206 const DisplayInfo& mirror_display_info) { |
| 208 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); | 207 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); |
| 209 gfx::Rect mirror_display_rect = | 208 gfx::Rect mirror_display_rect = |
| 210 gfx::Rect(mirror_display_info.bounds_in_native().size()); | 209 gfx::Rect(mirror_display_info.bounds_in_native().size()); |
| 211 | 210 |
| 212 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > | 211 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > |
| 213 root_bounds_.height() * mirror_display_rect.width(); | 212 root_bounds_.height() * mirror_display_rect.width(); |
| 214 if (letterbox) { | 213 if (letterbox) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 259 |
| 261 gfx::Transform transform_; | 260 gfx::Transform transform_; |
| 262 gfx::Rect root_bounds_; | 261 gfx::Rect root_bounds_; |
| 263 gfx::Insets insets_; | 262 gfx::Insets insets_; |
| 264 | 263 |
| 265 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); | 264 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); |
| 266 }; | 265 }; |
| 267 | 266 |
| 268 } // namespace | 267 } // namespace |
| 269 | 268 |
| 270 aura::RootWindowTransformer* CreateRootWindowTransformerForDisplay( | 269 RootWindowTransformer* CreateRootWindowTransformerForDisplay( |
| 271 aura::Window* root, | 270 aura::Window* root, |
| 272 const gfx::Display& display) { | 271 const gfx::Display& display) { |
| 273 return new AshRootWindowTransformer(root, display); | 272 return new AshRootWindowTransformer(root, display); |
| 274 } | 273 } |
| 275 | 274 |
| 276 aura::RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( | 275 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( |
| 277 const DisplayInfo& source_display_info, | 276 const DisplayInfo& source_display_info, |
| 278 const DisplayInfo& mirror_display_info) { | 277 const DisplayInfo& mirror_display_info) { |
| 279 return new MirrorRootWindowTransformer(source_display_info, | 278 return new MirrorRootWindowTransformer(source_display_info, |
| 280 mirror_display_info); | 279 mirror_display_info); |
| 281 } | 280 } |
| 282 | 281 |
| 283 } // namespace ash | 282 } // namespace ash |
| OLD | NEW |