1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GFX_ContainerLayerComposite_H
#define GFX_ContainerLayerComposite_H
#include "Layers.h" // for Layer (ptr only), etc
#include "mozilla/Attributes.h" // for override
#include "mozilla/UniquePtr.h" // for UniquePtr
#include "mozilla/layers/LayerManagerComposite.h"
#include "mozilla/gfx/Rect.h"
namespace mozilla {
namespace layers {
class CompositableHost;
class CompositingRenderTarget;
struct PreparedData;
class ContainerLayerComposite : public ContainerLayer,
public LayerComposite
{
template<class ContainerT>
friend void ContainerPrepare(ContainerT* aContainer,
LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend void ContainerRender(ContainerT* aContainer,
LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend void RenderLayers(ContainerT* aContainer,
LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend void RenderIntermediate(ContainerT* aContainer,
LayerManagerComposite* aManager,
const gfx::IntRect& aClipRect,
RefPtr<CompositingRenderTarget> surface);
template<class ContainerT>
friend RefPtr<CompositingRenderTarget>
CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer,
LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend RefPtr<CompositingRenderTarget>
CreateOrRecycleTarget(ContainerT* aContainer,
LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
void RenderMinimap(ContainerT* aContainer, LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect, Layer* aLayer);
public:
explicit ContainerLayerComposite(LayerManagerComposite *aManager);
protected:
~ContainerLayerComposite();
public:
// LayerComposite Implementation
virtual Layer* GetLayer() override { return this; }
virtual void SetLayerManager(LayerManagerComposite* aManager) override
{
LayerComposite::SetLayerManager(aManager);
mManager = aManager;
mLastIntermediateSurface = nullptr;
}
virtual void Destroy() override;
LayerComposite* GetFirstChildComposite() override;
virtual void RenderLayer(const gfx::IntRect& aClipRect) override;
virtual void Prepare(const RenderTargetIntRect& aClipRect) override;
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
{
DefaultComputeEffectiveTransforms(aTransformToSurface);
}
virtual void CleanupResources() override;
virtual LayerComposite* AsLayerComposite() override { return this; }
// container layers don't use a compositable
CompositableHost* GetCompositableHost() override { return nullptr; }
// If the layer is marked as scale-to-resolution, add a post-scale
// to the layer's transform equal to the pres shell resolution we're
// scaling to. This cancels out the post scale of '1 / resolution'
// added by Layout. TODO: It would be nice to get rid of both of these
// post-scales.
virtual float GetPostXScale() const override {
if (mScaleToResolution) {
return mPostXScale * mPresShellResolution;
}
return mPostXScale;
}
virtual float GetPostYScale() const override {
if (mScaleToResolution) {
return mPostYScale * mPresShellResolution;
}
return mPostYScale;
}
virtual const char* Name() const override { return "ContainerLayerComposite"; }
UniquePtr<PreparedData> mPrepared;
RefPtr<CompositingRenderTarget> mLastIntermediateSurface;
};
class RefLayerComposite : public RefLayer,
public LayerComposite
{
template<class ContainerT>
friend void ContainerPrepare(ContainerT* aContainer,
LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend void ContainerRender(ContainerT* aContainer,
LayerManagerComposite* aManager,
const gfx::IntRect& aClipRect);
template<class ContainerT>
friend void RenderLayers(ContainerT* aContainer,
LayerManagerComposite* aManager,
const gfx::IntRect& aClipRect);
template<class ContainerT>
friend void RenderIntermediate(ContainerT* aContainer,
LayerManagerComposite* aManager,
const gfx::IntRect& aClipRect,
RefPtr<CompositingRenderTarget> surface);
template<class ContainerT>
friend RefPtr<CompositingRenderTarget>
CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer,
LayerManagerComposite* aManager,
const gfx::IntRect& aClipRect);
template<class ContainerT>
friend RefPtr<CompositingRenderTarget>
CreateTemporaryTarget(ContainerT* aContainer,
LayerManagerComposite* aManager,
const gfx::IntRect& aClipRect);
public:
explicit RefLayerComposite(LayerManagerComposite *aManager);
protected:
~RefLayerComposite();
public:
/** LayerOGL implementation */
Layer* GetLayer() override { return this; }
virtual void SetLayerManager(LayerManagerComposite* aManager) override
{
LayerComposite::SetLayerManager(aManager);
mManager = aManager;
mLastIntermediateSurface = nullptr;
}
void Destroy() override;
LayerComposite* GetFirstChildComposite() override;
virtual void RenderLayer(const gfx::IntRect& aClipRect) override;
virtual void Prepare(const RenderTargetIntRect& aClipRect) override;
virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
{
DefaultComputeEffectiveTransforms(aTransformToSurface);
}
virtual void CleanupResources() override;
virtual LayerComposite* AsLayerComposite() override { return this; }
// ref layers don't use a compositable
CompositableHost* GetCompositableHost() override { return nullptr; }
virtual const char* Name() const override { return "RefLayerComposite"; }
UniquePtr<PreparedData> mPrepared;
RefPtr<CompositingRenderTarget> mLastIntermediateSurface;
};
} // namespace layers
} // namespace mozilla
#endif /* GFX_ContainerLayerComposite_H */
|