Index: src/gpu/GrAtlas.cpp |
diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp |
index b3f2e34c40e5ab1b79bcb4659761a1268af85165..29f2a54ed75c2ac36a34c66c393dff494c1bd4e5 100644 |
--- a/src/gpu/GrAtlas.cpp |
+++ b/src/gpu/GrAtlas.cpp |
@@ -50,7 +50,7 @@ |
static int g_UploadCount = 0; |
#endif |
-GrAtlas::GrAtlas(GrAtlasMgr* mgr, int plotX, int plotY, GrMaskFormat format) : |
+GrAtlas::GrAtlas(GrAtlasMgr* mgr, int plotX, int plotY, int bpp) : |
fDrawToken(NULL, 0) { |
fAtlasMgr = mgr; // just a pointer, not an owner |
fNext = NULL; |
@@ -61,7 +61,7 @@ GrAtlas::GrAtlas(GrAtlasMgr* mgr, int plotX, int plotY, GrMaskFormat format) : |
fRects = GrRectanizer::Factory(GR_ATLAS_WIDTH - BORDER, |
GR_ATLAS_HEIGHT - BORDER); |
- fMaskFormat = format; |
+ fBytesPerPixel = bpp; |
#ifdef SK_DEBUG |
// GrPrintf(" GrAtlas %p [%d %d] %d\n", this, plotX, plotY, gCounter); |
@@ -123,17 +123,16 @@ bool GrAtlas::addSubImage(int width, int height, const void* image, |
int dstW = width + 2*BORDER; |
int dstH = height + 2*BORDER; |
if (BORDER) { |
- const int bpp = GrMaskFormatBytesPerPixel(fMaskFormat); |
- const size_t dstRB = dstW * bpp; |
+ const size_t dstRB = dstW * fBytesPerPixel; |
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); |
+ dst = zerofill(dst, fBytesPerPixel); // zero left edge |
+ memcpy(dst, image, width * fBytesPerPixel); |
+ dst += width * fBytesPerPixel; |
+ dst = zerofill(dst, fBytesPerPixel); // zero right edge |
+ image = (const void*)((const char*)image + width * fBytesPerPixel); |
} |
Gr_bzero(dst, dstRB); // zero bottom row |
image = storage.get(); |
@@ -161,9 +160,9 @@ bool GrAtlas::addSubImage(int width, int height, const void* image, |
/////////////////////////////////////////////////////////////////////////////// |
-GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrMaskFormat format) { |
+GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrPixelConfig config) { |
fGpu = gpu; |
- fMaskFormat = format; |
+ fPixelConfig = config; |
gpu->ref(); |
fTexture = NULL; |
fPlotMgr = SkNEW_ARGS(GrPlotMgr, (GR_PLOT_WIDTH, GR_PLOT_HEIGHT)); |
@@ -179,20 +178,6 @@ GrAtlasMgr::~GrAtlasMgr() { |
#endif |
} |
-static GrPixelConfig maskformat2pixelconfig(GrMaskFormat format) { |
- switch (format) { |
- case kA8_GrMaskFormat: |
- return kAlpha_8_GrPixelConfig; |
- case kA565_GrMaskFormat: |
- return kRGB_565_GrPixelConfig; |
- case kA888_GrMaskFormat: |
- return kSkia8888_GrPixelConfig; |
- default: |
- SkDEBUGFAIL("unknown maskformat"); |
- } |
- return kUnknown_GrPixelConfig; |
-} |
- |
GrAtlas* GrAtlasMgr::addToAtlas(GrAtlas** atlas, |
int width, int height, const void* image, |
GrIPoint16* loc) { |
@@ -219,7 +204,7 @@ GrAtlas* GrAtlasMgr::addToAtlas(GrAtlas** atlas, |
desc.fFlags = kDynamicUpdate_GrTextureFlagBit; |
desc.fWidth = GR_ATLAS_TEXTURE_WIDTH; |
desc.fHeight = GR_ATLAS_TEXTURE_HEIGHT; |
- desc.fConfig = maskformat2pixelconfig(fMaskFormat); |
+ desc.fConfig = fPixelConfig; |
fTexture = fGpu->createTexture(desc, NULL, 0); |
if (NULL == fTexture) { |
@@ -227,7 +212,8 @@ GrAtlas* GrAtlasMgr::addToAtlas(GrAtlas** atlas, |
} |
} |
- GrAtlas* newAtlas = SkNEW_ARGS(GrAtlas, (this, plot.fX, plot.fY, fMaskFormat)); |
+ int bpp = GrBytesPerPixel(fPixelConfig); |
+ GrAtlas* newAtlas = SkNEW_ARGS(GrAtlas, (this, plot.fX, plot.fY, bpp)); |
if (!newAtlas->addSubImage(width, height, image, loc)) { |
delete newAtlas; |
return NULL; |