aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-15 19:15:15 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-15 19:15:15 +0000
commit759c16e20dc42577226c8805bfea92d8bacb14d8 (patch)
tree8365ad26b3e21dc315a07f7b9eaf8e64f5054828 /gpu
parent080773ca79cbdc230730d295441255e9254d76a6 (diff)
need a separate texture for each maskformat in atlasmgr
git-svn-id: http://skia.googlecode.com/svn/trunk@942 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu')
-rw-r--r--gpu/include/GrAtlas.h7
-rw-r--r--gpu/include/GrTypes.h4
-rw-r--r--gpu/src/GrAtlas.cpp17
3 files changed, 19 insertions, 9 deletions
diff --git a/gpu/include/GrAtlas.h b/gpu/include/GrAtlas.h
index 9fd2cab26c..a933842757 100644
--- a/gpu/include/GrAtlas.h
+++ b/gpu/include/GrAtlas.h
@@ -72,7 +72,10 @@ public:
GrAtlas* addToAtlas(GrAtlas*, int width, int height, const void*,
GrMaskFormat, GrIPoint16*);
- GrTexture* getTexture() const { return fTexture; }
+ GrTexture* getTexture(GrMaskFormat format) const {
+ GrAssert((unsigned)format < kCount_GrMaskFormats);
+ return fTexture[format];
+ }
// to be called by ~GrAtlas()
void freePlot(int x, int y);
@@ -81,7 +84,7 @@ public:
private:
GrGpu* fGpu;
- GrTexture* fTexture;
+ GrTexture* fTexture[kCount_GrMaskFormats];
GrPlotMgr* fPlotMgr;
};
diff --git a/gpu/include/GrTypes.h b/gpu/include/GrTypes.h
index 8e219f7c08..cc78c3e6a3 100644
--- a/gpu/include/GrTypes.h
+++ b/gpu/include/GrTypes.h
@@ -195,12 +195,14 @@ enum GrBlendCoeff {
};
/**
- * Formats for masks, used by the font cache
+ * Formats for masks, used by the font cache.
+ * Important that these are 0-based.
*/
enum GrMaskFormat {
kA8_GrMaskFormat, //!< 1-byte per pixel
kA565_GrMaskFormat //!< 2-bytes per pixel
};
+#define kCount_GrMaskFormats 2
/**
* Return the number of bytes-per-pixel for the specified mask format.
diff --git a/gpu/src/GrAtlas.cpp b/gpu/src/GrAtlas.cpp
index ea32719d19..ab99d9a280 100644
--- a/gpu/src/GrAtlas.cpp
+++ b/gpu/src/GrAtlas.cpp
@@ -54,7 +54,7 @@
GrAtlas::GrAtlas(GrAtlasMgr* mgr, int plotX, int plotY, GrMaskFormat format) {
fAtlasMgr = mgr; // just a pointer, not an owner
fNext = NULL;
- fTexture = mgr->getTexture(); // we're not an owner, just a pointer
+ fTexture = mgr->getTexture(format); // we're not an owner, just a pointer
fPlot.set(plotX, plotY);
fRects = GrRectanizer::Factory(GR_ATLAS_WIDTH - BORDER,
@@ -130,12 +130,14 @@ bool GrAtlas::addSubImage(int width, int height, const void* image,
GrAtlasMgr::GrAtlasMgr(GrGpu* gpu) {
fGpu = gpu;
gpu->ref();
- fTexture = NULL;
+ Gr_bzero(fTexture, sizeof(fTexture));
fPlotMgr = new GrPlotMgr(GR_PLOT_WIDTH, GR_PLOT_HEIGHT);
}
GrAtlasMgr::~GrAtlasMgr() {
- GrSafeUnref(fTexture);
+ for (size_t i = 0; i < GR_ARRAY_COUNT(fTexture); i++) {
+ GrSafeUnref(fTexture[i]);
+ }
delete fPlotMgr;
fGpu->unref();
}
@@ -157,6 +159,7 @@ GrAtlas* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
GrMaskFormat format,
GrIPoint16* loc) {
GrAssert(NULL == atlas || atlas->getMaskFormat() == format);
+
if (atlas && atlas->addSubImage(width, height, image, loc)) {
return atlas;
}
@@ -169,7 +172,9 @@ GrAtlas* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
return NULL;
}
- if (NULL == fTexture) {
+ GrAssert(0 == kA8_GrMaskFormat);
+ GrAssert(1 == kA565_GrMaskFormat);
+ if (NULL == fTexture[format]) {
GrGpu::TextureDesc desc = {
GrGpu::kDynamicUpdate_TextureFlag,
GrGpu::kNone_AALevel,
@@ -177,8 +182,8 @@ GrAtlas* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
GR_ATLAS_TEXTURE_HEIGHT,
maskformat2pixelconfig(format)
};
- fTexture = fGpu->createTexture(desc, NULL, 0);
- if (NULL == fTexture) {
+ fTexture[format] = fGpu->createTexture(desc, NULL, 0);
+ if (NULL == fTexture[format]) {
return NULL;
}
}