| 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 PaintWorklet_h | 5 #ifndef PaintWorklet_h |
| 6 #define PaintWorklet_h | 6 #define PaintWorklet_h |
| 7 | 7 |
| 8 #include "core/workers/MainThreadWorklet.h" | 8 #include "core/workers/MainThreadWorklet.h" |
| 9 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
| 10 #include "modules/csspaint/PaintWorkletGlobalScopeProxy.h" | 10 #include "modules/csspaint/PaintWorkletGlobalScopeProxy.h" |
| 11 #include "modules/csspaint/PaintWorkletPendingGeneratorRegistry.h" |
| 11 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class CSSPaintDefinition; | 16 class CSSPaintDefinition; |
| 16 class CSSPaintImageGeneratorImpl; | 17 class CSSPaintImageGeneratorImpl; |
| 17 | 18 |
| 18 // Manages a paint worklet: | 19 // Manages a paint worklet: |
| 19 // https://drafts.css-houdini.org/css-paint-api/#dom-css-paintworklet | 20 // https://drafts.css-houdini.org/css-paint-api/#dom-css-paintworklet |
| 20 class MODULES_EXPORT PaintWorklet final : public MainThreadWorklet { | 21 class MODULES_EXPORT PaintWorklet final : public MainThreadWorklet { |
| 21 WTF_MAKE_NONCOPYABLE(PaintWorklet); | 22 WTF_MAKE_NONCOPYABLE(PaintWorklet); |
| 22 | 23 |
| 23 public: | 24 public: |
| 24 static PaintWorklet* Create(LocalFrame*); | 25 static PaintWorklet* Create(LocalFrame*); |
| 25 ~PaintWorklet() override; | 26 ~PaintWorklet() override; |
| 26 | 27 |
| 27 WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const final; | |
| 28 CSSPaintDefinition* FindDefinition(const String& name); | 28 CSSPaintDefinition* FindDefinition(const String& name); |
| 29 void AddPendingGenerator(const String& name, CSSPaintImageGeneratorImpl*); | 29 void AddPendingGenerator(const String& name, CSSPaintImageGeneratorImpl*); |
| 30 | 30 |
| 31 DECLARE_VIRTUAL_TRACE(); | 31 DECLARE_VIRTUAL_TRACE(); |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 friend class PaintWorkletTest; |
| 35 |
| 34 explicit PaintWorklet(LocalFrame*); | 36 explicit PaintWorklet(LocalFrame*); |
| 35 | 37 |
| 36 // TODO(nhiroki): Make (Paint)WorkletGlobalScopeProxy GC-managed object. | 38 // Implements MainThreadWorklet. |
| 37 std::unique_ptr<PaintWorkletGlobalScopeProxy> global_scope_proxy_; | 39 bool NeedsToCreateGlobalScope() final; |
| 40 std::unique_ptr<WorkletGlobalScopeProxy> CreateGlobalScope() final; |
| 41 |
| 42 // Used for keeping pending generators until the first PaintWorkletGlobalScope |
| 43 // is created. Ownership of this registry is transferred to the global scope. |
| 44 Member<PaintWorkletPendingGeneratorRegistry> pending_generator_registry_; |
| 38 }; | 45 }; |
| 39 | 46 |
| 40 } // namespace blink | 47 } // namespace blink |
| 41 | 48 |
| 42 #endif // PaintWorklet_h | 49 #endif // PaintWorklet_h |
| OLD | NEW |