Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
DrawAtlas.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
10#include <memory>
11
17
18#include "src/base/SkMathPriv.h"
20#include "src/gpu/AtlasTypes.h"
27
28using namespace skia_private;
29
30namespace skgpu::graphite {
31
32#if defined(DUMP_ATLAS_DATA)
33static const constexpr bool kDumpAtlasData = true;
34#else
35static const constexpr bool kDumpAtlasData = false;
36#endif
37
38#ifdef SK_DEBUG
39void DrawAtlas::validate(const AtlasLocator& atlasLocator) const {
40 // Verify that the plotIndex stored in the PlotLocator is consistent with the glyph rectangle
41 int numPlotsX = fTextureWidth / fPlotWidth;
42 int numPlotsY = fTextureHeight / fPlotHeight;
43
44 int plotIndex = atlasLocator.plotIndex();
45 auto topLeft = atlasLocator.topLeft();
46 int plotX = topLeft.x() / fPlotWidth;
47 int plotY = topLeft.y() / fPlotHeight;
48 SkASSERT(plotIndex == (numPlotsY - plotY - 1) * numPlotsX + (numPlotsX - plotX - 1));
49}
50#endif
51
52std::unique_ptr<DrawAtlas> DrawAtlas::Make(SkColorType colorType, size_t bpp, int width,
53 int height, int plotWidth, int plotHeight,
54 AtlasGenerationCounter* generationCounter,
55 AllowMultitexturing allowMultitexturing,
56 PlotEvictionCallback* evictor,
57 std::string_view label) {
58 std::unique_ptr<DrawAtlas> atlas(new DrawAtlas(colorType, bpp, width, height,
59 plotWidth, plotHeight, generationCounter,
60 allowMultitexturing, label));
61
62 if (evictor != nullptr) {
63 atlas->fEvictionCallbacks.emplace_back(evictor);
64 }
65 return atlas;
66}
67
68///////////////////////////////////////////////////////////////////////////////
69static uint32_t next_id() {
70 static std::atomic<uint32_t> nextID{1};
71 uint32_t id;
72 do {
73 id = nextID.fetch_add(1, std::memory_order_relaxed);
74 } while (id == SK_InvalidGenID);
75 return id;
76}
77DrawAtlas::DrawAtlas(SkColorType colorType, size_t bpp, int width, int height,
78 int plotWidth, int plotHeight, AtlasGenerationCounter* generationCounter,
79 AllowMultitexturing allowMultitexturing, std::string_view label)
81 , fBytesPerPixel(bpp)
82 , fTextureWidth(width)
83 , fTextureHeight(height)
84 , fPlotWidth(plotWidth)
85 , fPlotHeight(plotHeight)
86 , fLabel(label)
87 , fAtlasID(next_id())
88 , fGenerationCounter(generationCounter)
89 , fAtlasGeneration(fGenerationCounter->next())
90 , fPrevFlushToken(AtlasToken::InvalidToken())
91 , fFlushesSinceLastUse(0)
92 , fMaxPages(AllowMultitexturing::kYes == allowMultitexturing ?
93 PlotLocator::kMaxMultitexturePages : 1)
94 , fNumActivePages(0) {
95 int numPlotsX = width/plotWidth;
96 int numPlotsY = height/plotHeight;
97 SkASSERT(numPlotsX * numPlotsY <= PlotLocator::kMaxPlots);
98 SkASSERTF(fPlotWidth * numPlotsX == fTextureWidth,
99 "Invalid DrawAtlas. Plot width: %d, texture width %d", fPlotWidth, fTextureWidth);
100 SkASSERTF(fPlotHeight * numPlotsY == fTextureHeight,
101 "Invalid DrawAtlas. Plot height: %d, texture height %d", fPlotHeight, fTextureHeight);
102
103 fNumPlots = numPlotsX * numPlotsY;
104
105 this->createPages(generationCounter);
106}
107
108inline void DrawAtlas::processEviction(PlotLocator plotLocator) {
109 for (PlotEvictionCallback* evictor : fEvictionCallbacks) {
110 evictor->evict(plotLocator);
111 }
112
113 fAtlasGeneration = fGenerationCounter->next();
114}
115
116inline void DrawAtlas::updatePlot(Plot* plot, AtlasLocator* atlasLocator) {
117 int pageIdx = plot->pageIndex();
118 this->makeMRU(plot, pageIdx);
119
120 // The actual upload will be created in recordUploads().
121
122 atlasLocator->updatePlotLocator(plot->plotLocator());
123 SkDEBUGCODE(this->validate(*atlasLocator);)
124}
125
126bool DrawAtlas::addRectToPage(unsigned int pageIdx, int width, int height,
127 AtlasLocator* atlasLocator) {
128 SkASSERT(fProxies[pageIdx]);
129
130 // look through all allocated plots for one we can share, in Most Recently Refed order
131 PlotList::Iter plotIter;
132 plotIter.init(fPages[pageIdx].fPlotList, PlotList::Iter::kHead_IterStart);
133
134 for (Plot* plot = plotIter.get(); plot; plot = plotIter.next()) {
135 if (plot->addRect(width, height, atlasLocator)) {
136 this->updatePlot(plot, atlasLocator);
137 return true;
138 }
139 }
140
141 return false;
142}
143
144bool DrawAtlas::recordUploads(DrawContext* dc, Recorder* recorder) {
145 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
146 for (uint32_t pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) {
147 PlotList::Iter plotIter;
148 plotIter.init(fPages[pageIdx].fPlotList, PlotList::Iter::kHead_IterStart);
149 for (Plot* plot = plotIter.get(); plot; plot = plotIter.next()) {
150 if (plot->needsUpload()) {
151 TextureProxy* proxy = fProxies[pageIdx].get();
152 SkASSERT(proxy);
153
154 const void* dataPtr;
155 SkIRect dstRect;
156 std::tie(dataPtr, dstRect) = plot->prepareForUpload();
157 if (dstRect.isEmpty()) {
158 continue;
159 }
160
161 std::vector<MipLevel> levels;
162 levels.push_back({dataPtr, fBytesPerPixel*fPlotWidth});
163
164 // Src and dst colorInfo are the same
165 SkColorInfo colorInfo(fColorType, kUnknown_SkAlphaType, nullptr);
166 if (!dc->recordUpload(recorder, sk_ref_sp(proxy), colorInfo, colorInfo, levels,
167 dstRect, /*ConditionalUploadContext=*/nullptr)) {
168 return false;
169 }
170 }
171 }
172 }
173 return true;
174}
175
176// Number of atlas-related flushes beyond which we consider a plot to no longer be in use.
177//
178// This value is somewhat arbitrary -- the idea is to keep it low enough that
179// a page with unused plots will get removed reasonably quickly, but allow it
180// to hang around for a bit in case it's needed. The assumption is that flushes
181// are rare; i.e., we are not continually refreshing the frame.
182static constexpr auto kPlotRecentlyUsedCount = 32;
183static constexpr auto kAtlasRecentlyUsedCount = 128;
184
185DrawAtlas::ErrorCode DrawAtlas::addRect(Recorder* recorder,
186 int width, int height,
187 AtlasLocator* atlasLocator) {
188 if (width > fPlotWidth || height > fPlotHeight || width < 0 || height < 0) {
189 return ErrorCode::kError;
190 }
191
192 // We permit zero-sized rects to allow inverse fills in the PathAtlases to work,
193 // but we don't want to enter them in the Rectanizer. So we handle this special case here.
194 // For text this should be caught at a higher level, but if not the only end result
195 // will be rendering a degenerate quad.
196 if (width == 0 || height == 0) {
197 if (fNumActivePages == 0) {
198 // Make sure we have a Page for the AtlasLocator to refer to
199 this->activateNewPage(recorder);
200 }
201 atlasLocator->updateRect(skgpu::IRect16::MakeXYWH(0, 0, 0, 0));
202 // Use the MRU Plot from the first Page
203 atlasLocator->updatePlotLocator(fPages[0].fPlotList.head()->plotLocator());
204 return ErrorCode::kSucceeded;
205 }
206
207 // Look through each page to see if we can upload without having to flush
208 // We prioritize this upload to the first pages, not the most recently used, to make it easier
209 // to remove unused pages in reverse page order.
210 for (unsigned int pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) {
211 if (this->addRectToPage(pageIdx, width, height, atlasLocator)) {
212 return ErrorCode::kSucceeded;
213 }
214 }
215
216 // If the above fails, then see if the least recently used plot per page has already been
217 // queued for upload if we're at max page allocation, or if the plot has aged out otherwise.
218 // We wait until we've grown to the full number of pages to begin evicting already queued
219 // plots so that we can maximize the opportunity for reuse.
220 // As before we prioritize this upload to the first pages, not the most recently used.
221 if (fNumActivePages == this->maxPages()) {
222 for (unsigned int pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) {
223 Plot* plot = fPages[pageIdx].fPlotList.tail();
224 SkASSERT(plot);
225 if (plot->lastUseToken() < recorder->priv().tokenTracker()->nextFlushToken()) {
226 this->processEvictionAndResetRects(plot);
227 SkDEBUGCODE(bool verify = )plot->addRect(width, height, atlasLocator);
228 SkASSERT(verify);
229 this->updatePlot(plot, atlasLocator);
230 return ErrorCode::kSucceeded;
231 }
232 }
233 } else {
234 // If we haven't activated all the available pages, try to create a new one and add to it
235 if (!this->activateNewPage(recorder)) {
236 return ErrorCode::kError;
237 }
238
239 if (this->addRectToPage(fNumActivePages-1, width, height, atlasLocator)) {
240 return ErrorCode::kSucceeded;
241 } else {
242 // If we fail to upload to a newly activated page then something has gone terribly
243 // wrong - return an error
244 return ErrorCode::kError;
245 }
246 }
247
248 if (!fNumActivePages) {
249 return ErrorCode::kError;
250 }
251
252 // All plots are currently in use by the current set of draws, so we need to fail. This
253 // gives the Device a chance to snap the current set of uploads and draws, advance the draw
254 // token, and call back into this function. The subsequent call will have plots available
255 // for fresh uploads.
256 return ErrorCode::kTryAgain;
257}
258
259DrawAtlas::ErrorCode DrawAtlas::addToAtlas(Recorder* recorder,
260 int width, int height, const void* image,
261 AtlasLocator* atlasLocator) {
262 ErrorCode ec = this->addRect(recorder, width, height, atlasLocator);
263 if (ec == ErrorCode::kSucceeded) {
264 Plot* plot = this->findPlot(*atlasLocator);
265 plot->copySubImage(*atlasLocator, image);
266 }
267
268 return ec;
269}
270
271SkIPoint DrawAtlas::prepForRender(const AtlasLocator& locator, SkAutoPixmapStorage* pixmap) {
272 Plot* plot = this->findPlot(locator);
273 return plot->prepForRender(locator, pixmap);
274}
275
276void DrawAtlas::compact(AtlasToken startTokenForNextFlush) {
277 if (fNumActivePages < 1) {
278 fPrevFlushToken = startTokenForNextFlush;
279 return;
280 }
281
282 // For all plots, reset number of flushes since used if used this frame.
283 PlotList::Iter plotIter;
284 bool atlasUsedThisFlush = false;
285 for (uint32_t pageIndex = 0; pageIndex < fNumActivePages; ++pageIndex) {
286 plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
287 while (Plot* plot = plotIter.get()) {
288 // Reset number of flushes since used
289 if (plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) {
290 plot->resetFlushesSinceLastUsed();
291 atlasUsedThisFlush = true;
292 }
293
294 plotIter.next();
295 }
296 }
297
298 if (atlasUsedThisFlush) {
299 fFlushesSinceLastUse = 0;
300 } else {
301 ++fFlushesSinceLastUse;
302 }
303
304 // We only try to compact if the atlas was used in the recently completed flush or
305 // hasn't been used in a long time.
306 // This is to handle the case where a lot of text or path rendering has occurred but then just
307 // a blinking cursor is drawn.
308 if (atlasUsedThisFlush || fFlushesSinceLastUse > kAtlasRecentlyUsedCount) {
309 TArray<Plot*> availablePlots;
310 uint32_t lastPageIndex = fNumActivePages - 1;
311
312 // For all plots but the last one, update number of flushes since used, and check to see
313 // if there are any in the first pages that the last page can safely upload to.
314 for (uint32_t pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex) {
315 if constexpr (kDumpAtlasData) {
316 SkDebugf("page %u: ", pageIndex);
317 }
318
319 plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
320 while (Plot* plot = plotIter.get()) {
321 // Update number of flushes since plot was last used
322 // We only increment the 'sinceLastUsed' count for flushes where the atlas was used
323 // to avoid deleting everything when we return to text drawing in the blinking
324 // cursor case
325 if (!plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) {
326 plot->incFlushesSinceLastUsed();
327 }
328
329 if constexpr (kDumpAtlasData) {
330 SkDebugf("%d ", plot->flushesSinceLastUsed());
331 }
332
333 // Count plots we can potentially upload to in all pages except the last one
334 // (the potential compactee).
335 if (plot->flushesSinceLastUsed() > kPlotRecentlyUsedCount) {
336 availablePlots.push_back() = plot;
337 }
338
339 plotIter.next();
340 }
341
342 if constexpr (kDumpAtlasData) {
343 SkDebugf("\n");
344 }
345 }
346
347 // Count recently used plots in the last page and evict any that are no longer in use.
348 // Since we prioritize uploading to the first pages, this will eventually
349 // clear out usage of this page unless we have a large need.
350 plotIter.init(fPages[lastPageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
351 unsigned int usedPlots = 0;
352 if constexpr (kDumpAtlasData) {
353 SkDebugf("page %u: ", lastPageIndex);
354 }
355 while (Plot* plot = plotIter.get()) {
356 // Update number of flushes since plot was last used
357 if (!plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) {
358 plot->incFlushesSinceLastUsed();
359 }
360
361 if constexpr (kDumpAtlasData) {
362 SkDebugf("%d ", plot->flushesSinceLastUsed());
363 }
364
365 // If this plot was used recently
366 if (plot->flushesSinceLastUsed() <= kPlotRecentlyUsedCount) {
367 usedPlots++;
368 } else if (plot->lastUseToken() != AtlasToken::InvalidToken()) {
369 // otherwise if aged out just evict it.
370 this->processEvictionAndResetRects(plot);
371 }
372 plotIter.next();
373 }
374
375 if constexpr (kDumpAtlasData) {
376 SkDebugf("\n");
377 }
378
379 // If recently used plots in the last page are using less than a quarter of the page, try
380 // to evict them if there's available space in lower index pages. Since we prioritize
381 // uploading to the first pages, this will eventually clear out usage of this page unless
382 // we have a large need.
383 if (availablePlots.size() && usedPlots && usedPlots <= fNumPlots / 4) {
384 plotIter.init(fPages[lastPageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
385 while (Plot* plot = plotIter.get()) {
386 // If this plot was used recently
387 if (plot->flushesSinceLastUsed() <= kPlotRecentlyUsedCount) {
388 // See if there's room in an lower index page and if so evict.
389 // We need to be somewhat harsh here so that a handful of plots that are
390 // consistently in use don't end up locking the page in memory.
391 if (availablePlots.size() > 0) {
392 this->processEvictionAndResetRects(plot);
393 this->processEvictionAndResetRects(availablePlots.back());
394 availablePlots.pop_back();
395 --usedPlots;
396 }
397 if (!usedPlots || !availablePlots.size()) {
398 break;
399 }
400 }
401 plotIter.next();
402 }
403 }
404
405 // If none of the plots in the last page have been used recently, delete it.
406 if (!usedPlots) {
407 if constexpr (kDumpAtlasData) {
408 SkDebugf("delete %u\n", fNumActivePages-1);
409 }
410
411 this->deactivateLastPage();
412 fFlushesSinceLastUse = 0;
413 }
414 }
415
416 fPrevFlushToken = startTokenForNextFlush;
417}
418
419bool DrawAtlas::createPages(AtlasGenerationCounter* generationCounter) {
420 SkASSERT(SkIsPow2(fTextureWidth) && SkIsPow2(fTextureHeight));
421
422 int numPlotsX = fTextureWidth/fPlotWidth;
423 int numPlotsY = fTextureHeight/fPlotHeight;
424
425 for (uint32_t i = 0; i < this->maxPages(); ++i) {
426 // Proxies are uncreated at first
427 fProxies[i] = nullptr;
428
429 // set up allocated plots
430 fPages[i].fPlotArray = std::make_unique<sk_sp<Plot>[]>(numPlotsX * numPlotsY);
431
432 sk_sp<Plot>* currPlot = fPages[i].fPlotArray.get();
433 for (int y = numPlotsY - 1, r = 0; y >= 0; --y, ++r) {
434 for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) {
435 uint32_t plotIndex = r * numPlotsX + c;
436 currPlot->reset(new Plot(
437 i, plotIndex, generationCounter, x, y, fPlotWidth, fPlotHeight, fColorType,
438 fBytesPerPixel));
439
440 // build LRU list
441 fPages[i].fPlotList.addToHead(currPlot->get());
442 ++currPlot;
443 }
444 }
445
446 }
447
448 return true;
449}
450
451bool DrawAtlas::activateNewPage(Recorder* recorder) {
452 SkASSERT(fNumActivePages < this->maxPages());
453 SkASSERT(!fProxies[fNumActivePages]);
454
455 const Caps* caps = recorder->priv().caps();
456 auto textureInfo = caps->getDefaultSampledTextureInfo(fColorType,
457 Mipmapped::kNo,
458 recorder->priv().isProtected(),
459 Renderable::kNo);
460 fProxies[fNumActivePages] = TextureProxy::Make(caps,
461 recorder->priv().resourceProvider(),
462 {fTextureWidth, fTextureHeight},
463 textureInfo,
465 if (!fProxies[fNumActivePages]) {
466 return false;
467 }
468
469 if constexpr (kDumpAtlasData) {
470 SkDebugf("activated page#: %u\n", fNumActivePages);
471 }
472
473 ++fNumActivePages;
474 return true;
475}
476
477inline void DrawAtlas::deactivateLastPage() {
478 SkASSERT(fNumActivePages);
479
480 uint32_t lastPageIndex = fNumActivePages - 1;
481
482 int numPlotsX = fTextureWidth/fPlotWidth;
483 int numPlotsY = fTextureHeight/fPlotHeight;
484
485 fPages[lastPageIndex].fPlotList.reset();
486 for (int r = 0; r < numPlotsY; ++r) {
487 for (int c = 0; c < numPlotsX; ++c) {
488 uint32_t plotIndex = r * numPlotsX + c;
489
490 Plot* currPlot = fPages[lastPageIndex].fPlotArray[plotIndex].get();
491 currPlot->resetRects();
492 currPlot->resetFlushesSinceLastUsed();
493
494 // rebuild the LRU list
495 SkDEBUGCODE(currPlot->resetListPtrs());
496 fPages[lastPageIndex].fPlotList.addToHead(currPlot);
497 }
498 }
499
500 // remove ref to the texture proxy
501 fProxies[lastPageIndex].reset();
502 --fNumActivePages;
503}
504
505void DrawAtlas::evictAllPlots() {
506 PlotList::Iter plotIter;
507 for (uint32_t pageIndex = 0; pageIndex < fNumActivePages; ++pageIndex) {
508 plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
509 while (Plot* plot = plotIter.get()) {
510 this->processEvictionAndResetRects(plot);
511 plotIter.next();
512 }
513 }
514}
515
516DrawAtlasConfig::DrawAtlasConfig(int maxTextureSize, size_t maxBytes) {
517 static const SkISize kARGBDimensions[] = {
518 {256, 256}, // maxBytes < 2^19
519 {512, 256}, // 2^19 <= maxBytes < 2^20
520 {512, 512}, // 2^20 <= maxBytes < 2^21
521 {1024, 512}, // 2^21 <= maxBytes < 2^22
522 {1024, 1024}, // 2^22 <= maxBytes < 2^23
523 {2048, 1024}, // 2^23 <= maxBytes
524 };
525
526 // Index 0 corresponds to maxBytes of 2^18, so start by dividing it by that
527 maxBytes >>= 18;
528 // Take the floor of the log to get the index
529 int index = maxBytes > 0
530 ? SkTPin<int>(SkPrevLog2(maxBytes), 0, std::size(kARGBDimensions) - 1)
531 : 0;
532
533 SkASSERT(kARGBDimensions[index].width() <= kMaxAtlasDim);
534 SkASSERT(kARGBDimensions[index].height() <= kMaxAtlasDim);
535 fARGBDimensions.set(std::min<int>(kARGBDimensions[index].width(), maxTextureSize),
536 std::min<int>(kARGBDimensions[index].height(), maxTextureSize));
537 fMaxTextureSize = std::min<int>(maxTextureSize, kMaxAtlasDim);
538}
539
540SkISize DrawAtlasConfig::atlasDimensions(MaskFormat type) const {
541 if (MaskFormat::kA8 == type) {
542 // A8 is always 2x the ARGB dimensions, clamped to the max allowed texture size
543 return { std::min<int>(2 * fARGBDimensions.width(), fMaxTextureSize),
544 std::min<int>(2 * fARGBDimensions.height(), fMaxTextureSize) };
545 } else {
546 return fARGBDimensions;
547 }
548}
549
550SkISize DrawAtlasConfig::plotDimensions(MaskFormat type) const {
551 if (MaskFormat::kA8 == type) {
552 SkISize atlasDimensions = this->atlasDimensions(type);
553 // For A8 we want to grow the plots at larger texture sizes to accept more of the
554 // larger SDF glyphs. Since the largest SDF glyph can be 170x170 with padding, this
555 // allows us to pack 3 in a 512x256 plot, or 9 in a 512x512 plot.
556
557 // This will give us 512x256 plots for 2048x1024, 512x512 plots for 2048x2048,
558 // and 256x256 plots otherwise.
559 int plotWidth = atlasDimensions.width() >= 2048 ? 512 : 256;
560 int plotHeight = atlasDimensions.height() >= 2048 ? 512 : 256;
561
562 return { plotWidth, plotHeight };
563 } else {
564 // ARGB and LCD always use 256x256 plots -- this has been shown to be faster
565 return { 256, 256 };
566 }
567}
568
569} // namespace skgpu::graphite
static constexpr auto kPlotRecentlyUsedCount
static constexpr auto kAtlasRecentlyUsedCount
static const constexpr bool kDumpAtlasData
static float next(float f)
SkColorType fColorType
@ kUnknown_SkAlphaType
uninitialized
Definition SkAlphaType.h:27
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkASSERTF(cond, fmt,...)
Definition SkAssert.h:117
SkColorType
Definition SkColorType.h:19
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static int SkPrevLog2(uint32_t value)
Definition SkMathPriv.h:257
constexpr bool SkIsPow2(T value)
Definition SkMath.h:51
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
#define TRACE_FUNC
static constexpr uint32_t SK_InvalidGenID
Definition SkTypes.h:192
T * get() const
Definition SkRefCnt.h:303
uint32_t plotIndex() const
Definition AtlasTypes.h:305
void updateRect(skgpu::IRect16 rect)
Definition AtlasTypes.h:345
SkIPoint topLeft() const
Definition AtlasTypes.h:309
void updatePlotLocator(PlotLocator p)
Definition AtlasTypes.h:337
AtlasToken next() const
Definition AtlasTypes.h:185
static AtlasToken InvalidToken()
Definition AtlasTypes.h:153
static constexpr int kMaxPlots
Definition AtlasTypes.h:246
void resetRects()
void resetFlushesSinceLastUsed()
Definition AtlasTypes.h:484
AtlasToken nextFlushToken() const
Definition AtlasTypes.h:207
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
static std::unique_ptr< DrawAtlas > Make(SkColorType ct, size_t bpp, int width, int height, int plotWidth, int plotHeight, AtlasGenerationCounter *generationCounter, AllowMultitexturing allowMultitexturing, PlotEvictionCallback *evictor, std::string_view label)
Definition DrawAtlas.cpp:52
bool recordUpload(Recorder *recorder, sk_sp< TextureProxy > targetProxy, const SkColorInfo &srcColorInfo, const SkColorInfo &dstColorInfo, const std::vector< MipLevel > &levels, const SkIRect &dstRect, std::unique_ptr< ConditionalUploadContext >)
TokenTracker * tokenTracker()
Protected isProtected() const
const Caps * caps() const
ResourceProvider * resourceProvider()
int size() const
Definition SkTArray.h:416
sk_sp< SkImage > image
Definition examples.cpp:29
double y
double x
static const constexpr bool kDumpAtlasData
Definition DrawAtlas.cpp:35
static uint32_t next_id()
Definition DrawAtlas.cpp:69
static void plot(SkCanvas *canvas, const char *fn, float xMin, float xMax, float yMin, float yMax, const char *label=nullptr, bool requireES3=false)
int32_t height
int32_t width
constexpr int32_t x() const
bool isEmpty() const
Definition SkRect.h:202
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37
static IRect16 MakeXYWH(int16_t x, int16_t y, int16_t w, int16_t h)
Definition AtlasTypes.h:54
const uintptr_t id
#define TRACE_EVENT0(category_group, name)