Chromium Code Reviews| Index: src/gpu/GrLayerCache.h |
| =================================================================== |
| --- src/gpu/GrLayerCache.h (revision 0) |
| +++ src/gpu/GrLayerCache.h (revision 0) |
| @@ -0,0 +1,80 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef GrLayerCache_DEFINED |
| +#define GrLayerCache_DEFINED |
| + |
| +#include "GrAllocPool.h" |
| +#include "GrTHashTable.h" |
| +#include "GrPictureUtils.h" |
| +#include "GrRect.h" |
| + |
| +class GrAtlasMgr; |
| +class GrGpu; |
| +class GrPlot; |
| +class SkPicture; |
| + |
| +// GrAtlasLocation captures an atlased item's position in the atlas. This |
| +// means the plot in which it resides and its bounds inside the plot. |
| +// TODO: Make GrGlyph use one of these? |
| +class GrAtlasLocation { |
| +public: |
| + GrAtlasLocation() : fPlot(NULL) {} |
| + |
| +private: |
| + GrPlot* fPlot; |
| + 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 { |
| +public: |
| + GrAtlasedLayer() : fPicture(NULL) { } |
| + |
| + const SkPicture* picture() const { return fPicture; } |
| + int id() const { return fID; } |
| + |
| + void init(SkPicture* picture, int id) { |
| + fPicture = picture; |
| + fID = id; |
| + } |
| + |
| +private: |
| + SkPicture* fPicture; |
|
bsalomon
2014/04/01 15:26:35
A bare ptr?
robertphillips
2014/04/01 16:51:49
I would greatly prefer a GenID on pictures.
bsalomon
2014/04/01 16:59:04
Is that something that could reasonably be done fi
|
| + int fID; // only valid if fPicture != NULL |
| + GrAtlasLocation fLocation; |
| +}; |
| + |
| +// The GrLayerCache caches pre-computed saveLayers for later rendering. |
| +// Unlike the GrFontCache, this cache 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. |
| +class GrLayerCache { |
| +public: |
| + GrLayerCache(GrGpu*); |
| + ~GrLayerCache(); |
| + |
| + void freeAll(); |
| + |
| + const GrAtlasedLayer* findLayer(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; |
| + |
| + void init(); |
| + GrAtlasedLayer* createLayer(SkPicture* picture, int id); |
| + |
| +}; |
| + |
| +#endif |
| Property changes on: src\gpu\GrLayerCache.h |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |