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

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

Issue 1700653002: CC Animation: Expose TargetProperty enum to be aliased in Blink Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 10 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
« no previous file with comments | « cc/animation/animation.h ('k') | cc/animation/animation_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/animation/animation.h" 5 #include "cc/animation/animation.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "cc/animation/animation_curve.h" 11 #include "cc/animation/animation_curve.h"
12 #include "cc/base/time_util.h" 12 #include "cc/base/time_util.h"
13 13
14 namespace { 14 namespace {
15 15
16 // This should match the RunState enum. 16 // This should match the RunState enum.
17 static const char* const s_runStateNames[] = {"WAITING_FOR_TARGET_AVAILABILITY", 17 static const char* const s_runStateNames[] = {"WAITING_FOR_TARGET_AVAILABILITY",
18 "WAITING_FOR_DELETION", 18 "WAITING_FOR_DELETION",
19 "STARTING", 19 "STARTING",
20 "RUNNING", 20 "RUNNING",
21 "PAUSED", 21 "PAUSED",
22 "FINISHED", 22 "FINISHED",
23 "ABORTED"}; 23 "ABORTED"};
24 24
25 static_assert(static_cast<int>(cc::Animation::LAST_RUN_STATE) + 1 == 25 static_assert(static_cast<int>(cc::Animation::LAST_RUN_STATE) + 1 ==
26 arraysize(s_runStateNames), 26 arraysize(s_runStateNames),
27 "RunStateEnumSize should equal the number of elements in " 27 "RunStateEnumSize should equal the number of elements in "
28 "s_runStateNames"); 28 "s_runStateNames");
29 29
30 // This should match the TargetProperty enum.
31 static const char* const s_targetPropertyNames[] = {"TRANSFORM",
32 "OPACITY",
33 "FILTER",
34 "SCROLL_OFFSET",
35 "BACKGROUND_COLOR"};
36
37 static_assert(static_cast<int>(cc::Animation::LAST_TARGET_PROPERTY) + 1 ==
38 arraysize(s_targetPropertyNames),
39 "TargetPropertyEnumSize should equal the number of elements in "
40 "s_targetPropertyNames");
41
42 } // namespace 30 } // namespace
43 31
44 namespace cc { 32 namespace cc {
45 33
46 scoped_ptr<Animation> Animation::Create( 34 scoped_ptr<Animation> Animation::Create(scoped_ptr<AnimationCurve> curve,
47 scoped_ptr<AnimationCurve> curve, 35 int animation_id,
48 int animation_id, 36 int group_id,
49 int group_id, 37 TargetProperty::Type target_property) {
50 TargetProperty target_property) {
51 return make_scoped_ptr( 38 return make_scoped_ptr(
52 new Animation(std::move(curve), animation_id, group_id, target_property)); 39 new Animation(std::move(curve), animation_id, group_id, target_property));
53 } 40 }
54 41
55 Animation::Animation(scoped_ptr<AnimationCurve> curve, 42 Animation::Animation(scoped_ptr<AnimationCurve> curve,
56 int animation_id, 43 int animation_id,
57 int group_id, 44 int group_id,
58 TargetProperty target_property) 45 TargetProperty::Type target_property)
59 : curve_(std::move(curve)), 46 : curve_(std::move(curve)),
60 id_(animation_id), 47 id_(animation_id),
61 group_(group_id), 48 group_(group_id),
62 target_property_(target_property), 49 target_property_(target_property),
63 run_state_(WAITING_FOR_TARGET_AVAILABILITY), 50 run_state_(WAITING_FOR_TARGET_AVAILABILITY),
64 iterations_(1), 51 iterations_(1),
65 iteration_start_(0), 52 iteration_start_(0),
66 direction_(DIRECTION_NORMAL), 53 direction_(DIRECTION_NORMAL),
67 playback_rate_(1), 54 playback_rate_(1),
68 fill_mode_(FILL_MODE_BOTH), 55 fill_mode_(FILL_MODE_BOTH),
69 needs_synchronized_start_time_(false), 56 needs_synchronized_start_time_(false),
70 received_finished_event_(false), 57 received_finished_event_(false),
71 suspended_(false), 58 suspended_(false),
72 is_controlling_instance_(false), 59 is_controlling_instance_(false),
73 is_impl_only_(false), 60 is_impl_only_(false),
74 affects_active_observers_(true), 61 affects_active_observers_(true),
75 affects_pending_observers_(true) {} 62 affects_pending_observers_(true) {}
76 63
77 Animation::~Animation() { 64 Animation::~Animation() {
78 if (run_state_ == RUNNING || run_state_ == PAUSED) 65 if (run_state_ == RUNNING || run_state_ == PAUSED)
79 SetRunState(ABORTED, base::TimeTicks()); 66 SetRunState(ABORTED, base::TimeTicks());
80 } 67 }
81 68
82 void Animation::SetRunState(RunState run_state, 69 void Animation::SetRunState(RunState run_state,
83 base::TimeTicks monotonic_time) { 70 base::TimeTicks monotonic_time) {
84 if (suspended_) 71 if (suspended_)
85 return; 72 return;
86 73
87 char name_buffer[256]; 74 char name_buffer[256];
88 base::snprintf(name_buffer, 75 base::snprintf(name_buffer, sizeof(name_buffer), "%s-%d",
89 sizeof(name_buffer), 76 TargetProperty::GetName(target_property_), group_);
90 "%s-%d",
91 s_targetPropertyNames[target_property_],
92 group_);
93 77
94 bool is_waiting_to_start = 78 bool is_waiting_to_start =
95 run_state_ == WAITING_FOR_TARGET_AVAILABILITY || run_state_ == STARTING; 79 run_state_ == WAITING_FOR_TARGET_AVAILABILITY || run_state_ == STARTING;
96 80
97 if (is_controlling_instance_ && is_waiting_to_start && run_state == RUNNING) { 81 if (is_controlling_instance_ && is_waiting_to_start && run_state == RUNNING) {
98 TRACE_EVENT_ASYNC_BEGIN1( 82 TRACE_EVENT_ASYNC_BEGIN1(
99 "cc", "Animation", this, "Name", TRACE_STR_COPY(name_buffer)); 83 "cc", "Animation", this, "Name", TRACE_STR_COPY(name_buffer));
100 } 84 }
101 85
102 bool was_finished = is_finished(); 86 bool was_finished = is_finished();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // the main thread. 261 // the main thread.
278 if (run_state_ == Animation::PAUSED || 262 if (run_state_ == Animation::PAUSED ||
279 other->run_state_ == Animation::PAUSED) { 263 other->run_state_ == Animation::PAUSED) {
280 other->run_state_ = run_state_; 264 other->run_state_ = run_state_;
281 other->pause_time_ = pause_time_; 265 other->pause_time_ = pause_time_;
282 other->total_paused_time_ = total_paused_time_; 266 other->total_paused_time_ = total_paused_time_;
283 } 267 }
284 } 268 }
285 269
286 } // namespace cc 270 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation.h ('k') | cc/animation/animation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698