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

Side by Side Diff: src/gpu/GrTextStrike.h

Issue 24981004: GrAtlas cleanup: Split out GrPlot and GrAtlas (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Tweaked comment Created 7 years, 2 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/GrTextContext.cpp ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 10
11 #ifndef GrTextStrike_DEFINED 11 #ifndef GrTextStrike_DEFINED
12 #define GrTextStrike_DEFINED 12 #define GrTextStrike_DEFINED
13 13
14 #include "GrAllocPool.h" 14 #include "GrAllocPool.h"
15 #include "GrFontScaler.h" 15 #include "GrFontScaler.h"
16 #include "GrTHashCache.h" 16 #include "GrTHashCache.h"
17 #include "GrPoint.h" 17 #include "GrPoint.h"
18 #include "GrGlyph.h" 18 #include "GrGlyph.h"
19 #include "GrDrawTarget.h" 19 #include "GrDrawTarget.h"
20 #include "GrAtlas.h"
20 21
21 class GrAtlasMgr;
22 class GrFontCache; 22 class GrFontCache;
23 class GrGpu; 23 class GrGpu;
24 class GrFontPurgeListener; 24 class GrFontPurgeListener;
25 25
26 /** 26 /**
27 * The textcache maps a hostfontscaler instance to a dictionary of 27 * The textcache maps a hostfontscaler instance to a dictionary of
28 * glyphid->strike 28 * glyphid->strike
29 */ 29 */
30 class GrTextStrike { 30 class GrTextStrike {
31 public: 31 public:
32 GrTextStrike(GrFontCache*, const GrKey* fontScalerKey, GrMaskFormat, 32 GrTextStrike(GrFontCache*, const GrKey* fontScalerKey, GrMaskFormat,
33 GrAtlasMgr*); 33 GrAtlasMgr*);
34 ~GrTextStrike(); 34 ~GrTextStrike();
35 35
36 const GrKey* getFontScalerKey() const { return fFontScalerKey; } 36 const GrKey* getFontScalerKey() const { return fFontScalerKey; }
37 GrFontCache* getFontCache() const { return fFontCache; } 37 GrFontCache* getFontCache() const { return fFontCache; }
38 GrMaskFormat getMaskFormat() const { return fMaskFormat; } 38 GrMaskFormat getMaskFormat() const { return fMaskFormat; }
39 39
40 inline GrGlyph* getGlyph(GrGlyph::PackedID, GrFontScaler*); 40 inline GrGlyph* getGlyph(GrGlyph::PackedID, GrFontScaler*);
41 bool getGlyphAtlas(GrGlyph*, GrFontScaler*, GrDrawTarget::DrawToken currentD rawToken); 41 bool getGlyphAtlas(GrGlyph*, GrFontScaler*, GrDrawTarget::DrawToken currentD rawToken);
42 42
43 // testing 43 // testing
44 int countGlyphs() const { return fCache.getArray().count(); } 44 int countGlyphs() const { return fCache.getArray().count(); }
45 const GrGlyph* glyphAt(int index) const { 45 const GrGlyph* glyphAt(int index) const {
46 return fCache.getArray()[index]; 46 return fCache.getArray()[index];
47 } 47 }
48 GrAtlas* getAtlas() const { return fAtlas; }
49 48
50 // returns true if an atlas was removed 49 // returns true if a plot was removed
51 bool removeUnusedAtlases(); 50 bool removeUnusedPlots();
52 51
53 public: 52 public:
54 // for LRU 53 // for LRU
55 GrTextStrike* fPrev; 54 GrTextStrike* fPrev;
56 GrTextStrike* fNext; 55 GrTextStrike* fNext;
57 56
58 private: 57 private:
59 class Key; 58 class Key;
60 GrTHashTable<GrGlyph, Key, 7> fCache; 59 GrTHashTable<GrGlyph, Key, 7> fCache;
61 const GrKey* fFontScalerKey; 60 const GrKey* fFontScalerKey;
62 GrTAllocPool<GrGlyph> fPool; 61 GrTAllocPool<GrGlyph> fPool;
63 62
64 GrFontCache* fFontCache; 63 GrFontCache* fFontCache;
65 GrAtlasMgr* fAtlasMgr; 64 GrAtlasMgr* fAtlasMgr;
66 GrAtlas* fAtlas; // linklist 65 GrAtlas fAtlas;
67 66
68 GrMaskFormat fMaskFormat; 67 GrMaskFormat fMaskFormat;
69 68
70 GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler); 69 GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler);
71 // returns true if after the purge, the strike is empty
72 bool purgeAtlasAtY(GrAtlas* atlas, int yCoord);
73 70
74 friend class GrFontCache; 71 friend class GrFontCache;
75 }; 72 };
76 73
77 class GrFontCache { 74 class GrFontCache {
78 public: 75 public:
79 GrFontCache(GrGpu*); 76 GrFontCache(GrGpu*);
80 ~GrFontCache(); 77 ~GrFontCache();
81 78
82 inline GrTextStrike* getStrike(GrFontScaler*); 79 inline GrTextStrike* getStrike(GrFontScaler*);
83 80
84 void freeAll(); 81 void freeAll();
85 82
86 void purgeExceptFor(GrTextStrike*); 83 void purgeExceptFor(GrTextStrike*);
87 84
88 // remove an unused atlas and its strike (if necessary) 85 // remove an unused plot and its strike (if necessary)
89 void freeAtlasExceptFor(GrTextStrike*); 86 void freePlotExceptFor(GrTextStrike*);
90 87
91 // testing 88 // testing
92 int countStrikes() const { return fCache.getArray().count(); } 89 int countStrikes() const { return fCache.getArray().count(); }
93 const GrTextStrike* strikeAt(int index) const { 90 const GrTextStrike* strikeAt(int index) const {
94 return fCache.getArray()[index]; 91 return fCache.getArray()[index];
95 } 92 }
96 GrTextStrike* getHeadStrike() const { return fHead; } 93 GrTextStrike* getHeadStrike() const { return fHead; }
97 94
98 #ifdef SK_DEBUG 95 #ifdef SK_DEBUG
99 void validate() const; 96 void validate() const;
100 #else 97 #else
101 void validate() const {} 98 void validate() const {}
102 #endif 99 #endif
103 100
104 private: 101 private:
105 friend class GrFontPurgeListener; 102 friend class GrFontPurgeListener;
106 103
107 class Key; 104 class Key;
108 GrTHashTable<GrTextStrike, Key, 8> fCache; 105 GrTHashTable<GrTextStrike, Key, 8> fCache;
109 // for LRU 106 // for LRU
110 GrTextStrike* fHead; 107 GrTextStrike* fHead;
111 GrTextStrike* fTail; 108 GrTextStrike* fTail;
112 109
113 GrGpu* fGpu; 110 GrGpu* fGpu;
114 GrAtlasMgr* fAtlasMgr[kMaskFormatCount]; 111 GrAtlasMgr* fAtlasMgr[kMaskFormatCount];
115 112
116
117 GrTextStrike* generateStrike(GrFontScaler*, const Key&); 113 GrTextStrike* generateStrike(GrFontScaler*, const Key&);
118 inline void detachStrikeFromList(GrTextStrike*); 114 inline void detachStrikeFromList(GrTextStrike*);
119 }; 115 };
120 116
121 #endif 117 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTextContext.cpp ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698