Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: views/animation/screen_rotation_setter.cc

Issue 7273073: Animated Rotation (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Pulled unnecessary changes out of this CL Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "views/animation/screen_rotation_setter.h"
6
7 #include "ui/gfx/compositor/layer.h"
8 #include "ui/gfx/interpolated_transform.h"
9 #include "views/view.h"
10
11 namespace {
12
13 static int SymmetricRound(float x) {
14 return static_cast<int>(
15 x > 0
16 ? std::floor(x + 0.5f)
17 : std::ceil(x - 0.5f));
18 }
19
20 } // namespace
21
22 namespace views {
23
24 ScreenRotationSetter::ScreenRotationSetter(views::View* view)
25 : rotation_(NULL),
sky 2011/08/25 03:00:13 don't need rotation_
26 view_(view) {
27 }
28
29 void ScreenRotationSetter::Installed(ui::Layer* layer) OVERRIDE {
30 }
31
32 void ScreenRotationSetter::Uninstalled(ui::Layer* layer) OVERRIDE {
33 }
34
35 void ScreenRotationSetter::SetTransform(
36 ui::Layer* layer, const ui::Transform& transform) OVERRIDE {
37 float degrees;
38 if (!ui::InterpolatedTransform::FactorTRS(transform, NULL, &degrees, NULL))
39 return;
40
41 if (rotation_.get()) {
42 rotation_->UpdateTarget(SymmetricRound(degrees));
43 } else {
44 float old_degrees;
45 if (ui::InterpolatedTransform::FactorTRS(layer->transform(),
46 NULL, &old_degrees, NULL)) {
47 rotation_.reset(new views::ScreenRotation(view_,
48 SymmetricRound(old_degrees),
49 SymmetricRound(degrees)));
50 rotation_->set_listener(this);
51 }
52 }
53 }
54
55 void ScreenRotationSetter::SetBounds(
56 ui::Layer* layer, const gfx::Rect& bounds) {
sky 2011/08/25 03:00:13 nit: each param on its own line.
57 // Ignore bounds changes during an animation.
58 if (rotation_.get() && !rotation_->done())
59 return;
sky 2011/08/25 03:00:13 Don't you need to cache and apply the bounds chang
60 layer->SetBounds(bounds);
61 }
62
63 void ScreenRotationSetter::OnScreenRotationCompleted(
64 views::ScreenRotation* rotation) {
65 DCHECK(rotation_.get() == rotation);
sky 2011/08/25 03:00:13 nit: DCHECK_EQ
66 rotation_.reset();
67 }
68
69 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698