/src/mozilla-central/gfx/layers/mlgpu/PaintedLayerMLGPU.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_PAINTEDLAYERMLGPU_H |
8 | | #define MOZILLA_GFX_PAINTEDLAYERMLGPU_H |
9 | | |
10 | | #include "LayerManagerMLGPU.h" |
11 | | #include "mozilla/layers/ContentHost.h" |
12 | | #include "MLGDeviceTypes.h" |
13 | | #include "nsRegionFwd.h" |
14 | | #include <functional> |
15 | | |
16 | | namespace mozilla { |
17 | | namespace layers { |
18 | | |
19 | | class TiledLayerBufferComposite; |
20 | | |
21 | | class PaintedLayerMLGPU final |
22 | | : public PaintedLayer, |
23 | | public LayerMLGPU |
24 | | { |
25 | | public: |
26 | | explicit PaintedLayerMLGPU(LayerManagerMLGPU* aManager); |
27 | | ~PaintedLayerMLGPU() override; |
28 | | |
29 | | // Layer |
30 | 0 | HostLayer* AsHostLayer() override { return this; } |
31 | 0 | PaintedLayerMLGPU* AsPaintedLayerMLGPU() override { return this; } |
32 | 0 | virtual Layer* GetLayer() override { return this; } |
33 | | bool SetCompositableHost(CompositableHost*) override; |
34 | | CompositableHost* GetCompositableHost() override; |
35 | | void Disconnect() override; |
36 | | bool IsContentOpaque() override; |
37 | | |
38 | | // PaintedLayer |
39 | 0 | void InvalidateRegion(const nsIntRegion& aRegion) override { |
40 | 0 | MOZ_CRASH("PaintedLayerMLGPU can't fill invalidated regions"); |
41 | 0 | } |
42 | | |
43 | 0 | bool HasComponentAlpha() const { |
44 | 0 | return !!mTextureOnWhite; |
45 | 0 | } |
46 | 0 | TextureSource* GetTexture() const { |
47 | 0 | return mTexture; |
48 | 0 | } |
49 | 0 | TextureSource* GetTextureOnWhite() const { |
50 | 0 | MOZ_ASSERT(HasComponentAlpha()); |
51 | 0 | return mTextureOnWhite; |
52 | 0 | } |
53 | | gfx::Point GetDestOrigin() const; |
54 | | |
55 | 0 | SamplerMode GetSamplerMode() { |
56 | 0 | // Note that when resamping, we must break the texture coordinates into |
57 | 0 | // no-repeat rects. When we have simple integer translations we can |
58 | 0 | // simply wrap around the edge of the buffer texture. |
59 | 0 | return MayResample() |
60 | 0 | ? SamplerMode::LinearClamp |
61 | 0 | : SamplerMode::LinearRepeat; |
62 | 0 | } |
63 | | |
64 | | void SetRenderRegion(LayerIntRegion&& aRegion) override; |
65 | | |
66 | | // To avoid sampling issues with complex regions and transforms, we |
67 | | // squash the visible region for PaintedLayers into a single draw |
68 | | // rect. RenderPasses should use this method instead of GetRenderRegion. |
69 | | const LayerIntRegion& GetDrawRects(); |
70 | | |
71 | | MOZ_LAYER_DECL_NAME("PaintedLayerMLGPU", TYPE_PAINTED) |
72 | | |
73 | | void CleanupCachedResources(); |
74 | | |
75 | | protected: |
76 | | void PrintInfo(std::stringstream& aStream, const char* aPrefix) override; |
77 | | bool OnPrepareToRender(FrameBuilder* aBuilder) override; |
78 | | |
79 | | // We override this to support tiling. |
80 | | void AssignToView(FrameBuilder* aBuilder, |
81 | | RenderViewMLGPU* aView, |
82 | | Maybe<gfx::Polygon>&& aGeometry) override; |
83 | | |
84 | | void AssignHighResTilesToView(FrameBuilder* aBuilder, |
85 | | RenderViewMLGPU* aView, |
86 | | TiledContentHost* aTileHost, |
87 | | const Maybe<gfx::Polygon>& aGeometry); |
88 | | |
89 | | // Helper for Assign*TilesToView. |
90 | | void AssignTileBufferToView(FrameBuilder* aBuilder, |
91 | | RenderViewMLGPU* aView, |
92 | | TiledLayerBufferComposite& aTiles, |
93 | | const LayerIntRegion& aCompositeRegion, |
94 | | const Maybe<gfx::Polygon>& aGeometry); |
95 | | |
96 | | void CleanupResources(); |
97 | | |
98 | | private: |
99 | | RefPtr<ContentHost> mHost; |
100 | | RefPtr<TextureSource> mTexture; |
101 | | RefPtr<TextureSource> mTextureOnWhite; |
102 | | #ifndef MOZ_IGNORE_PAINT_WILL_RESAMPLE |
103 | | LayerIntRegion mDrawRects; |
104 | | #endif |
105 | | gfx::IntPoint mDestOrigin; |
106 | | }; |
107 | | |
108 | | } // namespace layers |
109 | | } // namespace mozilla |
110 | | |
111 | | #endif |