michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 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_THEBESLAYERD3D9_H michael@0: #define GFX_THEBESLAYERD3D9_H michael@0: michael@0: #include "Layers.h" michael@0: #include "LayerManagerD3D9.h" michael@0: #include "ReadbackProcessor.h" michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class ReadbackProcessor; michael@0: michael@0: class ThebesLayerD3D9 : public ThebesLayer, michael@0: public LayerD3D9 michael@0: { michael@0: public: michael@0: ThebesLayerD3D9(LayerManagerD3D9 *aManager); michael@0: virtual ~ThebesLayerD3D9(); michael@0: michael@0: /* ThebesLayer implementation */ michael@0: void InvalidateRegion(const nsIntRegion& aRegion); michael@0: michael@0: /* LayerD3D9 implementation */ michael@0: Layer* GetLayer(); michael@0: virtual bool IsEmpty(); michael@0: virtual void RenderLayer() { RenderThebesLayer(nullptr); } michael@0: virtual void CleanResources(); michael@0: virtual void LayerManagerDestroyed(); michael@0: michael@0: void RenderThebesLayer(ReadbackProcessor* aReadback); michael@0: michael@0: private: michael@0: /* michael@0: * D3D9 texture michael@0: */ michael@0: nsRefPtr mTexture; michael@0: /* michael@0: * D3D9 texture for render-on-white when doing component alpha michael@0: */ michael@0: nsRefPtr mTextureOnWhite; michael@0: /** michael@0: * Visible region bounds used when we drew the contents of the textures michael@0: */ michael@0: nsIntRect mTextureRect; michael@0: michael@0: bool HaveTextures(SurfaceMode aMode) michael@0: { michael@0: return mTexture && (aMode != SurfaceMode::SURFACE_COMPONENT_ALPHA || mTextureOnWhite); michael@0: } michael@0: michael@0: /* Checks if our surface has the right content type */ michael@0: void VerifyContentType(SurfaceMode aMode); michael@0: michael@0: /* Ensures we have the necessary texture object(s) and that they correspond michael@0: * to mVisibleRegion.GetBounds(). This creates new texture objects as michael@0: * necessary and also copies existing valid texture data if necessary. michael@0: */ michael@0: void UpdateTextures(SurfaceMode aMode); michael@0: michael@0: /* Render the rectangles of mVisibleRegion with D3D9 using the currently michael@0: * bound textures, target, shaders, etc. michael@0: */ michael@0: void RenderRegion(const nsIntRegion& aRegion); michael@0: michael@0: /* Have a region of our layer drawn */ michael@0: void DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode, michael@0: const nsTArray& aReadbackUpdates); michael@0: michael@0: /* Create a new texture */ michael@0: void CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode); michael@0: michael@0: void CopyRegion(IDirect3DTexture9* aSrc, const nsIntPoint &aSrcOffset, michael@0: IDirect3DTexture9* aDest, const nsIntPoint &aDestOffset, michael@0: const nsIntRegion &aCopyRegion, nsIntRegion* aValidRegion); michael@0: }; michael@0: michael@0: } /* layers */ michael@0: } /* mozilla */ michael@0: #endif /* GFX_THEBESLAYERD3D9_H */