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