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 "core/html/canvas/CanvasImageSource.h" |
| 13 #include "core/offscreencanvas/ImageEncodeOptions.h" |
13 #include "platform/geometry/IntSize.h" | 14 #include "platform/geometry/IntSize.h" |
14 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" | 15 #include "platform/graphics/OffscreenCanvasFrameDispatcher.h" |
15 #include "platform/heap/Handle.h" | 16 #include "platform/heap/Handle.h" |
16 #include <memory> | 17 #include <memory> |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 | 20 |
20 class CanvasContextCreationAttributes; | 21 class CanvasContextCreationAttributes; |
21 class ImageBitmap; | 22 class ImageBitmap; |
22 class | 23 class |
(...skipping 11 matching lines...) Expand all Loading... |
34 static OffscreenCanvas* create(unsigned width, unsigned height); | 35 static OffscreenCanvas* create(unsigned width, unsigned height); |
35 | 36 |
36 // IDL attributes | 37 // IDL attributes |
37 unsigned width() const { return m_size.width(); } | 38 unsigned width() const { return m_size.width(); } |
38 unsigned height() const { return m_size.height(); } | 39 unsigned height() const { return m_size.height(); } |
39 void setWidth(unsigned, ExceptionState&); | 40 void setWidth(unsigned, ExceptionState&); |
40 void setHeight(unsigned, ExceptionState&); | 41 void setHeight(unsigned, ExceptionState&); |
41 | 42 |
42 // API Methods | 43 // API Methods |
43 ImageBitmap* transferToImageBitmap(ExceptionState&); | 44 ImageBitmap* transferToImageBitmap(ExceptionState&); |
| 45 ScriptPromise convertToBlob(ScriptState*, |
| 46 const ImageEncodeOptions&, |
| 47 ExceptionState&); |
44 | 48 |
45 IntSize size() const { return m_size; } | 49 IntSize size() const { return m_size; } |
46 void setAssociatedCanvasId(int canvasId) { m_canvasId = canvasId; } | 50 void setAssociatedCanvasId(int canvasId) { m_canvasId = canvasId; } |
47 int getAssociatedCanvasId() const { return m_canvasId; } | 51 int getAssociatedCanvasId() const { return m_canvasId; } |
48 bool isNeutered() const { return m_isNeutered; } | 52 bool isNeutered() const { return m_isNeutered; } |
49 void setNeutered(); | 53 void setNeutered(); |
50 CanvasRenderingContext* getCanvasRenderingContext( | 54 CanvasRenderingContext* getCanvasRenderingContext( |
51 ScriptState*, | 55 ScriptState*, |
52 const String&, | 56 const String&, |
53 const CanvasContextCreationAttributes&); | 57 const CanvasContextCreationAttributes&); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 explicit OffscreenCanvas(const IntSize&); | 102 explicit OffscreenCanvas(const IntSize&); |
99 | 103 |
100 using ContextFactoryVector = | 104 using ContextFactoryVector = |
101 Vector<std::unique_ptr<CanvasRenderingContextFactory>>; | 105 Vector<std::unique_ptr<CanvasRenderingContextFactory>>; |
102 static ContextFactoryVector& renderingContextFactories(); | 106 static ContextFactoryVector& renderingContextFactories(); |
103 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 107 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
104 | 108 |
105 Member<CanvasRenderingContext> m_context; | 109 Member<CanvasRenderingContext> m_context; |
106 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no | 110 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no |
107 // associated canvas element. | 111 // associated canvas element. |
| 112 |
108 IntSize m_size; | 113 IntSize m_size; |
109 bool m_isNeutered = false; | 114 bool m_isNeutered = false; |
110 | 115 |
111 bool m_originClean; | 116 bool m_originClean; |
112 bool m_disableReadingFromCanvas = false; | 117 bool m_disableReadingFromCanvas = false; |
113 | 118 |
114 bool isPaintable() const; | 119 bool isPaintable() const; |
115 | 120 |
116 std::unique_ptr<OffscreenCanvasFrameDispatcher> m_frameDispatcher; | 121 std::unique_ptr<OffscreenCanvasFrameDispatcher> m_frameDispatcher; |
117 // cc::SurfaceId is broken into three integer components as this can be used | 122 // cc::SurfaceId is broken into three integer components as this can be used |
118 // in transfer of OffscreenCanvas across threads | 123 // in transfer of OffscreenCanvas across threads |
119 // If this object is not created via | 124 // If this object is not created via |
120 // HTMLCanvasElement.transferControlToOffscreen(), | 125 // HTMLCanvasElement.transferControlToOffscreen(), |
121 // then the following members would remain as initialized zero values. | 126 // then the following members would remain as initialized zero values. |
122 uint32_t m_clientId = 0; | 127 uint32_t m_clientId = 0; |
123 uint32_t m_sinkId = 0; | 128 uint32_t m_sinkId = 0; |
124 uint32_t m_localId = 0; | 129 uint32_t m_localId = 0; |
125 uint64_t m_nonce = 0; | 130 uint64_t m_nonce = 0; |
126 }; | 131 }; |
127 | 132 |
128 } // namespace blink | 133 } // namespace blink |
129 | 134 |
130 #endif // OffscreenCanvas_h | 135 #endif // OffscreenCanvas_h |
OLD | NEW |