GrAtlas::GrAtlas(GrGpu* gpu, GrPixelConfig config, GrSurfaceFlags flags, const SkISize& backingTextureSize, int numPlotsX, int numPlotsY, bool batchUploads) { fGpu = SkRef(gpu); fPixelConfig = config; fFlags = flags; fBackingTextureSize = backingTextureSize; fNumPlotsX = numPlotsX; fNumPlotsY = numPlotsY; fBatchUploads = batchUploads; fTexture = NULL; int textureWidth = fBackingTextureSize.width(); int textureHeight = fBackingTextureSize.height(); int plotWidth = textureWidth / fNumPlotsX; int plotHeight = textureHeight / fNumPlotsY; SkASSERT(plotWidth * fNumPlotsX == textureWidth); SkASSERT(plotHeight * fNumPlotsY == textureHeight); // We currently do not support compressed atlases... SkASSERT(!GrPixelConfigIsCompressed(config)); // set up allocated plots size_t bpp = GrBytesPerPixel(fPixelConfig); fPlotArray = new GrPlot[(fNumPlotsX * fNumPlotsY)]; GrPlot* currPlot = fPlotArray; for (int y = numPlotsY-1; y >= 0; --y) { for (int x = numPlotsX-1; x >= 0; --x) { currPlot->init(this, y*numPlotsX+x, x, y, plotWidth, plotHeight, bpp, batchUploads); // build LRU list fPlotList.addToHead(currPlot); ++currPlot; } } }