8#ifndef skgpu_graphite_geom_BoundsManager_DEFINED
9#define skgpu_graphite_geom_BoundsManager_DEFINED
59 if (fLatestDraw < order) {
79 SkASSERT(fRects.count() == fOrders.count());
83 auto orderIter = fOrders.items().begin();
84 for (
const Rect& r : fRects.items()) {
85 if (r.intersects(boundsComplement) &&
max < *orderIter) {
95 fOrders.push_back(order);
103 int count()
const {
return fRects.count(); }
106 auto orderIter = fOrders.items().begin();
107 for (
const Rect& r : fRects.items()) {
108 manager->recordDraw(r, *orderIter);
125 static std::unique_ptr<GridBoundsManager>
Make(
const SkISize& deviceSize,
130 return std::unique_ptr<GridBoundsManager>(
new GridBoundsManager(deviceSize, gridSize));
133 static std::unique_ptr<GridBoundsManager>
Make(
const SkISize& deviceSize,
int gridSize) {
134 return Make(deviceSize, {gridSize, gridSize});
144 if (maxGridSize > 0 && gridWidth > maxGridSize) {
147 gridWidth = maxGridSize;
150 deviceSize.
fWidth = gridWidth * gridCellSize;
154 if (maxGridSize > 0 && gridHeight > maxGridSize) {
155 gridHeight = maxGridSize;
157 deviceSize.
fHeight = gridHeight * gridCellSize;
159 return Make(deviceSize, {gridWidth, gridHeight});
168 auto ltrb = this->getGridCoords(
bounds);
170 int h = ltrb[3] - ltrb[1];
171 int w = ltrb[2] - ltrb[0];
174 for (
int y = 0;
y <=
h; ++
y ) {
175 for (
int x = 0;
x <=
w; ++
x) {
190 auto ltrb = this->getGridCoords(
bounds);
192 int h = ltrb[3] - ltrb[1];
193 int w = ltrb[2] - ltrb[0];
195 for (
int y = 0;
y <=
h; ++
y) {
196 for (
int x = 0;
x <=
w; ++
x) {
214 , fGridWidth(gridSize.
width())
215 , fGridHeight(gridSize.
height())
216 , fNodes((size_t) fGridWidth * fGridHeight) {
226 skvx::int2(fGridWidth, fGridHeight).xyxy() - 1);
232 const int fGridWidth;
233 const int fGridHeight;
249 : fDeviceSize(deviceSize)
250 , fGridCellSize(gridCellSize)
251 , fMaxBruteForceN(maxBruteForceN)
252 , fMaxGridSize(maxGridSize)
253 , fCurrentManager(&fBruteForceManager) {
255 gridCellSize >= 1 && maxBruteForceN >= 1);
263 this->updateCurrentManagerIfNeeded();
268 const bool usedGrid = fCurrentManager == fGridManager.get();
271 fGridManager->reset();
273 fCurrentManager = &fBruteForceManager;
279 fGridManager =
nullptr;
281 fBruteForceManager.
reset();
282 SkASSERT(fCurrentManager == &fBruteForceManager);
288 const int fGridCellSize;
289 const int fMaxBruteForceN;
290 const int fMaxGridSize;
300 std::unique_ptr<GridBoundsManager> fGridManager;
302 void updateCurrentManagerIfNeeded() {
303 if (fCurrentManager == fGridManager.get() ||
304 fBruteForceManager.
count() < fMaxBruteForceN) {
313 fCurrentManager = fGridManager.get();
317 fBruteForceManager.
reset();
#define SkScalarCeilToInt(x)
virtual void recordDraw(const Rect &bounds, CompressedPaintersOrder order)=0
virtual CompressedPaintersOrder getMostRecentDraw(const Rect &bounds) const =0
~BruteForceBoundsManager() override
CompressedPaintersOrder getMostRecentDraw(const Rect &bounds) const override
void recordDraw(const Rect &bounds, CompressedPaintersOrder order) override
void replayDraws(BoundsManager *manager) const
~GridBoundsManager() override
CompressedPaintersOrder getMostRecentDraw(const Rect &bounds) const override
static std::unique_ptr< GridBoundsManager > Make(const SkISize &deviceSize, int gridSize)
static std::unique_ptr< GridBoundsManager > Make(const SkISize &deviceSize, const SkISize &gridSize)
void recordDraw(const Rect &bounds, CompressedPaintersOrder order) override
static std::unique_ptr< GridBoundsManager > MakeRes(SkISize deviceSize, int gridCellSize, int maxGridSize=0)
void recordDraw(const Rect &bounds, CompressedPaintersOrder order) override
CompressedPaintersOrder getMostRecentDraw(const Rect &bounds) const override
HybridBoundsManager(const SkISize &deviceSize, int gridCellSize, int maxBruteForceN, int maxGridSize=0)
static constexpr MonotonicValue First()
~NaiveBoundsManager() override
void recordDraw(const Rect &bounds, CompressedPaintersOrder order) override
CompressedPaintersOrder getMostRecentDraw(const Rect &bounds) const override
static float max(float r, float g, float b)
Optional< SkRect > bounds
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager
SINT Vec< N, T > pin(const Vec< N, T > &x, const Vec< N, T > &lo, const Vec< N, T > &hi)
constexpr int32_t width() const
constexpr int32_t height() const