Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/mlgpu/RenderViewMLGPU.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_RenderViewMLGPU_h
8
#define mozilla_gfx_layers_mlgpu_RenderViewMLGPU_h
9
10
#include "LayerManagerMLGPU.h"
11
#include "ClearRegionHelper.h"
12
#include "RenderPassMLGPU.h"
13
#include "Units.h"
14
#include <deque>
15
16
namespace mozilla {
17
namespace layers {
18
19
class FrameBuilder;
20
class ContainerLayerMLGPU;
21
class MLGRenderTarget;
22
23
class RenderViewMLGPU
24
{
25
public:
26
  NS_INLINE_DECL_REFCOUNTING(RenderViewMLGPU)
27
28
  // Constructor for the widget render target.
29
  RenderViewMLGPU(FrameBuilder* aBuilder,
30
                  MLGRenderTarget* aTarget,
31
                  const nsIntRegion& aInvalidRegion);
32
33
  // Constructor for intermediate surfaces.
34
  RenderViewMLGPU(FrameBuilder* aBuilder,
35
                  ContainerLayerMLGPU* aContainer,
36
                  RenderViewMLGPU* aParent);
37
38
  void Prepare();
39
  void Render();
40
  void AddChild(RenderViewMLGPU* aParent);
41
  void AddItem(LayerMLGPU* aItem,
42
               const gfx::IntRect& aBounds,
43
               Maybe<gfx::Polygon>&& aGeometry);
44
  void FinishBuilding();
45
46
0
  const gfx::IntPoint& GetTargetOffset() const {
47
0
    return mTargetOffset;
48
0
  }
49
0
  RenderViewMLGPU* GetParent() const {
50
0
    return mParent;
51
0
  }
52
0
  bool HasDepthBuffer() const {
53
0
    return mUseDepthBuffer;
54
0
  }
55
56
  // Render after having previously delayed rendering due to the view
57
  // requiring a backdrop copy.
58
  void RenderAfterBackdropCopy();
59
  void RestoreDeviceState();
60
61
  // The size and render target cannot be read until the view has finished
62
  // building, since we try to right-size the render target to the visible
63
  // region.
64
  MLGRenderTarget* GetRenderTarget() const;
65
  gfx::IntSize GetSize() const;
66
67
0
  gfx::IntRect GetInvalidRect() const {
68
0
    return mInvalidBounds;
69
0
  }
70
71
private:
72
  RenderViewMLGPU(FrameBuilder* aBuilder, RenderViewMLGPU* aParent);
73
  ~RenderViewMLGPU();
74
75
  void ExecuteRendering();
76
  bool UpdateVisibleRegion(ItemInfo& aItem);
77
  void AddItemFrontToBack(LayerMLGPU* aLayer, ItemInfo& aItem);
78
  void AddItemBackToFront(LayerMLGPU* aLayer, ItemInfo& aItem);
79
80
  void PrepareClears();
81
  void SetDeviceState();
82
  void SetDepthTestMode(MLGDepthTestMode aMode);
83
84
  void ExecutePass(RenderPassMLGPU* aPass);
85
86
  // Return the sorting index offset to use.
87
  int32_t PrepareDepthBuffer();
88
89
private:
90
  std::deque<RefPtr<RenderPassMLGPU>> mFrontToBack;
91
  std::deque<RefPtr<RenderPassMLGPU>> mBackToFront;
92
93
  FrameBuilder* mBuilder;
94
  RefPtr<MLGDevice> mDevice;
95
  RenderViewMLGPU* mParent;
96
  std::vector<RefPtr<RenderViewMLGPU>> mChildren;
97
98
  // Shader data.
99
  ConstantBufferSection mWorldConstants;
100
101
  // Information for the initial target surface clear. This covers the area that
102
  // won't be occluded by opaque content.
103
  ClearRegionHelper mPreClear;
104
105
  // The post-clear region, that must be cleared after all drawing is done.
106
  nsIntRegion mPostClearRegion;
107
  ClearRegionHelper mPostClear;
108
109
  // Either an MLGSwapChain-derived render target, or an intermediate surface.
110
  RefPtr<MLGRenderTarget> mTarget;
111
112
  // For intermediate render targets only, this is the layer owning the render target.
113
  ContainerLayerMLGPU* mContainer;
114
115
  // The offset adjustment from container layer space to render target space.
116
  // This is 0,0 for the root view.
117
  gfx::IntPoint mTargetOffset;
118
119
  // The invalid bounds as computed by LayerTreeInvalidation. This is the initial
120
  // render bounds size, if invalidation is disabled.
121
  gfx::IntRect mInvalidBounds;
122
123
  // The occluded region, which is updated every time we process an opaque,
124
  // rectangular item. This is not actually in LayerPixels, we do this to
125
  // avoid FromUnknownRegion which has array copies.
126
  LayerIntRegion mOccludedRegion;
127
128
  // True if we've finished adding layers to the view.
129
  bool mFinishedBuilding;
130
131
  // This state is used to avoid changing buffers while we execute batches.
132
  size_t mCurrentLayerBufferIndex;
133
  size_t mCurrentMaskRectBufferIndex;
134
135
  // This state is saved locally so it can be restored in RestoreDeviceState.
136
  MLGDepthTestMode mCurrentDepthMode;
137
138
  // Depth-buffer tracking.
139
  int32_t mNextSortIndex;
140
  bool mUseDepthBuffer;
141
  bool mDepthBufferNeedsClear;
142
};
143
144
} // namespace layers
145
} // namespace mozilla
146
147
#endif // mozilla_gfx_layers_mlgpu_RenderViewMLGPU_h