1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/d3d9/ThebesLayerD3D9.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_THEBESLAYERD3D9_H 1.10 +#define GFX_THEBESLAYERD3D9_H 1.11 + 1.12 +#include "Layers.h" 1.13 +#include "LayerManagerD3D9.h" 1.14 +#include "ReadbackProcessor.h" 1.15 + 1.16 +namespace mozilla { 1.17 +namespace layers { 1.18 + 1.19 +class ReadbackProcessor; 1.20 + 1.21 +class ThebesLayerD3D9 : public ThebesLayer, 1.22 + public LayerD3D9 1.23 +{ 1.24 +public: 1.25 + ThebesLayerD3D9(LayerManagerD3D9 *aManager); 1.26 + virtual ~ThebesLayerD3D9(); 1.27 + 1.28 + /* ThebesLayer implementation */ 1.29 + void InvalidateRegion(const nsIntRegion& aRegion); 1.30 + 1.31 + /* LayerD3D9 implementation */ 1.32 + Layer* GetLayer(); 1.33 + virtual bool IsEmpty(); 1.34 + virtual void RenderLayer() { RenderThebesLayer(nullptr); } 1.35 + virtual void CleanResources(); 1.36 + virtual void LayerManagerDestroyed(); 1.37 + 1.38 + void RenderThebesLayer(ReadbackProcessor* aReadback); 1.39 + 1.40 +private: 1.41 + /* 1.42 + * D3D9 texture 1.43 + */ 1.44 + nsRefPtr<IDirect3DTexture9> mTexture; 1.45 + /* 1.46 + * D3D9 texture for render-on-white when doing component alpha 1.47 + */ 1.48 + nsRefPtr<IDirect3DTexture9> mTextureOnWhite; 1.49 + /** 1.50 + * Visible region bounds used when we drew the contents of the textures 1.51 + */ 1.52 + nsIntRect mTextureRect; 1.53 + 1.54 + bool HaveTextures(SurfaceMode aMode) 1.55 + { 1.56 + return mTexture && (aMode != SurfaceMode::SURFACE_COMPONENT_ALPHA || mTextureOnWhite); 1.57 + } 1.58 + 1.59 + /* Checks if our surface has the right content type */ 1.60 + void VerifyContentType(SurfaceMode aMode); 1.61 + 1.62 + /* Ensures we have the necessary texture object(s) and that they correspond 1.63 + * to mVisibleRegion.GetBounds(). This creates new texture objects as 1.64 + * necessary and also copies existing valid texture data if necessary. 1.65 + */ 1.66 + void UpdateTextures(SurfaceMode aMode); 1.67 + 1.68 + /* Render the rectangles of mVisibleRegion with D3D9 using the currently 1.69 + * bound textures, target, shaders, etc. 1.70 + */ 1.71 + void RenderRegion(const nsIntRegion& aRegion); 1.72 + 1.73 + /* Have a region of our layer drawn */ 1.74 + void DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode, 1.75 + const nsTArray<ReadbackProcessor::Update>& aReadbackUpdates); 1.76 + 1.77 + /* Create a new texture */ 1.78 + void CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode); 1.79 + 1.80 + void CopyRegion(IDirect3DTexture9* aSrc, const nsIntPoint &aSrcOffset, 1.81 + IDirect3DTexture9* aDest, const nsIntPoint &aDestOffset, 1.82 + const nsIntRegion &aCopyRegion, nsIntRegion* aValidRegion); 1.83 +}; 1.84 + 1.85 +} /* layers */ 1.86 +} /* mozilla */ 1.87 +#endif /* GFX_THEBESLAYERD3D9_H */