/src/mozilla-central/gfx/layers/mlgpu/MaskOperation.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_gfx_layers_mlgpu_MaskOperation_h |
8 | | #define mozilla_gfx_layers_mlgpu_MaskOperation_h |
9 | | |
10 | | #include "mozilla/RefPtr.h" |
11 | | #include "mozilla/gfx/Rect.h" |
12 | | #include "SharedBufferMLGPU.h" |
13 | | #include <vector> |
14 | | |
15 | | namespace mozilla { |
16 | | namespace layers { |
17 | | |
18 | | class FrameBuilder; |
19 | | class Layer; |
20 | | class MLGDevice; |
21 | | class MLGRenderTarget; |
22 | | class MLGTexture; |
23 | | class TextureSource; |
24 | | |
25 | | class MaskOperation |
26 | | { |
27 | | NS_INLINE_DECL_REFCOUNTING(MaskOperation) |
28 | | |
29 | | public: |
30 | | // For when the exact texture is known ahead of time. |
31 | | MaskOperation(FrameBuilder* aBuilder, MLGTexture* aSource); |
32 | | |
33 | | // Return the mask rectangle in screen coordinates. This function takes a |
34 | | // layer because a single-texture mask operation is not dependent on a |
35 | | // specific mask transform. (Multiple mask layer operations are, and they |
36 | | // ignore the layer parameter). |
37 | | virtual gfx::Rect ComputeMaskRect(Layer* aLayer) const; |
38 | | |
39 | 0 | MLGTexture* GetTexture() const { |
40 | 0 | return mTexture; |
41 | 0 | } |
42 | 0 | bool IsEmpty() const { |
43 | 0 | return !mTexture; |
44 | 0 | } |
45 | | |
46 | | protected: |
47 | | explicit MaskOperation(FrameBuilder* aBuilder); |
48 | | virtual ~MaskOperation(); |
49 | | |
50 | | protected: |
51 | | RefPtr<MLGTexture> mTexture; |
52 | | }; |
53 | | |
54 | | struct MaskTexture |
55 | | { |
56 | | MaskTexture() : mSource(nullptr) |
57 | 0 | {} |
58 | | MaskTexture(const gfx::Rect& aRect, TextureSource* aSource) |
59 | | : mRect(aRect), mSource(aSource) |
60 | 0 | {} |
61 | | |
62 | | bool operator <(const MaskTexture& aOther) const; |
63 | | |
64 | | gfx::Rect mRect; |
65 | | RefPtr<TextureSource> mSource; |
66 | | }; |
67 | | |
68 | | typedef std::vector<MaskTexture> MaskTextureList; |
69 | | |
70 | | class MaskCombineOperation final : public MaskOperation |
71 | | { |
72 | | public: |
73 | | explicit MaskCombineOperation(FrameBuilder* aBuilder); |
74 | | ~MaskCombineOperation() override; |
75 | | |
76 | | void Init(const MaskTextureList& aTextures); |
77 | | |
78 | | void PrepareForRendering(); |
79 | | void Render(); |
80 | | |
81 | 0 | gfx::Rect ComputeMaskRect(Layer* aLayer) const override { |
82 | 0 | return mArea; |
83 | 0 | } |
84 | | |
85 | | private: |
86 | | FrameBuilder* mBuilder; |
87 | | gfx::Rect mArea; |
88 | | MaskTextureList mTextures; |
89 | | RefPtr<MLGRenderTarget> mTarget; |
90 | | |
91 | | std::vector<VertexBufferSection> mInputBuffers; |
92 | | }; |
93 | | |
94 | | RefPtr<TextureSource> GetMaskLayerTexture(Layer* aLayer); |
95 | | void AppendToMaskTextureList(MaskTextureList& aList, Layer* aLayer); |
96 | | |
97 | | } // namespace layers |
98 | | } // namespace mozilla |
99 | | |
100 | | #endif // mozilla_gfx_layers_mlgpu_MaskOperation_h |