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