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 "platform/geometry/IntSize.h" | 12 #include "platform/geometry/IntSize.h" |
13 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 14 #include <memory> |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 class CanvasContextCreationAttributes; | 18 class CanvasContextCreationAttributes; |
18 class ImageBitmap; | 19 class ImageBitmap; |
19 class OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingC
ontext; | 20 class OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingC
ontext; |
20 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext OffscreenRenderingContext; | 21 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext OffscreenRenderingContext; |
21 | 22 |
22 class CORE_EXPORT OffscreenCanvas final : public GarbageCollected<OffscreenCanva
s>, public ScriptWrappable { | 23 class CORE_EXPORT OffscreenCanvas final : public GarbageCollected<OffscreenCanva
s>, public ScriptWrappable { |
23 DEFINE_WRAPPERTYPEINFO(); | 24 DEFINE_WRAPPERTYPEINFO(); |
(...skipping 10 matching lines...) Expand all Loading... |
34 ImageBitmap* transferToImageBitmap(ExceptionState&); | 35 ImageBitmap* transferToImageBitmap(ExceptionState&); |
35 | 36 |
36 IntSize size() const { return m_size; } | 37 IntSize size() const { return m_size; } |
37 void setAssociatedCanvasId(int canvasId) { m_canvasId = canvasId; } | 38 void setAssociatedCanvasId(int canvasId) { m_canvasId = canvasId; } |
38 int getAssociatedCanvasId() const { return m_canvasId; } | 39 int getAssociatedCanvasId() const { return m_canvasId; } |
39 bool isNeutered() const { return m_isNeutered; } | 40 bool isNeutered() const { return m_isNeutered; } |
40 void setNeutered(); | 41 void setNeutered(); |
41 CanvasRenderingContext* getCanvasRenderingContext(ScriptState*, const String
&, const CanvasContextCreationAttributes&); | 42 CanvasRenderingContext* getCanvasRenderingContext(ScriptState*, const String
&, const CanvasContextCreationAttributes&); |
42 CanvasRenderingContext* renderingContext() { return m_context; } | 43 CanvasRenderingContext* renderingContext() { return m_context; } |
43 | 44 |
44 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); | 45 static void registerRenderingContextFactory(std::unique_ptr<CanvasRenderingC
ontextFactory>); |
45 | 46 |
46 bool originClean() const; | 47 bool originClean() const; |
47 void setOriginTainted() { m_originClean = false; } | 48 void setOriginTainted() { m_originClean = false; } |
48 | 49 |
49 DECLARE_VIRTUAL_TRACE(); | 50 DECLARE_VIRTUAL_TRACE(); |
50 | 51 |
51 private: | 52 private: |
52 explicit OffscreenCanvas(const IntSize&); | 53 explicit OffscreenCanvas(const IntSize&); |
53 | 54 |
54 using ContextFactoryVector = Vector<OwnPtr<CanvasRenderingContextFactory>>; | 55 using ContextFactoryVector = Vector<std::unique_ptr<CanvasRenderingContextFa
ctory>>; |
55 static ContextFactoryVector& renderingContextFactories(); | 56 static ContextFactoryVector& renderingContextFactories(); |
56 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 57 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
57 | 58 |
58 Member<CanvasRenderingContext> m_context; | 59 Member<CanvasRenderingContext> m_context; |
59 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no as
sociated canvas element. | 60 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no as
sociated canvas element. |
60 IntSize m_size; | 61 IntSize m_size; |
61 bool m_isNeutered = false; | 62 bool m_isNeutered = false; |
62 | 63 |
63 bool m_originClean; | 64 bool m_originClean; |
64 }; | 65 }; |
65 | 66 |
66 } // namespace blink | 67 } // namespace blink |
67 | 68 |
68 #endif // OffscreenCanvas_h | 69 #endif // OffscreenCanvas_h |
OLD | NEW |