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" |
(...skipping 29 matching lines...) Expand all Loading... |
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*, |
46 const ImageEncodeOptions&, | 46 const ImageEncodeOptions&, |
47 ExceptionState&); | 47 ExceptionState&); |
48 | 48 |
49 IntSize size() const { return m_size; } | 49 IntSize size() const { return m_size; } |
50 void setAssociatedCanvasId(int canvasId) { m_canvasId = canvasId; } | 50 void setPlaceholderCanvasId(int canvasId) { |
51 int getAssociatedCanvasId() const { return m_canvasId; } | 51 m_placeholderCanvasId = canvasId; |
| 52 } |
| 53 int placeholderCanvasId() const { return m_placeholderCanvasId; } |
| 54 bool hasPlaceholderCanvas() { |
| 55 return m_placeholderCanvasId != kNoPlaceholderCanvas; |
| 56 } |
52 bool isNeutered() const { return m_isNeutered; } | 57 bool isNeutered() const { return m_isNeutered; } |
53 void setNeutered(); | 58 void setNeutered(); |
54 CanvasRenderingContext* getCanvasRenderingContext( | 59 CanvasRenderingContext* getCanvasRenderingContext( |
55 ScriptState*, | 60 ScriptState*, |
56 const String&, | 61 const String&, |
57 const CanvasContextCreationAttributes&); | 62 const CanvasContextCreationAttributes&); |
58 CanvasRenderingContext* renderingContext() { return m_context; } | 63 CanvasRenderingContext* renderingContext() { return m_context; } |
59 | 64 |
60 static void registerRenderingContextFactory( | 65 static void registerRenderingContextFactory( |
61 std::unique_ptr<CanvasRenderingContextFactory>); | 66 std::unique_ptr<CanvasRenderingContextFactory>); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 105 |
101 private: | 106 private: |
102 explicit OffscreenCanvas(const IntSize&); | 107 explicit OffscreenCanvas(const IntSize&); |
103 | 108 |
104 using ContextFactoryVector = | 109 using ContextFactoryVector = |
105 Vector<std::unique_ptr<CanvasRenderingContextFactory>>; | 110 Vector<std::unique_ptr<CanvasRenderingContextFactory>>; |
106 static ContextFactoryVector& renderingContextFactories(); | 111 static ContextFactoryVector& renderingContextFactories(); |
107 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 112 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
108 | 113 |
109 Member<CanvasRenderingContext> m_context; | 114 Member<CanvasRenderingContext> m_context; |
110 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no | 115 |
111 // associated canvas element. | 116 enum { |
| 117 kNoPlaceholderCanvas = -1, // DOMNodeIds starts from 0, using -1 to |
| 118 // indicate no associated canvas element. |
| 119 }; |
| 120 int m_placeholderCanvasId = kNoPlaceholderCanvas; |
112 | 121 |
113 IntSize m_size; | 122 IntSize m_size; |
114 bool m_isNeutered = false; | 123 bool m_isNeutered = false; |
115 | 124 |
116 bool m_originClean; | 125 bool m_originClean; |
117 bool m_disableReadingFromCanvas = false; | 126 bool m_disableReadingFromCanvas = false; |
118 | 127 |
119 bool isPaintable() const; | 128 bool isPaintable() const; |
120 | 129 |
121 std::unique_ptr<OffscreenCanvasFrameDispatcher> m_frameDispatcher; | 130 std::unique_ptr<OffscreenCanvasFrameDispatcher> m_frameDispatcher; |
122 // cc::SurfaceId is broken into three integer components as this can be used | 131 // cc::SurfaceId is broken into three integer components as this can be used |
123 // in transfer of OffscreenCanvas across threads | 132 // in transfer of OffscreenCanvas across threads |
124 // If this object is not created via | 133 // If this object is not created via |
125 // HTMLCanvasElement.transferControlToOffscreen(), | 134 // HTMLCanvasElement.transferControlToOffscreen(), |
126 // then the following members would remain as initialized zero values. | 135 // then the following members would remain as initialized zero values. |
127 uint32_t m_clientId = 0; | 136 uint32_t m_clientId = 0; |
128 uint32_t m_sinkId = 0; | 137 uint32_t m_sinkId = 0; |
129 uint32_t m_localId = 0; | 138 uint32_t m_localId = 0; |
130 uint64_t m_nonce = 0; | 139 uint64_t m_nonce = 0; |
131 }; | 140 }; |
132 | 141 |
133 } // namespace blink | 142 } // namespace blink |
134 | 143 |
135 #endif // OffscreenCanvas_h | 144 #endif // OffscreenCanvas_h |
OLD | NEW |