| 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 | 19 |
| 20 class CORE_EXPORT OffscreenCanvas final : public GarbageCollectedFinalized<Offsc
reenCanvas>, public ScriptWrappable { | 20 class CORE_EXPORT OffscreenCanvas final : public GarbageCollected<OffscreenCanva
s>, public ScriptWrappable { |
| 21 DEFINE_WRAPPERTYPEINFO(); | 21 DEFINE_WRAPPERTYPEINFO(); |
| 22 public: | 22 public: |
| 23 static OffscreenCanvas* create(unsigned width, unsigned height); | 23 static OffscreenCanvas* create(unsigned width, unsigned height); |
| 24 ~OffscreenCanvas(); | |
| 25 | 24 |
| 26 // IDL attributes | 25 // IDL attributes |
| 27 unsigned width() const { return m_size.width(); } | 26 unsigned width() const { return m_size.width(); } |
| 28 unsigned height() const { return m_size.height(); } | 27 unsigned height() const { return m_size.height(); } |
| 29 void setWidth(unsigned); | 28 void setWidth(unsigned); |
| 30 void setHeight(unsigned); | 29 void setHeight(unsigned); |
| 31 | 30 |
| 32 // API Methods | 31 // API Methods |
| 33 ImageBitmap* transferToImageBitmap(ExceptionState&); | 32 ImageBitmap* transferToImageBitmap(ExceptionState&); |
| 34 | 33 |
| 35 IntSize size() const { return m_size; } | 34 IntSize size() const { return m_size; } |
| 36 void setAssociatedCanvas(HTMLCanvasElement* canvas) { m_canvas = canvas; } | 35 void setAssociatedCanvas(HTMLCanvasElement* canvas) { m_canvas = canvas; } |
| 37 HTMLCanvasElement* getAssociatedCanvas() const { return m_canvas; } | 36 HTMLCanvasElement* getAssociatedCanvas() const { return m_canvas; } |
| 38 CanvasRenderingContext* getCanvasRenderingContext(const String&, const Canva
sContextCreationAttributes&); | 37 CanvasRenderingContext* getCanvasRenderingContext(const String&, const Canva
sContextCreationAttributes&); |
| 39 | 38 |
| 40 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); | 39 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); |
| 41 | 40 |
| 42 DECLARE_VIRTUAL_TRACE(); | 41 DECLARE_VIRTUAL_TRACE(); |
| 43 | 42 |
| 44 private: | 43 private: |
| 45 OffscreenCanvas(const IntSize&); | 44 explicit OffscreenCanvas(const IntSize&); |
| 46 | 45 |
| 47 using ContextFactoryVector = Vector<OwnPtr<CanvasRenderingContextFactory>>; | 46 using ContextFactoryVector = Vector<OwnPtr<CanvasRenderingContextFactory>>; |
| 48 static ContextFactoryVector& renderingContextFactories(); | 47 static ContextFactoryVector& renderingContextFactories(); |
| 49 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 48 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
| 50 | 49 |
| 51 Member<CanvasRenderingContext> m_context; | 50 Member<CanvasRenderingContext> m_context; |
| 52 WeakMember<HTMLCanvasElement> m_canvas; | 51 WeakMember<HTMLCanvasElement> m_canvas; |
| 53 IntSize m_size; | 52 IntSize m_size; |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 } // namespace blink | 55 } // namespace blink |
| 57 | 56 |
| 58 #endif // OffscreenCanvas_h | 57 #endif // OffscreenCanvas_h |
| OLD | NEW |