| 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" | 10 #include "ash/common/display/display_info.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 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)) { |
| 67 return gfx::Transform(); | 67 return gfx::Transform(); |
| 68 } | 68 } |
| 69 root_window->SetProperty(kRotationPropertyKey, info.GetActiveRotation()); | 69 root_window->SetProperty(kRotationPropertyKey, info.GetActiveRotation()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 float y_offset = insets.top() / device_scale_factor; | 121 float y_offset = insets.top() / device_scale_factor; |
| 122 transform.Translate(x_offset, y_offset); | 122 transform.Translate(x_offset, y_offset); |
| 123 } | 123 } |
| 124 float inverted_scale = 1.0f / ui_scale; | 124 float inverted_scale = 1.0f / ui_scale; |
| 125 transform.Scale(inverted_scale, inverted_scale); | 125 transform.Scale(inverted_scale, inverted_scale); |
| 126 return transform; | 126 return transform; |
| 127 } | 127 } |
| 128 | 128 |
| 129 gfx::Transform CreateMirrorTransform(const display::Display& display) { | 129 gfx::Transform CreateMirrorTransform(const display::Display& display) { |
| 130 gfx::Transform transform; | 130 gfx::Transform transform; |
| 131 transform.matrix().set3x3(-1, 0, 0, | 131 transform.matrix().set3x3(-1, 0, 0, 0, 1, 0, 0, 0, 1); |
| 132 0, 1, 0, | |
| 133 0, 0, 1); | |
| 134 transform.Translate(-display.size().width(), 0); | 132 transform.Translate(-display.size().width(), 0); |
| 135 return transform; | 133 return transform; |
| 136 } | 134 } |
| 137 | 135 |
| 138 // RootWindowTransformer for ash environment. | 136 // RootWindowTransformer for ash environment. |
| 139 class AshRootWindowTransformer : public RootWindowTransformer { | 137 class AshRootWindowTransformer : public RootWindowTransformer { |
| 140 public: | 138 public: |
| 141 AshRootWindowTransformer(aura::Window* root, const display::Display& display) | 139 AshRootWindowTransformer(aura::Window* root, const display::Display& display) |
| 142 : root_window_(root) { | 140 : root_window_(root) { |
| 143 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 141 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // pixel size (excluding overscan insets). | 215 // pixel size (excluding overscan insets). |
| 218 class MirrorRootWindowTransformer : public RootWindowTransformer { | 216 class MirrorRootWindowTransformer : public RootWindowTransformer { |
| 219 public: | 217 public: |
| 220 MirrorRootWindowTransformer(const DisplayInfo& source_display_info, | 218 MirrorRootWindowTransformer(const DisplayInfo& source_display_info, |
| 221 const DisplayInfo& mirror_display_info) { | 219 const DisplayInfo& mirror_display_info) { |
| 222 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); | 220 root_bounds_ = gfx::Rect(source_display_info.bounds_in_native().size()); |
| 223 gfx::Rect mirror_display_rect = | 221 gfx::Rect mirror_display_rect = |
| 224 gfx::Rect(mirror_display_info.bounds_in_native().size()); | 222 gfx::Rect(mirror_display_info.bounds_in_native().size()); |
| 225 | 223 |
| 226 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > | 224 bool letterbox = root_bounds_.width() * mirror_display_rect.height() > |
| 227 root_bounds_.height() * mirror_display_rect.width(); | 225 root_bounds_.height() * mirror_display_rect.width(); |
| 228 if (letterbox) { | 226 if (letterbox) { |
| 229 float mirror_scale_ratio = | 227 float mirror_scale_ratio = |
| 230 (static_cast<float>(root_bounds_.width()) / | 228 (static_cast<float>(root_bounds_.width()) / |
| 231 static_cast<float>(mirror_display_rect.width())); | 229 static_cast<float>(mirror_display_rect.width())); |
| 232 float inverted_scale = 1.0f / mirror_scale_ratio; | 230 float inverted_scale = 1.0f / mirror_scale_ratio; |
| 233 int margin = static_cast<int>( | 231 int margin = static_cast<int>((mirror_display_rect.height() - |
| 234 (mirror_display_rect.height() - | 232 root_bounds_.height() * inverted_scale) / |
| 235 root_bounds_.height() * inverted_scale) / 2); | 233 2); |
| 236 insets_.Set(0, margin, 0, margin); | 234 insets_.Set(0, margin, 0, margin); |
| 237 | 235 |
| 238 transform_.Translate(0, margin); | 236 transform_.Translate(0, margin); |
| 239 transform_.Scale(inverted_scale, inverted_scale); | 237 transform_.Scale(inverted_scale, inverted_scale); |
| 240 } else { | 238 } else { |
| 241 float mirror_scale_ratio = | 239 float mirror_scale_ratio = |
| 242 (static_cast<float>(root_bounds_.height()) / | 240 (static_cast<float>(root_bounds_.height()) / |
| 243 static_cast<float>(mirror_display_rect.height())); | 241 static_cast<float>(mirror_display_rect.height())); |
| 244 float inverted_scale = 1.0f / mirror_scale_ratio; | 242 float inverted_scale = 1.0f / mirror_scale_ratio; |
| 245 int margin = static_cast<int>( | 243 int margin = static_cast<int>((mirror_display_rect.width() - |
| 246 (mirror_display_rect.width() - | 244 root_bounds_.width() * inverted_scale) / |
| 247 root_bounds_.width() * inverted_scale) / 2); | 245 2); |
| 248 insets_.Set(margin, 0, margin, 0); | 246 insets_.Set(margin, 0, margin, 0); |
| 249 | 247 |
| 250 transform_.Translate(margin, 0); | 248 transform_.Translate(margin, 0); |
| 251 transform_.Scale(inverted_scale, inverted_scale); | 249 transform_.Scale(inverted_scale, inverted_scale); |
| 252 } | 250 } |
| 253 } | 251 } |
| 254 | 252 |
| 255 // aura::RootWindowTransformer overrides: | 253 // aura::RootWindowTransformer overrides: |
| 256 gfx::Transform GetTransform() const override { return transform_; } | 254 gfx::Transform GetTransform() const override { return transform_; } |
| 257 gfx::Transform GetInverseTransform() const override { | 255 gfx::Transform GetInverseTransform() const override { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 mirror_display_info); | 323 mirror_display_info); |
| 326 } | 324 } |
| 327 | 325 |
| 328 RootWindowTransformer* CreateRootWindowTransformerForUnifiedDesktop( | 326 RootWindowTransformer* CreateRootWindowTransformerForUnifiedDesktop( |
| 329 const gfx::Rect& screen_bounds, | 327 const gfx::Rect& screen_bounds, |
| 330 const display::Display& display) { | 328 const display::Display& display) { |
| 331 return new PartialBoundsRootWindowTransformer(screen_bounds, display); | 329 return new PartialBoundsRootWindowTransformer(screen_bounds, display); |
| 332 } | 330 } |
| 333 | 331 |
| 334 } // namespace ash | 332 } // namespace ash |
| OLD | NEW |