| 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/ash_root_window_transformer.h" | 5 #include "ash/ash_root_window_transformer.h" |
| 6 | 6 |
| 7 #include "ui/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
| 8 #include "ui/compositor/dip_util.h" | 8 #include "ui/compositor/dip_util.h" |
| 9 #include "ui/gfx/size_conversions.h" | 9 #include "ui/gfx/size_conversions.h" |
| 10 | 10 |
| 11 namespace ash { | 11 namespace ash { |
| 12 | 12 |
| 13 AshRootWindowTransformer::AshRootWindowTransformer( | 13 AshRootWindowTransformer::AshRootWindowTransformer( |
| 14 aura::RootWindow* root, | 14 aura::RootWindow* root, |
| 15 const gfx::Transform& transform, | 15 const gfx::Transform& transform, |
| 16 const gfx::Transform& inverted, | |
| 17 const gfx::Insets& host_insets, | 16 const gfx::Insets& host_insets, |
| 18 float root_window_scale) | 17 float root_window_scale) |
| 19 : root_window_(root), | 18 : root_window_(root), |
| 20 transform_(transform), | 19 transform_(transform), |
| 21 root_window_scale_(root_window_scale), | 20 root_window_scale_(root_window_scale), |
| 22 host_insets_(host_insets) { | 21 host_insets_(host_insets) { |
| 23 root_window_->layer()->SetForceRenderSurface(root_window_scale_ != 1.0f); | 22 root_window_->layer()->SetForceRenderSurface(root_window_scale_ != 1.0f); |
| 24 | 23 |
| 25 gfx::Transform translate; | 24 gfx::Transform translate; |
| 26 invert_transform_ = inverted; | |
| 27 invert_transform_.Scale(root_window_scale_, root_window_scale_); | |
| 28 | 25 |
| 29 if (host_insets.top() != 0 || host_insets.left() != 0) { | 26 if (host_insets.top() != 0 || host_insets.left() != 0) { |
| 30 float device_scale_factor = ui::GetDeviceScaleFactor(root_window_->layer()); | 27 float device_scale_factor = ui::GetDeviceScaleFactor(root_window_->layer()); |
| 31 float x_offset = host_insets.left() / device_scale_factor; | 28 float x_offset = host_insets.left() / device_scale_factor; |
| 32 float y_offset = host_insets.top() / device_scale_factor; | 29 float y_offset = host_insets.top() / device_scale_factor; |
| 33 translate.Translate(x_offset, y_offset); | 30 translate.Translate(x_offset, y_offset); |
| 34 invert_transform_.Translate(-x_offset, -y_offset); | |
| 35 } | 31 } |
| 36 float inverted_scale = 1.0f / root_window_scale_; | 32 float inverted_scale = 1.0f / root_window_scale_; |
| 37 translate.Scale(inverted_scale, inverted_scale); | 33 translate.Scale(inverted_scale, inverted_scale); |
| 34 transform_ = translate * transform; |
| 38 | 35 |
| 39 transform_ = translate * transform; | 36 CHECK(transform_.GetInverse(&invert_transform_)); |
| 40 } | 37 } |
| 41 | 38 |
| 42 gfx::Transform AshRootWindowTransformer::GetTransform() const { | 39 gfx::Transform AshRootWindowTransformer::GetTransform() const { |
| 43 return transform_; | 40 return transform_; |
| 44 } | 41 } |
| 45 | 42 |
| 46 gfx::Transform AshRootWindowTransformer::GetInverseTransform() const { | 43 gfx::Transform AshRootWindowTransformer::GetInverseTransform() const { |
| 47 return invert_transform_; | 44 return invert_transform_; |
| 48 } | 45 } |
| 49 | 46 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 // backing pixel when |root_window_scale_| is specified | 66 // backing pixel when |root_window_scale_| is specified |
| 70 // (850 height at 1.25 scale becomes 1062.5 for example.) | 67 // (850 height at 1.25 scale becomes 1062.5 for example.) |
| 71 return gfx::Rect(gfx::ToFlooredSize(new_bounds.size())); | 68 return gfx::Rect(gfx::ToFlooredSize(new_bounds.size())); |
| 72 } | 69 } |
| 73 | 70 |
| 74 gfx::Insets AshRootWindowTransformer::GetHostInsets() const { | 71 gfx::Insets AshRootWindowTransformer::GetHostInsets() const { |
| 75 return host_insets_; | 72 return host_insets_; |
| 76 } | 73 } |
| 77 | 74 |
| 78 } // namespace ash | 75 } // namespace ash |
| OLD | NEW |