Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Unified Diff: src/gpu/GrLayerCache.h

Issue 217343006: Add a GrLayerCache to GrContext (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fixed compiler complaint Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrLayerCache.h
===================================================================
--- src/gpu/GrLayerCache.h (revision 0)
+++ src/gpu/GrLayerCache.h (revision 0)
@@ -0,0 +1,93 @@
+/*
+ * 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) {}
+
+ void set(GrPlot* plot, const GrIRect16& bounds) {
+ fPlot = plot;
+ fBounds = bounds;
+ }
+
+ const GrPlot* plot() const {
+ return fPlot;
+ }
+
+ const GrIRect16& bounds() const {
+ return fBounds;
+ }
+
+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() : fPictureID(SkPicture::kInvalidGenID) { }
+
+ uint32_t pictureID() const { return fPictureID; }
+ int layerID() const { return fLayerID; }
+
+ void init(uint32_t pictureID, int layerID) {
+ fPictureID = pictureID;
+ fLayerID = layerID;
+ }
+
+private:
+ uint32_t fPictureID;
+ int fLayerID; // only valid if fPicture != kInvalidGenID
+ 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* 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;
+
+ void init();
+ GrAtlasedLayer* createLayer(SkPicture* picture, int id);
+
+};
+
+#endif
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698