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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrLayerCache_DEFINED
9 #define GrLayerCache_DEFINED
10
11 #include "GrAllocPool.h"
12 #include "GrTHashTable.h"
13 #include "GrPictureUtils.h"
14 #include "GrRect.h"
15
16 class GrAtlasMgr;
17 class GrGpu;
18 class GrPlot;
19 class SkPicture;
20
21 // GrAtlasLocation captures an atlased item's position in the atlas. This
22 // means the plot in which it resides and its bounds inside the plot.
23 // TODO: Make GrGlyph use one of these?
24 class GrAtlasLocation {
25 public:
26 GrAtlasLocation() : fPlot(NULL) {}
27
28 void set(GrPlot* plot, const GrIRect16& bounds) {
29 fPlot = plot;
30 fBounds = bounds;
31 }
32
33 const GrPlot* plot() const {
34 return fPlot;
35 }
36
37 const GrIRect16& bounds() const {
38 return fBounds;
39 }
40
41 private:
42 GrPlot* fPlot;
43 GrIRect16 fBounds; // only valid is fPlot != NULL
44 };
45
46 // A GrAtlasedLayer encapsulates the atlasing information for a single saveLayer .
47 // It is roughly equivalent to a GrGlyph in the font caching system
48 class GrAtlasedLayer {
49 public:
50 GrAtlasedLayer() : fPictureID(SkPicture::kInvalidGenID) { }
51
52 uint32_t pictureID() const { return fPictureID; }
53 int layerID() const { return fLayerID; }
54
55 void init(uint32_t pictureID, int layerID) {
56 fPictureID = pictureID;
57 fLayerID = layerID;
58 }
59
60 private:
61 uint32_t fPictureID;
62 int fLayerID; // only valid if fPicture != kInvalidGenID
63 GrAtlasLocation fLocation;
64 };
65
66 // The GrLayerCache caches pre-computed saveLayers for later rendering.
67 // Unlike the GrFontCache, this cache only has one GrAtlasMgr (for 8888)
68 // and one GrPlot (for the entire atlas). As such, the GrLayerCache
69 // roughly combines the functionality of the GrFontCache and GrTextStrike
70 // classes.
71 class GrLayerCache {
72 public:
73 GrLayerCache(GrGpu*);
74 ~GrLayerCache();
75
76 void freeAll();
77
78 const GrAtlasedLayer* findLayerOrCreate(SkPicture* picture, int id);
79
80 private:
81 SkAutoTUnref<GrGpu> fGpu;
82 SkAutoTDelete<GrAtlasMgr> fAtlasMgr; // TODO: could lazily allocate
83
84 class PictureLayerKey;
85 GrTHashTable<GrAtlasedLayer, PictureLayerKey, 7> fLayerHash;
86 GrTAllocPool<GrAtlasedLayer> fLayerPool;
87
88 void init();
89 GrAtlasedLayer* createLayer(SkPicture* picture, int id);
90
91 };
92
93 #endif
OLDNEW
« 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