OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/host/transformer_helper.h" | 5 #include "ash/host/transformer_helper.h" |
6 | 6 |
7 #include "ash/host/ash_window_tree_host.h" | 7 #include "ash/host/ash_window_tree_host.h" |
8 #include "ash/host/root_window_transformer.h" | 8 #include "ash/host/root_window_transformer.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
11 #include "ui/compositor/dip_util.h" | 11 #include "ui/compositor/dip_util.h" |
12 #include "ui/gfx/geometry/insets.h" | 12 #include "ui/gfx/geometry/insets.h" |
13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/geometry/rect_f.h" | 14 #include "ui/gfx/geometry/rect_f.h" |
15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gfx/size_conversions.h" | 16 #include "ui/gfx/size_conversions.h" |
17 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
18 | 18 |
19 namespace ash { | 19 namespace ash { |
20 namespace { | 20 namespace { |
21 | 21 |
22 // A simple RootWindowTransformer without host insets. | 22 // A simple RootWindowTransformer without host insets. |
23 class SimpleRootWindowTransformer : public RootWindowTransformer { | 23 class SimpleRootWindowTransformer : public RootWindowTransformer { |
24 public: | 24 public: |
25 SimpleRootWindowTransformer(const aura::Window* root_window, | 25 SimpleRootWindowTransformer(const aura::Window* root_window, |
26 const gfx::Transform& transform) | 26 const gfx::Transform& transform) |
27 : root_window_(root_window), transform_(transform) {} | 27 : root_window_(root_window), transform_(transform) {} |
28 | 28 |
29 // RootWindowTransformer overrides: | 29 // RootWindowTransformer overrides: |
30 virtual gfx::Transform GetTransform() const OVERRIDE { return transform_; } | 30 virtual gfx::Transform GetTransform() const override { return transform_; } |
31 | 31 |
32 virtual gfx::Transform GetInverseTransform() const OVERRIDE { | 32 virtual gfx::Transform GetInverseTransform() const override { |
33 gfx::Transform invert; | 33 gfx::Transform invert; |
34 if (!transform_.GetInverse(&invert)) | 34 if (!transform_.GetInverse(&invert)) |
35 return transform_; | 35 return transform_; |
36 return invert; | 36 return invert; |
37 } | 37 } |
38 | 38 |
39 virtual gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const | 39 virtual gfx::Rect GetRootWindowBounds(const gfx::Size& host_size) const |
40 OVERRIDE { | 40 override { |
41 gfx::Rect bounds(host_size); | 41 gfx::Rect bounds(host_size); |
42 gfx::RectF new_bounds(ui::ConvertRectToDIP(root_window_->layer(), bounds)); | 42 gfx::RectF new_bounds(ui::ConvertRectToDIP(root_window_->layer(), bounds)); |
43 transform_.TransformRect(&new_bounds); | 43 transform_.TransformRect(&new_bounds); |
44 return gfx::Rect(gfx::ToFlooredSize(new_bounds.size())); | 44 return gfx::Rect(gfx::ToFlooredSize(new_bounds.size())); |
45 } | 45 } |
46 | 46 |
47 virtual gfx::Insets GetHostInsets() const OVERRIDE { return gfx::Insets(); } | 47 virtual gfx::Insets GetHostInsets() const override { return gfx::Insets(); } |
48 | 48 |
49 private: | 49 private: |
50 virtual ~SimpleRootWindowTransformer() {} | 50 virtual ~SimpleRootWindowTransformer() {} |
51 | 51 |
52 const aura::Window* root_window_; | 52 const aura::Window* root_window_; |
53 const gfx::Transform transform_; | 53 const gfx::Transform transform_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(SimpleRootWindowTransformer); | 55 DISALLOW_COPY_AND_ASSIGN(SimpleRootWindowTransformer); |
56 }; | 56 }; |
57 | 57 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 transform.Scale(1.0f / scale, 1.0f / scale); | 102 transform.Scale(1.0f / scale, 1.0f / scale); |
103 return transformer_->GetInverseTransform() * transform; | 103 return transformer_->GetInverseTransform() * transform; |
104 } | 104 } |
105 | 105 |
106 void TransformerHelper::UpdateWindowSize(const gfx::Size& host_size) { | 106 void TransformerHelper::UpdateWindowSize(const gfx::Size& host_size) { |
107 ash_host_->AsWindowTreeHost()->window()->SetBounds( | 107 ash_host_->AsWindowTreeHost()->window()->SetBounds( |
108 transformer_->GetRootWindowBounds(host_size)); | 108 transformer_->GetRootWindowBounds(host_size)); |
109 } | 109 } |
110 | 110 |
111 } // namespace ash | 111 } // namespace ash |
OLD | NEW |