bool GrAtlas::addSubImage(int width, int height, const void* image, GrIPoint16* loc) { if (!fRects->addRect(width + BORDER, height + BORDER, loc)) { return false; } SkAutoSMalloc<1024> storage; int dstW = width + 2*BORDER; int dstH = height + 2*BORDER; if (BORDER) { const int bpp = GrMaskFormatBytesPerPixel(fMaskFormat); const size_t dstRB = dstW * bpp; uint8_t* dst = (uint8_t*)storage.reset(dstH * dstRB); Gr_bzero(dst, dstRB); // zero top row dst += dstRB; for (int y = 0; y < height; y++) { dst = zerofill(dst, bpp); // zero left edge memcpy(dst, image, width * bpp); dst += width * bpp; dst = zerofill(dst, bpp); // zero right edge image = (const void*)((const char*)image + width * bpp); } Gr_bzero(dst, dstRB); // zero bottom row image = storage.get(); } adjustForPlot(loc, fPlot); GrContext* context = fTexture->getContext(); // We call the internal version so that we don't force a flush. We assume // our caller is smart and hasn't referenced the part of the texture we're // about to update since the last flush. context->internalWriteTexturePixels(fTexture, loc->fX, loc->fY, dstW, dstH, fTexture->config(), image, 0, GrContext::kDontFlush_PixelOpsFlag); // now tell the caller to skip the top/left BORDER loc->fX += BORDER; loc->fY += BORDER; return true; }