michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_COPYABLECANVASLAYER_H michael@0: #define GFX_COPYABLECANVASLAYER_H michael@0: michael@0: #include // for uint32_t michael@0: #include "GLContextTypes.h" // for GLContext michael@0: #include "Layers.h" // for CanvasLayer, etc michael@0: #include "gfxContext.h" // for gfxContext, etc michael@0: #include "gfxTypes.h" michael@0: #include "gfxPlatform.h" // for gfxImageFormat michael@0: #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc michael@0: #include "mozilla/Preferences.h" // for Preferences michael@0: #include "mozilla/RefPtr.h" // for RefPtr michael@0: #include "mozilla/gfx/2D.h" // for DrawTarget michael@0: #include "mozilla/mozalloc.h" // for operator delete, etc michael@0: #include "nsAutoPtr.h" // for nsRefPtr michael@0: #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace gfx { michael@0: class SurfaceStream; michael@0: class SharedSurface; michael@0: class SurfaceFactory; michael@0: } michael@0: michael@0: namespace layers { michael@0: michael@0: class CanvasClientWebGL; michael@0: michael@0: /** michael@0: * A shared CanvasLayer implementation that supports copying michael@0: * its contents into a gfxASurface using UpdateSurface. michael@0: */ michael@0: class CopyableCanvasLayer : public CanvasLayer michael@0: { michael@0: public: michael@0: CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData); michael@0: virtual ~CopyableCanvasLayer(); michael@0: michael@0: virtual void Initialize(const Data& aData); michael@0: michael@0: virtual bool IsDataValid(const Data& aData); michael@0: michael@0: protected: michael@0: void UpdateTarget(gfx::DrawTarget* aDestTarget = nullptr); michael@0: michael@0: RefPtr mSurface; michael@0: nsRefPtr mGLContext; michael@0: mozilla::RefPtr mDrawTarget; michael@0: michael@0: RefPtr mStream; michael@0: michael@0: uint32_t mCanvasFramebuffer; michael@0: michael@0: bool mIsGLAlphaPremult; michael@0: bool mNeedsYFlip; michael@0: michael@0: RefPtr mCachedTempSurface; michael@0: gfx::IntSize mCachedSize; michael@0: gfx::SurfaceFormat mCachedFormat; michael@0: michael@0: gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize, michael@0: const gfx::SurfaceFormat aFormat); michael@0: michael@0: void DiscardTempSurface(); michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif