| 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/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "ash/common/display/display_info.h" | |
| 11 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 12 #include "ash/host/root_window_transformer.h" | 11 #include "ash/host/root_window_transformer.h" |
| 13 #include "ash/magnifier/magnification_controller.h" | 12 #include "ash/magnifier/magnification_controller.h" |
| 14 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 15 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 16 #include "third_party/skia/include/core/SkMatrix44.h" | 15 #include "third_party/skia/include/core/SkMatrix44.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 18 #include "ui/aura/window_property.h" | 17 #include "ui/aura/window_property.h" |
| 19 #include "ui/compositor/dip_util.h" | 18 #include "ui/compositor/dip_util.h" |
| 20 #include "ui/display/display.h" | 19 #include "ui/display/display.h" |
| 20 #include "ui/display/manager/display_info.h" |
| 21 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
| 22 #include "ui/gfx/geometry/insets.h" | 22 #include "ui/gfx/geometry/insets.h" |
| 23 #include "ui/gfx/geometry/size_conversions.h" | 23 #include "ui/gfx/geometry/size_conversions.h" |
| 24 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
| 25 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" |
| 26 | 26 |
| 27 DECLARE_WINDOW_PROPERTY_TYPE(display::Display::Rotation); | 27 DECLARE_WINDOW_PROPERTY_TYPE(display::Display::Rotation); |
| 28 | 28 |
| 29 namespace ash { | 29 namespace ash { |
| 30 namespace { | 30 namespace { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 // TODO(oshima): Transformers should be able to adjust itself | 50 // TODO(oshima): Transformers should be able to adjust itself |
| 51 // when the device scale factor is changed, instead of | 51 // when the device scale factor is changed, instead of |
| 52 // precalculating the transform using fixed value. | 52 // precalculating the transform using fixed value. |
| 53 | 53 |
| 54 gfx::Transform CreateRotationTransform(aura::Window* root_window, | 54 gfx::Transform CreateRotationTransform(aura::Window* root_window, |
| 55 const display::Display& display) { | 55 const display::Display& display) { |
| 56 DisplayInfo info = | 56 ui::DisplayInfo info = |
| 57 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); | 57 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); |
| 58 | 58 |
| 59 // TODO(oshima): Add animation. (crossfade+rotation, or just cross-fade) | 59 // TODO(oshima): Add animation. (crossfade+rotation, or just cross-fade) |
| 60 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
| 61 // Windows 8 bots refused to resize the host window, and | 61 // Windows 8 bots refused to resize the host window, and |
| 62 // updating the transform results in incorrectly resizing | 62 // updating the transform results in incorrectly resizing |
| 63 // the root window. Don't apply the transform unless | 63 // the root window. Don't apply the transform unless |
| 64 // necessary so that unit tests pass on win8 bots. | 64 // necessary so that unit tests pass on win8 bots. |
| 65 if (info.GetActiveRotation() == | 65 if (info.GetActiveRotation() == |
| 66 root_window->GetProperty(kRotationPropertyKey)) { | 66 root_window->GetProperty(kRotationPropertyKey)) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 transform.Translate(-display.size().width(), 0); | 132 transform.Translate(-display.size().width(), 0); |
| 133 return transform; | 133 return transform; |
| 134 } | 134 } |
| 135 | 135 |
| 136 // RootWindowTransformer for ash environment. | 136 // RootWindowTransformer for ash environment. |
| 137 class AshRootWindowTransformer : public RootWindowTransformer { | 137 class AshRootWindowTransformer : public RootWindowTransformer { |
| 138 public: | 138 public: |
| 139 AshRootWindowTransformer(aura::Window* root, const display::Display& display) | 139 AshRootWindowTransformer(aura::Window* root, const display::Display& display) |
| 140 : root_window_(root) { | 140 : root_window_(root) { |
| 141 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 141 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 142 DisplayInfo info = display_manager->GetDisplayInfo(display.id()); | 142 ui::DisplayInfo info = display_manager->GetDisplayInfo(display.id()); |
| 143 host_insets_ = info.GetOverscanInsetsInPixel(); | 143 host_insets_ = info.GetOverscanInsetsInPixel(); |
| 144 root_window_ui_scale_ = info.GetEffectiveUIScale(); | 144 root_window_ui_scale_ = info.GetEffectiveUIScale(); |
| 145 root_window_bounds_transform_ = | 145 root_window_bounds_transform_ = |
| 146 CreateInsetsAndScaleTransform(host_insets_, | 146 CreateInsetsAndScaleTransform(host_insets_, |
| 147 display.device_scale_factor(), | 147 display.device_scale_factor(), |
| 148 root_window_ui_scale_) * | 148 root_window_ui_scale_) * |
| 149 CreateRotationTransform(root, display); | 149 CreateRotationTransform(root, display); |
| 150 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 150 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 151 switches::kAshEnableMirroredScreen)) { | 151 switches::kAshEnableMirroredScreen)) { |
| 152 // Apply the tranform that flips the screen image horizontally so that | 152 // Apply the tranform that flips the screen image horizontally so that |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 DISALLOW_COPY_AND_ASSIGN(AshRootWindowTransformer); | 209 DISALLOW_COPY_AND_ASSIGN(AshRootWindowTransformer); |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 // RootWindowTransformer for mirror root window. We simply copy the | 212 // RootWindowTransformer for mirror root window. We simply copy the |
| 213 // texture (bitmap) of the source display into the mirror window, so | 213 // texture (bitmap) of the source display into the mirror window, so |
| 214 // the root window bounds is the same as the source display's | 214 // the root window bounds is the same as the source display's |
| 215 // pixel size (excluding overscan insets). | 215 // pixel size (excluding overscan insets). |
| 216 class MirrorRootWindowTransformer : public RootWindowTransformer { | 216 class MirrorRootWindowTransformer : public RootWindowTransformer { |
| 217 public: | 217 public: |
| 218 MirrorRootWindowTransformer(const DisplayInfo& source_display_info, | 218 MirrorRootWindowTransformer(const ui::DisplayInfo& source_display_info, |
| 219 const DisplayInfo& mirror_display_info) { | 219 const ui::DisplayInfo& mirror_display_info) { |
| 220 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); | 220 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); |
| 221 gfx::Rect mirror_display_rect = | 221 gfx::Rect mirror_display_rect = |
| 222 gfx::Rect(mirror_display_info.bounds_in_native().size()); | 222 gfx::Rect(mirror_display_info.bounds_in_native().size()); |
| 223 | 223 |
| 224 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > | 224 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > |
| 225 root_bounds_.height() * mirror_display_rect.width(); | 225 root_bounds_.height() * mirror_display_rect.width(); |
| 226 if (letterbox) { | 226 if (letterbox) { |
| 227 float mirror_scale_ratio = | 227 float mirror_scale_ratio = |
| 228 (static_cast<float>(root_bounds_.width()) / | 228 (static_cast<float>(root_bounds_.width()) / |
| 229 static_cast<float>(mirror_display_rect.width())); | 229 static_cast<float>(mirror_display_rect.width())); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); | 272 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 class PartialBoundsRootWindowTransformer : public RootWindowTransformer { | 275 class PartialBoundsRootWindowTransformer : public RootWindowTransformer { |
| 276 public: | 276 public: |
| 277 PartialBoundsRootWindowTransformer(const gfx::Rect& screen_bounds, | 277 PartialBoundsRootWindowTransformer(const gfx::Rect& screen_bounds, |
| 278 const display::Display& display) { | 278 const display::Display& display) { |
| 279 display::Display unified_display = | 279 display::Display unified_display = |
| 280 display::Screen::GetScreen()->GetPrimaryDisplay(); | 280 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 281 DisplayInfo display_info = | 281 ui::DisplayInfo display_info = |
| 282 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); | 282 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); |
| 283 root_bounds_ = gfx::Rect(display_info.bounds_in_native().size()); | 283 root_bounds_ = gfx::Rect(display_info.bounds_in_native().size()); |
| 284 float scale = root_bounds_.height() / | 284 float scale = root_bounds_.height() / |
| 285 static_cast<float>(screen_bounds.height()) / | 285 static_cast<float>(screen_bounds.height()) / |
| 286 unified_display.device_scale_factor(); | 286 unified_display.device_scale_factor(); |
| 287 transform_.Scale(scale, scale); | 287 transform_.Scale(scale, scale); |
| 288 transform_.Translate(-SkIntToMScalar(display.bounds().x()), | 288 transform_.Translate(-SkIntToMScalar(display.bounds().x()), |
| 289 -SkIntToMScalar(display.bounds().y())); | 289 -SkIntToMScalar(display.bounds().y())); |
| 290 } | 290 } |
| 291 | 291 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 310 | 310 |
| 311 } // namespace | 311 } // namespace |
| 312 | 312 |
| 313 RootWindowTransformer* CreateRootWindowTransformerForDisplay( | 313 RootWindowTransformer* CreateRootWindowTransformerForDisplay( |
| 314 aura::Window* root, | 314 aura::Window* root, |
| 315 const display::Display& display) { | 315 const display::Display& display) { |
| 316 return new AshRootWindowTransformer(root, display); | 316 return new AshRootWindowTransformer(root, display); |
| 317 } | 317 } |
| 318 | 318 |
| 319 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( | 319 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( |
| 320 const DisplayInfo& source_display_info, | 320 const ui::DisplayInfo& source_display_info, |
| 321 const DisplayInfo& mirror_display_info) { | 321 const ui::DisplayInfo& mirror_display_info) { |
| 322 return new MirrorRootWindowTransformer(source_display_info, | 322 return new MirrorRootWindowTransformer(source_display_info, |
| 323 mirror_display_info); | 323 mirror_display_info); |
| 324 } | 324 } |
| 325 | 325 |
| 326 RootWindowTransformer* CreateRootWindowTransformerForUnifiedDesktop( | 326 RootWindowTransformer* CreateRootWindowTransformerForUnifiedDesktop( |
| 327 const gfx::Rect& screen_bounds, | 327 const gfx::Rect& screen_bounds, |
| 328 const display::Display& display) { | 328 const display::Display& display) { |
| 329 return new PartialBoundsRootWindowTransformer(screen_bounds, display); | 329 return new PartialBoundsRootWindowTransformer(screen_bounds, display); |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace ash | 332 } // namespace ash |
| OLD | NEW |