| 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/ash_switches.h" |
| 9 #include "ash/display/display_info.h" | 10 #include "ash/display/display_info.h" |
| 10 #include "ash/display/display_manager.h" | 11 #include "ash/display/display_manager.h" |
| 11 #include "ash/host/root_window_transformer.h" | 12 #include "ash/host/root_window_transformer.h" |
| 12 #include "ash/magnifier/magnification_controller.h" | 13 #include "ash/magnifier/magnification_controller.h" |
| 13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 14 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/command_line.h" |
| 15 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 16 #include "third_party/skia/include/utils/SkMatrix44.h" | 18 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 18 #include "ui/aura/window_property.h" | 20 #include "ui/aura/window_property.h" |
| 19 #include "ui/compositor/dip_util.h" | 21 #include "ui/compositor/dip_util.h" |
| 20 #include "ui/gfx/display.h" | 22 #include "ui/gfx/display.h" |
| 21 #include "ui/gfx/insets.h" | 23 #include "ui/gfx/insets.h" |
| 22 #include "ui/gfx/size_conversions.h" | 24 #include "ui/gfx/size_conversions.h" |
| 23 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" |
| 24 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 if (insets.top() != 0 || insets.left() != 0) { | 117 if (insets.top() != 0 || insets.left() != 0) { |
| 116 float x_offset = insets.left() / device_scale_factor; | 118 float x_offset = insets.left() / device_scale_factor; |
| 117 float y_offset = insets.top() / device_scale_factor; | 119 float y_offset = insets.top() / device_scale_factor; |
| 118 transform.Translate(x_offset, y_offset); | 120 transform.Translate(x_offset, y_offset); |
| 119 } | 121 } |
| 120 float inverted_scale = 1.0f / ui_scale; | 122 float inverted_scale = 1.0f / ui_scale; |
| 121 transform.Scale(inverted_scale, inverted_scale); | 123 transform.Scale(inverted_scale, inverted_scale); |
| 122 return transform; | 124 return transform; |
| 123 } | 125 } |
| 124 | 126 |
| 127 gfx::Transform CreateMirrorTransform(const gfx::Display& display) { |
| 128 gfx::Transform transform; |
| 129 transform.matrix().set3x3(-1, 0, 0, |
| 130 0, 1, 0, |
| 131 0, 0, 1); |
| 132 transform.Translate(-display.size().width(), 0); |
| 133 return transform; |
| 134 } |
| 135 |
| 125 // RootWindowTransformer for ash environment. | 136 // RootWindowTransformer for ash environment. |
| 126 class AshRootWindowTransformer : public RootWindowTransformer { | 137 class AshRootWindowTransformer : public RootWindowTransformer { |
| 127 public: | 138 public: |
| 128 AshRootWindowTransformer(aura::Window* root, | 139 AshRootWindowTransformer(aura::Window* root, |
| 129 const gfx::Display& display) | 140 const gfx::Display& display) |
| 130 : root_window_(root) { | 141 : root_window_(root) { |
| 131 DisplayInfo info = Shell::GetInstance()->display_manager()-> | 142 DisplayInfo info = Shell::GetInstance()->display_manager()-> |
| 132 GetDisplayInfo(display.id()); | 143 GetDisplayInfo(display.id()); |
| 133 host_insets_ = info.GetOverscanInsetsInPixel(); | 144 host_insets_ = info.GetOverscanInsetsInPixel(); |
| 134 root_window_ui_scale_ = info.GetEffectiveUIScale(); | 145 root_window_ui_scale_ = info.GetEffectiveUIScale(); |
| 135 root_window_bounds_transform_ = | 146 root_window_bounds_transform_ = |
| 136 CreateInsetsAndScaleTransform(host_insets_, | 147 CreateInsetsAndScaleTransform(host_insets_, |
| 137 display.device_scale_factor(), | 148 display.device_scale_factor(), |
| 138 root_window_ui_scale_) * | 149 root_window_ui_scale_) * |
| 139 CreateRotationTransform(root, display); | 150 CreateRotationTransform(root, display); |
| 151 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 152 switches::kAshEnableMirroredScreen)) { |
| 153 // Apply the tranform that flips the screen image horizontally so that |
| 154 // the screen looks normal when reflected on a mirror. |
| 155 root_window_bounds_transform_ = |
| 156 root_window_bounds_transform_ * CreateMirrorTransform(display); |
| 157 } |
| 140 transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root); | 158 transform_ = root_window_bounds_transform_ * CreateMagnifierTransform(root); |
| 159 |
| 141 CHECK(transform_.GetInverse(&invert_transform_)); | 160 CHECK(transform_.GetInverse(&invert_transform_)); |
| 142 } | 161 } |
| 143 | 162 |
| 144 // aura::RootWindowTransformer overrides: | 163 // aura::RootWindowTransformer overrides: |
| 145 gfx::Transform GetTransform() const override { return transform_; } | 164 gfx::Transform GetTransform() const override { return transform_; } |
| 146 gfx::Transform GetInverseTransform() const override { | 165 gfx::Transform GetInverseTransform() const override { |
| 147 return invert_transform_; | 166 return invert_transform_; |
| 148 } | 167 } |
| 149 gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override { | 168 gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const override { |
| 150 gfx::Rect bounds(host_size); | 169 gfx::Rect bounds(host_size); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 282 } |
| 264 | 283 |
| 265 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( | 284 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( |
| 266 const DisplayInfo& source_display_info, | 285 const DisplayInfo& source_display_info, |
| 267 const DisplayInfo& mirror_display_info) { | 286 const DisplayInfo& mirror_display_info) { |
| 268 return new MirrorRootWindowTransformer(source_display_info, | 287 return new MirrorRootWindowTransformer(source_display_info, |
| 269 mirror_display_info); | 288 mirror_display_info); |
| 270 } | 289 } |
| 271 | 290 |
| 272 } // namespace ash | 291 } // namespace ash |
| OLD | NEW |