| 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 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class CanvasContextCreationAttributes; | 17 class CanvasContextCreationAttributes; |
| 18 class ImageBitmap; | 18 class ImageBitmap; |
| 19 class OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingC
ontext; |
| 20 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext OffscreenRenderingContext; |
| 19 | 21 |
| 20 class CORE_EXPORT OffscreenCanvas final : public GarbageCollected<OffscreenCanva
s>, public ScriptWrappable { | 22 class CORE_EXPORT OffscreenCanvas final : public GarbageCollected<OffscreenCanva
s>, public ScriptWrappable { |
| 21 DEFINE_WRAPPERTYPEINFO(); | 23 DEFINE_WRAPPERTYPEINFO(); |
| 22 public: | 24 public: |
| 23 static OffscreenCanvas* create(unsigned width, unsigned height); | 25 static OffscreenCanvas* create(unsigned width, unsigned height); |
| 24 | 26 |
| 25 // IDL attributes | 27 // IDL attributes |
| 26 unsigned width() const { return m_size.width(); } | 28 unsigned width() const { return m_size.width(); } |
| 27 unsigned height() const { return m_size.height(); } | 29 unsigned height() const { return m_size.height(); } |
| 28 void setWidth(unsigned); | 30 void setWidth(unsigned); |
| 29 void setHeight(unsigned); | 31 void setHeight(unsigned); |
| 30 | 32 |
| 31 // API Methods | 33 // API Methods |
| 32 ImageBitmap* transferToImageBitmap(ExceptionState&); | 34 ImageBitmap* transferToImageBitmap(ExceptionState&); |
| 33 | 35 |
| 34 IntSize size() const { return m_size; } | 36 IntSize size() const { return m_size; } |
| 35 void setAssociatedCanvasId(int canvasId) { m_canvasId = canvasId; } | 37 void setAssociatedCanvasId(int canvasId) { m_canvasId = canvasId; } |
| 36 int getAssociatedCanvasId() const { return m_canvasId; } | 38 int getAssociatedCanvasId() const { return m_canvasId; } |
| 37 bool isNeutered() const { return m_isNeutered; } | 39 bool isNeutered() const { return m_isNeutered; } |
| 38 void setNeutered(); | 40 void setNeutered(); |
| 39 CanvasRenderingContext* getCanvasRenderingContext(const String&, const Canva
sContextCreationAttributes&); | 41 CanvasRenderingContext* getCanvasRenderingContext(ScriptState*, const String
&, const CanvasContextCreationAttributes&); |
| 40 CanvasRenderingContext* renderingContext() { return m_context; } | 42 CanvasRenderingContext* renderingContext() { return m_context; } |
| 41 | 43 |
| 42 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); | 44 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); |
| 43 | 45 |
| 44 DECLARE_VIRTUAL_TRACE(); | 46 DECLARE_VIRTUAL_TRACE(); |
| 45 | 47 |
| 46 private: | 48 private: |
| 47 explicit OffscreenCanvas(const IntSize&); | 49 explicit OffscreenCanvas(const IntSize&); |
| 48 | 50 |
| 49 using ContextFactoryVector = Vector<OwnPtr<CanvasRenderingContextFactory>>; | 51 using ContextFactoryVector = Vector<OwnPtr<CanvasRenderingContextFactory>>; |
| 50 static ContextFactoryVector& renderingContextFactories(); | 52 static ContextFactoryVector& renderingContextFactories(); |
| 51 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 53 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
| 52 | 54 |
| 53 Member<CanvasRenderingContext> m_context; | 55 Member<CanvasRenderingContext> m_context; |
| 54 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no as
sociated canvas element. | 56 int m_canvasId = -1; // DOMNodeIds starts from 0, using -1 to indicate no as
sociated canvas element. |
| 55 IntSize m_size; | 57 IntSize m_size; |
| 56 bool m_isNeutered = false; | 58 bool m_isNeutered = false; |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 } // namespace blink | 61 } // namespace blink |
| 60 | 62 |
| 61 #endif // OffscreenCanvas_h | 63 #endif // OffscreenCanvas_h |
| OLD | NEW |