| 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" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } | 142 } |
| 143 | 143 |
| 144 // aura::RootWindowTransformer overrides: | 144 // aura::RootWindowTransformer overrides: |
| 145 virtual gfx::Transform GetTransform() const OVERRIDE { | 145 virtual gfx::Transform GetTransform() const override { |
| 146 return transform_; | 146 return transform_; |
| 147 } | 147 } |
| 148 virtual gfx::Transform GetInverseTransform() const OVERRIDE { | 148 virtual gfx::Transform GetInverseTransform() const override { |
| 149 return invert_transform_; | 149 return invert_transform_; |
| 150 } | 150 } |
| 151 virtual gfx::Rect GetRootWindowBounds( | 151 virtual gfx::Rect GetRootWindowBounds( |
| 152 const gfx::Size& host_size) const OVERRIDE { | 152 const gfx::Size& host_size) const override { |
| 153 gfx::Rect bounds(host_size); | 153 gfx::Rect bounds(host_size); |
| 154 bounds.Inset(host_insets_); | 154 bounds.Inset(host_insets_); |
| 155 bounds = ui::ConvertRectToDIP(root_window_->layer(), bounds); | 155 bounds = ui::ConvertRectToDIP(root_window_->layer(), bounds); |
| 156 gfx::RectF new_bounds(bounds); | 156 gfx::RectF new_bounds(bounds); |
| 157 root_window_bounds_transform_.TransformRect(&new_bounds); | 157 root_window_bounds_transform_.TransformRect(&new_bounds); |
| 158 // Apply |root_window_scale_| twice as the downscaling | 158 // Apply |root_window_scale_| twice as the downscaling |
| 159 // is already applied once in |SetTransformInternal()|. | 159 // is already applied once in |SetTransformInternal()|. |
| 160 // TODO(oshima): This is a bit ugly. Consider specifying | 160 // TODO(oshima): This is a bit ugly. Consider specifying |
| 161 // the pseudo host resolution instead. | 161 // the pseudo host resolution instead. |
| 162 new_bounds.Scale(root_window_ui_scale_ * root_window_ui_scale_); | 162 new_bounds.Scale(root_window_ui_scale_ * root_window_ui_scale_); |
| 163 // Ignore the origin because RootWindow's insets are handled by | 163 // Ignore the origin because RootWindow's insets are handled by |
| 164 // the transform. | 164 // the transform. |
| 165 // Floor the size because the bounds is no longer aligned to | 165 // Floor the size because the bounds is no longer aligned to |
| 166 // backing pixel when |root_window_scale_| is specified | 166 // backing pixel when |root_window_scale_| is specified |
| 167 // (850 height at 1.25 scale becomes 1062.5 for example.) | 167 // (850 height at 1.25 scale becomes 1062.5 for example.) |
| 168 return gfx::Rect(gfx::ToFlooredSize(new_bounds.size())); | 168 return gfx::Rect(gfx::ToFlooredSize(new_bounds.size())); |
| 169 } | 169 } |
| 170 | 170 |
| 171 virtual gfx::Insets GetHostInsets() const OVERRIDE { | 171 virtual gfx::Insets GetHostInsets() const override { |
| 172 return host_insets_; | 172 return host_insets_; |
| 173 } | 173 } |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 virtual ~AshRootWindowTransformer() {} | 176 virtual ~AshRootWindowTransformer() {} |
| 177 | 177 |
| 178 aura::Window* root_window_; | 178 aura::Window* root_window_; |
| 179 gfx::Transform transform_; | 179 gfx::Transform transform_; |
| 180 | 180 |
| 181 // The accurate representation of the inverse of the |transform_|. | 181 // The accurate representation of the inverse of the |transform_|. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 (mirror_display_rect.width() - | 231 (mirror_display_rect.width() - |
| 232 root_bounds_.width() * inverted_scale) / 2); | 232 root_bounds_.width() * inverted_scale) / 2); |
| 233 insets_.Set(margin, 0, margin, 0); | 233 insets_.Set(margin, 0, margin, 0); |
| 234 | 234 |
| 235 transform_.Translate(margin, 0); | 235 transform_.Translate(margin, 0); |
| 236 transform_.Scale(inverted_scale, inverted_scale); | 236 transform_.Scale(inverted_scale, inverted_scale); |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 // aura::RootWindowTransformer overrides: | 240 // aura::RootWindowTransformer overrides: |
| 241 virtual gfx::Transform GetTransform() const OVERRIDE { | 241 virtual gfx::Transform GetTransform() const override { |
| 242 return transform_; | 242 return transform_; |
| 243 } | 243 } |
| 244 virtual gfx::Transform GetInverseTransform() const OVERRIDE { | 244 virtual gfx::Transform GetInverseTransform() const override { |
| 245 gfx::Transform invert; | 245 gfx::Transform invert; |
| 246 CHECK(transform_.GetInverse(&invert)); | 246 CHECK(transform_.GetInverse(&invert)); |
| 247 return invert; | 247 return invert; |
| 248 } | 248 } |
| 249 virtual gfx::Rect GetRootWindowBounds( | 249 virtual gfx::Rect GetRootWindowBounds( |
| 250 const gfx::Size& host_size) const OVERRIDE { | 250 const gfx::Size& host_size) const override { |
| 251 return root_bounds_; | 251 return root_bounds_; |
| 252 } | 252 } |
| 253 virtual gfx::Insets GetHostInsets() const OVERRIDE { | 253 virtual gfx::Insets GetHostInsets() const override { |
| 254 return insets_; | 254 return insets_; |
| 255 } | 255 } |
| 256 | 256 |
| 257 private: | 257 private: |
| 258 virtual ~MirrorRootWindowTransformer() {} | 258 virtual ~MirrorRootWindowTransformer() {} |
| 259 | 259 |
| 260 gfx::Transform transform_; | 260 gfx::Transform transform_; |
| 261 gfx::Rect root_bounds_; | 261 gfx::Rect root_bounds_; |
| 262 gfx::Insets insets_; | 262 gfx::Insets insets_; |
| 263 | 263 |
| 264 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); | 264 DISALLOW_COPY_AND_ASSIGN(MirrorRootWindowTransformer); |
| 265 }; | 265 }; |
| 266 | 266 |
| 267 } // namespace | 267 } // namespace |
| 268 | 268 |
| 269 RootWindowTransformer* CreateRootWindowTransformerForDisplay( | 269 RootWindowTransformer* CreateRootWindowTransformerForDisplay( |
| 270 aura::Window* root, | 270 aura::Window* root, |
| 271 const gfx::Display& display) { | 271 const gfx::Display& display) { |
| 272 return new AshRootWindowTransformer(root, display); | 272 return new AshRootWindowTransformer(root, display); |
| 273 } | 273 } |
| 274 | 274 |
| 275 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( | 275 RootWindowTransformer* CreateRootWindowTransformerForMirroredDisplay( |
| 276 const DisplayInfo& source_display_info, | 276 const DisplayInfo& source_display_info, |
| 277 const DisplayInfo& mirror_display_info) { | 277 const DisplayInfo& mirror_display_info) { |
| 278 return new MirrorRootWindowTransformer(source_display_info, | 278 return new MirrorRootWindowTransformer(source_display_info, |
| 279 mirror_display_info); | 279 mirror_display_info); |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace ash | 282 } // namespace ash |
| OLD | NEW |