static int g_UploadCount = 0;
#endif
-GrPlot::GrPlot() : fDrawToken(NULL, 0)
- , fTexture(NULL)
- , fRects(NULL)
- , fAtlas(NULL)
- , fBytesPerPixel(1)
- , fDirty(false)
- , fBatchUploads(false)
+GrPlot::GrPlot()
+ : fDrawToken(NULL, 0)
+ , fID(-1)
+ , fTexture(NULL)
+ , fRects(NULL)
+ , fAtlas(NULL)
+ , fBytesPerPixel(1)
+ , fDirty(false)
+ , fBatchUploads(false)
{
fOffset.set(0, 0);
}
delete fRects;
}
-void GrPlot::init(GrAtlas* atlas, int offX, int offY, int width, int height, size_t bpp,
+void GrPlot::init(GrAtlas* atlas, int id, int offX, int offY, int width, int height, size_t bpp,
bool batchUploads) {
+ fID = id;
fRects = GrRectanizer::Factory(width, height);
fAtlas = atlas;
fOffset.set(offX * width, offY * height);
GrPlot* currPlot = fPlotArray;
for (int y = numPlotsY-1; y >= 0; --y) {
for (int x = numPlotsX-1; x >= 0; --x) {
- currPlot->init(this, x, y, plotWidth, plotHeight, bpp, batchUploads);
+ currPlot->init(this, y*numPlotsX+x, x, y, plotWidth, plotHeight, bpp, batchUploads);
// build LRU list
fPlotList.addToHead(currPlot);
public:
SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot);
+ // This returns a plot ID unique to each plot in a given GrAtlas. They are
+ // consecutive and start at 0.
+ int id() const { return fID; }
+
GrTexture* texture() const { return fTexture; }
bool addSubImage(int width, int height, const void*, SkIPoint16*);
private:
GrPlot();
~GrPlot(); // does not try to delete the fNext field
- void init(GrAtlas* atlas, int offX, int offY, int width, int height, size_t bpp,
+ void init(GrAtlas* atlas, int id, int offX, int offY, int width, int height, size_t bpp,
bool batchUploads);
// for recycling
GrDrawTarget::DrawToken fDrawToken;
+ int fID;
unsigned char* fPlotData;
GrTexture* fTexture;
GrRectanizer* fRects;