| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 108 |
| 104 private: | 109 private: |
| 105 explicit OffscreenCanvas(const IntSize&); | 110 explicit OffscreenCanvas(const IntSize&); |
| 106 | 111 |
| 107 using ContextFactoryVector = | 112 using ContextFactoryVector = |
| 108 Vector<std::unique_ptr<CanvasRenderingContextFactory>>; | 113 Vector<std::unique_ptr<CanvasRenderingContextFactory>>; |
| 109 static ContextFactoryVector& renderingContextFactories(); | 114 static ContextFactoryVector& renderingContextFactories(); |
| 110 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 115 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
| 111 | 116 |
| 112 Member<CanvasRenderingContext> m_context; | 117 Member<CanvasRenderingContext> m_context; |
| 113 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no | 118 |
| 114 // associated canvas element. | 119 enum { |
| 120 kNoPlaceholderCanvas = -1, // DOMNodeIds starts from 0, using -1 to |
| 121 // indicate no associated canvas element. |
| 122 }; |
| 123 int m_placeholderCanvasId = kNoPlaceholderCanvas; |
| 115 | 124 |
| 116 IntSize m_size; | 125 IntSize m_size; |
| 117 bool m_isNeutered = false; | 126 bool m_isNeutered = false; |
| 118 | 127 |
| 119 bool m_originClean; | 128 bool m_originClean; |
| 120 bool m_disableReadingFromCanvas = false; | 129 bool m_disableReadingFromCanvas = false; |
| 121 | 130 |
| 122 bool isPaintable() const; | 131 bool isPaintable() const; |
| 123 | 132 |
| 124 std::unique_ptr<OffscreenCanvasFrameDispatcher> m_frameDispatcher; | 133 std::unique_ptr<OffscreenCanvasFrameDispatcher> m_frameDispatcher; |
| 125 // cc::SurfaceId is broken into three integer components as this can be used | 134 // cc::SurfaceId is broken into three integer components as this can be used |
| 126 // in transfer of OffscreenCanvas across threads | 135 // in transfer of OffscreenCanvas across threads |
| 127 // If this object is not created via | 136 // If this object is not created via |
| 128 // HTMLCanvasElement.transferControlToOffscreen(), | 137 // HTMLCanvasElement.transferControlToOffscreen(), |
| 129 // then the following members would remain as initialized zero values. | 138 // then the following members would remain as initialized zero values. |
| 130 uint32_t m_clientId = 0; | 139 uint32_t m_clientId = 0; |
| 131 uint32_t m_sinkId = 0; | 140 uint32_t m_sinkId = 0; |
| 132 uint32_t m_localId = 0; | 141 uint32_t m_localId = 0; |
| 133 uint64_t m_nonceHigh = 0; | 142 uint64_t m_nonceHigh = 0; |
| 134 uint64_t m_nonceLow = 0; | 143 uint64_t m_nonceLow = 0; |
| 135 }; | 144 }; |
| 136 | 145 |
| 137 } // namespace blink | 146 } // namespace blink |
| 138 | 147 |
| 139 #endif // OffscreenCanvas_h | 148 #endif // OffscreenCanvas_h |
| OLD | NEW |