Rename GrAtlasMgr to GrAtlas (and other cleanup)
This CL also renames the old GrAtlas to ClientPlotUsage and moves it into the new GrAtlas. R=jvanverth@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/355673002
This commit is contained in:
parent
20fa0c3238
commit
1d86ee8363
@ -23,7 +23,7 @@ static int g_UploadCount = 0;
|
|||||||
GrPlot::GrPlot() : fDrawToken(NULL, 0)
|
GrPlot::GrPlot() : fDrawToken(NULL, 0)
|
||||||
, fTexture(NULL)
|
, fTexture(NULL)
|
||||||
, fRects(NULL)
|
, fRects(NULL)
|
||||||
, fAtlasMgr(NULL)
|
, fAtlas(NULL)
|
||||||
, fBytesPerPixel(1)
|
, fBytesPerPixel(1)
|
||||||
, fDirty(false)
|
, fDirty(false)
|
||||||
, fBatchUploads(false)
|
, fBatchUploads(false)
|
||||||
@ -37,10 +37,10 @@ GrPlot::~GrPlot() {
|
|||||||
delete fRects;
|
delete fRects;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrPlot::init(GrAtlasMgr* mgr, int offX, int offY, int width, int height, size_t bpp,
|
void GrPlot::init(GrAtlas* atlas, int offX, int offY, int width, int height, size_t bpp,
|
||||||
bool batchUploads) {
|
bool batchUploads) {
|
||||||
fRects = GrRectanizer::Factory(width, height);
|
fRects = GrRectanizer::Factory(width, height);
|
||||||
fAtlasMgr = mgr;
|
fAtlas = atlas;
|
||||||
fOffset.set(offX * width, offY * height);
|
fOffset.set(offX * width, offY * height);
|
||||||
fBytesPerPixel = bpp;
|
fBytesPerPixel = bpp;
|
||||||
fPlotData = NULL;
|
fPlotData = NULL;
|
||||||
@ -146,9 +146,9 @@ void GrPlot::resetRects() {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrPixelConfig config,
|
GrAtlas::GrAtlas(GrGpu* gpu, GrPixelConfig config,
|
||||||
const SkISize& backingTextureSize,
|
const SkISize& backingTextureSize,
|
||||||
int numPlotsX, int numPlotsY, bool batchUploads) {
|
int numPlotsX, int numPlotsY, bool batchUploads) {
|
||||||
fGpu = SkRef(gpu);
|
fGpu = SkRef(gpu);
|
||||||
fPixelConfig = config;
|
fPixelConfig = config;
|
||||||
fBackingTextureSize = backingTextureSize;
|
fBackingTextureSize = backingTextureSize;
|
||||||
@ -185,7 +185,7 @@ GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrPixelConfig config,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GrAtlasMgr::~GrAtlasMgr() {
|
GrAtlas::~GrAtlas() {
|
||||||
SkSafeUnref(fTexture);
|
SkSafeUnref(fTexture);
|
||||||
SkDELETE_ARRAY(fPlotArray);
|
SkDELETE_ARRAY(fPlotArray);
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ GrAtlasMgr::~GrAtlasMgr() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrAtlasMgr::moveToHead(GrPlot* plot) {
|
void GrAtlas::makeMRU(GrPlot* plot) {
|
||||||
if (fPlotList.head() == plot) {
|
if (fPlotList.head() == plot) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -204,15 +204,15 @@ void GrAtlasMgr::moveToHead(GrPlot* plot) {
|
|||||||
fPlotList.addToHead(plot);
|
fPlotList.addToHead(plot);
|
||||||
};
|
};
|
||||||
|
|
||||||
GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
|
GrPlot* GrAtlas::addToAtlas(ClientPlotUsage* usage,
|
||||||
int width, int height, const void* image,
|
int width, int height, const void* image,
|
||||||
SkIPoint16* loc) {
|
SkIPoint16* loc) {
|
||||||
// iterate through entire plot list for this atlas, see if we can find a hole
|
// iterate through entire plot list for this atlas, see if we can find a hole
|
||||||
// last one was most recently added and probably most empty
|
// last one was most recently added and probably most empty
|
||||||
for (int i = atlas->fPlots.count()-1; i >= 0; --i) {
|
for (int i = usage->fPlots.count()-1; i >= 0; --i) {
|
||||||
GrPlot* plot = atlas->fPlots[i];
|
GrPlot* plot = usage->fPlots[i];
|
||||||
if (plot->addSubImage(width, height, image, loc)) {
|
if (plot->addSubImage(width, height, image, loc)) {
|
||||||
this->moveToHead(plot);
|
this->makeMRU(plot);
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,9 +240,10 @@ GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
|
|||||||
// make sure texture is set for quick lookup
|
// make sure texture is set for quick lookup
|
||||||
plot->fTexture = fTexture;
|
plot->fTexture = fTexture;
|
||||||
if (plot->addSubImage(width, height, image, loc)) {
|
if (plot->addSubImage(width, height, image, loc)) {
|
||||||
this->moveToHead(plot);
|
this->makeMRU(plot);
|
||||||
// new plot for atlas, put at end of array
|
// new plot for atlas, put at end of array
|
||||||
*(atlas->fPlots.append()) = plot;
|
SkASSERT(!usage->fPlots.contains(plot));
|
||||||
|
*(usage->fPlots.append()) = plot;
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
plotIter.next();
|
plotIter.next();
|
||||||
@ -252,21 +253,15 @@ GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrAtlasMgr::removePlot(GrAtlas* atlas, const GrPlot* plot) {
|
void GrAtlas::removePlot(ClientPlotUsage* usage, const GrPlot* plot) {
|
||||||
// iterate through plot list for this atlas
|
int index = usage->fPlots.find(const_cast<GrPlot*>(plot));
|
||||||
int count = atlas->fPlots.count();
|
if (index >= 0) {
|
||||||
for (int i = 0; i < count; ++i) {
|
usage->fPlots.remove(index);
|
||||||
if (plot == atlas->fPlots[i]) {
|
|
||||||
atlas->fPlots.remove(i);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a plot that's not being used by the current draw
|
// get a plot that's not being used by the current draw
|
||||||
GrPlot* GrAtlasMgr::getUnusedPlot() {
|
GrPlot* GrAtlas::getUnusedPlot() {
|
||||||
GrPlotList::Iter plotIter;
|
GrPlotList::Iter plotIter;
|
||||||
plotIter.init(fPlotList, GrPlotList::Iter::kTail_IterStart);
|
plotIter.init(fPlotList, GrPlotList::Iter::kTail_IterStart);
|
||||||
GrPlot* plot;
|
GrPlot* plot;
|
||||||
@ -280,7 +275,7 @@ GrPlot* GrAtlasMgr::getUnusedPlot() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrAtlasMgr::uploadPlotsToTexture() {
|
void GrAtlas::uploadPlotsToTexture() {
|
||||||
if (fBatchUploads) {
|
if (fBatchUploads) {
|
||||||
GrPlotList::Iter plotIter;
|
GrPlotList::Iter plotIter;
|
||||||
plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart);
|
plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart);
|
||||||
|
@ -16,18 +16,17 @@
|
|||||||
|
|
||||||
class GrGpu;
|
class GrGpu;
|
||||||
class GrRectanizer;
|
class GrRectanizer;
|
||||||
class GrAtlasMgr;
|
|
||||||
class GrAtlas;
|
class GrAtlas;
|
||||||
|
|
||||||
// The backing GrTexture for a set of GrAtlases is broken into a spatial grid of GrPlots. When
|
// The backing GrTexture for a set of GrAtlases is broken into a spatial grid of GrPlots. When
|
||||||
// a GrAtlas needs space on the texture, it requests a GrPlot. Each GrAtlas can claim one
|
// a GrAtlas needs space on the texture, it requests a GrPlot. Each GrAtlas can claim one
|
||||||
// or more GrPlots. The GrPlots keep track of subimage placement via their GrRectanizer. Once a
|
// or more GrPlots. The GrPlots keep track of subimage placement via their GrRectanizer. Once a
|
||||||
// GrPlot is "full" (i.e. there is no room for the new subimage according to the GrRectanizer), the
|
// GrPlot is "full" (i.e. there is no room for the new subimage according to the GrRectanizer), the
|
||||||
// GrAtlas can request a new GrPlot via GrAtlasMgr::addToAtlas().
|
// GrAtlas can request a new GrPlot via GrAtlas::addToAtlas().
|
||||||
//
|
//
|
||||||
// If all GrPlots are allocated, the replacement strategy is up to the client. The drawToken is
|
// If all GrPlots are allocated, the replacement strategy is up to the client. The drawToken is
|
||||||
// available to ensure that all draw calls are finished for that particular GrPlot.
|
// available to ensure that all draw calls are finished for that particular GrPlot.
|
||||||
// GrAtlasMgr::removeUnusedPlots() will free up any finished plots for a given GrAtlas.
|
// GrAtlas::removeUnusedPlots() will free up any finished plots for a given GrAtlas.
|
||||||
|
|
||||||
class GrPlot {
|
class GrPlot {
|
||||||
public:
|
public:
|
||||||
@ -47,7 +46,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
GrPlot();
|
GrPlot();
|
||||||
~GrPlot(); // does not try to delete the fNext field
|
~GrPlot(); // does not try to delete the fNext field
|
||||||
void init(GrAtlasMgr* mgr, int offX, int offY, int width, int height, size_t bpp,
|
void init(GrAtlas* atlas, int offX, int offY, int width, int height, size_t bpp,
|
||||||
bool batchUploads);
|
bool batchUploads);
|
||||||
|
|
||||||
// for recycling
|
// for recycling
|
||||||
@ -56,30 +55,42 @@ private:
|
|||||||
unsigned char* fPlotData;
|
unsigned char* fPlotData;
|
||||||
GrTexture* fTexture;
|
GrTexture* fTexture;
|
||||||
GrRectanizer* fRects;
|
GrRectanizer* fRects;
|
||||||
GrAtlasMgr* fAtlasMgr;
|
GrAtlas* fAtlas;
|
||||||
SkIPoint16 fOffset; // the offset of the plot in the backing texture
|
SkIPoint16 fOffset; // the offset of the plot in the backing texture
|
||||||
size_t fBytesPerPixel;
|
size_t fBytesPerPixel;
|
||||||
SkIRect fDirtyRect;
|
SkIRect fDirtyRect;
|
||||||
bool fDirty;
|
bool fDirty;
|
||||||
bool fBatchUploads;
|
bool fBatchUploads;
|
||||||
|
|
||||||
friend class GrAtlasMgr;
|
friend class GrAtlas;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SkTInternalLList<GrPlot> GrPlotList;
|
typedef SkTInternalLList<GrPlot> GrPlotList;
|
||||||
|
|
||||||
class GrAtlasMgr {
|
class GrAtlas {
|
||||||
public:
|
public:
|
||||||
GrAtlasMgr(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize,
|
// This class allows each client to independently track the GrPlots in
|
||||||
int numPlotsX, int numPlotsY, bool batchUploads);
|
// which its data is stored.
|
||||||
~GrAtlasMgr();
|
class ClientPlotUsage {
|
||||||
|
public:
|
||||||
|
bool isEmpty() const { return 0 == fPlots.count(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SkTDArray<GrPlot*> fPlots;
|
||||||
|
|
||||||
|
friend class GrAtlas;
|
||||||
|
};
|
||||||
|
|
||||||
|
GrAtlas(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize,
|
||||||
|
int numPlotsX, int numPlotsY, bool batchUploads);
|
||||||
|
~GrAtlas();
|
||||||
|
|
||||||
// add subimage of width, height dimensions to atlas
|
// add subimage of width, height dimensions to atlas
|
||||||
// returns the containing GrPlot and location relative to the backing texture
|
// returns the containing GrPlot and location relative to the backing texture
|
||||||
GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, SkIPoint16*);
|
GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void*, SkIPoint16*);
|
||||||
|
|
||||||
// remove reference to this plot
|
// remove reference to this plot
|
||||||
bool removePlot(GrAtlas* atlas, const GrPlot* plot);
|
void removePlot(ClientPlotUsage* usage, const GrPlot* plot);
|
||||||
|
|
||||||
// get a plot that's not being used by the current draw
|
// get a plot that's not being used by the current draw
|
||||||
// this allows us to overwrite this plot without flushing
|
// this allows us to overwrite this plot without flushing
|
||||||
@ -92,7 +103,7 @@ public:
|
|||||||
void uploadPlotsToTexture();
|
void uploadPlotsToTexture();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void moveToHead(GrPlot* plot);
|
void makeMRU(GrPlot* plot);
|
||||||
|
|
||||||
GrGpu* fGpu;
|
GrGpu* fGpu;
|
||||||
GrPixelConfig fPixelConfig;
|
GrPixelConfig fPixelConfig;
|
||||||
@ -104,21 +115,8 @@ private:
|
|||||||
|
|
||||||
// allocated array of GrPlots
|
// allocated array of GrPlots
|
||||||
GrPlot* fPlotArray;
|
GrPlot* fPlotArray;
|
||||||
// LRU list of GrPlots
|
// LRU list of GrPlots (MRU at head - LRU at tail)
|
||||||
GrPlotList fPlotList;
|
GrPlotList fPlotList;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GrAtlas {
|
|
||||||
public:
|
|
||||||
GrAtlas() { }
|
|
||||||
~GrAtlas() { }
|
|
||||||
|
|
||||||
bool isEmpty() { return 0 == fPlots.count(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
SkTDArray<GrPlot*> fPlots;
|
|
||||||
|
|
||||||
friend class GrAtlasMgr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "GrTextContext.h"
|
#include "GrTextContext.h"
|
||||||
|
|
||||||
class GrTextStrike;
|
class GrTextStrike;
|
||||||
class GrAtlasMgr;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class implements GrTextContext using standard bitmap fonts
|
* This class implements GrTextContext using standard bitmap fonts
|
||||||
|
@ -53,17 +53,17 @@ void GrLayerCache::init() {
|
|||||||
static const int kAtlasTextureWidth = 1024;
|
static const int kAtlasTextureWidth = 1024;
|
||||||
static const int kAtlasTextureHeight = 1024;
|
static const int kAtlasTextureHeight = 1024;
|
||||||
|
|
||||||
SkASSERT(NULL == fAtlasMgr.get());
|
SkASSERT(NULL == fAtlas.get());
|
||||||
|
|
||||||
// The layer cache only gets 1 plot
|
// The layer cache only gets 1 plot
|
||||||
SkISize textureSize = SkISize::Make(kAtlasTextureWidth, kAtlasTextureHeight);
|
SkISize textureSize = SkISize::Make(kAtlasTextureWidth, kAtlasTextureHeight);
|
||||||
fAtlasMgr.reset(SkNEW_ARGS(GrAtlasMgr, (fContext->getGpu(), kSkia8888_GrPixelConfig,
|
fAtlas.reset(SkNEW_ARGS(GrAtlas, (fContext->getGpu(), kSkia8888_GrPixelConfig,
|
||||||
textureSize, 1, 1, false)));
|
textureSize, 1, 1, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrLayerCache::freeAll() {
|
void GrLayerCache::freeAll() {
|
||||||
fLayerHash.deleteAll();
|
fLayerHash.deleteAll();
|
||||||
fAtlasMgr.free();
|
fAtlas.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
GrCachedLayer* GrLayerCache::createLayer(const SkPicture* picture, int layerID) {
|
GrCachedLayer* GrLayerCache::createLayer(const SkPicture* picture, int layerID) {
|
||||||
|
@ -90,7 +90,7 @@ private:
|
|||||||
// The GrLayerCache caches pre-computed saveLayers for later rendering.
|
// The GrLayerCache caches pre-computed saveLayers for later rendering.
|
||||||
// Non-atlased layers are stored in their own GrTexture while the atlased
|
// Non-atlased layers are stored in their own GrTexture while the atlased
|
||||||
// layers share a single GrTexture.
|
// layers share a single GrTexture.
|
||||||
// Unlike the GrFontCache, the GrTexture atlas only has one GrAtlasMgr (for 8888)
|
// Unlike the GrFontCache, the GrTexture atlas only has one GrAtlas (for 8888)
|
||||||
// and one GrPlot (for the entire atlas). As such, the GrLayerCache
|
// and one GrPlot (for the entire atlas). As such, the GrLayerCache
|
||||||
// roughly combines the functionality of the GrFontCache and GrTextStrike
|
// roughly combines the functionality of the GrFontCache and GrTextStrike
|
||||||
// classes.
|
// classes.
|
||||||
@ -117,8 +117,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
GrContext* fContext; // pointer back to owning context
|
GrContext* fContext; // pointer back to owning context
|
||||||
SkAutoTDelete<GrAtlasMgr> fAtlasMgr; // TODO: could lazily allocate
|
SkAutoTDelete<GrAtlas> fAtlas; // TODO: could lazily allocate
|
||||||
GrAtlas fPlotUsage;
|
GrAtlas::ClientPlotUsage fPlotUsage;
|
||||||
|
|
||||||
class PictureLayerKey;
|
class PictureLayerKey;
|
||||||
GrTHashTable<GrCachedLayer, PictureLayerKey, 7> fLayerHash;
|
GrTHashTable<GrCachedLayer, PictureLayerKey, 7> fLayerHash;
|
||||||
|
@ -32,7 +32,7 @@ static int g_PurgeCount = 0;
|
|||||||
GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) {
|
GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) {
|
||||||
gpu->ref();
|
gpu->ref();
|
||||||
for (int i = 0; i < kAtlasCount; ++i) {
|
for (int i = 0; i < kAtlasCount; ++i) {
|
||||||
fAtlasMgr[i] = NULL;
|
fAtlases[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fHead = fTail = NULL;
|
fHead = fTail = NULL;
|
||||||
@ -41,7 +41,7 @@ GrFontCache::GrFontCache(GrGpu* gpu) : fGpu(gpu) {
|
|||||||
GrFontCache::~GrFontCache() {
|
GrFontCache::~GrFontCache() {
|
||||||
fCache.deleteAll();
|
fCache.deleteAll();
|
||||||
for (int i = 0; i < kAtlasCount; ++i) {
|
for (int i = 0; i < kAtlasCount; ++i) {
|
||||||
delete fAtlasMgr[i];
|
delete fAtlases[i];
|
||||||
}
|
}
|
||||||
fGpu->unref();
|
fGpu->unref();
|
||||||
#if FONT_CACHE_STATS
|
#if FONT_CACHE_STATS
|
||||||
@ -79,17 +79,17 @@ GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler,
|
|||||||
GrMaskFormat format = scaler->getMaskFormat();
|
GrMaskFormat format = scaler->getMaskFormat();
|
||||||
GrPixelConfig config = mask_format_to_pixel_config(format);
|
GrPixelConfig config = mask_format_to_pixel_config(format);
|
||||||
int atlasIndex = mask_format_to_atlas_index(format);
|
int atlasIndex = mask_format_to_atlas_index(format);
|
||||||
if (NULL == fAtlasMgr[atlasIndex]) {
|
if (NULL == fAtlases[atlasIndex]) {
|
||||||
SkISize textureSize = SkISize::Make(GR_ATLAS_TEXTURE_WIDTH,
|
SkISize textureSize = SkISize::Make(GR_ATLAS_TEXTURE_WIDTH,
|
||||||
GR_ATLAS_TEXTURE_HEIGHT);
|
GR_ATLAS_TEXTURE_HEIGHT);
|
||||||
fAtlasMgr[atlasIndex] = SkNEW_ARGS(GrAtlasMgr, (fGpu, config,
|
fAtlases[atlasIndex] = SkNEW_ARGS(GrAtlas, (fGpu, config,
|
||||||
textureSize,
|
textureSize,
|
||||||
GR_NUM_PLOTS_X,
|
GR_NUM_PLOTS_X,
|
||||||
GR_NUM_PLOTS_Y,
|
GR_NUM_PLOTS_Y,
|
||||||
true));
|
true));
|
||||||
}
|
}
|
||||||
GrTextStrike* strike = SkNEW_ARGS(GrTextStrike,
|
GrTextStrike* strike = SkNEW_ARGS(GrTextStrike,
|
||||||
(this, scaler->getKey(), format, fAtlasMgr[atlasIndex]));
|
(this, scaler->getKey(), format, fAtlases[atlasIndex]));
|
||||||
fCache.insert(key, strike);
|
fCache.insert(key, strike);
|
||||||
|
|
||||||
if (fHead) {
|
if (fHead) {
|
||||||
@ -108,8 +108,8 @@ GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler,
|
|||||||
void GrFontCache::freeAll() {
|
void GrFontCache::freeAll() {
|
||||||
fCache.deleteAll();
|
fCache.deleteAll();
|
||||||
for (int i = 0; i < kAtlasCount; ++i) {
|
for (int i = 0; i < kAtlasCount; ++i) {
|
||||||
delete fAtlasMgr[i];
|
delete fAtlases[i];
|
||||||
fAtlasMgr[i] = NULL;
|
fAtlases[i] = NULL;
|
||||||
}
|
}
|
||||||
fHead = NULL;
|
fHead = NULL;
|
||||||
fTail = NULL;
|
fTail = NULL;
|
||||||
@ -125,8 +125,8 @@ void GrFontCache::purgeStrike(GrTextStrike* strike) {
|
|||||||
bool GrFontCache::freeUnusedPlot(GrTextStrike* preserveStrike) {
|
bool GrFontCache::freeUnusedPlot(GrTextStrike* preserveStrike) {
|
||||||
SkASSERT(NULL != preserveStrike);
|
SkASSERT(NULL != preserveStrike);
|
||||||
|
|
||||||
GrAtlasMgr* atlasMgr = preserveStrike->fAtlasMgr;
|
GrAtlas* atlas = preserveStrike->fAtlas;
|
||||||
GrPlot* plot = atlasMgr->getUnusedPlot();
|
GrPlot* plot = atlas->getUnusedPlot();
|
||||||
if (NULL == plot) {
|
if (NULL == plot) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ bool GrFontCache::freeUnusedPlot(GrTextStrike* preserveStrike) {
|
|||||||
strikeToPurge->removePlot(plot);
|
strikeToPurge->removePlot(plot);
|
||||||
|
|
||||||
// clear out any empty strikes (except this one)
|
// clear out any empty strikes (except this one)
|
||||||
if (strikeToPurge != preserveStrike && strikeToPurge->fAtlas.isEmpty()) {
|
if (strikeToPurge != preserveStrike && strikeToPurge->fPlotUsage.isEmpty()) {
|
||||||
this->purgeStrike(strikeToPurge);
|
this->purgeStrike(strikeToPurge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,8 +190,8 @@ void GrFontCache::validate() const {
|
|||||||
void GrFontCache::dump() const {
|
void GrFontCache::dump() const {
|
||||||
static int gDumpCount = 0;
|
static int gDumpCount = 0;
|
||||||
for (int i = 0; i < kAtlasCount; ++i) {
|
for (int i = 0; i < kAtlasCount; ++i) {
|
||||||
if (NULL != fAtlasMgr[i]) {
|
if (NULL != fAtlases[i]) {
|
||||||
GrTexture* texture = fAtlasMgr[i]->getTexture();
|
GrTexture* texture = fAtlases[i]->getTexture();
|
||||||
if (NULL != texture) {
|
if (NULL != texture) {
|
||||||
SkString filename;
|
SkString filename;
|
||||||
#ifdef SK_BUILD_FOR_ANDROID
|
#ifdef SK_BUILD_FOR_ANDROID
|
||||||
@ -222,12 +222,12 @@ void GrFontCache::dump() const {
|
|||||||
|
|
||||||
GrTextStrike::GrTextStrike(GrFontCache* cache, const GrKey* key,
|
GrTextStrike::GrTextStrike(GrFontCache* cache, const GrKey* key,
|
||||||
GrMaskFormat format,
|
GrMaskFormat format,
|
||||||
GrAtlasMgr* atlasMgr) : fPool(64) {
|
GrAtlas* atlas) : fPool(64) {
|
||||||
fFontScalerKey = key;
|
fFontScalerKey = key;
|
||||||
fFontScalerKey->ref();
|
fFontScalerKey->ref();
|
||||||
|
|
||||||
fFontCache = cache; // no need to ref, it won't go away before we do
|
fFontCache = cache; // no need to ref, it won't go away before we do
|
||||||
fAtlasMgr = atlasMgr; // no need to ref, it won't go away before we do
|
fAtlas = atlas; // no need to ref, it won't go away before we do
|
||||||
|
|
||||||
fMaskFormat = format;
|
fMaskFormat = format;
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ void GrTextStrike::removePlot(const GrPlot* plot) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fAtlasMgr->removePlot(&fAtlas, plot);
|
fAtlas->removePlot(&fPlotUsage, plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -314,9 +314,9 @@ bool GrTextStrike::addGlyphToAtlas(GrGlyph* glyph, GrFontScaler* scaler) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPlot* plot = fAtlasMgr->addToAtlas(&fAtlas, glyph->width(),
|
GrPlot* plot = fAtlas->addToAtlas(&fPlotUsage, glyph->width(),
|
||||||
glyph->height(), storage.get(),
|
glyph->height(), storage.get(),
|
||||||
&glyph->fAtlasLocation);
|
&glyph->fAtlasLocation);
|
||||||
|
|
||||||
if (NULL == plot) {
|
if (NULL == plot) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -28,7 +28,7 @@ class GrFontPurgeListener;
|
|||||||
*/
|
*/
|
||||||
class GrTextStrike {
|
class GrTextStrike {
|
||||||
public:
|
public:
|
||||||
GrTextStrike(GrFontCache*, const GrKey* fontScalerKey, GrMaskFormat, GrAtlasMgr*);
|
GrTextStrike(GrFontCache*, const GrKey* fontScalerKey, GrMaskFormat, GrAtlas*);
|
||||||
~GrTextStrike();
|
~GrTextStrike();
|
||||||
|
|
||||||
const GrKey* getFontScalerKey() const { return fFontScalerKey; }
|
const GrKey* getFontScalerKey() const { return fFontScalerKey; }
|
||||||
@ -59,11 +59,11 @@ private:
|
|||||||
GrTAllocPool<GrGlyph> fPool;
|
GrTAllocPool<GrGlyph> fPool;
|
||||||
|
|
||||||
GrFontCache* fFontCache;
|
GrFontCache* fFontCache;
|
||||||
GrAtlasMgr* fAtlasMgr;
|
GrAtlas* fAtlas;
|
||||||
GrMaskFormat fMaskFormat;
|
GrMaskFormat fMaskFormat;
|
||||||
bool fUseDistanceField;
|
bool fUseDistanceField;
|
||||||
|
|
||||||
GrAtlas fAtlas;
|
GrAtlas::ClientPlotUsage fPlotUsage;
|
||||||
|
|
||||||
GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler);
|
GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler);
|
||||||
|
|
||||||
@ -91,8 +91,8 @@ public:
|
|||||||
|
|
||||||
void updateTextures() {
|
void updateTextures() {
|
||||||
for (int i = 0; i < kAtlasCount; ++i) {
|
for (int i = 0; i < kAtlasCount; ++i) {
|
||||||
if (fAtlasMgr[i]) {
|
if (fAtlases[i]) {
|
||||||
fAtlasMgr[i]->uploadPlotsToTexture();
|
fAtlases[i]->uploadPlotsToTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ private:
|
|||||||
GrTextStrike* fTail;
|
GrTextStrike* fTail;
|
||||||
|
|
||||||
GrGpu* fGpu;
|
GrGpu* fGpu;
|
||||||
GrAtlasMgr* fAtlasMgr[kAtlasCount];
|
GrAtlas* fAtlases[kAtlasCount];
|
||||||
|
|
||||||
GrTextStrike* generateStrike(GrFontScaler*, const Key&);
|
GrTextStrike* generateStrike(GrFontScaler*, const Key&);
|
||||||
inline void detachStrikeFromList(GrTextStrike*);
|
inline void detachStrikeFromList(GrTextStrike*);
|
||||||
|
Loading…
Reference in New Issue
Block a user