need a separate texture for each maskformat in atlasmgr
git-svn-id: http://skia.googlecode.com/svn/trunk@942 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
080773ca79
commit
759c16e20d
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user