Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::GridBoundsManager Class Reference

#include <BoundsManager.h>

Inheritance diagram for skgpu::graphite::GridBoundsManager:
skgpu::graphite::BoundsManager

Public Member Functions

 ~GridBoundsManager () override
 
CompressedPaintersOrder getMostRecentDraw (const Rect &bounds) const override
 
void recordDraw (const Rect &bounds, CompressedPaintersOrder order) override
 
void reset () override
 
- Public Member Functions inherited from skgpu::graphite::BoundsManager
virtual ~BoundsManager ()
 

Static Public Member Functions

static std::unique_ptr< GridBoundsManagerMake (const SkISize &deviceSize, const SkISize &gridSize)
 
static std::unique_ptr< GridBoundsManagerMake (const SkISize &deviceSize, int gridSize)
 
static std::unique_ptr< GridBoundsManagerMakeRes (SkISize deviceSize, int gridCellSize, int maxGridSize=0)
 

Detailed Description

Definition at line 121 of file BoundsManager.h.

Constructor & Destructor Documentation

◆ ~GridBoundsManager()

skgpu::graphite::GridBoundsManager::~GridBoundsManager ( )
inlineoverride

Definition at line 162 of file BoundsManager.h.

162{}

Member Function Documentation

◆ getMostRecentDraw()

CompressedPaintersOrder skgpu::graphite::GridBoundsManager::getMostRecentDraw ( const Rect bounds) const
inlineoverridevirtual

Implements skgpu::graphite::BoundsManager.

Definition at line 165 of file BoundsManager.h.

165 {
166 SkASSERT(!bounds.isEmptyNegativeOrNaN());
167
168 auto ltrb = this->getGridCoords(bounds);
169 const CompressedPaintersOrder* p = fNodes.data() + ltrb[1] * fGridWidth + ltrb[0];
170 int h = ltrb[3] - ltrb[1];
171 int w = ltrb[2] - ltrb[0];
172
174 for (int y = 0; y <= h; ++y ) {
175 for (int x = 0; x <= w; ++x) {
176 CompressedPaintersOrder v = *(p + x);
177 if (v > max) {
178 max = v;
179 }
180 }
181 p = p + fGridWidth;
182 }
183
184 return max;
185 }
#define SkASSERT(cond)
Definition SkAssert.h:116
static float max(float r, float g, float b)
Definition hsl.cpp:49
double y
double x
Optional< SkRect > bounds
Definition SkRecords.h:189
MonotonicValue< CompressedPaintersOrderSequence > CompressedPaintersOrder
Definition DrawOrder.h:58
SkScalar w
SkScalar h

◆ Make() [1/2]

static std::unique_ptr< GridBoundsManager > skgpu::graphite::GridBoundsManager::Make ( const SkISize deviceSize,
const SkISize gridSize 
)
inlinestatic

Definition at line 125 of file BoundsManager.h.

126 {
127 SkASSERT(deviceSize.width() > 0 && deviceSize.height() > 0);
128 SkASSERT(gridSize.width() >= 1 && gridSize.height() >= 1);
129
130 return std::unique_ptr<GridBoundsManager>(new GridBoundsManager(deviceSize, gridSize));
131 }
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

◆ Make() [2/2]

static std::unique_ptr< GridBoundsManager > skgpu::graphite::GridBoundsManager::Make ( const SkISize deviceSize,
int  gridSize 
)
inlinestatic

Definition at line 133 of file BoundsManager.h.

133 {
134 return Make(deviceSize, {gridSize, gridSize});
135 }
static std::unique_ptr< GridBoundsManager > Make(const SkISize &deviceSize, const SkISize &gridSize)

◆ MakeRes()

static std::unique_ptr< GridBoundsManager > skgpu::graphite::GridBoundsManager::MakeRes ( SkISize  deviceSize,
int  gridCellSize,
int  maxGridSize = 0 
)
inlinestatic

Definition at line 137 of file BoundsManager.h.

139 {
140 SkASSERT(deviceSize.width() > 0 && deviceSize.height() > 0);
141 SkASSERT(gridCellSize >= 1);
142
143 int gridWidth = SkScalarCeilToInt(deviceSize.width() / (float) gridCellSize);
144 if (maxGridSize > 0 && gridWidth > maxGridSize) {
145 // We'd have too many sizes so clamp the grid resolution, leave the device size alone
146 // since the grid cell size can't be preserved anyways.
147 gridWidth = maxGridSize;
148 } else {
149 // Pad out the device size to keep cell size the same
150 deviceSize.fWidth = gridWidth * gridCellSize;
151 }
152
153 int gridHeight = SkScalarCeilToInt(deviceSize.height() / (float) gridCellSize);
154 if (maxGridSize > 0 && gridHeight > maxGridSize) {
155 gridHeight = maxGridSize;
156 } else {
157 deviceSize.fHeight = gridHeight * gridCellSize;
158 }
159 return Make(deviceSize, {gridWidth, gridHeight});
160 }
#define SkScalarCeilToInt(x)
Definition SkScalar.h:36
int32_t fHeight
Definition SkSize.h:18
int32_t fWidth
Definition SkSize.h:17

◆ recordDraw()

void skgpu::graphite::GridBoundsManager::recordDraw ( const Rect bounds,
CompressedPaintersOrder  order 
)
inlineoverridevirtual

Implements skgpu::graphite::BoundsManager.

Definition at line 187 of file BoundsManager.h.

187 {
188 SkASSERT(!bounds.isEmptyNegativeOrNaN());
189
190 auto ltrb = this->getGridCoords(bounds);
191 CompressedPaintersOrder* p = fNodes.data() + ltrb[1] * fGridWidth + ltrb[0];
192 int h = ltrb[3] - ltrb[1];
193 int w = ltrb[2] - ltrb[0];
194
195 for (int y = 0; y <= h; ++y) {
196 for (int x = 0; x <= w; ++x) {
197 CompressedPaintersOrder v = *(p + x);
198 if (order > v) {
199 *(p + x) = order;
200 }
201 }
202 p = p + fGridWidth;
203 }
204 }

◆ reset()

void skgpu::graphite::GridBoundsManager::reset ( )
inlineoverridevirtual

Implements skgpu::graphite::BoundsManager.

Definition at line 206 of file BoundsManager.h.

206 {
207 memset(fNodes.data(), 0, sizeof(CompressedPaintersOrder) * fGridWidth * fGridHeight);
208 }

The documentation for this class was generated from the following file: