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: third_party/WebKit/Source/core/animation/Animation.h

Issue 2570503002: Avoid conditional Animation prefinalizers. (Closed)
Patch Set: rebased upto r437900 Created 4 years 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 | « no previous file | third_party/WebKit/Source/core/animation/Animation.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 class ExceptionState; 55 class ExceptionState;
56 class TreeScope; 56 class TreeScope;
57 57
58 class CORE_EXPORT Animation final : public EventTargetWithInlineData, 58 class CORE_EXPORT Animation final : public EventTargetWithInlineData,
59 public ActiveScriptWrappable, 59 public ActiveScriptWrappable,
60 public SuspendableObject, 60 public SuspendableObject,
61 public CompositorAnimationDelegate, 61 public CompositorAnimationDelegate,
62 public CompositorAnimationPlayerClient { 62 public CompositorAnimationPlayerClient {
63 DEFINE_WRAPPERTYPEINFO(); 63 DEFINE_WRAPPERTYPEINFO();
64 USING_GARBAGE_COLLECTED_MIXIN(Animation); 64 USING_GARBAGE_COLLECTED_MIXIN(Animation);
65 USING_PRE_FINALIZER(Animation, dispose);
66 65
67 public: 66 public:
68 enum AnimationPlayState { Unset, Idle, Pending, Running, Paused, Finished }; 67 enum AnimationPlayState { Unset, Idle, Pending, Running, Paused, Finished };
69 68
70 static Animation* create(AnimationEffectReadOnly*, AnimationTimeline*); 69 static Animation* create(AnimationEffectReadOnly*, AnimationTimeline*);
71 ~Animation(); 70 ~Animation();
72 void dispose(); 71 void dispose();
73 72
74 // Returns whether the animation is finished. 73 // Returns whether the animation is finished.
75 bool update(TimingUpdateReason); 74 bool update(TimingUpdateReason);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 bool maybeStartAnimationOnCompositor(); 154 bool maybeStartAnimationOnCompositor();
156 void cancelAnimationOnCompositor(); 155 void cancelAnimationOnCompositor();
157 void restartAnimationOnCompositor(); 156 void restartAnimationOnCompositor();
158 void cancelIncompatibleAnimationsOnCompositor(); 157 void cancelIncompatibleAnimationsOnCompositor();
159 bool hasActiveAnimationsOnCompositor(); 158 bool hasActiveAnimationsOnCompositor();
160 void setCompositorPending(bool effectChanged = false); 159 void setCompositorPending(bool effectChanged = false);
161 void notifyCompositorStartTime(double timelineTime); 160 void notifyCompositorStartTime(double timelineTime);
162 void notifyStartTime(double timelineTime); 161 void notifyStartTime(double timelineTime);
163 // CompositorAnimationPlayerClient implementation. 162 // CompositorAnimationPlayerClient implementation.
164 CompositorAnimationPlayer* compositorPlayer() const override { 163 CompositorAnimationPlayer* compositorPlayer() const override {
165 return m_compositorPlayer.get(); 164 return m_compositorPlayer ? m_compositorPlayer->player() : nullptr;
166 } 165 }
167 166
168 bool affects(const Element&, CSSPropertyID) const; 167 bool affects(const Element&, CSSPropertyID) const;
169 168
170 // Returns whether we should continue with the commit for this animation or 169 // Returns whether we should continue with the commit for this animation or
171 // wait until next commit. 170 // wait until next commit.
172 bool preCommit(int compositorGroup, bool startOnCompositor); 171 bool preCommit(int compositorGroup, bool startOnCompositor);
173 void postCommit(double timelineTime); 172 void postCommit(double timelineTime);
174 173
175 unsigned sequenceNumber() const { return m_sequenceNumber; } 174 unsigned sequenceNumber() const { return m_sequenceNumber; }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 TimingUpdateReason, 292 TimingUpdateReason,
294 CompositorPendingChange = SetCompositorPending); 293 CompositorPendingChange = SetCompositorPending);
295 ~PlayStateUpdateScope(); 294 ~PlayStateUpdateScope();
296 295
297 private: 296 private:
298 Member<Animation> m_animation; 297 Member<Animation> m_animation;
299 AnimationPlayState m_initialPlayState; 298 AnimationPlayState m_initialPlayState;
300 CompositorPendingChange m_compositorPendingChange; 299 CompositorPendingChange m_compositorPendingChange;
301 }; 300 };
302 301
302 // CompositorAnimationPlayer objects need to eagerly sever
303 // their connection to their Animation delegate; use a separate
304 // 'holder' on-heap object to accomplish that.
305 class CompositorAnimationPlayerHolder
306 : public GarbageCollectedFinalized<CompositorAnimationPlayerHolder> {
307 USING_PRE_FINALIZER(CompositorAnimationPlayerHolder, dispose);
308
309 public:
310 static CompositorAnimationPlayerHolder* create(Animation*);
311
312 void detach();
313
314 DEFINE_INLINE_TRACE() { visitor->trace(m_animation); }
315
316 CompositorAnimationPlayer* player() const {
317 return m_compositorPlayer.get();
318 }
319
320 private:
321 explicit CompositorAnimationPlayerHolder(Animation*);
322
323 void dispose();
324
325 std::unique_ptr<CompositorAnimationPlayer> m_compositorPlayer;
326 Member<Animation> m_animation;
327 };
328
303 // This mirrors the known compositor state. It is created when a compositor 329 // This mirrors the known compositor state. It is created when a compositor
304 // animation is started. Updated once the start time is known and each time 330 // animation is started. Updated once the start time is known and each time
305 // modifications are pushed to the compositor. 331 // modifications are pushed to the compositor.
306 std::unique_ptr<CompositorState> m_compositorState; 332 std::unique_ptr<CompositorState> m_compositorState;
307 bool m_compositorPending; 333 bool m_compositorPending;
308 int m_compositorGroup; 334 int m_compositorGroup;
309 335
310 std::unique_ptr<CompositorAnimationPlayer> m_compositorPlayer; 336 Member<CompositorAnimationPlayerHolder> m_compositorPlayer;
311 bool m_preFinalizerRegistered;
312 337
313 bool m_currentTimePending; 338 bool m_currentTimePending;
314 bool m_stateIsBeingUpdated; 339 bool m_stateIsBeingUpdated;
315 340
316 bool m_effectSuppressed; 341 bool m_effectSuppressed;
317 }; 342 };
318 343
319 } // namespace blink 344 } // namespace blink
320 345
321 #endif // Animation_h 346 #endif // Animation_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/animation/Animation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698