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

Side by Side Diff: third_party/WebKit/Source/core/animation/CompositorPendingAnimations.cpp

Issue 2944423003: Implement new AnimationTimeline superclass (Closed)
Patch Set: Rebase Created 3 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 #include "core/page/Page.h" 37 #include "core/page/Page.h"
38 #include "platform/instrumentation/tracing/TraceEvent.h" 38 #include "platform/instrumentation/tracing/TraceEvent.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 void CompositorPendingAnimations::Add(Animation* animation) { 42 void CompositorPendingAnimations::Add(Animation* animation) {
43 DCHECK(animation); 43 DCHECK(animation);
44 DCHECK_EQ(pending_.Find(animation), kNotFound); 44 DCHECK_EQ(pending_.Find(animation), kNotFound);
45 pending_.push_back(animation); 45 pending_.push_back(animation);
46 46
47 Document* document = animation->timeline()->GetDocument(); 47 Document* document = animation->TimelineInternal()->GetDocument();
48 if (document->View()) 48 if (document->View())
49 document->View()->ScheduleAnimation(); 49 document->View()->ScheduleAnimation();
50 50
51 bool visible = document->GetPage() && document->GetPage()->IsPageVisible(); 51 bool visible = document->GetPage() && document->GetPage()->IsPageVisible();
52 if (!visible && !timer_.IsActive()) { 52 if (!visible && !timer_.IsActive()) {
53 timer_.StartOneShot(0, BLINK_FROM_HERE); 53 timer_.StartOneShot(0, BLINK_FROM_HERE);
54 } 54 }
55 } 55 }
56 56
57 bool CompositorPendingAnimations::Update( 57 bool CompositorPendingAnimations::Update(
(...skipping 19 matching lines...) Expand all
77 // Animations with a start time do not participate in compositor start-time 77 // Animations with a start time do not participate in compositor start-time
78 // grouping. 78 // grouping.
79 if (animation->PreCommit(animation->HasStartTime() ? 1 : compositor_group, 79 if (animation->PreCommit(animation->HasStartTime() ? 1 : compositor_group,
80 composited_element_ids, start_on_compositor)) { 80 composited_element_ids, start_on_compositor)) {
81 if (animation->HasActiveAnimationsOnCompositor() && 81 if (animation->HasActiveAnimationsOnCompositor() &&
82 !had_compositor_animation) { 82 !had_compositor_animation) {
83 started_synchronized_on_compositor = true; 83 started_synchronized_on_compositor = true;
84 } 84 }
85 85
86 if (animation->Playing() && !animation->HasStartTime() && 86 if (animation->Playing() && !animation->HasStartTime() &&
87 animation->timeline() && animation->timeline()->IsActive()) { 87 animation->TimelineInternal() &&
88 animation->TimelineInternal()->IsActive()) {
88 waiting_for_start_time.push_back(animation.Get()); 89 waiting_for_start_time.push_back(animation.Get());
89 } 90 }
90 } else { 91 } else {
91 deferred.push_back(animation); 92 deferred.push_back(animation);
92 } 93 }
93 } 94 }
94 95
95 // If any synchronized animations were started on the compositor, all 96 // If any synchronized animations were started on the compositor, all
96 // remaining synchronized animations need to wait for the synchronized 97 // remaining synchronized animations need to wait for the synchronized
97 // start time. Otherwise they may start immediately. 98 // start time. Otherwise they may start immediately.
98 if (started_synchronized_on_compositor) { 99 if (started_synchronized_on_compositor) {
99 for (auto& animation : waiting_for_start_time) { 100 for (auto& animation : waiting_for_start_time) {
100 if (!animation->HasStartTime()) { 101 if (!animation->HasStartTime()) {
101 waiting_for_compositor_animation_start_.push_back(animation); 102 waiting_for_compositor_animation_start_.push_back(animation);
102 } 103 }
103 } 104 }
104 } else { 105 } else {
105 for (auto& animation : waiting_for_start_time) { 106 for (auto& animation : waiting_for_start_time) {
106 if (!animation->HasStartTime()) { 107 if (!animation->HasStartTime()) {
107 animation->NotifyCompositorStartTime( 108 animation->NotifyCompositorStartTime(
108 animation->timeline()->CurrentTimeInternal()); 109 animation->TimelineInternal()->CurrentTimeInternal());
109 } 110 }
110 } 111 }
111 } 112 }
112 113
113 // FIXME: The postCommit should happen *after* the commit, not before. 114 // FIXME: The postCommit should happen *after* the commit, not before.
114 for (auto& animation : animations) 115 for (auto& animation : animations)
115 animation->PostCommit(animation->timeline()->CurrentTimeInternal()); 116 animation->PostCommit(animation->TimelineInternal()->CurrentTimeInternal());
116 117
117 DCHECK(pending_.IsEmpty()); 118 DCHECK(pending_.IsEmpty());
118 DCHECK(start_on_compositor || deferred.IsEmpty()); 119 DCHECK(start_on_compositor || deferred.IsEmpty());
119 for (auto& animation : deferred) 120 for (auto& animation : deferred)
120 animation->SetCompositorPending(); 121 animation->SetCompositorPending();
121 DCHECK_EQ(pending_.size(), deferred.size()); 122 DCHECK_EQ(pending_.size(), deferred.size());
122 123
123 if (started_synchronized_on_compositor) 124 if (started_synchronized_on_compositor)
124 return true; 125 return true;
125 126
(...skipping 17 matching lines...) Expand all
143 double monotonic_animation_start_time, 144 double monotonic_animation_start_time,
144 int compositor_group) { 145 int compositor_group) {
145 TRACE_EVENT0("blink", 146 TRACE_EVENT0("blink",
146 "CompositorPendingAnimations::notifyCompositorAnimationStarted"); 147 "CompositorPendingAnimations::notifyCompositorAnimationStarted");
147 HeapVector<Member<Animation>> animations; 148 HeapVector<Member<Animation>> animations;
148 animations.swap(waiting_for_compositor_animation_start_); 149 animations.swap(waiting_for_compositor_animation_start_);
149 150
150 for (auto animation : animations) { 151 for (auto animation : animations) {
151 if (animation->HasStartTime() || 152 if (animation->HasStartTime() ||
152 animation->PlayStateInternal() != Animation::kPending || 153 animation->PlayStateInternal() != Animation::kPending ||
153 !animation->timeline() || !animation->timeline()->IsActive()) { 154 !animation->TimelineInternal() ||
155 !animation->TimelineInternal()->IsActive()) {
154 // Already started or no longer relevant. 156 // Already started or no longer relevant.
155 continue; 157 continue;
156 } 158 }
157 if (compositor_group && animation->CompositorGroup() != compositor_group) { 159 if (compositor_group && animation->CompositorGroup() != compositor_group) {
158 // Still waiting. 160 // Still waiting.
159 waiting_for_compositor_animation_start_.push_back(animation); 161 waiting_for_compositor_animation_start_.push_back(animation);
160 continue; 162 continue;
161 } 163 }
162 animation->NotifyCompositorStartTime(monotonic_animation_start_time - 164 animation->NotifyCompositorStartTime(
163 animation->timeline()->ZeroTime()); 165 monotonic_animation_start_time -
166 animation->TimelineInternal()->ZeroTime());
164 } 167 }
165 } 168 }
166 169
167 DEFINE_TRACE(CompositorPendingAnimations) { 170 DEFINE_TRACE(CompositorPendingAnimations) {
168 visitor->Trace(pending_); 171 visitor->Trace(pending_);
169 visitor->Trace(waiting_for_compositor_animation_start_); 172 visitor->Trace(waiting_for_compositor_animation_start_);
170 } 173 }
171 174
172 } // namespace blink 175 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/BUILD.gn ('k') | third_party/WebKit/Source/core/animation/DocumentTimeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698