blob: 03a96f6e28bde6d6016c4bf913011a5f1a1b6243 [file] [log] [blame]
joshualitt5bf99f12015-03-13 11:47:42 -07001/*
2 * Copyright 2015 Google Inc.
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/GrDrawOpAtlas.h"
Robert Phillips32f28182017-02-28 16:20:03 -05009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/gpu/GrContext.h"
11#include "include/gpu/GrTexture.h"
Robert Phillips03e4c952019-11-26 16:20:22 -050012#include "src/core/SkOpts.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/GrContextPriv.h"
Greg Daniel7fd7a8a2019-10-10 16:10:31 -040014#include "src/gpu/GrGpu.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "src/gpu/GrOnFlushResourceProvider.h"
16#include "src/gpu/GrOpFlushState.h"
17#include "src/gpu/GrProxyProvider.h"
18#include "src/gpu/GrRectanizer.h"
19#include "src/gpu/GrResourceProvider.h"
Greg Daniel7fd7a8a2019-10-10 16:10:31 -040020#include "src/gpu/GrResourceProviderPriv.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050021#include "src/gpu/GrSurfaceProxyPriv.h"
22#include "src/gpu/GrTracing.h"
joshualitt5bf99f12015-03-13 11:47:42 -070023
Robert Phillipscd5099c2018-02-09 09:56:56 -050024// When proxy allocation is deferred until flush time the proxies acting as atlases require
25// special handling. This is because the usage that can be determined from the ops themselves
26// isn't sufficient. Independent of the ops there will be ASAP and inline uploads to the
27// atlases. Extending the usage interval of any op that uses an atlas to the start of the
28// flush (as is done for proxies that are used for sw-generated masks) also won't work because
29// the atlas persists even beyond the last use in an op - for a given flush. Given this, atlases
30// must explicitly manage the lifetime of their backing proxies via the onFlushCallback system
31// (which calls this method).
32void GrDrawOpAtlas::instantiate(GrOnFlushResourceProvider* onFlushResourceProvider) {
Robert Phillips4bc70112018-03-01 10:24:02 -050033 for (uint32_t i = 0; i < fNumActivePages; ++i) {
34 // All the atlas pages are now instantiated at flush time in the activeNewPage method.
Greg Daniel9715b6c2019-12-10 15:03:10 -050035 SkASSERT(fViews[i].proxy() && fViews[i].proxy()->isInstantiated());
Robert Phillipscd5099c2018-02-09 09:56:56 -050036 }
37}
38
Robert Phillips4bc70112018-03-01 10:24:02 -050039std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrProxyProvider* proxyProvider,
Greg Daniel4065d452018-11-16 15:43:41 -050040 const GrBackendFormat& format,
Robert Phillips42dda082019-05-14 13:29:45 -040041 GrColorType colorType, int width,
Jim Van Verthf6206f92018-12-14 08:22:24 -050042 int height, int plotWidth, int plotHeight,
Brian Salomon9f545bc2017-11-06 10:36:57 -050043 AllowMultitexturing allowMultitexturing,
44 GrDrawOpAtlas::EvictionFunc func, void* data) {
Robert Phillips0a15cc62019-07-30 12:49:10 -040045 if (!format.isValid()) {
46 return nullptr;
47 }
48
Robert Phillips42dda082019-05-14 13:29:45 -040049 std::unique_ptr<GrDrawOpAtlas> atlas(new GrDrawOpAtlas(proxyProvider, format, colorType, width,
Jim Van Verthf6206f92018-12-14 08:22:24 -050050 height, plotWidth, plotHeight,
Robert Phillips4bc70112018-03-01 10:24:02 -050051 allowMultitexturing));
Greg Daniel9715b6c2019-12-10 15:03:10 -050052 if (!atlas->getViews()[0].proxy()) {
Jim Van Verthd74f3f22017-08-31 16:44:08 -040053 return nullptr;
54 }
55
Robert Phillips256c37b2017-03-01 14:32:46 -050056 atlas->registerEvictionCallback(func, data);
57 return atlas;
58}
59
Jim Van Verthc3269ae2017-09-28 15:04:00 -040060#ifdef DUMP_ATLAS_DATA
61static bool gDumpAtlasData = false;
62#endif
Robert Phillips256c37b2017-03-01 14:32:46 -050063
joshualitt5df175e2015-11-18 13:37:54 -080064////////////////////////////////////////////////////////////////////////////////
Jim Van Vertha950b632017-09-12 11:54:11 -040065GrDrawOpAtlas::Plot::Plot(int pageIndex, int plotIndex, uint64_t genID, int offX, int offY,
Robert Phillips42dda082019-05-14 13:29:45 -040066 int width, int height, GrColorType colorType)
Brian Salomon943ed792017-10-30 09:37:55 -040067 : fLastUpload(GrDeferredUploadToken::AlreadyFlushedToken())
68 , fLastUse(GrDeferredUploadToken::AlreadyFlushedToken())
Jim Van Verth106b5c42017-09-26 12:45:29 -040069 , fFlushesSinceLastUse(0)
Jim Van Vertha950b632017-09-12 11:54:11 -040070 , fPageIndex(pageIndex)
71 , fPlotIndex(plotIndex)
Brian Salomon2ee084e2016-12-16 18:59:19 -050072 , fGenID(genID)
Jim Van Vertha950b632017-09-12 11:54:11 -040073 , fID(CreateId(fPageIndex, fPlotIndex, fGenID))
Brian Salomon2ee084e2016-12-16 18:59:19 -050074 , fData(nullptr)
75 , fWidth(width)
76 , fHeight(height)
77 , fX(offX)
78 , fY(offY)
79 , fRects(nullptr)
80 , fOffset(SkIPoint16::Make(fX * fWidth, fY * fHeight))
Robert Phillips42dda082019-05-14 13:29:45 -040081 , fColorType(colorType)
82 , fBytesPerPixel(GrColorTypeBytesPerPixel(colorType))
joshualitt5df175e2015-11-18 13:37:54 -080083#ifdef SK_DEBUG
Brian Salomon2ee084e2016-12-16 18:59:19 -050084 , fDirty(false)
joshualitt5df175e2015-11-18 13:37:54 -080085#endif
86{
Jim Van Vertha8c55fa2018-02-20 15:38:08 -050087 // We expect the allocated dimensions to be a multiple of 4 bytes
88 SkASSERT(((width*fBytesPerPixel) & 0x3) == 0);
89 // The padding for faster uploads only works for 1, 2 and 4 byte texels
90 SkASSERT(fBytesPerPixel != 3 && fBytesPerPixel <= 4);
joshualitt5df175e2015-11-18 13:37:54 -080091 fDirtyRect.setEmpty();
92}
joshualitt5bf99f12015-03-13 11:47:42 -070093
Brian Salomon2ee084e2016-12-16 18:59:19 -050094GrDrawOpAtlas::Plot::~Plot() {
jvanverthc3d706f2016-04-20 10:33:27 -070095 sk_free(fData);
joshualitt5df175e2015-11-18 13:37:54 -080096 delete fRects;
97}
joshualitt5bf99f12015-03-13 11:47:42 -070098
Brian Salomon2ee084e2016-12-16 18:59:19 -050099bool GrDrawOpAtlas::Plot::addSubImage(int width, int height, const void* image, SkIPoint16* loc) {
joshualitt5df175e2015-11-18 13:37:54 -0800100 SkASSERT(width <= fWidth && height <= fHeight);
joshualitt5bf99f12015-03-13 11:47:42 -0700101
joshualitt5df175e2015-11-18 13:37:54 -0800102 if (!fRects) {
103 fRects = GrRectanizer::Factory(fWidth, fHeight);
joshualitt5bf99f12015-03-13 11:47:42 -0700104 }
105
joshualitt5df175e2015-11-18 13:37:54 -0800106 if (!fRects->addRect(width, height, loc)) {
107 return false;
joshualittb4c507e2015-04-08 08:07:59 -0700108 }
joshualitt5bf99f12015-03-13 11:47:42 -0700109
jvanverthc3d706f2016-04-20 10:33:27 -0700110 if (!fData) {
111 fData = reinterpret_cast<unsigned char*>(sk_calloc_throw(fBytesPerPixel * fWidth *
112 fHeight));
joshualitt5df175e2015-11-18 13:37:54 -0800113 }
114 size_t rowBytes = width * fBytesPerPixel;
115 const unsigned char* imagePtr = (const unsigned char*)image;
116 // point ourselves at the right starting spot
jvanverthc3d706f2016-04-20 10:33:27 -0700117 unsigned char* dataPtr = fData;
joshualitt5df175e2015-11-18 13:37:54 -0800118 dataPtr += fBytesPerPixel * fWidth * loc->fY;
119 dataPtr += fBytesPerPixel * loc->fX;
Brian Osmancce3e582016-10-14 11:42:20 -0400120 // copy into the data buffer, swizzling as we go if this is ARGB data
121 if (4 == fBytesPerPixel && kSkia8888_GrPixelConfig == kBGRA_8888_GrPixelConfig) {
122 for (int i = 0; i < height; ++i) {
Mike Klein6e78ae52018-09-19 13:37:16 -0400123 SkOpts::RGBA_to_BGRA((uint32_t*)dataPtr, (const uint32_t*)imagePtr, width);
Brian Osmancce3e582016-10-14 11:42:20 -0400124 dataPtr += fBytesPerPixel * fWidth;
125 imagePtr += rowBytes;
126 }
127 } else {
128 for (int i = 0; i < height; ++i) {
129 memcpy(dataPtr, imagePtr, rowBytes);
130 dataPtr += fBytesPerPixel * fWidth;
131 imagePtr += rowBytes;
132 }
joshualitt5bf99f12015-03-13 11:47:42 -0700133 }
134
Mike Reed92b33352019-08-24 19:39:13 -0400135 fDirtyRect.join({loc->fX, loc->fY, loc->fX + width, loc->fY + height});
robertphillips2b0536f2015-11-06 14:10:42 -0800136
joshualitt5df175e2015-11-18 13:37:54 -0800137 loc->fX += fOffset.fX;
138 loc->fY += fOffset.fY;
139 SkDEBUGCODE(fDirty = true;)
joshualitt5bf99f12015-03-13 11:47:42 -0700140
joshualitt5df175e2015-11-18 13:37:54 -0800141 return true;
142}
joshualitt5bf99f12015-03-13 11:47:42 -0700143
Brian Salomon943ed792017-10-30 09:37:55 -0400144void GrDrawOpAtlas::Plot::uploadToTexture(GrDeferredTextureUploadWritePixelsFn& writePixels,
Robert Phillipsacaa6072017-07-28 10:54:53 -0400145 GrTextureProxy* proxy) {
joshualitt5df175e2015-11-18 13:37:54 -0800146 // We should only be issuing uploads if we are in fact dirty
Brian Salomonfd98c2c2018-07-31 17:25:29 -0400147 SkASSERT(fDirty && fData && proxy && proxy->peekTexture());
Brian Osman39c08ac2017-07-26 09:36:09 -0400148 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
joshualitt5df175e2015-11-18 13:37:54 -0800149 size_t rowBytes = fBytesPerPixel * fWidth;
jvanverthc3d706f2016-04-20 10:33:27 -0700150 const unsigned char* dataPtr = fData;
Jim Van Vertha8c55fa2018-02-20 15:38:08 -0500151 // Clamp to 4-byte aligned boundaries
152 unsigned int clearBits = 0x3 / fBytesPerPixel;
153 fDirtyRect.fLeft &= ~clearBits;
154 fDirtyRect.fRight += clearBits;
155 fDirtyRect.fRight &= ~clearBits;
156 SkASSERT(fDirtyRect.fRight <= fWidth);
157 // Set up dataPtr
jvanverthc3d706f2016-04-20 10:33:27 -0700158 dataPtr += rowBytes * fDirtyRect.fTop;
159 dataPtr += fBytesPerPixel * fDirtyRect.fLeft;
Robert Phillips42dda082019-05-14 13:29:45 -0400160
Robert Phillipsacaa6072017-07-28 10:54:53 -0400161 writePixels(proxy, fOffset.fX + fDirtyRect.fLeft, fOffset.fY + fDirtyRect.fTop,
Robert Phillips42dda082019-05-14 13:29:45 -0400162 fDirtyRect.width(), fDirtyRect.height(), fColorType, dataPtr, rowBytes);
joshualitt5df175e2015-11-18 13:37:54 -0800163 fDirtyRect.setEmpty();
164 SkDEBUGCODE(fDirty = false;)
165}
166
Brian Salomon2ee084e2016-12-16 18:59:19 -0500167void GrDrawOpAtlas::Plot::resetRects() {
joshualitt5df175e2015-11-18 13:37:54 -0800168 if (fRects) {
169 fRects->reset();
joshualitt5bf99f12015-03-13 11:47:42 -0700170 }
171
joshualitt5df175e2015-11-18 13:37:54 -0800172 fGenID++;
Jim Van Vertha950b632017-09-12 11:54:11 -0400173 fID = CreateId(fPageIndex, fPlotIndex, fGenID);
Brian Salomon943ed792017-10-30 09:37:55 -0400174 fLastUpload = GrDeferredUploadToken::AlreadyFlushedToken();
175 fLastUse = GrDeferredUploadToken::AlreadyFlushedToken();
joshualitt5df175e2015-11-18 13:37:54 -0800176
177 // zero out the plot
jvanverthc3d706f2016-04-20 10:33:27 -0700178 if (fData) {
179 sk_bzero(fData, fBytesPerPixel * fWidth * fHeight);
joshualitt5bf99f12015-03-13 11:47:42 -0700180 }
181
joshualitt5df175e2015-11-18 13:37:54 -0800182 fDirtyRect.setEmpty();
183 SkDEBUGCODE(fDirty = false;)
184}
joshualitt5bf99f12015-03-13 11:47:42 -0700185
joshualitt5bf99f12015-03-13 11:47:42 -0700186///////////////////////////////////////////////////////////////////////////////
187
Greg Daniel4065d452018-11-16 15:43:41 -0500188GrDrawOpAtlas::GrDrawOpAtlas(GrProxyProvider* proxyProvider, const GrBackendFormat& format,
Robert Phillips42dda082019-05-14 13:29:45 -0400189 GrColorType colorType, int width, int height,
Jim Van Verthf6206f92018-12-14 08:22:24 -0500190 int plotWidth, int plotHeight, AllowMultitexturing allowMultitexturing)
Greg Daniel4065d452018-11-16 15:43:41 -0500191 : fFormat(format)
Robert Phillips42dda082019-05-14 13:29:45 -0400192 , fColorType(colorType)
Jim Van Verthd74f3f22017-08-31 16:44:08 -0400193 , fTextureWidth(width)
194 , fTextureHeight(height)
Jim Van Verthf6206f92018-12-14 08:22:24 -0500195 , fPlotWidth(plotWidth)
196 , fPlotHeight(plotHeight)
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400197 , fAtlasGeneration(kInvalidAtlasGeneration + 1)
Brian Salomon943ed792017-10-30 09:37:55 -0400198 , fPrevFlushToken(GrDeferredUploadToken::AlreadyFlushedToken())
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500199 , fMaxPages(AllowMultitexturing::kYes == allowMultitexturing ? kMaxMultitexturePages : 1)
Robert Phillips4bc70112018-03-01 10:24:02 -0500200 , fNumActivePages(0) {
Jim Van Verthf6206f92018-12-14 08:22:24 -0500201 int numPlotsX = width/plotWidth;
202 int numPlotsY = height/plotHeight;
Herb Derbybbf5fb52018-10-15 16:39:39 -0400203 SkASSERT(numPlotsX * numPlotsY <= GrDrawOpAtlas::kMaxPlots);
Jim Van Verthd74f3f22017-08-31 16:44:08 -0400204 SkASSERT(fPlotWidth * numPlotsX == fTextureWidth);
205 SkASSERT(fPlotHeight * numPlotsY == fTextureHeight);
robertphillips2b0536f2015-11-06 14:10:42 -0800206
Jim Van Verth06f593c2018-02-20 11:30:10 -0500207 fNumPlots = numPlotsX * numPlotsY;
joshualitt5bf99f12015-03-13 11:47:42 -0700208
Robert Phillips4bc70112018-03-01 10:24:02 -0500209 this->createPages(proxyProvider);
joshualitt5bf99f12015-03-13 11:47:42 -0700210}
211
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400212inline void GrDrawOpAtlas::processEviction(AtlasID id) {
joshualitt5bf99f12015-03-13 11:47:42 -0700213 for (int i = 0; i < fEvictionCallbacks.count(); i++) {
214 (*fEvictionCallbacks[i].fFunc)(id, fEvictionCallbacks[i].fData);
215 }
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400216 ++fAtlasGeneration;
joshualitt5bf99f12015-03-13 11:47:42 -0700217}
218
Brian Salomon29b60c92017-10-31 14:42:10 -0400219inline bool GrDrawOpAtlas::updatePlot(GrDeferredUploadTarget* target, AtlasID* id, Plot* plot) {
Jim Van Vertha950b632017-09-12 11:54:11 -0400220 int pageIdx = GetPageIndexFromID(plot->id());
221 this->makeMRU(plot, pageIdx);
joshualitt5bf99f12015-03-13 11:47:42 -0700222
223 // If our most recent upload has already occurred then we have to insert a new
224 // upload. Otherwise, we already have a scheduled upload that hasn't yet ocurred.
225 // This new update will piggy back on that previously scheduled update.
Robert Phillips40a29d72018-01-18 12:59:22 -0500226 if (plot->lastUploadToken() < target->tokenTracker()->nextTokenToFlush()) {
jvanverthc3d706f2016-04-20 10:33:27 -0700227 // With c+14 we could move sk_sp into lamba to only ref once.
Brian Salomon2ee084e2016-12-16 18:59:19 -0500228 sk_sp<Plot> plotsp(SkRef(plot));
Robert Phillips256c37b2017-03-01 14:32:46 -0500229
Greg Daniel9715b6c2019-12-10 15:03:10 -0500230 GrTextureProxy* proxy = fViews[pageIdx].asTextureProxy();
231 SkASSERT(proxy && proxy->isInstantiated()); // This is occurring at flush time
Robert Phillips256c37b2017-03-01 14:32:46 -0500232
Brian Salomon29b60c92017-10-31 14:42:10 -0400233 GrDeferredUploadToken lastUploadToken = target->addASAPUpload(
Brian Salomon943ed792017-10-30 09:37:55 -0400234 [plotsp, proxy](GrDeferredTextureUploadWritePixelsFn& writePixels) {
235 plotsp->uploadToTexture(writePixels, proxy);
236 });
Robert Phillips256c37b2017-03-01 14:32:46 -0500237 plot->setLastUploadToken(lastUploadToken);
joshualitt5bf99f12015-03-13 11:47:42 -0700238 }
239 *id = plot->id();
Robert Phillips256c37b2017-03-01 14:32:46 -0500240 return true;
joshualitt5bf99f12015-03-13 11:47:42 -0700241}
242
Greg Daniel7fd7a8a2019-10-10 16:10:31 -0400243bool GrDrawOpAtlas::uploadToPage(const GrCaps& caps, unsigned int pageIdx, AtlasID* id,
244 GrDeferredUploadTarget* target, int width, int height,
245 const void* image, SkIPoint16* loc) {
Greg Daniel9715b6c2019-12-10 15:03:10 -0500246 SkASSERT(fViews[pageIdx].proxy() && fViews[pageIdx].proxy()->isInstantiated());
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500247
248 // look through all allocated plots for one we can share, in Most Recently Refed order
249 PlotList::Iter plotIter;
250 plotIter.init(fPages[pageIdx].fPlotList, PlotList::Iter::kHead_IterStart);
251
252 for (Plot* plot = plotIter.get(); plot; plot = plotIter.next()) {
Greg Daniel9715b6c2019-12-10 15:03:10 -0500253 SkASSERT(caps.bytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) == plot->bpp());
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500254
255 if (plot->addSubImage(width, height, image, loc)) {
256 return this->updatePlot(target, id, plot);
257 }
258 }
259
260 return false;
261}
262
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400263// Number of atlas-related flushes beyond which we consider a plot to no longer be in use.
264//
265// This value is somewhat arbitrary -- the idea is to keep it low enough that
266// a page with unused plots will get removed reasonably quickly, but allow it
267// to hang around for a bit in case it's needed. The assumption is that flushes
268// are rare; i.e., we are not continually refreshing the frame.
Derek Sollenberger90196cc2017-10-09 15:00:33 -0400269static constexpr auto kRecentlyUsedCount = 256;
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400270
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500271GrDrawOpAtlas::ErrorCode GrDrawOpAtlas::addToAtlas(GrResourceProvider* resourceProvider,
272 AtlasID* id, GrDeferredUploadTarget* target,
273 int width, int height,
274 const void* image, SkIPoint16* loc) {
bsalomon6d6b6ad2016-07-13 14:45:28 -0700275 if (width > fPlotWidth || height > fPlotHeight) {
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500276 return ErrorCode::kError;
bsalomon6d6b6ad2016-07-13 14:45:28 -0700277 }
joshualitt5bf99f12015-03-13 11:47:42 -0700278
Greg Daniel7fd7a8a2019-10-10 16:10:31 -0400279 const GrCaps& caps = *resourceProvider->caps();
280
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400281 // Look through each page to see if we can upload without having to flush
282 // We prioritize this upload to the first pages, not the most recently used, to make it easier
283 // to remove unused pages in reverse page order.
Robert Phillips4bc70112018-03-01 10:24:02 -0500284 for (unsigned int pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) {
Greg Daniel7fd7a8a2019-10-10 16:10:31 -0400285 if (this->uploadToPage(caps, pageIdx, id, target, width, height, image, loc)) {
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500286 return ErrorCode::kSucceeded;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400287 }
Jim Van Verth712fe732017-09-25 16:53:49 -0400288 }
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400289
Jim Van Verth712fe732017-09-25 16:53:49 -0400290 // If the above fails, then see if the least recently used plot per page has already been
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400291 // flushed to the gpu if we're at max page allocation, or if the plot has aged out otherwise.
292 // We wait until we've grown to the full number of pages to begin evicting already flushed
293 // plots so that we can maximize the opportunity for reuse.
Jim Van Verth712fe732017-09-25 16:53:49 -0400294 // As before we prioritize this upload to the first pages, not the most recently used.
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500295 if (fNumActivePages == this->maxPages()) {
296 for (unsigned int pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) {
297 Plot* plot = fPages[pageIdx].fPlotList.tail();
298 SkASSERT(plot);
Jim Van Verthba98b7d2018-12-05 12:33:43 -0500299 if (plot->lastUseToken() < target->tokenTracker()->nextTokenToFlush()) {
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500300 this->processEvictionAndResetRects(plot);
Greg Daniel9715b6c2019-12-10 15:03:10 -0500301 SkASSERT(caps.bytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) ==
302 plot->bpp());
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500303 SkDEBUGCODE(bool verify = )plot->addSubImage(width, height, image, loc);
304 SkASSERT(verify);
305 if (!this->updatePlot(target, id, plot)) {
306 return ErrorCode::kError;
307 }
308 return ErrorCode::kSucceeded;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400309 }
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500310 }
311 } else {
312 // If we haven't activated all the available pages, try to create a new one and add to it
313 if (!this->activateNewPage(resourceProvider)) {
314 return ErrorCode::kError;
315 }
316
Greg Daniel7fd7a8a2019-10-10 16:10:31 -0400317 if (this->uploadToPage(caps, fNumActivePages-1, id, target, width, height, image, loc)) {
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500318 return ErrorCode::kSucceeded;
319 } else {
320 // If we fail to upload to a newly activated page then something has gone terribly
321 // wrong - return an error
322 return ErrorCode::kError;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400323 }
324 }
325
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500326 if (!fNumActivePages) {
327 return ErrorCode::kError;
joshualitt5bf99f12015-03-13 11:47:42 -0700328 }
329
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400330 // Try to find a plot that we can perform an inline upload to.
331 // We prioritize this upload in reverse order of pages to counterbalance the order above.
332 Plot* plot = nullptr;
Robert Phillips6250f292018-03-01 10:53:45 -0500333 for (int pageIdx = ((int)fNumActivePages)-1; pageIdx >= 0; --pageIdx) {
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400334 Plot* currentPlot = fPages[pageIdx].fPlotList.tail();
Robert Phillips40a29d72018-01-18 12:59:22 -0500335 if (currentPlot->lastUseToken() != target->tokenTracker()->nextDrawToken()) {
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400336 plot = currentPlot;
337 break;
Robert Phillips256c37b2017-03-01 14:32:46 -0500338 }
joshualitt5bf99f12015-03-13 11:47:42 -0700339 }
340
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400341 // If we can't find a plot that is not used in a draw currently being prepared by an op, then
342 // we have to fail. This gives the op a chance to enqueue the draw, and call back into this
343 // function. When that draw is enqueued, the draw token advances, and the subsequent call will
344 // continue past this branch and prepare an inline upload that will occur after the enqueued
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500345 // draw which references the plot's pre-upload content.
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400346 if (!plot) {
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500347 return ErrorCode::kTryAgain;
joshualitt5bf99f12015-03-13 11:47:42 -0700348 }
349
joshualitt5bf99f12015-03-13 11:47:42 -0700350 this->processEviction(plot->id());
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400351 int pageIdx = GetPageIndexFromID(plot->id());
Jim Van Vertha950b632017-09-12 11:54:11 -0400352 fPages[pageIdx].fPlotList.remove(plot);
353 sk_sp<Plot>& newPlot = fPages[pageIdx].fPlotArray[plot->index()];
robertphillips2b0536f2015-11-06 14:10:42 -0800354 newPlot.reset(plot->clone());
joshualitt5bf99f12015-03-13 11:47:42 -0700355
Jim Van Vertha950b632017-09-12 11:54:11 -0400356 fPages[pageIdx].fPlotList.addToHead(newPlot.get());
Greg Daniel9715b6c2019-12-10 15:03:10 -0500357 SkASSERT(caps.bytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) == newPlot->bpp());
robertphillips2b0536f2015-11-06 14:10:42 -0800358 SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, loc);
joshualitt5bf99f12015-03-13 11:47:42 -0700359 SkASSERT(verify);
robertphillips2b0536f2015-11-06 14:10:42 -0800360
robertphillips1f0e3502015-11-10 10:19:50 -0800361 // Note that this plot will be uploaded inline with the draws whereas the
Brian Salomon29b60c92017-10-31 14:42:10 -0400362 // one it displaced most likely was uploaded ASAP.
Brian Salomon2ee084e2016-12-16 18:59:19 -0500363 // With c+14 we could move sk_sp into lambda to only ref once.
364 sk_sp<Plot> plotsp(SkRef(newPlot.get()));
Robert Phillips4bc70112018-03-01 10:24:02 -0500365
Greg Daniel9715b6c2019-12-10 15:03:10 -0500366 GrTextureProxy* proxy = fViews[pageIdx].asTextureProxy();
367 SkASSERT(proxy && proxy->isInstantiated());
bsalomon342bfc22016-04-01 06:06:20 -0700368
Brian Salomon943ed792017-10-30 09:37:55 -0400369 GrDeferredUploadToken lastUploadToken = target->addInlineUpload(
370 [plotsp, proxy](GrDeferredTextureUploadWritePixelsFn& writePixels) {
371 plotsp->uploadToTexture(writePixels, proxy);
372 });
Robert Phillips256c37b2017-03-01 14:32:46 -0500373 newPlot->setLastUploadToken(lastUploadToken);
374
joshualitt5bf99f12015-03-13 11:47:42 -0700375 *id = newPlot->id();
robertphillips2b0536f2015-11-06 14:10:42 -0800376
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500377 return ErrorCode::kSucceeded;
joshualitt5bf99f12015-03-13 11:47:42 -0700378}
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400379
Brian Salomon943ed792017-10-30 09:37:55 -0400380void GrDrawOpAtlas::compact(GrDeferredUploadToken startTokenForNextFlush) {
Robert Phillips4bc70112018-03-01 10:24:02 -0500381 if (fNumActivePages <= 1) {
Jim Van Verth106b5c42017-09-26 12:45:29 -0400382 fPrevFlushToken = startTokenForNextFlush;
383 return;
384 }
385
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400386 // For all plots, reset number of flushes since used if used this frame.
Jim Van Verth106b5c42017-09-26 12:45:29 -0400387 PlotList::Iter plotIter;
Jim Van Verth106b5c42017-09-26 12:45:29 -0400388 bool atlasUsedThisFlush = false;
Robert Phillips4bc70112018-03-01 10:24:02 -0500389 for (uint32_t pageIndex = 0; pageIndex < fNumActivePages; ++pageIndex) {
Jim Van Verth106b5c42017-09-26 12:45:29 -0400390 plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
391 while (Plot* plot = plotIter.get()) {
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400392 // Reset number of flushes since used
Jim Van Verth106b5c42017-09-26 12:45:29 -0400393 if (plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) {
394 plot->resetFlushesSinceLastUsed();
395 atlasUsedThisFlush = true;
Jim Van Verth106b5c42017-09-26 12:45:29 -0400396 }
397
398 plotIter.next();
399 }
400 }
401
402 // We only try to compact if the atlas was used in the recently completed flush.
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400403 // This is to handle the case where a lot of text or path rendering has occurred but then just
404 // a blinking cursor is drawn.
Jim Van Verth106b5c42017-09-26 12:45:29 -0400405 // TODO: consider if we should also do this if it's been a long time since the last atlas use
406 if (atlasUsedThisFlush) {
Jim Van Verthcad0acf2018-02-16 18:41:41 -0500407 SkTArray<Plot*> availablePlots;
Robert Phillips4bc70112018-03-01 10:24:02 -0500408 uint32_t lastPageIndex = fNumActivePages - 1;
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400409
410 // For all plots but the last one, update number of flushes since used, and check to see
411 // if there are any in the first pages that the last page can safely upload to.
412 for (uint32_t pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex) {
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400413#ifdef DUMP_ATLAS_DATA
414 if (gDumpAtlasData) {
415 SkDebugf("page %d: ", pageIndex);
416 }
417#endif
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400418 plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
419 while (Plot* plot = plotIter.get()) {
420 // Update number of flushes since plot was last used
421 // We only increment the 'sinceLastUsed' count for flushes where the atlas was used
422 // to avoid deleting everything when we return to text drawing in the blinking
423 // cursor case
424 if (!plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) {
425 plot->incFlushesSinceLastUsed();
426 }
427
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400428#ifdef DUMP_ATLAS_DATA
429 if (gDumpAtlasData) {
430 SkDebugf("%d ", plot->flushesSinceLastUsed());
431 }
432#endif
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400433 // Count plots we can potentially upload to in all pages except the last one
434 // (the potential compactee).
435 if (plot->flushesSinceLastUsed() > kRecentlyUsedCount) {
Jim Van Verthcad0acf2018-02-16 18:41:41 -0500436 availablePlots.push_back() = plot;
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400437 }
438
439 plotIter.next();
440 }
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400441#ifdef DUMP_ATLAS_DATA
442 if (gDumpAtlasData) {
443 SkDebugf("\n");
444 }
445#endif
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400446 }
447
Jim Van Verth06f593c2018-02-20 11:30:10 -0500448 // Count recently used plots in the last page and evict any that are no longer in use.
449 // Since we prioritize uploading to the first pages, this will eventually
Jim Van Verth106b5c42017-09-26 12:45:29 -0400450 // clear out usage of this page unless we have a large need.
451 plotIter.init(fPages[lastPageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
Jim Van Verth06f593c2018-02-20 11:30:10 -0500452 unsigned int usedPlots = 0;
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400453#ifdef DUMP_ATLAS_DATA
454 if (gDumpAtlasData) {
455 SkDebugf("page %d: ", lastPageIndex);
456 }
457#endif
Jim Van Verth106b5c42017-09-26 12:45:29 -0400458 while (Plot* plot = plotIter.get()) {
Jim Van Verth62ea0cd2017-09-27 12:59:45 -0400459 // Update number of flushes since plot was last used
460 if (!plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) {
461 plot->incFlushesSinceLastUsed();
462 }
463
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400464#ifdef DUMP_ATLAS_DATA
465 if (gDumpAtlasData) {
466 SkDebugf("%d ", plot->flushesSinceLastUsed());
467 }
468#endif
Jim Van Verth106b5c42017-09-26 12:45:29 -0400469 // If this plot was used recently
470 if (plot->flushesSinceLastUsed() <= kRecentlyUsedCount) {
471 usedPlots++;
Brian Salomon943ed792017-10-30 09:37:55 -0400472 } else if (plot->lastUseToken() != GrDeferredUploadToken::AlreadyFlushedToken()) {
Jim Van Verth106b5c42017-09-26 12:45:29 -0400473 // otherwise if aged out just evict it.
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400474 this->processEvictionAndResetRects(plot);
Jim Van Verth106b5c42017-09-26 12:45:29 -0400475 }
476 plotIter.next();
477 }
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400478#ifdef DUMP_ATLAS_DATA
479 if (gDumpAtlasData) {
480 SkDebugf("\n");
481 }
482#endif
Jim Van Verth06f593c2018-02-20 11:30:10 -0500483
484 // If recently used plots in the last page are using less than a quarter of the page, try
485 // to evict them if there's available space in earlier pages. Since we prioritize uploading
486 // to the first pages, this will eventually clear out usage of this page unless we have a
487 // large need.
488 if (availablePlots.count() && usedPlots && usedPlots <= fNumPlots / 4) {
489 plotIter.init(fPages[lastPageIndex].fPlotList, PlotList::Iter::kHead_IterStart);
490 while (Plot* plot = plotIter.get()) {
491 // If this plot was used recently
492 if (plot->flushesSinceLastUsed() <= kRecentlyUsedCount) {
493 // See if there's room in an earlier page and if so evict.
494 // We need to be somewhat harsh here so that a handful of plots that are
495 // consistently in use don't end up locking the page in memory.
496 if (availablePlots.count() > 0) {
497 this->processEvictionAndResetRects(plot);
498 this->processEvictionAndResetRects(availablePlots.back());
499 availablePlots.pop_back();
500 --usedPlots;
501 }
502 if (!usedPlots || !availablePlots.count()) {
503 break;
504 }
505 }
506 plotIter.next();
507 }
508 }
509
Jim Van Verth106b5c42017-09-26 12:45:29 -0400510 // If none of the plots in the last page have been used recently, delete it.
511 if (!usedPlots) {
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400512#ifdef DUMP_ATLAS_DATA
513 if (gDumpAtlasData) {
514 SkDebugf("delete %d\n", fNumPages-1);
515 }
516#endif
Robert Phillips4bc70112018-03-01 10:24:02 -0500517 this->deactivateLastPage();
Jim Van Verth106b5c42017-09-26 12:45:29 -0400518 }
519 }
520
521 fPrevFlushToken = startTokenForNextFlush;
522}
523
Robert Phillips4bc70112018-03-01 10:24:02 -0500524bool GrDrawOpAtlas::createPages(GrProxyProvider* proxyProvider) {
525 SkASSERT(SkIsPow2(fTextureWidth) && SkIsPow2(fTextureHeight));
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500526
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400527 GrSurfaceDesc desc;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400528 desc.fWidth = fTextureWidth;
529 desc.fHeight = fTextureHeight;
Greg Daniele877dce2019-07-11 10:52:43 -0400530 desc.fConfig = GrColorTypeToPixelConfig(fColorType);
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400531
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400532 int numPlotsX = fTextureWidth/fPlotWidth;
533 int numPlotsY = fTextureHeight/fPlotHeight;
534
Robert Phillips4bc70112018-03-01 10:24:02 -0500535 for (uint32_t i = 0; i < this->maxPages(); ++i) {
Greg Daniel9715b6c2019-12-10 15:03:10 -0500536 sk_sp<GrSurfaceProxy> proxy = proxyProvider->createProxy(
Brian Salomonbeb7f522019-08-30 16:19:42 -0400537 fFormat, desc, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
538 SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo,
539 GrInternalSurfaceFlags::kNone, GrSurfaceProxy::UseAllocator::kNo);
Greg Daniel9715b6c2019-12-10 15:03:10 -0500540 if (!proxy) {
Robert Phillips4bc70112018-03-01 10:24:02 -0500541 return false;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400542 }
Greg Daniel9715b6c2019-12-10 15:03:10 -0500543 GrSwizzle swizzle = proxyProvider->caps()->getTextureSwizzle(fFormat, fColorType);
544 fViews[i] = GrSurfaceProxyView(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle);
Robert Phillips4bc70112018-03-01 10:24:02 -0500545
546 // set up allocated plots
547 fPages[i].fPlotArray.reset(new sk_sp<Plot>[ numPlotsX * numPlotsY ]);
548
549 sk_sp<Plot>* currPlot = fPages[i].fPlotArray.get();
550 for (int y = numPlotsY - 1, r = 0; y >= 0; --y, ++r) {
551 for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) {
552 uint32_t plotIndex = r * numPlotsX + c;
553 currPlot->reset(new Plot(i, plotIndex, 1, x, y, fPlotWidth, fPlotHeight,
Robert Phillips42dda082019-05-14 13:29:45 -0400554 fColorType));
Robert Phillips4bc70112018-03-01 10:24:02 -0500555
556 // build LRU list
557 fPages[i].fPlotList.addToHead(currPlot->get());
558 ++currPlot;
559 }
560 }
561
562 }
563
564 return true;
565}
566
567
568bool GrDrawOpAtlas::activateNewPage(GrResourceProvider* resourceProvider) {
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500569 SkASSERT(fNumActivePages < this->maxPages());
Robert Phillips4bc70112018-03-01 10:24:02 -0500570
Greg Daniel9715b6c2019-12-10 15:03:10 -0500571 if (!fViews[fNumActivePages].proxy()->instantiate(resourceProvider)) {
Robert Phillips4bc70112018-03-01 10:24:02 -0500572 return false;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400573 }
574
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400575#ifdef DUMP_ATLAS_DATA
576 if (gDumpAtlasData) {
Robert Phillips4bc70112018-03-01 10:24:02 -0500577 SkDebugf("activated page#: %d\n", fNumActivePages);
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400578 }
579#endif
Robert Phillips4bc70112018-03-01 10:24:02 -0500580
581 ++fNumActivePages;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400582 return true;
583}
Jim Van Verth106b5c42017-09-26 12:45:29 -0400584
Robert Phillips4bc70112018-03-01 10:24:02 -0500585
586inline void GrDrawOpAtlas::deactivateLastPage() {
587 SkASSERT(fNumActivePages);
588
589 uint32_t lastPageIndex = fNumActivePages - 1;
590
591 int numPlotsX = fTextureWidth/fPlotWidth;
592 int numPlotsY = fTextureHeight/fPlotHeight;
593
Jim Van Verth106b5c42017-09-26 12:45:29 -0400594 fPages[lastPageIndex].fPlotList.reset();
Robert Phillips6250f292018-03-01 10:53:45 -0500595 for (int r = 0; r < numPlotsY; ++r) {
596 for (int c = 0; c < numPlotsX; ++c) {
Robert Phillips4bc70112018-03-01 10:24:02 -0500597 uint32_t plotIndex = r * numPlotsX + c;
598
599 Plot* currPlot = fPages[lastPageIndex].fPlotArray[plotIndex].get();
600 currPlot->resetRects();
601 currPlot->resetFlushesSinceLastUsed();
602
603 // rebuild the LRU list
604 SkDEBUGCODE(currPlot->fPrev = currPlot->fNext = nullptr);
605 SkDEBUGCODE(currPlot->fList = nullptr);
606 fPages[lastPageIndex].fPlotList.addToHead(currPlot);
607 }
608 }
609
610 // remove ref to the backing texture
Greg Daniel9715b6c2019-12-10 15:03:10 -0500611 fViews[lastPageIndex].proxy()->deinstantiate();
Robert Phillips4bc70112018-03-01 10:24:02 -0500612 --fNumActivePages;
Jim Van Verth106b5c42017-09-26 12:45:29 -0400613}
Herb Derby15d9ef22018-10-18 13:41:32 -0400614
Jim Van Verthf6206f92018-12-14 08:22:24 -0500615GrDrawOpAtlasConfig::GrDrawOpAtlasConfig(int maxTextureSize, size_t maxBytes) {
616 static const SkISize kARGBDimensions[] = {
617 {256, 256}, // maxBytes < 2^19
618 {512, 256}, // 2^19 <= maxBytes < 2^20
619 {512, 512}, // 2^20 <= maxBytes < 2^21
620 {1024, 512}, // 2^21 <= maxBytes < 2^22
621 {1024, 1024}, // 2^22 <= maxBytes < 2^23
622 {2048, 1024}, // 2^23 <= maxBytes
623 };
Herb Derby15d9ef22018-10-18 13:41:32 -0400624
Jim Van Verthf6206f92018-12-14 08:22:24 -0500625 // Index 0 corresponds to maxBytes of 2^18, so start by dividing it by that
626 maxBytes >>= 18;
627 // Take the floor of the log to get the index
628 int index = maxBytes > 0
629 ? SkTPin<int>(SkPrevLog2(maxBytes), 0, SK_ARRAY_COUNT(kARGBDimensions) - 1)
630 : 0;
Herb Derby15d9ef22018-10-18 13:41:32 -0400631
Jim Van Verthf6206f92018-12-14 08:22:24 -0500632 SkASSERT(kARGBDimensions[index].width() <= kMaxAtlasDim);
633 SkASSERT(kARGBDimensions[index].height() <= kMaxAtlasDim);
634 fARGBDimensions.set(SkTMin<int>(kARGBDimensions[index].width(), maxTextureSize),
635 SkTMin<int>(kARGBDimensions[index].height(), maxTextureSize));
636 fMaxTextureSize = SkTMin<int>(maxTextureSize, kMaxAtlasDim);
Herb Derby15d9ef22018-10-18 13:41:32 -0400637}
638
639SkISize GrDrawOpAtlasConfig::atlasDimensions(GrMaskFormat type) const {
Jim Van Verthf6206f92018-12-14 08:22:24 -0500640 if (kA8_GrMaskFormat == type) {
641 // A8 is always 2x the ARGB dimensions, clamped to the max allowed texture size
642 return { SkTMin<int>(2 * fARGBDimensions.width(), fMaxTextureSize),
643 SkTMin<int>(2 * fARGBDimensions.height(), fMaxTextureSize) };
644 } else {
645 return fARGBDimensions;
646 }
Herb Derby15d9ef22018-10-18 13:41:32 -0400647}
648
Jim Van Verthf6206f92018-12-14 08:22:24 -0500649SkISize GrDrawOpAtlasConfig::plotDimensions(GrMaskFormat type) const {
650 if (kA8_GrMaskFormat == type) {
651 SkISize atlasDimensions = this->atlasDimensions(type);
652 // For A8 we want to grow the plots at larger texture sizes to accept more of the
653 // larger SDF glyphs. Since the largest SDF glyph can be 170x170 with padding, this
654 // allows us to pack 3 in a 512x256 plot, or 9 in a 512x512 plot.
Herb Derby15d9ef22018-10-18 13:41:32 -0400655
Jim Van Verth578b0892018-12-20 20:48:55 +0000656 // This will give us 512x256 plots for 2048x1024, 512x512 plots for 2048x2048,
657 // and 256x256 plots otherwise.
Jim Van Verthf6206f92018-12-14 08:22:24 -0500658 int plotWidth = atlasDimensions.width() >= 2048 ? 512 : 256;
Jim Van Verth578b0892018-12-20 20:48:55 +0000659 int plotHeight = atlasDimensions.height() >= 2048 ? 512 : 256;
Herb Derby15d9ef22018-10-18 13:41:32 -0400660
Jim Van Verthf6206f92018-12-14 08:22:24 -0500661 return { plotWidth, plotHeight };
662 } else {
663 // ARGB and LCD always use 256x256 plots -- this has been shown to be faster
664 return { 256, 256 };
665 }
Herb Derby15d9ef22018-10-18 13:41:32 -0400666}
667
Jim Van Verthf6206f92018-12-14 08:22:24 -0500668constexpr int GrDrawOpAtlasConfig::kMaxAtlasDim;