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

Side by Side Diff: third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp

Issue 2204183002: Prepare CompositorWorker for per thread heap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 3 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/web/CompositorProxyClientImpl.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "web/CompositorProxyClientImpl.h" 5 #include "web/CompositorProxyClientImpl.h"
6 6
7 #include "core/dom/CompositorProxy.h" 7 #include "core/dom/CompositorProxy.h"
8 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" 8 #include "modules/compositorworker/CompositorWorkerGlobalScope.h"
9 #include "platform/TraceEvent.h" 9 #include "platform/TraceEvent.h"
10 #include "platform/graphics/CompositorMutableStateProvider.h" 10 #include "platform/graphics/CompositorMutableStateProvider.h"
(...skipping 22 matching lines...) Expand all
33 proxy->takeCompositorMutableState(nullptr); 33 proxy->takeCompositorMutableState(nullptr);
34 } 34 }
35 private: 35 private:
36 HeapHashSet<WeakMember<CompositorProxy>>& m_proxies; 36 HeapHashSet<WeakMember<CompositorProxy>>& m_proxies;
37 }; 37 };
38 38
39 CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* muta tor) 39 CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* muta tor)
40 : m_mutator(mutator) 40 : m_mutator(mutator)
41 , m_globalScope(nullptr) 41 , m_globalScope(nullptr)
42 { 42 {
43 DCHECK(isMainThread());
43 } 44 }
44 45
45 DEFINE_TRACE(CompositorProxyClientImpl) 46 DEFINE_TRACE(CompositorProxyClientImpl)
46 { 47 {
47 CompositorProxyClient::trace(visitor); 48 CompositorProxyClient::trace(visitor);
48 visitor->trace(m_mutator);
49 visitor->trace(m_globalScope);
50 visitor->trace(m_proxies); 49 visitor->trace(m_proxies);
51 } 50 }
52 51
53 void CompositorProxyClientImpl::setGlobalScope(WorkerGlobalScope* scope) 52 void CompositorProxyClientImpl::setGlobalScope(WorkerGlobalScope* scope)
54 { 53 {
55 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::setGlobalScope "); 54 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::setGlobalScope ");
56 DCHECK(!m_globalScope); 55 DCHECK(!m_globalScope);
57 DCHECK(scope); 56 DCHECK(scope);
58 m_globalScope = static_cast<CompositorWorkerGlobalScope*>(scope); 57 m_globalScope = static_cast<CompositorWorkerGlobalScope*>(scope);
59 m_mutator->registerProxyClient(this); 58 m_mutator->registerProxyClient(this);
60 } 59 }
61 60
61 void CompositorProxyClientImpl::dispose()
62 {
63 // CompositorProxyClientImpl and CompositorMutatorImpl form a reference
64 // cycle. CompositorWorkerGlobalScope and CompositorProxyClientImpl
65 // also form another big reference cycle. So dispose needs to be called on
66 // Worker termination to break these cycles. If not, layout test leak
67 // detection will report a WorkerGlobalScope leak.
68 m_mutator->unregisterProxyClient(this);
69 m_globalScope = nullptr;
70 }
71
62 void CompositorProxyClientImpl::requestAnimationFrame() 72 void CompositorProxyClientImpl::requestAnimationFrame()
63 { 73 {
64 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::requestAnimati onFrame"); 74 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::requestAnimati onFrame");
65 m_requestedAnimationFrameCallbacks = true; 75 m_requestedAnimationFrameCallbacks = true;
66 m_mutator->setNeedsMutate(); 76 m_mutator->setNeedsMutate();
67 } 77 }
68 78
69 bool CompositorProxyClientImpl::mutate(double monotonicTimeNow, CompositorMutabl eStateProvider* stateProvider) 79 bool CompositorProxyClientImpl::mutate(double monotonicTimeNow, CompositorMutabl eStateProvider* stateProvider)
70 { 80 {
71 if (!m_globalScope) 81 if (!m_globalScope)
72 return false; 82 return false;
73 83
74 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::mutate"); 84 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::mutate");
75 if (!m_requestedAnimationFrameCallbacks) 85 if (!m_requestedAnimationFrameCallbacks)
76 return false; 86 return false;
77 87
78 { 88 {
79 ScopedCompositorMutableState mutableState(m_proxies, stateProvider); 89 ScopedCompositorMutableState mutableState(m_proxies, stateProvider);
80 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(mono tonicTimeNow); 90 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(mono tonicTimeNow);
81 } 91 }
82 92
83 return m_requestedAnimationFrameCallbacks; 93 return m_requestedAnimationFrameCallbacks;
84 } 94 }
85 95
86 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT imeNow) 96 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT imeNow)
87 { 97 {
88 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati onFrameCallbacks"); 98 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati onFrameCallbacks");
89 99
100 DCHECK(m_globalScope);
90 // Convert to zero based document time in milliseconds consistent with reque stAnimationFrame. 101 // Convert to zero based document time in milliseconds consistent with reque stAnimationFrame.
91 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi n()); 102 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi n());
92 return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs); 103 return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs);
93 } 104 }
94 105
95 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy) 106 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy)
96 { 107 {
97 m_proxies.add(proxy); 108 m_proxies.add(proxy);
98 } 109 }
99 110
100 void CompositorProxyClientImpl::unregisterCompositorProxy(CompositorProxy* proxy ) 111 void CompositorProxyClientImpl::unregisterCompositorProxy(CompositorProxy* proxy )
101 { 112 {
102 m_proxies.remove(proxy); 113 m_proxies.remove(proxy);
103 } 114 }
104 115
105 } // namespace blink 116 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/CompositorProxyClientImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698