|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef GFX_THEBESLAYERD3D9_H |
|
7 #define GFX_THEBESLAYERD3D9_H |
|
8 |
|
9 #include "Layers.h" |
|
10 #include "LayerManagerD3D9.h" |
|
11 #include "ReadbackProcessor.h" |
|
12 |
|
13 namespace mozilla { |
|
14 namespace layers { |
|
15 |
|
16 class ReadbackProcessor; |
|
17 |
|
18 class ThebesLayerD3D9 : public ThebesLayer, |
|
19 public LayerD3D9 |
|
20 { |
|
21 public: |
|
22 ThebesLayerD3D9(LayerManagerD3D9 *aManager); |
|
23 virtual ~ThebesLayerD3D9(); |
|
24 |
|
25 /* ThebesLayer implementation */ |
|
26 void InvalidateRegion(const nsIntRegion& aRegion); |
|
27 |
|
28 /* LayerD3D9 implementation */ |
|
29 Layer* GetLayer(); |
|
30 virtual bool IsEmpty(); |
|
31 virtual void RenderLayer() { RenderThebesLayer(nullptr); } |
|
32 virtual void CleanResources(); |
|
33 virtual void LayerManagerDestroyed(); |
|
34 |
|
35 void RenderThebesLayer(ReadbackProcessor* aReadback); |
|
36 |
|
37 private: |
|
38 /* |
|
39 * D3D9 texture |
|
40 */ |
|
41 nsRefPtr<IDirect3DTexture9> mTexture; |
|
42 /* |
|
43 * D3D9 texture for render-on-white when doing component alpha |
|
44 */ |
|
45 nsRefPtr<IDirect3DTexture9> mTextureOnWhite; |
|
46 /** |
|
47 * Visible region bounds used when we drew the contents of the textures |
|
48 */ |
|
49 nsIntRect mTextureRect; |
|
50 |
|
51 bool HaveTextures(SurfaceMode aMode) |
|
52 { |
|
53 return mTexture && (aMode != SurfaceMode::SURFACE_COMPONENT_ALPHA || mTextureOnWhite); |
|
54 } |
|
55 |
|
56 /* Checks if our surface has the right content type */ |
|
57 void VerifyContentType(SurfaceMode aMode); |
|
58 |
|
59 /* Ensures we have the necessary texture object(s) and that they correspond |
|
60 * to mVisibleRegion.GetBounds(). This creates new texture objects as |
|
61 * necessary and also copies existing valid texture data if necessary. |
|
62 */ |
|
63 void UpdateTextures(SurfaceMode aMode); |
|
64 |
|
65 /* Render the rectangles of mVisibleRegion with D3D9 using the currently |
|
66 * bound textures, target, shaders, etc. |
|
67 */ |
|
68 void RenderRegion(const nsIntRegion& aRegion); |
|
69 |
|
70 /* Have a region of our layer drawn */ |
|
71 void DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode, |
|
72 const nsTArray<ReadbackProcessor::Update>& aReadbackUpdates); |
|
73 |
|
74 /* Create a new texture */ |
|
75 void CreateNewTextures(const gfx::IntSize &aSize, SurfaceMode aMode); |
|
76 |
|
77 void CopyRegion(IDirect3DTexture9* aSrc, const nsIntPoint &aSrcOffset, |
|
78 IDirect3DTexture9* aDest, const nsIntPoint &aDestOffset, |
|
79 const nsIntRegion &aCopyRegion, nsIntRegion* aValidRegion); |
|
80 }; |
|
81 |
|
82 } /* layers */ |
|
83 } /* mozilla */ |
|
84 #endif /* GFX_THEBESLAYERD3D9_H */ |