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 "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
11 #include "modules/worklet/WorkletGlobalScope.h" | 11 #include "modules/worklet/WorkletGlobalScope.h" |
| 12 #include "platform/graphics/ImageBuffer.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 class CSSPaintDefinition; | 16 class CSSPaintDefinition; |
| 17 class CSSPaintImageGeneratorImpl; |
16 class ExceptionState; | 18 class ExceptionState; |
17 | 19 |
18 class MODULES_EXPORT PaintWorkletGlobalScope : public WorkletGlobalScope { | 20 class MODULES_EXPORT PaintWorkletGlobalScope : public WorkletGlobalScope { |
19 DEFINE_WRAPPERTYPEINFO(); | 21 DEFINE_WRAPPERTYPEINFO(); |
20 public: | 22 public: |
21 static PaintWorkletGlobalScope* create(LocalFrame*, const KURL&, const Strin
g& userAgent, PassRefPtr<SecurityOrigin>, v8::Isolate*); | 23 static PaintWorkletGlobalScope* create(LocalFrame*, const KURL&, const Strin
g& userAgent, PassRefPtr<SecurityOrigin>, v8::Isolate*); |
22 ~PaintWorkletGlobalScope() override; | 24 ~PaintWorkletGlobalScope() override; |
23 void dispose() override; | 25 void dispose() override; |
24 | 26 |
25 bool isPaintWorkletGlobalScope() const final { return true; } | 27 bool isPaintWorkletGlobalScope() const final { return true; } |
26 void registerPaint(const String& name, const ScriptValue& ctor, ExceptionSta
te&); | 28 void registerPaint(const String& name, const ScriptValue& ctor, ExceptionSta
te&); |
27 | 29 |
28 CSSPaintDefinition* findDefinition(const String& name); | 30 CSSPaintDefinition* findDefinition(const String& name); |
| 31 void addPendingGenerator(const String& name, CSSPaintImageGeneratorImpl*); |
29 | 32 |
30 DECLARE_VIRTUAL_TRACE(); | 33 DECLARE_VIRTUAL_TRACE(); |
31 | 34 |
32 private: | 35 private: |
33 PaintWorkletGlobalScope(LocalFrame*, const KURL&, const String& userAgent, P
assRefPtr<SecurityOrigin>, v8::Isolate*); | 36 PaintWorkletGlobalScope(LocalFrame*, const KURL&, const String& userAgent, P
assRefPtr<SecurityOrigin>, v8::Isolate*); |
34 | 37 |
35 typedef HeapHashMap<String, Member<CSSPaintDefinition>> DefinitionMap; | 38 typedef HeapHashMap<String, Member<CSSPaintDefinition>> DefinitionMap; |
36 DefinitionMap m_paintDefinitions; | 39 DefinitionMap m_paintDefinitions; |
| 40 |
| 41 // The map of CSSPaintImageGeneratorImpl which are waiting for a |
| 42 // CSSPaintDefinition to be registered. The global scope is expected to |
| 43 // outlive the generators hence are held onto with a WeakMember. |
| 44 typedef HeapHashSet<WeakMember<CSSPaintImageGeneratorImpl>> GeneratorHashSet
; |
| 45 typedef HeapHashMap<String, Member<GeneratorHashSet>> PendingGeneratorMap; |
| 46 PendingGeneratorMap m_pendingGenerators; |
37 }; | 47 }; |
38 | 48 |
39 DEFINE_TYPE_CASTS(PaintWorkletGlobalScope, ExecutionContext, context, context->i
sPaintWorkletGlobalScope(), context.isPaintWorkletGlobalScope()); | 49 DEFINE_TYPE_CASTS(PaintWorkletGlobalScope, ExecutionContext, context, context->i
sPaintWorkletGlobalScope(), context.isPaintWorkletGlobalScope()); |
40 | 50 |
41 } // namespace blink | 51 } // namespace blink |
42 | 52 |
43 #endif // PaintWorkletGlobalScope_h | 53 #endif // PaintWorkletGlobalScope_h |
OLD | NEW |