Have multiple plotmgrs, one for each mask format.
Only flush/purge those strikes that match our format.
R=bsalomon@google.com
Review URL: https://codereview.chromium.org/24047005
git-svn-id: http://skia.googlecode.com/svn/trunk/src@11303 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/GrAtlas.cpp b/gpu/GrAtlas.cpp
index ca46e8a..9cdde22 100644
--- a/gpu/GrAtlas.cpp
+++ b/gpu/GrAtlas.cpp
@@ -165,14 +165,18 @@
fGpu = gpu;
gpu->ref();
Gr_bzero(fTexture, sizeof(fTexture));
- fPlotMgr = SkNEW_ARGS(GrPlotMgr, (GR_PLOT_WIDTH, GR_PLOT_HEIGHT));
+ for (int i = 0; i < kCount_GrMaskFormats; ++i) {
+ fPlotMgr[i] = SkNEW_ARGS(GrPlotMgr, (GR_PLOT_WIDTH, GR_PLOT_HEIGHT));
+ }
}
GrAtlasMgr::~GrAtlasMgr() {
for (size_t i = 0; i < GR_ARRAY_COUNT(fTexture); i++) {
SkSafeUnref(fTexture[i]);
}
- delete fPlotMgr;
+ for (int i = 0; i < kCount_GrMaskFormats; ++i) {
+ delete fPlotMgr[i];
+ }
fGpu->unref();
#if FONT_CACHE_STATS
@@ -213,7 +217,7 @@
// atlas list is full. Either way we need to allocate a new atlas
GrIPoint16 plot;
- if (!fPlotMgr->newPlot(&plot)) {
+ if (!fPlotMgr[format]->newPlot(&plot)) {
return NULL;
}
@@ -247,6 +251,6 @@
}
void GrAtlasMgr::freePlot(GrMaskFormat format, int x, int y) {
- SkASSERT(fPlotMgr->isBusy(x, y));
- fPlotMgr->freePlot(x, y);
+ SkASSERT(fPlotMgr[format]->isBusy(x, y));
+ fPlotMgr[format]->freePlot(x, y);
}
diff --git a/gpu/GrAtlas.h b/gpu/GrAtlas.h
index 01a639d..e4472e7 100644
--- a/gpu/GrAtlas.h
+++ b/gpu/GrAtlas.h
@@ -82,7 +82,7 @@
private:
GrGpu* fGpu;
GrTexture* fTexture[kCount_GrMaskFormats];
- GrPlotMgr* fPlotMgr;
+ GrPlotMgr* fPlotMgr[kCount_GrMaskFormats];
};
#endif
diff --git a/gpu/GrTextStrike.cpp b/gpu/GrTextStrike.cpp
index d3214a7..47b6216 100644
--- a/gpu/GrTextStrike.cpp
+++ b/gpu/GrTextStrike.cpp
@@ -69,10 +69,12 @@
}
void GrFontCache::purgeExceptFor(GrTextStrike* preserveStrike) {
+ SkASSERT(NULL != preserveStrike);
GrTextStrike* strike = fTail;
bool purge = true;
+ GrMaskFormat maskFormat = preserveStrike->fMaskFormat;
while (strike) {
- if (strike == preserveStrike) {
+ if (strike == preserveStrike || maskFormat != strike->fMaskFormat) {
strike = strike->fPrev;
continue;
}
@@ -94,9 +96,11 @@
}
void GrFontCache::freeAtlasExceptFor(GrTextStrike* preserveStrike) {
+ SkASSERT(NULL != preserveStrike);
GrTextStrike* strike = fTail;
+ GrMaskFormat maskFormat = preserveStrike->fMaskFormat;
while (strike) {
- if (strike == preserveStrike) {
+ if (strike == preserveStrike || maskFormat != strike->fMaskFormat) {
strike = strike->fPrev;
continue;
}