michael@0: /* -*- Mode: C++; tab-width: 20; 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_CANVASLAYERD3D9_H michael@0: #define GFX_CANVASLAYERD3D9_H michael@0: michael@0: #include "LayerManagerD3D9.h" michael@0: #include "GLContextTypes.h" michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: michael@0: class CanvasLayerD3D9 : michael@0: public CanvasLayer, michael@0: public LayerD3D9 michael@0: { michael@0: public: michael@0: CanvasLayerD3D9(LayerManagerD3D9 *aManager); michael@0: ~CanvasLayerD3D9(); michael@0: michael@0: // CanvasLayer implementation michael@0: virtual void Initialize(const Data& aData); michael@0: michael@0: // LayerD3D9 implementation michael@0: virtual Layer* GetLayer(); michael@0: virtual void RenderLayer(); michael@0: virtual void CleanResources(); michael@0: virtual void LayerManagerDestroyed(); michael@0: michael@0: void CreateTexture(); michael@0: michael@0: protected: michael@0: typedef mozilla::gl::GLContext GLContext; michael@0: michael@0: void UpdateSurface(); michael@0: michael@0: nsRefPtr mGLContext; michael@0: nsRefPtr mTexture; michael@0: RefPtr mDrawTarget; michael@0: michael@0: bool mDataIsPremultiplied; michael@0: bool mNeedsYFlip; michael@0: bool mHasAlpha; michael@0: michael@0: nsAutoArrayPtr mCachedTempBlob; michael@0: uint32_t mCachedTempBlob_Size; michael@0: michael@0: uint8_t* GetTempBlob(const uint32_t aSize) michael@0: { michael@0: if (!mCachedTempBlob || aSize != mCachedTempBlob_Size) { michael@0: mCachedTempBlob = new uint8_t[aSize]; michael@0: mCachedTempBlob_Size = aSize; michael@0: } michael@0: michael@0: return mCachedTempBlob; michael@0: } michael@0: michael@0: void DiscardTempBlob() michael@0: { michael@0: mCachedTempBlob = nullptr; michael@0: } michael@0: }; michael@0: michael@0: } /* layers */ michael@0: } /* mozilla */ michael@0: #endif /* GFX_CANVASLAYERD3D9_H */