blob: 647e6a58b92880e19723b2b4c7e40eae0605da83 [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
Brian Salomon2ee084e2016-12-16 18:59:19 -05008#ifndef GrDrawOpAtlas_DEFINED
9#define GrDrawOpAtlas_DEFINED
joshualitt5bf99f12015-03-13 11:47:42 -070010
joshualitt5bf99f12015-03-13 11:47:42 -070011#include "SkPoint.h"
12#include "SkTDArray.h"
13#include "SkTInternalLList.h"
14
Brian Salomon89527432016-12-16 09:52:16 -050015#include "ops/GrDrawOp.h"
joshualittddd22d82016-02-16 06:47:52 -080016
joshualitt5bf99f12015-03-13 11:47:42 -070017class GrRectanizer;
18
Brian Salomon2ee084e2016-12-16 18:59:19 -050019struct GrDrawOpAtlasConfig {
joshualittda04e0e2015-08-19 08:16:43 -070020 int numPlotsX() const { return fWidth / fPlotWidth; }
21 int numPlotsY() const { return fHeight / fPlotWidth; }
22 int fWidth;
23 int fHeight;
24 int fPlotWidth;
25 int fPlotHeight;
26};
27
Brian Salomon2ee084e2016-12-16 18:59:19 -050028/**
Jim Van Verth106b5c42017-09-26 12:45:29 -040029 * This class manages one or more atlas textures on behalf of GrDrawOps. The draw ops that use the
30 * atlas perform texture uploads when preparing their draws during flush. The class provides
31 * facilities for using GrDrawOpUploadToken to detect data hazards. Op's uploads are performed in
32 * "asap" mode until it is impossible to add data without overwriting texels read by draws that
33 * have not yet executed on the gpu. At that point, the atlas will attempt to allocate a new
34 * atlas texture (or "page") of the same size, up to a maximum number of textures, and upload
35 * to that texture. If that's not possible, the uploads are performed "inline" between draws. If a
36 * single draw would use enough subimage space to overflow the atlas texture then the atlas will
37 * fail to add a subimage. This gives the op the chance to end the draw and begin a new one.
38 * Additional uploads will then succeed in inline mode.
39 *
40 * When the atlas has multiple pages, new uploads are prioritized to the lower index pages, i.e.,
41 * it will try to upload to page 0 before page 1 or 2. To keep the atlas from continually using
42 * excess space, periodic garbage collection is needed to shift data from the higher index pages to
43 * the lower ones, and then eventually remove any pages that are no longer in use. "In use" is
44 * determined by using the GrDrawUploadToken system: After a flush each subarea of the page
45 * is checked to see whether it was used in that flush; if it is not, a counter is incremented.
46 * Once that counter reaches a threshold that subarea is considered to be no longer in use.
47 *
48 * Garbage collection is initiated by the GrDrawOpAtlas's client via the compact() method. One
49 * solution is to make the client a subclass of GrOnFlushCallbackObject, register it with the
50 * GrContext via addOnFlushCallbackObject(), and the client's postFlush() method calls compact()
51 * and passes in the given GrDrawUploadToken.
Brian Salomon2ee084e2016-12-16 18:59:19 -050052 */
53class GrDrawOpAtlas {
joshualitt5bf99f12015-03-13 11:47:42 -070054public:
Brian Salomon2ee084e2016-12-16 18:59:19 -050055 /**
56 * An AtlasID is an opaque handle which callers can use to determine if the atlas contains
57 * a specific piece of data.
58 */
joshualitt8db6fdc2015-07-31 08:25:07 -070059 typedef uint64_t AtlasID;
joshualitt7c3a2f82015-03-31 13:32:05 -070060 static const uint32_t kInvalidAtlasID = 0;
61 static const uint64_t kInvalidAtlasGeneration = 0;
joshualitt5bf99f12015-03-13 11:47:42 -070062
Brian Salomon2ee084e2016-12-16 18:59:19 -050063 /**
64 * A function pointer for use as a callback during eviction. Whenever GrDrawOpAtlas evicts a
65 * specific AtlasID, it will call all of the registered listeners so they can process the
66 * eviction.
67 */
68 typedef void (*EvictionFunc)(GrDrawOpAtlas::AtlasID, void*);
joshualitt5bf99f12015-03-13 11:47:42 -070069
Robert Phillips256c37b2017-03-01 14:32:46 -050070 /**
71 * Returns a GrDrawOpAtlas. This function can be called anywhere, but the returned atlas
72 * should only be used inside of GrMeshDrawOp::onPrepareDraws.
73 * @param GrPixelConfig The pixel config which this atlas will store
74 * @param width width in pixels of the atlas
75 * @param height height in pixels of the atlas
76 * @param numPlotsX The number of plots the atlas should be broken up into in the X
77 * direction
78 * @param numPlotsY The number of plots the atlas should be broken up into in the Y
79 * direction
80 * @param func An eviction function which will be called whenever the atlas has to
81 * evict data
82 * @param data User supplied data which will be passed into func whenver an
83 * eviction occurs
84 * @return An initialized GrDrawOpAtlas, or nullptr if creation fails
85 */
86 static std::unique_ptr<GrDrawOpAtlas> Make(GrContext*, GrPixelConfig,
87 int width, int height,
88 int numPlotsX, int numPlotsY,
89 GrDrawOpAtlas::EvictionFunc func, void* data);
joshualitt5bf99f12015-03-13 11:47:42 -070090
Brian Salomon2ee084e2016-12-16 18:59:19 -050091 /**
92 * Adds a width x height subimage to the atlas. Upon success it returns an ID and the subimage's
93 * coordinates in the backing texture. False is returned if the subimage cannot fit in the
94 * atlas without overwriting texels that will be read in the current draw. This indicates that
95 * the op should end its current draw and begin another before adding more data. Upon success,
96 * an upload of the provided image data will have been added to the GrDrawOp::Target, in "asap"
97 * mode if possible, otherwise in "inline" mode. Successive uploads in either mode may be
98 * consolidated.
99 * NOTE: When the GrDrawOp prepares a draw that reads from the atlas, it must immediately call
100 * 'setUseToken' with the currentToken from the GrDrawOp::Target, otherwise the next call to
101 * addToAtlas might cause the previous data to be overwritten before it has been read.
102 */
Brian Salomon9afd3712016-12-01 10:59:09 -0500103 bool addToAtlas(AtlasID*, GrDrawOp::Target*, int width, int height, const void* image,
joshualitt5bf99f12015-03-13 11:47:42 -0700104 SkIPoint16* loc);
105
Robert Phillips32f28182017-02-28 16:20:03 -0500106 GrContext* context() const { return fContext; }
Jim Van Vertha950b632017-09-12 11:54:11 -0400107 const sk_sp<GrTextureProxy>* getProxies() const { return fProxies; }
joshualitt5bf99f12015-03-13 11:47:42 -0700108
joshualitt7c3a2f82015-03-31 13:32:05 -0700109 uint64_t atlasGeneration() const { return fAtlasGeneration; }
joshualitt5df175e2015-11-18 13:37:54 -0800110
111 inline bool hasID(AtlasID id) {
Jim Van Vertha950b632017-09-12 11:54:11 -0400112 uint32_t plot = GetPlotIndexFromID(id);
113 SkASSERT(plot < fNumPlots);
114 uint32_t page = GetPageIndexFromID(id);
115 SkASSERT(page < fNumPages);
116 return fPages[page].fPlotArray[plot]->genID() == GetGenerationFromID(id);
joshualitt5df175e2015-11-18 13:37:54 -0800117 }
joshualittb4c507e2015-04-08 08:07:59 -0700118
Brian Salomon2ee084e2016-12-16 18:59:19 -0500119 /** To ensure the atlas does not evict a given entry, the client must set the last use token. */
120 inline void setLastUseToken(AtlasID id, GrDrawOpUploadToken token) {
joshualitt5df175e2015-11-18 13:37:54 -0800121 SkASSERT(this->hasID(id));
Jim Van Vertha950b632017-09-12 11:54:11 -0400122 uint32_t plotIdx = GetPlotIndexFromID(id);
123 SkASSERT(plotIdx < fNumPlots);
124 uint32_t pageIdx = GetPageIndexFromID(id);
125 SkASSERT(pageIdx < fNumPages);
126 Plot* plot = fPages[pageIdx].fPlotArray[plotIdx].get();
127 this->makeMRU(plot, pageIdx);
128 plot->setLastUseToken(token);
joshualitt5df175e2015-11-18 13:37:54 -0800129 }
130
131 inline void registerEvictionCallback(EvictionFunc func, void* userData) {
joshualitt5bf99f12015-03-13 11:47:42 -0700132 EvictionData* data = fEvictionCallbacks.append();
133 data->fFunc = func;
134 data->fData = userData;
135 }
136
Jim Van Vertha950b632017-09-12 11:54:11 -0400137 static constexpr auto kMaxPages = 4;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400138 uint32_t pageCount() { return fNumPages; }
Jim Van Vertha950b632017-09-12 11:54:11 -0400139
Brian Salomon2ee084e2016-12-16 18:59:19 -0500140 /**
141 * A class which can be handed back to GrDrawOpAtlas for updating last use tokens in bulk. The
Jim Van Vertha950b632017-09-12 11:54:11 -0400142 * current max number of plots per page the GrDrawOpAtlas can handle is 32. If in the future
143 * this is insufficient then we can move to a 64 bit int.
joshualittb4c507e2015-04-08 08:07:59 -0700144 */
145 class BulkUseTokenUpdater {
146 public:
Jim Van Vertha950b632017-09-12 11:54:11 -0400147 BulkUseTokenUpdater() {
148 memset(fPlotAlreadyUpdated, 0, sizeof(fPlotAlreadyUpdated));
149 }
joshualitt7e97b0b2015-07-31 15:18:08 -0700150 BulkUseTokenUpdater(const BulkUseTokenUpdater& that)
Jim Van Vertha950b632017-09-12 11:54:11 -0400151 : fPlotsToUpdate(that.fPlotsToUpdate) {
152 memcpy(fPlotAlreadyUpdated, that.fPlotAlreadyUpdated, sizeof(fPlotAlreadyUpdated));
joshualitt7e97b0b2015-07-31 15:18:08 -0700153 }
154
joshualittb4c507e2015-04-08 08:07:59 -0700155 void add(AtlasID id) {
Jim Van Vertha950b632017-09-12 11:54:11 -0400156 int index = GrDrawOpAtlas::GetPlotIndexFromID(id);
157 int pageIdx = GrDrawOpAtlas::GetPageIndexFromID(id);
158 if (!this->find(pageIdx, index)) {
159 this->set(pageIdx, index);
joshualittb4c507e2015-04-08 08:07:59 -0700160 }
161 }
162
163 void reset() {
joshualitt4314e082015-04-23 08:03:35 -0700164 fPlotsToUpdate.reset();
Jim Van Vertha950b632017-09-12 11:54:11 -0400165 memset(fPlotAlreadyUpdated, 0, sizeof(fPlotAlreadyUpdated));
joshualittb4c507e2015-04-08 08:07:59 -0700166 }
167
Jim Van Vertha950b632017-09-12 11:54:11 -0400168 struct PlotData {
169 PlotData(int pageIdx, int plotIdx) : fPageIndex(pageIdx), fPlotIndex(plotIdx) {}
170 uint32_t fPageIndex;
171 uint32_t fPlotIndex;
172 };
173
joshualittb4c507e2015-04-08 08:07:59 -0700174 private:
Jim Van Vertha950b632017-09-12 11:54:11 -0400175 bool find(int pageIdx, int index) const {
joshualittb4c507e2015-04-08 08:07:59 -0700176 SkASSERT(index < kMaxPlots);
Jim Van Vertha950b632017-09-12 11:54:11 -0400177 return (fPlotAlreadyUpdated[pageIdx] >> index) & 1;
joshualittb4c507e2015-04-08 08:07:59 -0700178 }
179
Jim Van Vertha950b632017-09-12 11:54:11 -0400180 void set(int pageIdx, int index) {
181 SkASSERT(!this->find(pageIdx, index));
182 fPlotAlreadyUpdated[pageIdx] |= (1 << index);
183 fPlotsToUpdate.push_back(PlotData(pageIdx, index));
joshualittb4c507e2015-04-08 08:07:59 -0700184 }
185
Jim Van Vertha950b632017-09-12 11:54:11 -0400186 static constexpr int kMinItems = 4;
187 static constexpr int kMaxPlots = 32;
188 SkSTArray<kMinItems, PlotData, true> fPlotsToUpdate;
189 uint32_t fPlotAlreadyUpdated[kMaxPages];
joshualittb4c507e2015-04-08 08:07:59 -0700190
Brian Salomon2ee084e2016-12-16 18:59:19 -0500191 friend class GrDrawOpAtlas;
joshualittb4c507e2015-04-08 08:07:59 -0700192 };
193
Brian Salomon2ee084e2016-12-16 18:59:19 -0500194 void setLastUseTokenBulk(const BulkUseTokenUpdater& updater, GrDrawOpUploadToken token) {
joshualitt5df175e2015-11-18 13:37:54 -0800195 int count = updater.fPlotsToUpdate.count();
196 for (int i = 0; i < count; i++) {
Jim Van Vertha950b632017-09-12 11:54:11 -0400197 const BulkUseTokenUpdater::PlotData& pd = updater.fPlotsToUpdate[i];
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400198 // it's possible we've added a plot to the updater and subsequently the plot's page
199 // was deleted -- so we check to prevent a crash
Jim Van Verth6ca9c6f2017-09-27 18:04:34 -0400200 if (pd.fPageIndex < fNumPages) {
201 Plot* plot = fPages[pd.fPageIndex].fPlotArray[pd.fPlotIndex].get();
202 this->makeMRU(plot, pd.fPageIndex);
203 plot->setLastUseToken(token);
204 }
joshualitt5df175e2015-11-18 13:37:54 -0800205 }
206 }
joshualittb4c507e2015-04-08 08:07:59 -0700207
Jim Van Verth106b5c42017-09-26 12:45:29 -0400208 void compact(GrDrawOpUploadToken startTokenForNextFlush);
209
Jim Van Vertha950b632017-09-12 11:54:11 -0400210 static constexpr auto kGlyphMaxDim = 256;
joshualitt010db532015-04-21 10:07:26 -0700211 static bool GlyphTooLargeForAtlas(int width, int height) {
212 return width > kGlyphMaxDim || height > kGlyphMaxDim;
213 }
214
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400215 static uint32_t GetPageIndexFromID(AtlasID id) {
216 return id & 0xff;
217 }
218
joshualitt5bf99f12015-03-13 11:47:42 -0700219private:
Jim Van Verthd74f3f22017-08-31 16:44:08 -0400220 GrDrawOpAtlas(GrContext*, GrPixelConfig config, int width, int height,
221 int numPlotsX, int numPlotsY);
Robert Phillips256c37b2017-03-01 14:32:46 -0500222
Brian Salomon2ee084e2016-12-16 18:59:19 -0500223 /**
224 * The backing GrTexture for a GrDrawOpAtlas is broken into a spatial grid of Plots. The Plots
225 * keep track of subimage placement via their GrRectanizer. A Plot manages the lifetime of its
226 * data using two tokens, a last use token and a last upload token. Once a Plot is "full" (i.e.
227 * there is no room for the new subimage according to the GrRectanizer), it can no longer be
228 * used unless the last use of the Plot has already been flushed through to the gpu.
229 */
230 class Plot : public SkRefCnt {
231 SK_DECLARE_INTERNAL_LLIST_INTERFACE(Plot);
joshualitt5df175e2015-11-18 13:37:54 -0800232
233 public:
Jim Van Vertha950b632017-09-12 11:54:11 -0400234 /** index() is a unique id for the plot relative to the owning GrAtlas and page. */
235 uint32_t index() const { return fPlotIndex; }
Brian Salomon2ee084e2016-12-16 18:59:19 -0500236 /**
237 * genID() is incremented when the plot is evicted due to a atlas spill. It is used to know
238 * if a particular subimage is still present in the atlas.
239 */
joshualitt5df175e2015-11-18 13:37:54 -0800240 uint64_t genID() const { return fGenID; }
Brian Salomon2ee084e2016-12-16 18:59:19 -0500241 GrDrawOpAtlas::AtlasID id() const {
242 SkASSERT(GrDrawOpAtlas::kInvalidAtlasID != fID);
joshualitt5df175e2015-11-18 13:37:54 -0800243 return fID;
244 }
245 SkDEBUGCODE(size_t bpp() const { return fBytesPerPixel; })
246
247 bool addSubImage(int width, int height, const void* image, SkIPoint16* loc);
248
Brian Salomon2ee084e2016-12-16 18:59:19 -0500249 /**
250 * To manage the lifetime of a plot, we use two tokens. We use the last upload token to
251 * know when we can 'piggy back' uploads, i.e. if the last upload hasn't been flushed to
252 * the gpu, we don't need to issue a new upload even if we update the cpu backing store. We
253 * use lastUse to determine when we can evict a plot from the cache, i.e. if the last use
254 * has already flushed through the gpu then we can reuse the plot.
255 */
Brian Salomon9afd3712016-12-01 10:59:09 -0500256 GrDrawOpUploadToken lastUploadToken() const { return fLastUpload; }
257 GrDrawOpUploadToken lastUseToken() const { return fLastUse; }
Brian Salomon2ee084e2016-12-16 18:59:19 -0500258 void setLastUploadToken(GrDrawOpUploadToken token) { fLastUpload = token; }
259 void setLastUseToken(GrDrawOpUploadToken token) { fLastUse = token; }
joshualitt5df175e2015-11-18 13:37:54 -0800260
Robert Phillipsacaa6072017-07-28 10:54:53 -0400261 void uploadToTexture(GrDrawOp::WritePixelsFn&, GrTextureProxy*);
joshualitt5df175e2015-11-18 13:37:54 -0800262 void resetRects();
263
Jim Van Verth106b5c42017-09-26 12:45:29 -0400264 int flushesSinceLastUsed() { return fFlushesSinceLastUse; }
265 void resetFlushesSinceLastUsed() { fFlushesSinceLastUse = 0; }
266 void incFlushesSinceLastUsed() { fFlushesSinceLastUse++; }
267
joshualitt5df175e2015-11-18 13:37:54 -0800268 private:
Jim Van Vertha950b632017-09-12 11:54:11 -0400269 Plot(int pageIndex, int plotIndex, uint64_t genID, int offX, int offY, int width, int height,
Brian Salomon2ee084e2016-12-16 18:59:19 -0500270 GrPixelConfig config);
joshualitt5df175e2015-11-18 13:37:54 -0800271
Brian Salomon2ee084e2016-12-16 18:59:19 -0500272 ~Plot() override;
joshualitt5df175e2015-11-18 13:37:54 -0800273
Brian Salomon2ee084e2016-12-16 18:59:19 -0500274 /**
275 * Create a clone of this plot. The cloned plot will take the place of the current plot in
276 * the atlas
277 */
278 Plot* clone() const {
Jim Van Vertha950b632017-09-12 11:54:11 -0400279 return new Plot(fPageIndex, fPlotIndex, fGenID + 1, fX, fY, fWidth, fHeight, fConfig);
joshualitt5df175e2015-11-18 13:37:54 -0800280 }
281
Jim Van Vertha950b632017-09-12 11:54:11 -0400282 static GrDrawOpAtlas::AtlasID CreateId(uint32_t pageIdx, uint32_t plotIdx,
283 uint64_t generation) {
284 SkASSERT(pageIdx < (1 << 8));
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400285 SkASSERT(pageIdx < kMaxPages);
Jim Van Vertha950b632017-09-12 11:54:11 -0400286 SkASSERT(plotIdx < (1 << 8));
joshualitt5df175e2015-11-18 13:37:54 -0800287 SkASSERT(generation < ((uint64_t)1 << 48));
Jim Van Vertha950b632017-09-12 11:54:11 -0400288 return generation << 16 | plotIdx << 8 | pageIdx;
joshualitt5df175e2015-11-18 13:37:54 -0800289 }
290
Brian Salomon9afd3712016-12-01 10:59:09 -0500291 GrDrawOpUploadToken fLastUpload;
292 GrDrawOpUploadToken fLastUse;
Jim Van Verth106b5c42017-09-26 12:45:29 -0400293 // the number of flushes since this plot has been last used
294 int fFlushesSinceLastUse;
joshualitt5df175e2015-11-18 13:37:54 -0800295
Jim Van Vertha950b632017-09-12 11:54:11 -0400296 struct {
297 const uint32_t fPageIndex : 16;
298 const uint32_t fPlotIndex : 16;
299 };
Brian Salomon2ee084e2016-12-16 18:59:19 -0500300 uint64_t fGenID;
301 GrDrawOpAtlas::AtlasID fID;
302 unsigned char* fData;
303 const int fWidth;
304 const int fHeight;
305 const int fX;
306 const int fY;
307 GrRectanizer* fRects;
308 const SkIPoint16 fOffset; // the offset of the plot in the backing texture
309 const GrPixelConfig fConfig;
310 const size_t fBytesPerPixel;
311 SkIRect fDirtyRect;
312 SkDEBUGCODE(bool fDirty);
joshualitt5df175e2015-11-18 13:37:54 -0800313
Brian Salomon2ee084e2016-12-16 18:59:19 -0500314 friend class GrDrawOpAtlas;
joshualitt5df175e2015-11-18 13:37:54 -0800315
316 typedef SkRefCnt INHERITED;
317 };
318
Brian Salomon2ee084e2016-12-16 18:59:19 -0500319 typedef SkTInternalLList<Plot> PlotList;
robertphillips2b0536f2015-11-06 14:10:42 -0800320
Jim Van Vertha950b632017-09-12 11:54:11 -0400321 static uint32_t GetPlotIndexFromID(AtlasID id) {
322 return (id >> 8) & 0xff;
joshualitt5bf99f12015-03-13 11:47:42 -0700323 }
324
joshualitt8db6fdc2015-07-31 08:25:07 -0700325 // top 48 bits are reserved for the generation ID
326 static uint64_t GetGenerationFromID(AtlasID id) {
327 return (id >> 16) & 0xffffffffffff;
joshualitt5bf99f12015-03-13 11:47:42 -0700328 }
329
Robert Phillips256c37b2017-03-01 14:32:46 -0500330 inline bool updatePlot(GrDrawOp::Target*, AtlasID*, Plot*);
joshualitt5bf99f12015-03-13 11:47:42 -0700331
Jim Van Vertha950b632017-09-12 11:54:11 -0400332 inline void makeMRU(Plot* plot, int pageIdx) {
333 if (fPages[pageIdx].fPlotList.head() == plot) {
joshualitt5df175e2015-11-18 13:37:54 -0800334 return;
335 }
336
Jim Van Vertha950b632017-09-12 11:54:11 -0400337 fPages[pageIdx].fPlotList.remove(plot);
338 fPages[pageIdx].fPlotList.addToHead(plot);
339
Jim Van Verth106b5c42017-09-26 12:45:29 -0400340 // No MRU update for pages -- since we will always try to add from
341 // the front and remove from the back there is no need for MRU.
joshualitt5df175e2015-11-18 13:37:54 -0800342 }
joshualitt5bf99f12015-03-13 11:47:42 -0700343
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400344 bool createNewPage();
Jim Van Verth106b5c42017-09-26 12:45:29 -0400345 void deleteLastPage();
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400346
Jim Van Verthc3269ae2017-09-28 15:04:00 -0400347 void processEviction(AtlasID);
348 inline void processEvictionAndResetRects(Plot* plot) {
349 this->processEviction(plot->id());
350 plot->resetRects();
351 }
joshualitt5bf99f12015-03-13 11:47:42 -0700352
Robert Phillips32f28182017-02-28 16:20:03 -0500353 GrContext* fContext;
Jim Van Verthd74f3f22017-08-31 16:44:08 -0400354 GrPixelConfig fPixelConfig;
355 int fTextureWidth;
356 int fTextureHeight;
Robert Phillips32f28182017-02-28 16:20:03 -0500357 int fPlotWidth;
358 int fPlotHeight;
359 SkDEBUGCODE(uint32_t fNumPlots;)
robertphillips2b0536f2015-11-06 14:10:42 -0800360
Robert Phillips32f28182017-02-28 16:20:03 -0500361 uint64_t fAtlasGeneration;
Jim Van Verth106b5c42017-09-26 12:45:29 -0400362 // nextTokenToFlush() value at the end of the previous flush
363 GrDrawOpUploadToken fPrevFlushToken;
joshualitt5bf99f12015-03-13 11:47:42 -0700364
365 struct EvictionData {
366 EvictionFunc fFunc;
367 void* fData;
368 };
369
370 SkTDArray<EvictionData> fEvictionCallbacks;
Jim Van Vertha950b632017-09-12 11:54:11 -0400371
372 struct Page {
373 // allocated array of Plots
374 std::unique_ptr<sk_sp<Plot>[]> fPlotArray;
375 // LRU list of Plots (MRU at head - LRU at tail)
376 PlotList fPlotList;
377 };
378 // proxies kept separate to make it easier to pass them up to client
379 sk_sp<GrTextureProxy> fProxies[kMaxPages];
380 Page fPages[kMaxPages];
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400381 uint32_t fNumPages;
joshualitt5bf99f12015-03-13 11:47:42 -0700382};
383
384#endif