// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef OffscreenCanvas_h #define OffscreenCanvas_h #include "bindings/core/v8/ScriptPromise.h" #include "bindings/core/v8/ScriptState.h" #include "bindings/core/v8/ScriptWrappable.h" #include "modules/ModulesExport.h" #include "platform/geometry/IntSize.h" #include "platform/heap/Handle.h" namespace blink { class CanvasContextCreationAttributes; class ImageBitmap; class OffscreenCanvasRenderingContext; class OffscreenCanvasRenderingContext2D; class OffscreenCanvasRenderingContextFactory; class MODULES_EXPORT OffscreenCanvas final : public GarbageCollectedFinalized, public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: static OffscreenCanvas* create(unsigned width, unsigned height); ~OffscreenCanvas(); // IDL attributes unsigned width() const { return m_size.width(); } unsigned height() const { return m_size.height(); } void setWidth(unsigned); void setHeight(unsigned); // API Methods OffscreenCanvasRenderingContext2D* getContext(const String&, const CanvasContextCreationAttributes&); PassRefPtrWillBeRawPtr transferToImageBitmap(ExceptionState&); IntSize size() const { return m_size; } OffscreenCanvasRenderingContext2D* renderingContext() const; static void registerRenderingContextFactory(PassOwnPtr); DECLARE_VIRTUAL_TRACE(); private: OffscreenCanvas(const IntSize&); using ContextFactoryVector = Vector>; static ContextFactoryVector& renderingContextFactories(); static OffscreenCanvasRenderingContextFactory* getRenderingContextFactory(int); Member m_context; IntSize m_size; }; } // namespace blink #endif // OffscreenCanvas_h