/src/mozilla-central/gfx/layers/mlgpu/TexturedLayerMLGPU.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_TexturedLayerMLGPU_h |
8 | | #define mozilla_gfx_layers_mlgpu_TexturedLayerMLGPU_h |
9 | | |
10 | | #include "LayerMLGPU.h" |
11 | | #include "ImageLayers.h" |
12 | | #include "mozilla/layers/ImageHost.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace layers { |
16 | | |
17 | | // This is the base class for canvas and image layers. |
18 | | class TexturedLayerMLGPU : public LayerMLGPU |
19 | | { |
20 | | public: |
21 | 0 | TexturedLayerMLGPU* AsTexturedLayerMLGPU() override { return this; } |
22 | | |
23 | | virtual gfx::SamplingFilter GetSamplingFilter() = 0; |
24 | | |
25 | | bool SetCompositableHost(CompositableHost* aHost) override; |
26 | | CompositableHost* GetCompositableHost() override; |
27 | | |
28 | | void AssignToView(FrameBuilder* aBuilder, |
29 | | RenderViewMLGPU* aView, |
30 | | Maybe<gfx::Polygon>&& aGeometry) override; |
31 | | |
32 | 0 | TextureSource* GetTexture() const { |
33 | 0 | return mTexture; |
34 | 0 | } |
35 | 0 | ImageHost* GetImageHost() const { |
36 | 0 | return mHost; |
37 | 0 | } |
38 | | |
39 | | // Return the scale factor from the texture source to the picture rect. |
40 | 0 | virtual Maybe<gfx::Size> GetPictureScale() const { |
41 | 0 | return Nothing(); |
42 | 0 | } |
43 | | |
44 | | // Mask layers aren't prepared like normal layers. They are bound as |
45 | | // mask operations are built. Mask layers are never tiled (they are |
46 | | // scaled to a lower resolution if too big), so this pathway returns |
47 | | // a TextureSource. |
48 | | RefPtr<TextureSource> BindAndGetTexture(); |
49 | | |
50 | | protected: |
51 | | explicit TexturedLayerMLGPU(LayerManagerMLGPU* aManager); |
52 | | virtual ~TexturedLayerMLGPU() override; |
53 | | |
54 | | void AssignBigImage(FrameBuilder* aBuilder, |
55 | | RenderViewMLGPU* aView, |
56 | | BigImageIterator* aIter, |
57 | | const Maybe<gfx::Polygon>& aGeometry); |
58 | | |
59 | | bool OnPrepareToRender(FrameBuilder* aBuilder) override; |
60 | | |
61 | | protected: |
62 | | RefPtr<ImageHost> mHost; |
63 | | RefPtr<TextureSource> mTexture; |
64 | | RefPtr<TextureSource> mBigImageTexture; |
65 | | gfx::IntRect mPictureRect; |
66 | | }; |
67 | | |
68 | | // This is a pseudo layer that wraps a tile in an ImageLayer backed by a |
69 | | // BigImage. Without this, we wouldn't have anything sensible to add to |
70 | | // RenderPasses. In the future we could potentially consume the source |
71 | | // layer more intelligently instead (for example, having it compute |
72 | | // which textures are relevant for a given tile). |
73 | | class TempImageLayerMLGPU final : public ImageLayer, |
74 | | public TexturedLayerMLGPU |
75 | | { |
76 | | public: |
77 | | explicit TempImageLayerMLGPU(LayerManagerMLGPU* aManager); |
78 | | |
79 | | // Layer |
80 | 0 | HostLayer* AsHostLayer() override { return this; } |
81 | 0 | gfx::SamplingFilter GetSamplingFilter() override { |
82 | 0 | return mFilter; |
83 | 0 | } |
84 | 0 | bool IsContentOpaque() override { |
85 | 0 | return mIsOpaque; |
86 | 0 | } |
87 | | |
88 | | void Init(TexturedLayerMLGPU* aSource, |
89 | | const RefPtr<TextureSource>& aTexture, |
90 | | const gfx::IntRect& aPictureRect); |
91 | | |
92 | | // HostLayer |
93 | 0 | Layer* GetLayer() override { return this; } |
94 | | |
95 | | protected: |
96 | | ~TempImageLayerMLGPU() override; |
97 | | |
98 | | private: |
99 | | gfx::SamplingFilter mFilter; |
100 | | bool mIsOpaque; |
101 | | }; |
102 | | |
103 | | } // namespace layers |
104 | | } // namespace mozilla |
105 | | |
106 | | #endif // mozilla_gfx_layers_mlgpu_TexturedLayerMLGPU_h |