Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: src/gpu/GrBatchAtlas.h

Issue 1050113004: Adding bulk plot reffer to cached textblobs (Closed) Base URL: https://skia.googlesource.com/skia.git@atlastext
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrBatchAtlas.h
diff --git a/src/gpu/GrBatchAtlas.h b/src/gpu/GrBatchAtlas.h
index cd8123f140980fdb581ceb9789948098c85d7452..665b3da32d69164e636a108d84421e129da2e64f 100644
--- a/src/gpu/GrBatchAtlas.h
+++ b/src/gpu/GrBatchAtlas.h
@@ -54,12 +54,53 @@ public:
data->fData = userData;
}
+ /*
+ * A class which can be handed back to GrBatchAtlas for updating in bulk last ref tokens.
+ * NOTE: This class assumes you want to set the same BatchToken for each plot.
+ */
+ class BulkTokenReffer {
bsalomon 2015/04/01 20:21:31 I find the use of "Ref" confusing in this class. I
+ public:
+ BulkTokenReffer() : fPlotAlreadyUpdated(0), fBatchToken(0) {}
+ void setRefToken(GrBatchAtlas* atlas, AtlasID id, BatchToken token) {
bsalomon 2015/04/01 20:21:31 Does this mean it sets here and when setLastRefTok
+ int index = GrBatchAtlas::GetIndexFromID(id);
+ if (!this->find(index)) {
+ this->set(index);
+ atlas->setLastRefTokenInternal(index, token);
+ fBatchToken = token;
+ }
+ }
+
+ void reset() {
+ fPlotsToUpdate.reset();
+ fPlotAlreadyUpdated = 0;
+ }
+
+ private:
+ bool find(int index) const {
+ return (fPlotAlreadyUpdated >> index) & 1;
+ }
+ void set(int index) {
+ SkASSERT(!this->find(index));
+ fPlotAlreadyUpdated = fPlotAlreadyUpdated | (1 << index);
+ fPlotsToUpdate.push_back(index);
+ }
+
+ static const int kMaxPlots = 32;
+ uint32_t fPlotAlreadyUpdated;
+ BatchToken fBatchToken;
+ SkSTArray<4, int, true> fPlotsToUpdate;
+
+ friend class GrBatchAtlas;
+ };
+
+ void setLastRefTokenBulk(const BulkTokenReffer& reffer);
+
private:
- int getIndexFromID(AtlasID id) {
+ static int GetIndexFromID(AtlasID id) {
return id & 0xffff;
}
- int getGenerationFromID(AtlasID id) {
+ static int GetGenerationFromID(AtlasID id) {
return (id >> 16) & 0xffff;
}
@@ -69,6 +110,8 @@ private:
inline void processEviction(AtlasID);
+ void setLastRefTokenInternal(int index, BatchToken);
+
GrTexture* fTexture;
int fNumPlotsX;
int fNumPlotsY;
@@ -87,6 +130,8 @@ private:
SkAutoTUnref<BatchPlot>* fPlotArray;
// LRU list of GrPlots (MRU at head - LRU at tail)
GrBatchPlotList fPlotList;
+
+ friend class BulkTokenReffer;
};
#endif

Powered by Google App Engine
This is Rietveld 408576698