OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 OffscreenCanvas_h | 5 #ifndef OffscreenCanvas_h |
6 #define OffscreenCanvas_h | 6 #define OffscreenCanvas_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
| 11 #include "core/events/EventTarget.h" |
11 #include "core/html/HTMLCanvasElement.h" | 12 #include "core/html/HTMLCanvasElement.h" |
12 #include "core/html/canvas/CanvasImageSource.h" | 13 #include "core/html/canvas/CanvasImageSource.h" |
13 #include "core/offscreencanvas/ImageEncodeOptions.h" | 14 #include "core/offscreencanvas/ImageEncodeOptions.h" |
14 #include "platform/geometry/IntSize.h" | 15 #include "platform/geometry/IntSize.h" |
15 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" | 16 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" |
16 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
17 #include <memory> | 18 #include <memory> |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 | 21 |
21 class CanvasContextCreationAttributes; | 22 class CanvasContextCreationAttributes; |
22 class ImageBitmap; | 23 class ImageBitmap; |
23 class | 24 class |
24 OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingCon
text; | 25 OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingCon
text; |
25 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext | 26 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext |
26 OffscreenRenderingContext; | 27 OffscreenRenderingContext; |
27 | 28 |
28 class CORE_EXPORT OffscreenCanvas final | 29 class CORE_EXPORT OffscreenCanvas final : public EventTargetWithInlineData, |
29 : public GarbageCollectedFinalized<OffscreenCanvas>, | 30 public CanvasImageSource { |
30 public ScriptWrappable, | |
31 public CanvasImageSource { | |
32 DEFINE_WRAPPERTYPEINFO(); | 31 DEFINE_WRAPPERTYPEINFO(); |
33 | 32 |
34 public: | 33 public: |
35 static OffscreenCanvas* create(unsigned width, unsigned height); | 34 static OffscreenCanvas* create(unsigned width, unsigned height); |
| 35 ~OffscreenCanvas() override {} |
36 | 36 |
37 // IDL attributes | 37 // IDL attributes |
38 unsigned width() const { return m_size.width(); } | 38 unsigned width() const { return m_size.width(); } |
39 unsigned height() const { return m_size.height(); } | 39 unsigned height() const { return m_size.height(); } |
40 void setWidth(unsigned, ExceptionState&); | 40 void setWidth(unsigned, ExceptionState&); |
41 void setHeight(unsigned, ExceptionState&); | 41 void setHeight(unsigned, ExceptionState&); |
42 | 42 |
43 // API Methods | 43 // API Methods |
44 ImageBitmap* transferToImageBitmap(ScriptState*, ExceptionState&); | 44 ImageBitmap* transferToImageBitmap(ScriptState*, ExceptionState&); |
45 ScriptPromise convertToBlob(ScriptState*, | 45 ScriptPromise convertToBlob(ScriptState*, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 m_localId = localId; | 77 m_localId = localId; |
78 m_nonceHigh = nonceHigh; | 78 m_nonceHigh = nonceHigh; |
79 m_nonceLow = nonceLow; | 79 m_nonceLow = nonceLow; |
80 } | 80 } |
81 uint32_t clientId() const { return m_clientId; } | 81 uint32_t clientId() const { return m_clientId; } |
82 uint32_t sinkId() const { return m_sinkId; } | 82 uint32_t sinkId() const { return m_sinkId; } |
83 uint32_t localId() const { return m_localId; } | 83 uint32_t localId() const { return m_localId; } |
84 uint64_t nonceHigh() const { return m_nonceHigh; } | 84 uint64_t nonceHigh() const { return m_nonceHigh; } |
85 uint64_t nonceLow() const { return m_nonceLow; } | 85 uint64_t nonceLow() const { return m_nonceLow; } |
86 | 86 |
| 87 // EventTarget implementation |
| 88 const AtomicString& interfaceName() const final { |
| 89 return EventTargetNames::OffscreenCanvas; |
| 90 } |
| 91 ExecutionContext* getExecutionContext() const final; |
| 92 |
87 // CanvasImageSource implementation | 93 // CanvasImageSource implementation |
88 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, | 94 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, |
89 AccelerationHint, | 95 AccelerationHint, |
90 SnapshotReason, | 96 SnapshotReason, |
91 const FloatSize&) const final; | 97 const FloatSize&) const final; |
92 bool wouldTaintOrigin(SecurityOrigin*) const final { return !m_originClean; } | 98 bool wouldTaintOrigin(SecurityOrigin*) const final { return !m_originClean; } |
93 bool isOffscreenCanvas() const final { return true; } | 99 bool isOffscreenCanvas() const final { return true; } |
94 FloatSize elementSize(const FloatSize& defaultObjectSize) const final { | 100 FloatSize elementSize(const FloatSize& defaultObjectSize) const final { |
95 return FloatSize(width(), height()); | 101 return FloatSize(width(), height()); |
96 } | 102 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 uint32_t m_clientId = 0; | 136 uint32_t m_clientId = 0; |
131 uint32_t m_sinkId = 0; | 137 uint32_t m_sinkId = 0; |
132 uint32_t m_localId = 0; | 138 uint32_t m_localId = 0; |
133 uint64_t m_nonceHigh = 0; | 139 uint64_t m_nonceHigh = 0; |
134 uint64_t m_nonceLow = 0; | 140 uint64_t m_nonceLow = 0; |
135 }; | 141 }; |
136 | 142 |
137 } // namespace blink | 143 } // namespace blink |
138 | 144 |
139 #endif // OffscreenCanvas_h | 145 #endif // OffscreenCanvas_h |
OLD | NEW |