Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/compositorworker/AnimationWorklet.h" | 5 #include "modules/compositorworker/AnimationWorklet.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
| 8 #include "core/dom/AnimationWorkletProxyClient.h" | |
| 8 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 9 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| 11 #include "core/page/ChromeClient.h" | |
| 10 #include "modules/compositorworker/AnimationWorkletMessagingProxy.h" | 12 #include "modules/compositorworker/AnimationWorkletMessagingProxy.h" |
| 11 #include "modules/compositorworker/AnimationWorkletThread.h" | 13 #include "modules/compositorworker/AnimationWorkletThread.h" |
| 12 | 14 |
| 13 namespace blink { | 15 namespace blink { |
| 14 | 16 |
| 15 // static | 17 // static |
| 16 AnimationWorklet* AnimationWorklet::create(LocalFrame* frame) { | 18 AnimationWorklet* AnimationWorklet::create(LocalFrame* frame) { |
| 17 return new AnimationWorklet(frame); | 19 return new AnimationWorklet(frame); |
| 18 } | 20 } |
| 19 | 21 |
| 20 AnimationWorklet::AnimationWorklet(LocalFrame* frame) | 22 AnimationWorklet::AnimationWorklet(LocalFrame* frame) |
| 21 : Worklet(frame), m_workletMessagingProxy(nullptr) {} | 23 : Worklet(frame), m_workletMessagingProxy(nullptr) {} |
| 22 | 24 |
| 23 AnimationWorklet::~AnimationWorklet() { | 25 AnimationWorklet::~AnimationWorklet() { |
| 24 if (m_workletMessagingProxy) | 26 if (m_workletMessagingProxy) |
| 25 m_workletMessagingProxy->parentObjectDestroyed(); | 27 m_workletMessagingProxy->parentObjectDestroyed(); |
| 26 } | 28 } |
| 27 | 29 |
| 28 void AnimationWorklet::initialize() { | 30 void AnimationWorklet::initialize() { |
| 29 AnimationWorkletThread::ensureSharedBackingThread(); | 31 AnimationWorkletThread::ensureSharedBackingThread(); |
| 30 | 32 |
| 31 DCHECK(!m_workletMessagingProxy); | 33 DCHECK(!m_workletMessagingProxy); |
| 32 DCHECK(getExecutionContext()); | 34 DCHECK(getExecutionContext()); |
| 35 Document* document = toDocument(getExecutionContext()); | |
| 36 CompositorProxyClient* client = | |
| 37 document->frame()->chromeClient().createCompositorProxyClient( | |
| 38 CompositorProxyClient::kWorkletClient, document->frame()); | |
| 39 AnimationWorkletProxyClient* proxyClient = | |
| 40 static_cast<AnimationWorkletProxyClient*>(client); | |
|
dcheng
2017/01/24 22:56:26
Rather than downcasting here and below, we should
majidvp
2017/01/26 15:00:04
This means adding two methods to more than a few p
| |
| 33 | 41 |
| 34 m_workletMessagingProxy = | 42 m_workletMessagingProxy = |
| 35 new AnimationWorkletMessagingProxy(getExecutionContext()); | 43 new AnimationWorkletMessagingProxy(getExecutionContext(), proxyClient); |
| 36 m_workletMessagingProxy->initialize(); | 44 m_workletMessagingProxy->initialize(); |
| 37 } | 45 } |
| 38 | 46 |
| 39 bool AnimationWorklet::isInitialized() const { | 47 bool AnimationWorklet::isInitialized() const { |
| 40 return m_workletMessagingProxy; | 48 return m_workletMessagingProxy; |
| 41 } | 49 } |
| 42 | 50 |
| 43 WorkletGlobalScopeProxy* AnimationWorklet::workletGlobalScopeProxy() const { | 51 WorkletGlobalScopeProxy* AnimationWorklet::workletGlobalScopeProxy() const { |
| 44 DCHECK(m_workletMessagingProxy); | 52 DCHECK(m_workletMessagingProxy); |
| 45 return m_workletMessagingProxy; | 53 return m_workletMessagingProxy; |
| 46 } | 54 } |
| 47 | 55 |
| 48 DEFINE_TRACE(AnimationWorklet) { | 56 DEFINE_TRACE(AnimationWorklet) { |
| 49 Worklet::trace(visitor); | 57 Worklet::trace(visitor); |
| 50 } | 58 } |
| 51 | 59 |
| 52 } // namespace blink | 60 } // namespace blink |
| OLD | NEW |