Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/composite/ContainerLayerComposite.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 GFX_ContainerLayerComposite_H
8
#define GFX_ContainerLayerComposite_H
9
10
#include "Layers.h"                     // for Layer (ptr only), etc
11
#include "mozilla/Attributes.h"         // for override
12
#include "mozilla/UniquePtr.h"          // for UniquePtr
13
#include "mozilla/layers/LayerManagerComposite.h"
14
#include "mozilla/gfx/Rect.h"
15
16
namespace mozilla {
17
namespace layers {
18
19
class APZSampler;
20
class CompositableHost;
21
class CompositingRenderTarget;
22
struct PreparedData;
23
24
class ContainerLayerComposite : public ContainerLayer,
25
                                public LayerComposite
26
{
27
  template<class ContainerT>
28
  friend void ContainerPrepare(ContainerT* aContainer,
29
                               LayerManagerComposite* aManager,
30
                               const RenderTargetIntRect& aClipRect);
31
  template<class ContainerT>
32
  friend void ContainerRender(ContainerT* aContainer,
33
                              LayerManagerComposite* aManager,
34
                              const RenderTargetIntRect& aClipRect,
35
                              const Maybe<gfx::Polygon>& aGeometry);
36
  template<class ContainerT>
37
  friend void RenderLayers(ContainerT* aContainer,
38
                           LayerManagerComposite* aManager,
39
                           const RenderTargetIntRect& aClipRect,
40
                           const Maybe<gfx::Polygon>& aGeometry);
41
  template<class ContainerT>
42
  friend void RenderIntermediate(ContainerT* aContainer,
43
                   LayerManagerComposite* aManager,
44
                   const gfx::IntRect& aClipRect,
45
                   RefPtr<CompositingRenderTarget> surface);
46
  template<class ContainerT>
47
  friend RefPtr<CompositingRenderTarget>
48
  CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer,
49
                                             LayerManagerComposite* aManager,
50
                                             const RenderTargetIntRect& aClipRect);
51
  template<class ContainerT>
52
  friend RefPtr<CompositingRenderTarget>
53
  CreateOrRecycleTarget(ContainerT* aContainer,
54
                        LayerManagerComposite* aManager,
55
                        const RenderTargetIntRect& aClipRect);
56
57
  template<class ContainerT>
58
  void RenderMinimap(ContainerT* aContainer,
59
                     const RefPtr<APZSampler>& aSampler,
60
                     LayerManagerComposite* aManager,
61
                     const RenderTargetIntRect& aClipRect, Layer* aLayer);
62
public:
63
  explicit ContainerLayerComposite(LayerManagerComposite *aManager);
64
65
protected:
66
  ~ContainerLayerComposite();
67
68
public:
69
  // LayerComposite Implementation
70
0
  virtual Layer* GetLayer() override { return this; }
71
72
  virtual void SetLayerManager(HostLayerManager* aManager) override
73
0
  {
74
0
    LayerComposite::SetLayerManager(aManager);
75
0
    mManager = aManager;
76
0
    mLastIntermediateSurface = nullptr;
77
0
  }
78
79
  virtual void Destroy() override;
80
81
  LayerComposite* GetFirstChildComposite() override;
82
83
  virtual void Cleanup() override;
84
85
  virtual void RenderLayer(const gfx::IntRect& aClipRect,
86
                           const Maybe<gfx::Polygon>& aGeometry) override;
87
88
  virtual void Prepare(const RenderTargetIntRect& aClipRect) override;
89
90
  virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
91
0
  {
92
0
    DefaultComputeEffectiveTransforms(aTransformToSurface);
93
0
  }
94
95
  virtual const LayerIntRegion& GetShadowVisibleRegion() override;
96
97
  virtual void CleanupResources() override;
98
99
0
  virtual HostLayer* AsHostLayer() override { return this; }
100
101
  // container layers don't use a compositable
102
0
  CompositableHost* GetCompositableHost() override { return nullptr; }
103
104
  // If the layer is marked as scale-to-resolution, add a post-scale
105
  // to the layer's transform equal to the pres shell resolution we're
106
  // scaling to. This cancels out the post scale of '1 / resolution'
107
  // added by Layout. TODO: It would be nice to get rid of both of these
108
  // post-scales.
109
0
  virtual float GetPostXScale() const override {
110
0
    if (mScaleToResolution) {
111
0
      return mSimpleAttrs.GetPostXScale() * mPresShellResolution;
112
0
    }
113
0
    return mSimpleAttrs.GetPostXScale();
114
0
  }
115
0
  virtual float GetPostYScale() const override {
116
0
    if (mScaleToResolution) {
117
0
      return mSimpleAttrs.GetPostYScale() * mPresShellResolution;
118
0
    }
119
0
    return mSimpleAttrs.GetPostYScale();
120
0
  }
121
122
0
  virtual const char* Name() const override { return "ContainerLayerComposite"; }
123
  UniquePtr<PreparedData> mPrepared;
124
125
  RefPtr<CompositingRenderTarget> mLastIntermediateSurface;
126
};
127
128
class RefLayerComposite : public RefLayer,
129
                          public LayerComposite
130
{
131
  template<class ContainerT>
132
  friend void ContainerPrepare(ContainerT* aContainer,
133
                               LayerManagerComposite* aManager,
134
                               const RenderTargetIntRect& aClipRect);
135
  template<class ContainerT>
136
  friend void ContainerRender(ContainerT* aContainer,
137
                              LayerManagerComposite* aManager,
138
                              const gfx::IntRect& aClipRect,
139
                              const Maybe<gfx::Polygon>& aGeometry);
140
  template<class ContainerT>
141
  friend void RenderLayers(ContainerT* aContainer,
142
                           LayerManagerComposite* aManager,
143
                           const gfx::IntRect& aClipRect,
144
                           const Maybe<gfx::Polygon>& aGeometry);
145
  template<class ContainerT>
146
  friend void RenderIntermediate(ContainerT* aContainer,
147
                   LayerManagerComposite* aManager,
148
                   const gfx::IntRect& aClipRect,
149
                   RefPtr<CompositingRenderTarget> surface);
150
  template<class ContainerT>
151
  friend RefPtr<CompositingRenderTarget>
152
  CreateTemporaryTargetAndCopyFromBackground(ContainerT* aContainer,
153
                                             LayerManagerComposite* aManager,
154
                                             const gfx::IntRect& aClipRect);
155
  template<class ContainerT>
156
  friend RefPtr<CompositingRenderTarget>
157
  CreateTemporaryTarget(ContainerT* aContainer,
158
                        LayerManagerComposite* aManager,
159
                        const gfx::IntRect& aClipRect);
160
161
public:
162
  explicit RefLayerComposite(LayerManagerComposite *aManager);
163
164
protected:
165
  ~RefLayerComposite();
166
167
public:
168
  /** LayerOGL implementation */
169
0
  Layer* GetLayer() override { return this; }
170
171
  virtual void SetLayerManager(HostLayerManager* aManager) override
172
0
  {
173
0
    LayerComposite::SetLayerManager(aManager);
174
0
    mManager = aManager;
175
0
    mLastIntermediateSurface = nullptr;
176
0
  }
177
178
  void Destroy() override;
179
180
  LayerComposite* GetFirstChildComposite() override;
181
182
  virtual void RenderLayer(const gfx::IntRect& aClipRect,
183
                           const Maybe<gfx::Polygon>& aGeometry) override;
184
185
  virtual void Prepare(const RenderTargetIntRect& aClipRect) override;
186
187
  virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
188
0
  {
189
0
    DefaultComputeEffectiveTransforms(aTransformToSurface);
190
0
  }
191
192
  virtual const LayerIntRegion& GetShadowVisibleRegion() override;
193
194
  virtual void Cleanup() override;
195
196
  virtual void CleanupResources() override;
197
198
0
  virtual HostLayer* AsHostLayer() override { return this; }
199
200
  // ref layers don't use a compositable
201
0
  CompositableHost* GetCompositableHost() override { return nullptr; }
202
203
0
  virtual const char* Name() const override { return "RefLayerComposite"; }
204
  UniquePtr<PreparedData> mPrepared;
205
  RefPtr<CompositingRenderTarget> mLastIntermediateSurface;
206
};
207
208
} // namespace layers
209
} // namespace mozilla
210
211
#endif /* GFX_ContainerLayerComposite_H */