| Index: src/gpu/GrLayerCache.h
|
| ===================================================================
|
| --- src/gpu/GrLayerCache.h (revision 14079)
|
| +++ src/gpu/GrLayerCache.h (working copy)
|
| @@ -43,28 +43,55 @@
|
| GrIRect16 fBounds; // only valid is fPlot != NULL
|
| };
|
|
|
| -// A GrAtlasedLayer encapsulates the atlasing information for a single saveLayer.
|
| -// It is roughly equivalent to a GrGlyph in the font caching system
|
| -class GrAtlasedLayer {
|
| +// GrCachedLayer encapsulates the caching information for a single saveLayer.
|
| +//
|
| +// Atlased layers get a ref to their atlas GrTexture and their GrAtlasLocation
|
| +// is filled in.
|
| +// In this case GrCachedLayer is roughly equivalent to a GrGlyph in the font
|
| +// caching system.
|
| +//
|
| +// Non-atlased layers get a ref to the GrTexture in which they reside.
|
| +// TODO: can we easily reuse the empty space in the non-atlased GrTexture's?
|
| +struct GrCachedLayer {
|
| public:
|
| - GrAtlasedLayer() : fPictureID(SK_InvalidGenID) { }
|
| -
|
| uint32_t pictureID() const { return fPictureID; }
|
| int layerID() const { return fLayerID; }
|
|
|
| void init(uint32_t pictureID, int layerID) {
|
| fPictureID = pictureID;
|
| fLayerID = layerID;
|
| + fTexture = NULL;
|
| + fLocation.set(NULL, GrIRect16::MakeEmpty());
|
| }
|
|
|
| + // This call takes over the caller's ref
|
| + void setTexture(GrTexture* texture) {
|
| + if (NULL != fTexture) {
|
| + fTexture->unref();
|
| + }
|
| +
|
| + fTexture = texture; // just take over caller's ref
|
| + }
|
| + GrTexture* getTexture() { return fTexture; }
|
| +
|
| private:
|
| uint32_t fPictureID;
|
| - int fLayerID; // only valid if fPicture != kInvalidGenID
|
| - GrAtlasLocation fLocation;
|
| + // fLayerID is only valid when fPicture != kInvalidGenID in which case it
|
| + // is the index of this layer in the picture (one of 0 .. #layers).
|
| + int fLayerID;
|
| +
|
| + // fTexture is a ref on the atlasing texture for atlased layers and a
|
| + // ref on a GrTexture for non-atlased textures. In both cases, if this is
|
| + // non-NULL, that means that the texture is locked in the texture cache.
|
| + GrTexture* fTexture;
|
| +
|
| + GrAtlasLocation fLocation; // only valid if the layer is atlased
|
| };
|
|
|
| // The GrLayerCache caches pre-computed saveLayers for later rendering.
|
| -// Unlike the GrFontCache, this cache only has one GrAtlasMgr (for 8888)
|
| +// Non-atlased layers are stored in their own GrTexture while the atlased
|
| +// layers share a single GrTexture.
|
| +// Unlike the GrFontCache, the GrTexture atlas only has one GrAtlasMgr (for 8888)
|
| // and one GrPlot (for the entire atlas). As such, the GrLayerCache
|
| // roughly combines the functionality of the GrFontCache and GrTextStrike
|
| // classes.
|
| @@ -75,18 +102,18 @@
|
|
|
| void freeAll();
|
|
|
| - const GrAtlasedLayer* findLayerOrCreate(SkPicture* picture, int id);
|
| + GrCachedLayer* findLayerOrCreate(SkPicture* picture, int id);
|
|
|
| private:
|
| SkAutoTUnref<GrGpu> fGpu;
|
| SkAutoTDelete<GrAtlasMgr> fAtlasMgr; // TODO: could lazily allocate
|
|
|
| class PictureLayerKey;
|
| - GrTHashTable<GrAtlasedLayer, PictureLayerKey, 7> fLayerHash;
|
| - GrTAllocPool<GrAtlasedLayer> fLayerPool;
|
| + GrTHashTable<GrCachedLayer, PictureLayerKey, 7> fLayerHash;
|
| + GrTAllocPool<GrCachedLayer> fLayerPool;
|
|
|
| void init();
|
| - GrAtlasedLayer* createLayer(SkPicture* picture, int id);
|
| + GrCachedLayer* createLayer(SkPicture* picture, int id);
|
|
|
| };
|
|
|
|
|