| 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 "modules/ModulesExport.h" | 12 #include "modules/ModulesExport.h" |
| 13 #include "platform/geometry/IntSize.h" | 13 #include "platform/geometry/IntSize.h" |
| 14 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 class CanvasContextCreationAttributes; | 18 class CanvasContextCreationAttributes; |
| 19 class ImageBitmap; | 19 class ImageBitmap; |
| 20 class OffscreenCanvasRenderingContext; | 20 class OffscreenCanvasRenderingContext; |
| 21 class OffscreenCanvasRenderingContext2D; | 21 class OffscreenCanvasRenderingContext2D; |
| 22 class OffscreenCanvasRenderingContextFactory; | 22 class OffscreenCanvasRenderingContextFactory; |
| 23 class OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingC
ontext; |
| 24 typedef OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2Renderin
gContext OffscreenRenderingContext; |
| 23 | 25 |
| 24 class MODULES_EXPORT OffscreenCanvas final : public GarbageCollectedFinalized<Of
fscreenCanvas>, public ScriptWrappable { | 26 class MODULES_EXPORT OffscreenCanvas final : public GarbageCollectedFinalized<Of
fscreenCanvas>, public ScriptWrappable { |
| 25 DEFINE_WRAPPERTYPEINFO(); | 27 DEFINE_WRAPPERTYPEINFO(); |
| 26 public: | 28 public: |
| 27 static OffscreenCanvas* create(unsigned width, unsigned height); | 29 static OffscreenCanvas* create(unsigned width, unsigned height); |
| 28 ~OffscreenCanvas(); | 30 ~OffscreenCanvas(); |
| 29 | 31 |
| 30 // IDL attributes | 32 // IDL attributes |
| 31 unsigned width() const { return m_size.width(); } | 33 unsigned width() const { return m_size.width(); } |
| 32 unsigned height() const { return m_size.height(); } | 34 unsigned height() const { return m_size.height(); } |
| 33 void setWidth(unsigned); | 35 void setWidth(unsigned); |
| 34 void setHeight(unsigned); | 36 void setHeight(unsigned); |
| 35 | 37 |
| 36 // API Methods | 38 // API Methods |
| 37 OffscreenCanvasRenderingContext2D* getContext(const String&, const CanvasCon
textCreationAttributes&); | 39 void getContext(ScriptState*, const String&, const CanvasContextCreationAttr
ibutes&, OffscreenRenderingContext&); |
| 38 ImageBitmap* transferToImageBitmap(ExceptionState&); | 40 ImageBitmap* transferToImageBitmap(ExceptionState&); |
| 39 | 41 |
| 40 IntSize size() const { return m_size; } | 42 IntSize size() const { return m_size; } |
| 41 OffscreenCanvasRenderingContext2D* renderingContext() const; | 43 OffscreenCanvasRenderingContext* renderingContext() const; |
| 42 void setAssociatedCanvas(HTMLCanvasElement* canvas) { m_canvas = canvas; } | 44 void setAssociatedCanvas(HTMLCanvasElement* canvas) { m_canvas = canvas; } |
| 43 HTMLCanvasElement* getAssociatedCanvas() const { return m_canvas; } | 45 HTMLCanvasElement* getAssociatedCanvas() const { return m_canvas; } |
| 44 | 46 |
| 45 static void registerRenderingContextFactory(PassOwnPtr<OffscreenCanvasRender
ingContextFactory>); | 47 static void registerRenderingContextFactory(PassOwnPtr<OffscreenCanvasRender
ingContextFactory>); |
| 46 | 48 |
| 47 DECLARE_VIRTUAL_TRACE(); | 49 DECLARE_VIRTUAL_TRACE(); |
| 48 | 50 |
| 49 private: | 51 private: |
| 50 OffscreenCanvas(const IntSize&); | 52 OffscreenCanvas(const IntSize&); |
| 51 | 53 |
| 52 using ContextFactoryVector = Vector<OwnPtr<OffscreenCanvasRenderingContextFa
ctory>>; | 54 using ContextFactoryVector = Vector<OwnPtr<OffscreenCanvasRenderingContextFa
ctory>>; |
| 53 static ContextFactoryVector& renderingContextFactories(); | 55 static ContextFactoryVector& renderingContextFactories(); |
| 54 static OffscreenCanvasRenderingContextFactory* getRenderingContextFactory(in
t); | 56 static OffscreenCanvasRenderingContextFactory* getRenderingContextFactory(in
t); |
| 55 | 57 |
| 56 Member<OffscreenCanvasRenderingContext> m_context; | 58 Member<OffscreenCanvasRenderingContext> m_context; |
| 57 WeakMember<HTMLCanvasElement> m_canvas; | 59 WeakMember<HTMLCanvasElement> m_canvas; |
| 58 IntSize m_size; | 60 IntSize m_size; |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 } // namespace blink | 63 } // namespace blink |
| 62 | 64 |
| 63 #endif // OffscreenCanvas_h | 65 #endif // OffscreenCanvas_h |
| OLD | NEW |