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 #ifndef PaintWorkletGlobalScope_h | 5 #ifndef PaintWorkletGlobalScope_h |
6 #define PaintWorkletGlobalScope_h | 6 #define PaintWorkletGlobalScope_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptValue.h" | 8 #include "bindings/core/v8/ScriptValue.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/workers/MainThreadWorkletGlobalScope.h" | 10 #include "core/workers/MainThreadWorkletGlobalScope.h" |
11 #include "modules/ModulesExport.h" | 11 #include "modules/ModulesExport.h" |
12 #include "platform/graphics/ImageBuffer.h" | 12 #include "platform/graphics/ImageBuffer.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 class CSSPaintDefinition; | 16 class CSSPaintDefinition; |
17 class CSSPaintImageGeneratorImpl; | 17 class CSSPaintImageGeneratorImpl; |
18 class ExceptionState; | 18 class ExceptionState; |
19 | 19 |
20 class MODULES_EXPORT PaintWorkletGlobalScope final | 20 class MODULES_EXPORT PaintWorkletGlobalScope final |
21 : public MainThreadWorkletGlobalScope { | 21 : public MainThreadWorkletGlobalScope { |
22 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
23 USING_GARBAGE_COLLECTED_MIXIN(PaintWorkletGlobalScope); | 23 USING_GARBAGE_COLLECTED_MIXIN(PaintWorkletGlobalScope); |
24 | 24 |
25 public: | 25 public: |
26 static PaintWorkletGlobalScope* Create(LocalFrame*, | 26 static PaintWorkletGlobalScope* Create(LocalFrame*, |
27 const KURL&, | 27 const KURL&, |
28 const String& user_agent, | 28 const String& user_agent, |
29 PassRefPtr<SecurityOrigin>, | 29 PassRefPtr<SecurityOrigin>, |
30 v8::Isolate*, | 30 v8::Isolate*); |
31 WorkletObjectProxy*); | |
32 ~PaintWorkletGlobalScope() override; | 31 ~PaintWorkletGlobalScope() override; |
33 void Dispose() final; | 32 void Dispose() final; |
34 | 33 |
35 bool IsPaintWorkletGlobalScope() const final { return true; } | 34 bool IsPaintWorkletGlobalScope() const final { return true; } |
36 void registerPaint(const String& name, | 35 void registerPaint(const String& name, |
37 const ScriptValue& ctor, | 36 const ScriptValue& ctor, |
38 ExceptionState&); | 37 ExceptionState&); |
39 | 38 |
40 CSSPaintDefinition* FindDefinition(const String& name); | 39 CSSPaintDefinition* FindDefinition(const String& name); |
41 void AddPendingGenerator(const String& name, CSSPaintImageGeneratorImpl*); | 40 void AddPendingGenerator(const String& name, CSSPaintImageGeneratorImpl*); |
42 | 41 |
43 DECLARE_VIRTUAL_TRACE(); | 42 DECLARE_VIRTUAL_TRACE(); |
44 | 43 |
45 private: | 44 private: |
46 PaintWorkletGlobalScope(LocalFrame*, | 45 PaintWorkletGlobalScope(LocalFrame*, |
47 const KURL&, | 46 const KURL&, |
48 const String& user_agent, | 47 const String& user_agent, |
49 PassRefPtr<SecurityOrigin>, | 48 PassRefPtr<SecurityOrigin>, |
50 v8::Isolate*, | 49 v8::Isolate*); |
51 WorkletObjectProxy*); | |
52 | 50 |
53 typedef HeapHashMap<String, Member<CSSPaintDefinition>> DefinitionMap; | 51 typedef HeapHashMap<String, Member<CSSPaintDefinition>> DefinitionMap; |
54 DefinitionMap paint_definitions_; | 52 DefinitionMap paint_definitions_; |
55 | 53 |
56 // The map of CSSPaintImageGeneratorImpl which are waiting for a | 54 // The map of CSSPaintImageGeneratorImpl which are waiting for a |
57 // CSSPaintDefinition to be registered. The global scope is expected to | 55 // CSSPaintDefinition to be registered. The global scope is expected to |
58 // outlive the generators hence are held onto with a WeakMember. | 56 // outlive the generators hence are held onto with a WeakMember. |
59 typedef HeapHashSet<WeakMember<CSSPaintImageGeneratorImpl>> GeneratorHashSet; | 57 typedef HeapHashSet<WeakMember<CSSPaintImageGeneratorImpl>> GeneratorHashSet; |
60 typedef HeapHashMap<String, Member<GeneratorHashSet>> PendingGeneratorMap; | 58 typedef HeapHashMap<String, Member<GeneratorHashSet>> PendingGeneratorMap; |
61 PendingGeneratorMap pending_generators_; | 59 PendingGeneratorMap pending_generators_; |
62 }; | 60 }; |
63 | 61 |
64 DEFINE_TYPE_CASTS(PaintWorkletGlobalScope, | 62 DEFINE_TYPE_CASTS(PaintWorkletGlobalScope, |
65 ExecutionContext, | 63 ExecutionContext, |
66 context, | 64 context, |
67 context->IsPaintWorkletGlobalScope(), | 65 context->IsPaintWorkletGlobalScope(), |
68 context.IsPaintWorkletGlobalScope()); | 66 context.IsPaintWorkletGlobalScope()); |
69 | 67 |
70 } // namespace blink | 68 } // namespace blink |
71 | 69 |
72 #endif // PaintWorkletGlobalScope_h | 70 #endif // PaintWorkletGlobalScope_h |
OLD | NEW |