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

Unified Diff: src/gpu/GrBatchAtlas.h

Issue 975303005: Creation of GrBatchAtlas and Distancefieldpathrenderer batch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit 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
« no previous file with comments | « src/gpu/GrBatch.h ('k') | src/gpu/GrBatchAtlas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBatchAtlas.h
diff --git a/src/gpu/GrBatchAtlas.h b/src/gpu/GrBatchAtlas.h
new file mode 100644
index 0000000000000000000000000000000000000000..b514b9d74fbcc0b3198109ebaf86eb387283a617
--- /dev/null
+++ b/src/gpu/GrBatchAtlas.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrBatchAtlas_DEFINED
+#define GrBatchAtlas_DEFINED
+
+#include "GrTexture.h"
+#include "SkPoint.h"
+#include "SkTDArray.h"
+#include "SkTInternalLList.h"
+
+class BatchPlot;
+class GrBatchTarget;
+class GrRectanizer;
+
+typedef SkTInternalLList<BatchPlot> GrBatchPlotList;
+
+class GrBatchAtlas {
+public:
+ typedef uint64_t BatchToken;
+ // An AtlasID is an opaque handle which callers can use to determine if the atlas contains
+ // a specific piece of data
+ typedef uint32_t AtlasID;
+
+ // A function pointer for use as a callback during eviction. Whenever GrBatchAtlas evicts a
+ // specific AtlasID, it will call all of the registered listeners so they can optionally process
+ // the eviction
+ typedef void (*EvictionFunc)(GrBatchAtlas::AtlasID, void*);
+
+ GrBatchAtlas(GrTexture*, int numPlotsX, int numPlotsY);
+ ~GrBatchAtlas();
+
+ // Adds a width x height subimage to the atlas. Upon success it returns
+ // the containing GrPlot and absolute location in the backing texture.
+ // NULL is returned if the subimage cannot fit in the atlas.
+ // If provided, the image data will be written to the CPU-side backing bitmap.
+ bool addToAtlas(AtlasID*, GrBatchTarget*, int width, int height, const void* image,
+ SkIPoint16* loc);
+
+ GrTexture* getTexture() const { return fTexture; }
+
+ bool hasID(AtlasID id);
+ void setLastRefToken(AtlasID id, BatchToken batchToken);
+ void registerEvictionCallback(EvictionFunc func, void* userData) {
+ EvictionData* data = fEvictionCallbacks.append();
+ data->fFunc = func;
+ data->fData = userData;
+ }
+
+private:
+ int getIndexFromID(AtlasID id) {
+ return id & 0xffff;
+ }
+
+ int getGenerationFromID(AtlasID id) {
+ return (id >> 16) & 0xffff;
+ }
+
+ inline void updatePlot(GrBatchTarget*, AtlasID*, BatchPlot*);
+
+ inline void makeMRU(BatchPlot* plot);
+
+ inline void processEviction(AtlasID);
+
+ GrTexture* fTexture;
+ int fNumPlotsX;
+ int fNumPlotsY;
+ int fPlotWidth;
+ int fPlotHeight;
+ size_t fBPP;
+
+ struct EvictionData {
+ EvictionFunc fFunc;
+ void* fData;
+ };
+
+ SkTDArray<EvictionData> fEvictionCallbacks;
+ // allocated array of GrBatchPlots
+ SkAutoTUnref<BatchPlot>* fPlotArray;
+ // LRU list of GrPlots (MRU at head - LRU at tail)
+ GrBatchPlotList fPlotList;
+};
+
+#endif
« no previous file with comments | « src/gpu/GrBatch.h ('k') | src/gpu/GrBatchAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698