blob: d4a81a0106f5f411f1a461f8cce0ccd3d337ece4 [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];
198 Plot* plot = fPages[pd.fPageIndex].fPlotArray[pd.fPlotIndex].get();
199 this->makeMRU(plot, pd.fPageIndex);
Brian Salomon2ee084e2016-12-16 18:59:19 -0500200 plot->setLastUseToken(token);
joshualitt5df175e2015-11-18 13:37:54 -0800201 }
202 }
joshualittb4c507e2015-04-08 08:07:59 -0700203
Jim Van Verth106b5c42017-09-26 12:45:29 -0400204 void compact(GrDrawOpUploadToken startTokenForNextFlush);
205
Jim Van Vertha950b632017-09-12 11:54:11 -0400206 static constexpr auto kGlyphMaxDim = 256;
joshualitt010db532015-04-21 10:07:26 -0700207 static bool GlyphTooLargeForAtlas(int width, int height) {
208 return width > kGlyphMaxDim || height > kGlyphMaxDim;
209 }
210
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400211 static uint32_t GetPageIndexFromID(AtlasID id) {
212 return id & 0xff;
213 }
214
joshualitt5bf99f12015-03-13 11:47:42 -0700215private:
Jim Van Verthd74f3f22017-08-31 16:44:08 -0400216 GrDrawOpAtlas(GrContext*, GrPixelConfig config, int width, int height,
217 int numPlotsX, int numPlotsY);
Robert Phillips256c37b2017-03-01 14:32:46 -0500218
Brian Salomon2ee084e2016-12-16 18:59:19 -0500219 /**
220 * The backing GrTexture for a GrDrawOpAtlas is broken into a spatial grid of Plots. The Plots
221 * keep track of subimage placement via their GrRectanizer. A Plot manages the lifetime of its
222 * data using two tokens, a last use token and a last upload token. Once a Plot is "full" (i.e.
223 * there is no room for the new subimage according to the GrRectanizer), it can no longer be
224 * used unless the last use of the Plot has already been flushed through to the gpu.
225 */
226 class Plot : public SkRefCnt {
227 SK_DECLARE_INTERNAL_LLIST_INTERFACE(Plot);
joshualitt5df175e2015-11-18 13:37:54 -0800228
229 public:
Jim Van Vertha950b632017-09-12 11:54:11 -0400230 /** index() is a unique id for the plot relative to the owning GrAtlas and page. */
231 uint32_t index() const { return fPlotIndex; }
Brian Salomon2ee084e2016-12-16 18:59:19 -0500232 /**
233 * genID() is incremented when the plot is evicted due to a atlas spill. It is used to know
234 * if a particular subimage is still present in the atlas.
235 */
joshualitt5df175e2015-11-18 13:37:54 -0800236 uint64_t genID() const { return fGenID; }
Brian Salomon2ee084e2016-12-16 18:59:19 -0500237 GrDrawOpAtlas::AtlasID id() const {
238 SkASSERT(GrDrawOpAtlas::kInvalidAtlasID != fID);
joshualitt5df175e2015-11-18 13:37:54 -0800239 return fID;
240 }
241 SkDEBUGCODE(size_t bpp() const { return fBytesPerPixel; })
242
243 bool addSubImage(int width, int height, const void* image, SkIPoint16* loc);
244
Brian Salomon2ee084e2016-12-16 18:59:19 -0500245 /**
246 * To manage the lifetime of a plot, we use two tokens. We use the last upload token to
247 * know when we can 'piggy back' uploads, i.e. if the last upload hasn't been flushed to
248 * the gpu, we don't need to issue a new upload even if we update the cpu backing store. We
249 * use lastUse to determine when we can evict a plot from the cache, i.e. if the last use
250 * has already flushed through the gpu then we can reuse the plot.
251 */
Brian Salomon9afd3712016-12-01 10:59:09 -0500252 GrDrawOpUploadToken lastUploadToken() const { return fLastUpload; }
253 GrDrawOpUploadToken lastUseToken() const { return fLastUse; }
Brian Salomon2ee084e2016-12-16 18:59:19 -0500254 void setLastUploadToken(GrDrawOpUploadToken token) { fLastUpload = token; }
255 void setLastUseToken(GrDrawOpUploadToken token) { fLastUse = token; }
joshualitt5df175e2015-11-18 13:37:54 -0800256
Robert Phillipsacaa6072017-07-28 10:54:53 -0400257 void uploadToTexture(GrDrawOp::WritePixelsFn&, GrTextureProxy*);
joshualitt5df175e2015-11-18 13:37:54 -0800258 void resetRects();
259
Jim Van Verth106b5c42017-09-26 12:45:29 -0400260 int flushesSinceLastUsed() { return fFlushesSinceLastUse; }
261 void resetFlushesSinceLastUsed() { fFlushesSinceLastUse = 0; }
262 void incFlushesSinceLastUsed() { fFlushesSinceLastUse++; }
263
joshualitt5df175e2015-11-18 13:37:54 -0800264 private:
Jim Van Vertha950b632017-09-12 11:54:11 -0400265 Plot(int pageIndex, int plotIndex, uint64_t genID, int offX, int offY, int width, int height,
Brian Salomon2ee084e2016-12-16 18:59:19 -0500266 GrPixelConfig config);
joshualitt5df175e2015-11-18 13:37:54 -0800267
Brian Salomon2ee084e2016-12-16 18:59:19 -0500268 ~Plot() override;
joshualitt5df175e2015-11-18 13:37:54 -0800269
Brian Salomon2ee084e2016-12-16 18:59:19 -0500270 /**
271 * Create a clone of this plot. The cloned plot will take the place of the current plot in
272 * the atlas
273 */
274 Plot* clone() const {
Jim Van Vertha950b632017-09-12 11:54:11 -0400275 return new Plot(fPageIndex, fPlotIndex, fGenID + 1, fX, fY, fWidth, fHeight, fConfig);
joshualitt5df175e2015-11-18 13:37:54 -0800276 }
277
Jim Van Vertha950b632017-09-12 11:54:11 -0400278 static GrDrawOpAtlas::AtlasID CreateId(uint32_t pageIdx, uint32_t plotIdx,
279 uint64_t generation) {
280 SkASSERT(pageIdx < (1 << 8));
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400281 SkASSERT(pageIdx < kMaxPages);
Jim Van Vertha950b632017-09-12 11:54:11 -0400282 SkASSERT(plotIdx < (1 << 8));
joshualitt5df175e2015-11-18 13:37:54 -0800283 SkASSERT(generation < ((uint64_t)1 << 48));
Jim Van Vertha950b632017-09-12 11:54:11 -0400284 return generation << 16 | plotIdx << 8 | pageIdx;
joshualitt5df175e2015-11-18 13:37:54 -0800285 }
286
Brian Salomon9afd3712016-12-01 10:59:09 -0500287 GrDrawOpUploadToken fLastUpload;
288 GrDrawOpUploadToken fLastUse;
Jim Van Verth106b5c42017-09-26 12:45:29 -0400289 // the number of flushes since this plot has been last used
290 int fFlushesSinceLastUse;
joshualitt5df175e2015-11-18 13:37:54 -0800291
Jim Van Vertha950b632017-09-12 11:54:11 -0400292 struct {
293 const uint32_t fPageIndex : 16;
294 const uint32_t fPlotIndex : 16;
295 };
Brian Salomon2ee084e2016-12-16 18:59:19 -0500296 uint64_t fGenID;
297 GrDrawOpAtlas::AtlasID fID;
298 unsigned char* fData;
299 const int fWidth;
300 const int fHeight;
301 const int fX;
302 const int fY;
303 GrRectanizer* fRects;
304 const SkIPoint16 fOffset; // the offset of the plot in the backing texture
305 const GrPixelConfig fConfig;
306 const size_t fBytesPerPixel;
307 SkIRect fDirtyRect;
308 SkDEBUGCODE(bool fDirty);
joshualitt5df175e2015-11-18 13:37:54 -0800309
Brian Salomon2ee084e2016-12-16 18:59:19 -0500310 friend class GrDrawOpAtlas;
joshualitt5df175e2015-11-18 13:37:54 -0800311
312 typedef SkRefCnt INHERITED;
313 };
314
Brian Salomon2ee084e2016-12-16 18:59:19 -0500315 typedef SkTInternalLList<Plot> PlotList;
robertphillips2b0536f2015-11-06 14:10:42 -0800316
Jim Van Vertha950b632017-09-12 11:54:11 -0400317 static uint32_t GetPlotIndexFromID(AtlasID id) {
318 return (id >> 8) & 0xff;
joshualitt5bf99f12015-03-13 11:47:42 -0700319 }
320
joshualitt8db6fdc2015-07-31 08:25:07 -0700321 // top 48 bits are reserved for the generation ID
322 static uint64_t GetGenerationFromID(AtlasID id) {
323 return (id >> 16) & 0xffffffffffff;
joshualitt5bf99f12015-03-13 11:47:42 -0700324 }
325
Robert Phillips256c37b2017-03-01 14:32:46 -0500326 inline bool updatePlot(GrDrawOp::Target*, AtlasID*, Plot*);
joshualitt5bf99f12015-03-13 11:47:42 -0700327
Jim Van Vertha950b632017-09-12 11:54:11 -0400328 inline void makeMRU(Plot* plot, int pageIdx) {
329 if (fPages[pageIdx].fPlotList.head() == plot) {
joshualitt5df175e2015-11-18 13:37:54 -0800330 return;
331 }
332
Jim Van Vertha950b632017-09-12 11:54:11 -0400333 fPages[pageIdx].fPlotList.remove(plot);
334 fPages[pageIdx].fPlotList.addToHead(plot);
335
Jim Van Verth106b5c42017-09-26 12:45:29 -0400336 // No MRU update for pages -- since we will always try to add from
337 // the front and remove from the back there is no need for MRU.
joshualitt5df175e2015-11-18 13:37:54 -0800338 }
joshualitt5bf99f12015-03-13 11:47:42 -0700339
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400340 bool createNewPage();
Jim Van Verth106b5c42017-09-26 12:45:29 -0400341 void deleteLastPage();
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400342
joshualitt5bf99f12015-03-13 11:47:42 -0700343 inline void processEviction(AtlasID);
344
Robert Phillips32f28182017-02-28 16:20:03 -0500345 GrContext* fContext;
Jim Van Verthd74f3f22017-08-31 16:44:08 -0400346 GrPixelConfig fPixelConfig;
347 int fTextureWidth;
348 int fTextureHeight;
Robert Phillips32f28182017-02-28 16:20:03 -0500349 int fPlotWidth;
350 int fPlotHeight;
351 SkDEBUGCODE(uint32_t fNumPlots;)
robertphillips2b0536f2015-11-06 14:10:42 -0800352
Robert Phillips32f28182017-02-28 16:20:03 -0500353 uint64_t fAtlasGeneration;
Jim Van Verth106b5c42017-09-26 12:45:29 -0400354 // nextTokenToFlush() value at the end of the previous flush
355 GrDrawOpUploadToken fPrevFlushToken;
joshualitt5bf99f12015-03-13 11:47:42 -0700356
357 struct EvictionData {
358 EvictionFunc fFunc;
359 void* fData;
360 };
361
362 SkTDArray<EvictionData> fEvictionCallbacks;
Jim Van Vertha950b632017-09-12 11:54:11 -0400363
364 struct Page {
365 // allocated array of Plots
366 std::unique_ptr<sk_sp<Plot>[]> fPlotArray;
367 // LRU list of Plots (MRU at head - LRU at tail)
368 PlotList fPlotList;
369 };
370 // proxies kept separate to make it easier to pass them up to client
371 sk_sp<GrTextureProxy> fProxies[kMaxPages];
372 Page fPages[kMaxPages];
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400373 uint32_t fNumPages;
joshualitt5bf99f12015-03-13 11:47:42 -0700374};
375
376#endif