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

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

Issue 2765053002: Avoid exposing cc::Layer tree to CompositorProxy (Closed)
Patch Set: Minor changes Created 3 years, 9 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 // 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/CompositorWorkerProxyClientImpl.h" 5 #include "web/CompositorWorkerProxyClientImpl.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/graphics/CompositorMutableStateProvider.h" 9 #include "platform/graphics/CompositorMutableStateProvider.h"
10 #include "platform/instrumentation/tracing/TraceEvent.h" 10 #include "platform/instrumentation/tracing/TraceEvent.h"
11 #include "web/CompositorMutatorImpl.h" 11 #include "web/CompositorMutatorImpl.h"
12 #include "wtf/CurrentTime.h" 12 #include "wtf/CurrentTime.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 // A helper class that updates proxies mutable state on creation and reset it 16 // A helper class that updates proxies mutable state on creation and reset it
17 // on destruction. This can be used with rAF callback to ensure no mutation is 17 // on destruction. This can be used with rAF callback to ensure no mutation is
18 // allowed outside rAF. 18 // allowed outside rAF.
19 class ScopedCompositorMutableState final { 19 class ScopedCompositorMutableState final {
20 WTF_MAKE_NONCOPYABLE(ScopedCompositorMutableState); 20 WTF_MAKE_NONCOPYABLE(ScopedCompositorMutableState);
21 STACK_ALLOCATED(); 21 STACK_ALLOCATED();
22 22
23 public: 23 public:
24 ScopedCompositorMutableState( 24 ScopedCompositorMutableState(
25 HeapHashSet<WeakMember<CompositorProxy>>& proxies, 25 HeapHashSet<WeakMember<CompositorProxy>>& proxies,
26 CompositorMutableStateProvider* stateProvider) 26 CompositorMutableStateProvider* stateProvider)
27 : m_proxies(proxies) { 27 : m_proxies(proxies) {
28 for (CompositorProxy* proxy : m_proxies) { 28 for (CompositorProxy* proxy : m_proxies) {
29 proxy->takeCompositorMutableState( 29 proxy->takeCompositorMutableState(
30 stateProvider->getMutableStateFor(proxy->elementId())); 30 stateProvider->getMutableStateFor(proxy->proxyId()));
31 } 31 }
32 } 32 }
33 ~ScopedCompositorMutableState() { 33 ~ScopedCompositorMutableState() {
34 for (CompositorProxy* proxy : m_proxies) 34 for (CompositorProxy* proxy : m_proxies)
35 proxy->takeCompositorMutableState(nullptr); 35 proxy->takeCompositorMutableState(nullptr);
36 } 36 }
37 37
38 private: 38 private:
39 HeapHashSet<WeakMember<CompositorProxy>>& m_proxies; 39 HeapHashSet<WeakMember<CompositorProxy>>& m_proxies;
40 }; 40 };
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 DCHECK(m_globalScope); 105 DCHECK(m_globalScope);
106 // Convert to zero based document time in milliseconds consistent with 106 // Convert to zero based document time in milliseconds consistent with
107 // requestAnimationFrame. 107 // requestAnimationFrame.
108 double highResTimeMs = 108 double highResTimeMs =
109 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigin()); 109 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigin());
110 return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs); 110 return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs);
111 } 111 }
112 112
113 void CompositorWorkerProxyClientImpl::registerCompositorProxy( 113 void CompositorWorkerProxyClientImpl::registerCompositorProxy(
114 CompositorProxy* proxy) { 114 CompositorProxy* proxy) {
115 TRACE_EVENT0("compositor-worker",
116 "CompositorWorkerProxyClientImpl::registerCompositorProxy");
117 m_mutator->registerCompositorProxy(proxy);
115 m_proxies.insert(proxy); 118 m_proxies.insert(proxy);
116 } 119 }
117 120
118 void CompositorWorkerProxyClientImpl::unregisterCompositorProxy( 121 void CompositorWorkerProxyClientImpl::unregisterCompositorProxy(
119 CompositorProxy* proxy) { 122 CompositorProxy* proxy) {
123 TRACE_EVENT0("compositor-worker",
124 "CompositorWorkerProxyClientImpl::unregisterCompositorProxy");
125 m_mutator->registerCompositorProxy(proxy);
120 m_proxies.erase(proxy); 126 m_proxies.erase(proxy);
121 } 127 }
122 128
123 } // namespace blink 129 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698