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

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

Issue 2188623006: Add pre finalizer to Animation to ensure compositor handles get cleaned up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove AnimationTimeline pre-finalizer Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/animation/AnimationTimeline.h ('k') | no next file » | 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 AnimationTimeline::AnimationTimeline(Document* document, PlatformTiming* timing) 68 AnimationTimeline::AnimationTimeline(Document* document, PlatformTiming* timing)
69 : m_document(document) 69 : m_document(document)
70 , m_zeroTime(0) // 0 is used by unit tests which cannot initialize from the loader 70 , m_zeroTime(0) // 0 is used by unit tests which cannot initialize from the loader
71 , m_zeroTimeInitialized(false) 71 , m_zeroTimeInitialized(false)
72 , m_outdatedAnimationCount(0) 72 , m_outdatedAnimationCount(0)
73 , m_playbackRate(1) 73 , m_playbackRate(1)
74 , m_lastCurrentTimeInternal(0) 74 , m_lastCurrentTimeInternal(0)
75 { 75 {
76 ThreadState::current()->registerPreFinalizer(this);
77 if (!timing) 76 if (!timing)
78 m_timing = new AnimationTimelineTiming(this); 77 m_timing = new AnimationTimelineTiming(this);
79 else 78 else
80 m_timing = timing; 79 m_timing = timing;
81 80
82 if (Platform::current()->isThreadedAnimationEnabled()) 81 if (Platform::current()->isThreadedAnimationEnabled())
83 m_compositorTimeline = CompositorAnimationTimeline::create(); 82 m_compositorTimeline = CompositorAnimationTimeline::create();
84 83
85 ASSERT(document); 84 ASSERT(document);
86 } 85 }
87 86
88 AnimationTimeline::~AnimationTimeline() 87 AnimationTimeline::~AnimationTimeline()
89 { 88 {
90 }
91
92 void AnimationTimeline::dispose()
93 {
94 // The Animation objects depend on using this AnimationTimeline to 89 // The Animation objects depend on using this AnimationTimeline to
95 // unregister from its underlying compositor timeline. To arrange 90 // unregister from its underlying compositor timeline.
96 // for that safely, this dispose() method will return first
97 // during prefinalization, notifying each Animation object of
98 // impending destruction.
99 for (const auto& animation : m_animations) 91 for (const auto& animation : m_animations)
100 animation->dispose(); 92 animation->dispose();
haraken 2016/07/28 12:04:26 I was assuming that we can entirely stop calling a
101 } 93 }
102 94
103 bool AnimationTimeline::isActive() 95 bool AnimationTimeline::isActive()
104 { 96 {
105 return m_document && m_document->page(); 97 return m_document && m_document->page();
106 } 98 }
107 99
108 void AnimationTimeline::animationAttached(Animation& animation) 100 void AnimationTimeline::animationAttached(Animation& animation)
109 { 101 {
110 ASSERT(animation.timeline() == this); 102 ASSERT(animation.timeline() == this);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 347
356 DEFINE_TRACE(AnimationTimeline) 348 DEFINE_TRACE(AnimationTimeline)
357 { 349 {
358 visitor->trace(m_document); 350 visitor->trace(m_document);
359 visitor->trace(m_timing); 351 visitor->trace(m_timing);
360 visitor->trace(m_animationsNeedingUpdate); 352 visitor->trace(m_animationsNeedingUpdate);
361 visitor->trace(m_animations); 353 visitor->trace(m_animations);
362 } 354 }
363 355
364 } // namespace blink 356 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/AnimationTimeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698