| Index: third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp
|
| diff --git a/third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp b/third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp
|
| index f477ca2bcabce6c21fc276dd52f500bc44077150..4a621c5f1ab5d7c8d7e5e260394e8bf827287093 100644
|
| --- a/third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp
|
| +++ b/third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp
|
| @@ -7,11 +7,35 @@
|
| #include "core/dom/CompositorProxy.h"
|
| #include "modules/compositorworker/CompositorWorkerGlobalScope.h"
|
| #include "platform/TraceEvent.h"
|
| +#include "platform/graphics/CompositorMutableStateProvider.h"
|
| #include "web/CompositorMutatorImpl.h"
|
| #include "wtf/CurrentTime.h"
|
|
|
| namespace blink {
|
|
|
| +// A helper class that updates proxies mutable state on creation and reset it
|
| +// on destruction. This can be used with rAF callback to ensure no mutation is
|
| +// allowed outside rAF.
|
| +class ScopedCompositorMutableState final {
|
| + WTF_MAKE_NONCOPYABLE(ScopedCompositorMutableState);
|
| + STACK_ALLOCATED();
|
| +public:
|
| + ScopedCompositorMutableState(HeapHashSet<WeakMember<CompositorProxy>>& proxies, CompositorMutableStateProvider* stateProvider)
|
| + : m_proxies(proxies)
|
| + {
|
| + for (CompositorProxy* proxy : m_proxies)
|
| + proxy->takeCompositorMutableState(stateProvider->getMutableStateFor(proxy->elementId()));
|
| +
|
| + }
|
| + ~ScopedCompositorMutableState()
|
| + {
|
| + for (CompositorProxy* proxy : m_proxies)
|
| + proxy->takeCompositorMutableState(nullptr);
|
| + }
|
| +private:
|
| + HeapHashSet<WeakMember<CompositorProxy>>& m_proxies;
|
| +};
|
| +
|
| CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* mutator)
|
| : m_mutator(mutator)
|
| , m_globalScope(nullptr)
|
| @@ -42,7 +66,7 @@ void CompositorProxyClientImpl::requestAnimationFrame()
|
| m_mutator->setNeedsMutate();
|
| }
|
|
|
| -bool CompositorProxyClientImpl::mutate(double monotonicTimeNow)
|
| +bool CompositorProxyClientImpl::mutate(double monotonicTimeNow, CompositorMutableStateProvider* stateProvider)
|
| {
|
| if (!m_globalScope)
|
| return false;
|
| @@ -51,7 +75,10 @@ bool CompositorProxyClientImpl::mutate(double monotonicTimeNow)
|
| if (!m_requestedAnimationFrameCallbacks)
|
| return false;
|
|
|
| - m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(monotonicTimeNow);
|
| + {
|
| + ScopedCompositorMutableState mutableState(m_proxies, stateProvider);
|
| + m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(monotonicTimeNow);
|
| + }
|
|
|
| return m_requestedAnimationFrameCallbacks;
|
| }
|
| @@ -59,10 +86,10 @@ bool CompositorProxyClientImpl::mutate(double monotonicTimeNow)
|
| bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicTimeNow)
|
| {
|
| TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimationFrameCallbacks");
|
| +
|
| // Convert to zero based document time in milliseconds consistent with requestAnimationFrame.
|
| double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigin());
|
| - const bool shouldReinvoke = m_globalScope->executeAnimationFrameCallbacks(highResTimeMs);
|
| - return shouldReinvoke;
|
| + return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs);
|
| }
|
|
|
| void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy)
|
|
|