Index: third_party/WebKit/Source/core/dom/CompositorProxy.cpp |
diff --git a/third_party/WebKit/Source/core/dom/CompositorProxy.cpp b/third_party/WebKit/Source/core/dom/CompositorProxy.cpp |
index 3ad9c0ce20af8a90ac9321a1f1f75e433abca58e..ab05f670fe4cb80d4f09e42c8ce452aaa6729a31 100644 |
--- a/third_party/WebKit/Source/core/dom/CompositorProxy.cpp |
+++ b/third_party/WebKit/Source/core/dom/CompositorProxy.cpp |
@@ -6,17 +6,24 @@ |
#include "bindings/core/v8/ExceptionMessages.h" |
#include "bindings/core/v8/ExceptionState.h" |
+#include "core/dom/CompositorProxyClient.h" |
#include "core/dom/DOMNodeIds.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/dom/ExecutionContext.h" |
+#include "core/workers/WorkerClients.h" |
+#include "core/workers/WorkerGlobalScope.h" |
#include "platform/ThreadSafeFunctional.h" |
#include "platform/graphics/CompositorMutableProperties.h" |
+#include "platform/graphics/CompositorMutableState.h" |
#include "public/platform/Platform.h" |
#include "public/platform/WebTraceLocation.h" |
#include <algorithm> |
namespace blink { |
+// When adding to this list, make sure to update |
+// LayoutTests/virtual/threaded/fast/compositorworker/compositor-proxy-supports.html. |
+ |
static const struct { |
const char* name; |
uint32_t property; |
@@ -112,14 +119,18 @@ CompositorProxy* CompositorProxy::create(ExecutionContext* context, Element* ele |
return new CompositorProxy(*element, attributeArray); |
} |
-CompositorProxy* CompositorProxy::create(uint64_t elementId, uint32_t compositorMutableProperties) |
+CompositorProxy* CompositorProxy::create(ExecutionContext* context, uint64_t elementId, uint32_t compositorMutableProperties) |
{ |
- return new CompositorProxy(elementId, compositorMutableProperties); |
+ WorkerClients* clients = toWorkerGlobalScope(context)->clients(); |
+ ASSERT(clients); |
+ CompositorProxyClient* client = CompositorProxyClient::from(clients); |
+ return new CompositorProxy(elementId, compositorMutableProperties, client); |
} |
CompositorProxy::CompositorProxy(Element& element, const Vector<String>& attributeArray) |
: m_elementId(DOMNodeIds::idForNode(&element)) |
, m_compositorMutableProperties(compositorMutablePropertiesFromNames(attributeArray)) |
+ , m_client(nullptr) |
{ |
ASSERT(isMainThread()); |
ASSERT(m_compositorMutableProperties); |
@@ -128,13 +139,15 @@ CompositorProxy::CompositorProxy(Element& element, const Vector<String>& attribu |
incrementCompositorProxiedPropertiesForElement(m_elementId, m_compositorMutableProperties); |
} |
-CompositorProxy::CompositorProxy(uint64_t elementId, uint32_t compositorMutableProperties) |
+CompositorProxy::CompositorProxy(uint64_t elementId, uint32_t compositorMutableProperties, CompositorProxyClient* client) |
: m_elementId(elementId) |
, m_compositorMutableProperties(compositorMutableProperties) |
+ , m_client(client) |
{ |
ASSERT(isControlThread()); |
ASSERT(sanityCheckMutableProperties(m_compositorMutableProperties)); |
Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&incrementCompositorProxiedPropertiesForElement, m_elementId, m_compositorMutableProperties)); |
+ m_client->registerCompositorProxy(this); |
} |
CompositorProxy::~CompositorProxy() |
@@ -150,29 +163,35 @@ bool CompositorProxy::supports(const String& attributeName) const |
double CompositorProxy::opacity(ExceptionState& exceptionState) const |
{ |
- if (raiseExceptionIfMutationNotAllowed(exceptionState)) |
- return 0.0; |
- if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptionState)) |
- return 0.0; |
- return m_opacity; |
+ double value = 0.0; |
+ if (!raiseExceptionIfMutationNotAllowed(exceptionState) |
+ && !raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptionState) |
+ && m_state.get()) { |
+ value = m_state->opacity(); |
+ } |
+ return value; |
} |
double CompositorProxy::scrollLeft(ExceptionState& exceptionState) const |
{ |
- if (raiseExceptionIfMutationNotAllowed(exceptionState)) |
- return 0.0; |
- if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, exceptionState)) |
- return 0.0; |
- return m_scrollLeft; |
+ double value = 0.0; |
+ if (!raiseExceptionIfMutationNotAllowed(exceptionState) |
+ && !raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, exceptionState) |
+ && m_state.get()) { |
+ value = m_state->scrollLeft(); |
+ } |
+ return value; |
} |
double CompositorProxy::scrollTop(ExceptionState& exceptionState) const |
{ |
- if (raiseExceptionIfMutationNotAllowed(exceptionState)) |
- return 0.0; |
- if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, exceptionState)) |
- return 0.0; |
- return m_scrollTop; |
+ double value = 0.0; |
+ if (!raiseExceptionIfMutationNotAllowed(exceptionState) |
+ && !raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, exceptionState) |
+ && m_state.get()) { |
+ value = m_state->scrollTop(); |
+ } |
+ return value; |
} |
DOMMatrix* CompositorProxy::transform(ExceptionState& exceptionState) const |
@@ -181,7 +200,9 @@ DOMMatrix* CompositorProxy::transform(ExceptionState& exceptionState) const |
return nullptr; |
if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, exceptionState)) |
return nullptr; |
- return m_transform; |
+ if (!m_state.get()) |
+ return DOMMatrix::create(); |
+ return DOMMatrix::create(m_state->transform()); |
} |
void CompositorProxy::setOpacity(double opacity, ExceptionState& exceptionState) |
@@ -190,8 +211,10 @@ void CompositorProxy::setOpacity(double opacity, ExceptionState& exceptionState) |
return; |
if (raiseExceptionIfNotMutable(CompositorMutableProperty::kOpacity, exceptionState)) |
return; |
- m_opacity = std::min(1., std::max(0., opacity)); |
- m_mutatedProperties |= CompositorMutableProperty::kTransform; |
+ if (!m_state.get()) |
+ return; |
+ opacity = std::min(1., std::max(0., opacity)); |
+ m_state->setOpacity(opacity); |
} |
void CompositorProxy::setScrollLeft(double scrollLeft, ExceptionState& exceptionState) |
@@ -200,8 +223,9 @@ void CompositorProxy::setScrollLeft(double scrollLeft, ExceptionState& exception |
return; |
if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollLeft, exceptionState)) |
return; |
- m_scrollLeft = scrollLeft; |
- m_mutatedProperties |= CompositorMutableProperty::kScrollLeft; |
+ if (!m_state.get()) |
+ return; |
+ m_state->setScrollLeft(scrollLeft); |
} |
void CompositorProxy::setScrollTop(double scrollTop, ExceptionState& exceptionState) |
@@ -210,8 +234,9 @@ void CompositorProxy::setScrollTop(double scrollTop, ExceptionState& exceptionSt |
return; |
if (raiseExceptionIfNotMutable(CompositorMutableProperty::kScrollTop, exceptionState)) |
return; |
- m_scrollTop = scrollTop; |
- m_mutatedProperties |= CompositorMutableProperty::kScrollTop; |
+ if (!m_state.get()) |
+ return; |
+ m_state->setScrollTop(scrollTop); |
} |
void CompositorProxy::setTransform(DOMMatrix* transform, ExceptionState& exceptionState) |
@@ -220,8 +245,9 @@ void CompositorProxy::setTransform(DOMMatrix* transform, ExceptionState& excepti |
return; |
if (raiseExceptionIfNotMutable(CompositorMutableProperty::kTransform, exceptionState)) |
return; |
- m_transform = transform; |
- m_mutatedProperties |= CompositorMutableProperty::kTransform; |
+ if (!m_state.get()) |
+ return; |
+ m_state->setTransform(TransformationMatrix::toSkMatrix44(transform->matrix())); |
} |
bool CompositorProxy::raiseExceptionIfNotMutable(uint32_t property, ExceptionState& exceptionState) const |
@@ -235,11 +261,22 @@ bool CompositorProxy::raiseExceptionIfNotMutable(uint32_t property, ExceptionSta |
void CompositorProxy::disconnect() |
{ |
+ if (!m_connected) |
+ return; |
m_connected = false; |
- if (isMainThread()) |
+ if (isMainThread()) { |
decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositorMutableProperties); |
- else |
- Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_elementId, m_compositorMutableProperties)); |
+ } else { |
+ Platform::current()->mainThread()->taskRunner()->postTask( |
+ BLINK_FROM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_elementId, m_compositorMutableProperties)); |
+ if (m_client) |
+ m_client->unregisterCompositorProxy(this); |
+ } |
+} |
+ |
+void CompositorProxy::takeCompositorMutableState(PassOwnPtr<CompositorMutableState> state) |
+{ |
+ m_state = state; |
} |
} // namespace blink |