OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/rotator/screen_rotation_animator.h" | 5 #include "ash/rotator/screen_rotation_animator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 int rotation_degree_offset, | 171 int rotation_degree_offset, |
172 gfx::Tween::Type tween_type, | 172 gfx::Tween::Type tween_type, |
173 bool should_scale) { | 173 bool should_scale) { |
174 aura::Window* root_window = Shell::GetInstance() | 174 aura::Window* root_window = Shell::GetInstance() |
175 ->window_tree_host_manager() | 175 ->window_tree_host_manager() |
176 ->GetRootWindowForDisplayId(display_id); | 176 ->GetRootWindowForDisplayId(display_id); |
177 | 177 |
178 const gfx::Display::Rotation initial_orientation = | 178 const gfx::Display::Rotation initial_orientation = |
179 GetCurrentRotation(display_id); | 179 GetCurrentRotation(display_id); |
180 | 180 |
181 const gfx::RectF original_screen_bounds = root_window->GetTargetBounds(); | 181 const gfx::Rect original_screen_bounds = root_window->GetTargetBounds(); |
182 // 180 degree rotations should animate clock-wise. | 182 // 180 degree rotations should animate clock-wise. |
183 const int rotation_factor = | 183 const int rotation_factor = |
184 (initial_orientation + 3) % 4 == new_rotation ? 1 : -1; | 184 (initial_orientation + 3) % 4 == new_rotation ? 1 : -1; |
185 | 185 |
186 scoped_ptr<ui::LayerTreeOwner> old_layer_tree = | 186 scoped_ptr<ui::LayerTreeOwner> old_layer_tree = |
187 wm::RecreateLayers(root_window); | 187 wm::RecreateLayers(root_window); |
188 | 188 |
189 // Add the cloned layer tree in to the root, so it will be rendered. | 189 // Add the cloned layer tree in to the root, so it will be rendered. |
190 root_window->layer()->Add(old_layer_tree->root()); | 190 root_window->layer()->Add(old_layer_tree->root()); |
191 root_window->layer()->StackAtTop(old_layer_tree->root()); | 191 root_window->layer()->StackAtTop(old_layer_tree->root()); |
192 | 192 |
193 scoped_ptr<LayerCleanupObserver> layer_cleanup_observer( | 193 scoped_ptr<LayerCleanupObserver> layer_cleanup_observer( |
194 new LayerCleanupObserver(old_layer_tree.Pass())); | 194 new LayerCleanupObserver(old_layer_tree.Pass())); |
195 | 195 |
196 Shell::GetInstance()->display_manager()->SetDisplayRotation( | 196 Shell::GetInstance()->display_manager()->SetDisplayRotation( |
197 display_id, new_rotation, source); | 197 display_id, new_rotation, source); |
198 | 198 |
199 const gfx::RectF rotated_screen_bounds = root_window->GetTargetBounds(); | 199 const gfx::Rect rotated_screen_bounds = root_window->GetTargetBounds(); |
200 const gfx::Point pivot = gfx::Point(rotated_screen_bounds.width() / 2, | 200 const gfx::Point pivot = gfx::Point(rotated_screen_bounds.width() / 2, |
201 rotated_screen_bounds.height() / 2); | 201 rotated_screen_bounds.height() / 2); |
202 | 202 |
203 gfx::Point3F new_layer_initial_scale = gfx::Point3F(1.0f, 1.0f, 1.0f); | 203 gfx::Point3F new_layer_initial_scale = gfx::Point3F(1.0f, 1.0f, 1.0f); |
204 gfx::Point3F old_layer_target_scale = gfx::Point3F(1.0f, 1.0f, 1.0f); | 204 gfx::Point3F old_layer_target_scale = gfx::Point3F(1.0f, 1.0f, 1.0f); |
205 | 205 |
206 if (should_scale) { | 206 if (should_scale) { |
207 new_layer_initial_scale = gfx::Point3F( | 207 new_layer_initial_scale = |
208 original_screen_bounds.width() / rotated_screen_bounds.width(), | 208 gfx::Point3F(static_cast<float>(original_screen_bounds.width()) / |
209 original_screen_bounds.height() / rotated_screen_bounds.height(), 1.0f); | 209 rotated_screen_bounds.width(), |
| 210 static_cast<float>(original_screen_bounds.height()) / |
| 211 rotated_screen_bounds.height(), |
| 212 1.0f); |
210 | 213 |
211 old_layer_target_scale = gfx::Point3F( | 214 old_layer_target_scale = |
212 rotated_screen_bounds.width() / original_screen_bounds.width(), | 215 gfx::Point3F(static_cast<float>(rotated_screen_bounds.width()) / |
213 rotated_screen_bounds.height() / original_screen_bounds.height(), 1.0f); | 216 original_screen_bounds.width(), |
| 217 static_cast<float>(rotated_screen_bounds.height()) / |
| 218 original_screen_bounds.height(), |
| 219 1.0f); |
214 } | 220 } |
215 | 221 |
216 // We must animate each non-cloned child layer individually because the cloned | 222 // We must animate each non-cloned child layer individually because the cloned |
217 // layer was added as a child to |root_window|'s layer so that it will be | 223 // layer was added as a child to |root_window|'s layer so that it will be |
218 // rendered. | 224 // rendered. |
219 // TODO(bruthig): Add a NOT_DRAWN layer in between the root_window's layer and | 225 // TODO(bruthig): Add a NOT_DRAWN layer in between the root_window's layer and |
220 // its current children so that we only need to initiate two | 226 // its current children so that we only need to initiate two |
221 // LayerAnimationSequences. One for the new layers and one for the old layer. | 227 // LayerAnimationSequences. One for the new layers and one for the old layer. |
222 for (ui::Layer* child_layer : root_window->layer()->children()) { | 228 for (ui::Layer* child_layer : root_window->layer()->children()) { |
223 // Skip the cloned layer because it has a different animation. | 229 // Skip the cloned layer because it has a different animation. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 RotateScreen(display_id_, new_rotation, source, | 325 RotateScreen(display_id_, new_rotation, source, |
320 base::TimeDelta::FromMilliseconds(kRotationDurationInMs), | 326 base::TimeDelta::FromMilliseconds(kRotationDurationInMs), |
321 rotation_degrees, 0 /* rotation_degree_offset */, | 327 rotation_degrees, 0 /* rotation_degree_offset */, |
322 gfx::Tween::FAST_OUT_LINEAR_IN, true /* should_scale */); | 328 gfx::Tween::FAST_OUT_LINEAR_IN, true /* should_scale */); |
323 } else { | 329 } else { |
324 NOTREACHED(); | 330 NOTREACHED(); |
325 } | 331 } |
326 } | 332 } |
327 | 333 |
328 } // namespace ash | 334 } // namespace ash |
OLD | NEW |