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/Document.h" | |
9 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
10 #include "modules/compositorworker/AnimationWorkletMessagingProxy.h" | 9 #include "core/workers/ThreadedWorkletGlobalScopeProxy.h" |
11 #include "modules/compositorworker/AnimationWorkletThread.h" | |
12 | 10 |
13 namespace blink { | 11 namespace blink { |
14 | 12 |
15 // static | 13 // static |
16 AnimationWorklet* AnimationWorklet::create(LocalFrame* frame) | 14 AnimationWorklet* AnimationWorklet::create(LocalFrame* frame) |
17 { | 15 { |
18 AnimationWorkletThread::ensureSharedBackingThread(); | |
19 AnimationWorklet* worklet = new AnimationWorklet(frame); | 16 AnimationWorklet* worklet = new AnimationWorklet(frame); |
20 worklet->suspendIfNeeded(); | 17 worklet->suspendIfNeeded(); |
21 return worklet; | 18 return worklet; |
22 } | 19 } |
23 | 20 |
24 AnimationWorklet::AnimationWorklet(LocalFrame* frame) | 21 AnimationWorklet::AnimationWorklet(LocalFrame* frame) |
25 : Worklet(frame) | 22 : Worklet(frame) |
26 , m_workletMessagingProxy(new AnimationWorkletMessagingProxy(frame->document
())) | 23 , m_workletGlobalScopeProxy(new ThreadedWorkletGlobalScopeProxy()) |
27 { | 24 { |
28 m_workletMessagingProxy->initialize(); | |
29 } | 25 } |
30 | 26 |
31 AnimationWorklet::~AnimationWorklet() | 27 AnimationWorklet::~AnimationWorklet() |
32 { | 28 { |
33 m_workletMessagingProxy->parentObjectDestroyed(); | |
34 } | 29 } |
35 | 30 |
36 WorkletGlobalScopeProxy* AnimationWorklet::workletGlobalScopeProxy() const | 31 WorkletGlobalScopeProxy* AnimationWorklet::workletGlobalScopeProxy() const |
37 { | 32 { |
38 return m_workletMessagingProxy; | 33 return m_workletGlobalScopeProxy.get(); |
39 } | 34 } |
40 | 35 |
41 DEFINE_TRACE(AnimationWorklet) | 36 DEFINE_TRACE(AnimationWorklet) |
42 { | 37 { |
43 Worklet::trace(visitor); | 38 Worklet::trace(visitor); |
44 } | 39 } |
45 | 40 |
46 } // namespace blink | 41 } // namespace blink |
OLD | NEW |