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/html/HTMLCanvasElement.h" | 11 #include "core/html/HTMLCanvasElement.h" |
| 12 #include "core/html/canvas/CanvasImageSource.h" |
12 #include "platform/geometry/IntSize.h" | 13 #include "platform/geometry/IntSize.h" |
13 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
14 #include <memory> | 15 #include <memory> |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 class CanvasContextCreationAttributes; | 19 class CanvasContextCreationAttributes; |
19 class ImageBitmap; | 20 class ImageBitmap; |
20 class OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingC
ontext; | 21 class OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingC
ontext; |
21 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext OffscreenRenderingContext; | 22 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext OffscreenRenderingContext; |
22 | 23 |
23 class CORE_EXPORT OffscreenCanvas final : public GarbageCollected<OffscreenCanva
s>, public ScriptWrappable { | 24 class CORE_EXPORT OffscreenCanvas final : public GarbageCollectedFinalized<Offsc
reenCanvas>, public ScriptWrappable, public CanvasImageSource { |
24 DEFINE_WRAPPERTYPEINFO(); | 25 DEFINE_WRAPPERTYPEINFO(); |
25 public: | 26 public: |
26 static OffscreenCanvas* create(unsigned width, unsigned height); | 27 static OffscreenCanvas* create(unsigned width, unsigned height); |
27 | 28 |
28 // IDL attributes | 29 // IDL attributes |
29 unsigned width() const { return m_size.width(); } | 30 unsigned width() const { return m_size.width(); } |
30 unsigned height() const { return m_size.height(); } | 31 unsigned height() const { return m_size.height(); } |
31 void setWidth(unsigned); | 32 void setWidth(unsigned); |
32 void setHeight(unsigned); | 33 void setHeight(unsigned); |
33 | 34 |
(...skipping 18 matching lines...) Expand all Loading... |
52 void setSurfaceId(uint32_t clientId, uint32_t localId, uint64_t nonce) | 53 void setSurfaceId(uint32_t clientId, uint32_t localId, uint64_t nonce) |
53 { | 54 { |
54 m_clientId = clientId; | 55 m_clientId = clientId; |
55 m_localId = localId; | 56 m_localId = localId; |
56 m_nonce = nonce; | 57 m_nonce = nonce; |
57 } | 58 } |
58 uint32_t clientId() const { return m_clientId; } | 59 uint32_t clientId() const { return m_clientId; } |
59 uint32_t localId() const { return m_localId; } | 60 uint32_t localId() const { return m_localId; } |
60 uint64_t nonce() const { return m_nonce; } | 61 uint64_t nonce() const { return m_nonce; } |
61 | 62 |
| 63 // CanvasImageSource implementation |
| 64 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi
nt, SnapshotReason, const FloatSize&) const final; |
| 65 bool wouldTaintOrigin(SecurityOrigin*) const final { return !m_originClean;
} |
| 66 bool isOffscreenCanvas() const final { return true; } |
| 67 FloatSize elementSize(const FloatSize& defaultObjectSize) const final { retu
rn FloatSize(width(), height()); } |
| 68 bool isOpaque() const final; |
| 69 int sourceWidth() final { return width(); } |
| 70 int sourceHeight() final { return height(); } |
| 71 |
62 DECLARE_VIRTUAL_TRACE(); | 72 DECLARE_VIRTUAL_TRACE(); |
63 | 73 |
64 private: | 74 private: |
65 explicit OffscreenCanvas(const IntSize&); | 75 explicit OffscreenCanvas(const IntSize&); |
66 | 76 |
67 using ContextFactoryVector = Vector<std::unique_ptr<CanvasRenderingContextFa
ctory>>; | 77 using ContextFactoryVector = Vector<std::unique_ptr<CanvasRenderingContextFa
ctory>>; |
68 static ContextFactoryVector& renderingContextFactories(); | 78 static ContextFactoryVector& renderingContextFactories(); |
69 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 79 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
70 | 80 |
71 Member<CanvasRenderingContext> m_context; | 81 Member<CanvasRenderingContext> m_context; |
(...skipping 11 matching lines...) Expand all Loading... |
83 // If this object is not created via HTMLCanvasElement.transferControlToOffs
creen(), | 93 // If this object is not created via HTMLCanvasElement.transferControlToOffs
creen(), |
84 // then the following members would remain as initialized zero values. | 94 // then the following members would remain as initialized zero values. |
85 uint32_t m_clientId = 0; | 95 uint32_t m_clientId = 0; |
86 uint32_t m_localId = 0; | 96 uint32_t m_localId = 0; |
87 uint64_t m_nonce = 0; | 97 uint64_t m_nonce = 0; |
88 }; | 98 }; |
89 | 99 |
90 } // namespace blink | 100 } // namespace blink |
91 | 101 |
92 #endif // OffscreenCanvas_h | 102 #endif // OffscreenCanvas_h |
OLD | NEW |