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

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

Issue 636183005: Fix color emoji. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Check for atlas ownership when searching ClientPlotUsage. Created 6 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
« no previous file with comments | « src/gpu/GrFontScaler.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 "SkTDynamicHash.h" 16 #include "SkTDynamicHash.h"
17 #include "GrGlyph.h" 17 #include "GrGlyph.h"
18 #include "GrDrawTarget.h" 18 #include "GrDrawTarget.h"
19 #include "GrAtlas.h" 19 #include "GrAtlas.h"
20 20
21 class GrFontCache; 21 class GrFontCache;
22 class GrGpu; 22 class GrGpu;
23 class GrFontPurgeListener; 23 class GrFontPurgeListener;
24 24
25 /** 25 /**
26 * The textcache maps a hostfontscaler instance to a dictionary of 26 * The textstrike maps a hostfontscaler instance to a dictionary of
27 * glyphid->strike 27 * glyphid->strike
28 */ 28 */
29 class GrTextStrike { 29 class GrTextStrike {
30 public: 30 public:
31 GrTextStrike(GrFontCache*, const GrFontDescKey* fontScalerKey, GrMaskFormat, GrAtlas*); 31 GrTextStrike(GrFontCache*, const GrFontDescKey* fontScalerKey);
32 ~GrTextStrike(); 32 ~GrTextStrike();
33 33
34 const GrFontDescKey* getFontScalerKey() const { return fFontScalerKey; } 34 const GrFontDescKey* getFontScalerKey() const { return fFontScalerKey; }
35 GrFontCache* getFontCache() const { return fFontCache; } 35 GrFontCache* getFontCache() const { return fFontCache; }
36 GrMaskFormat getMaskFormat() const { return fMaskFormat; }
37 GrTexture* getTexture() const { return fAtlas->getTexture(); }
38 36
39 inline GrGlyph* getGlyph(GrGlyph::PackedID, GrFontScaler*); 37 inline GrGlyph* getGlyph(GrGlyph::PackedID, GrFontScaler*);
40 // returns true if glyph (or glyph+padding for distance field) 38 // returns true if glyph (or glyph+padding for distance field)
41 // is too large to ever fit in texture atlas subregions (GrPlots) 39 // is too large to ever fit in texture atlas subregions (GrPlots)
42 bool glyphTooLargeForAtlas(GrGlyph*); 40 bool glyphTooLargeForAtlas(GrGlyph*);
43 // returns true if glyph successfully added to texture atlas, false otherwis e 41 // returns true if glyph successfully added to texture atlas, false otherwis e
44 bool addGlyphToAtlas(GrGlyph*, GrFontScaler*); 42 bool addGlyphToAtlas(GrGlyph*, GrFontScaler*);
45 43
46 // testing 44 // testing
47 int countGlyphs() const { return fCache.count(); } 45 int countGlyphs() const { return fCache.count(); }
(...skipping 12 matching lines...) Expand all
60 // for easy removal from list 58 // for easy removal from list
61 GrTextStrike* fPrev; 59 GrTextStrike* fPrev;
62 GrTextStrike* fNext; 60 GrTextStrike* fNext;
63 61
64 private: 62 private:
65 SkTDynamicHash<GrGlyph, GrGlyph::PackedID> fCache; 63 SkTDynamicHash<GrGlyph, GrGlyph::PackedID> fCache;
66 const GrFontDescKey* fFontScalerKey; 64 const GrFontDescKey* fFontScalerKey;
67 GrTAllocPool<GrGlyph> fPool; 65 GrTAllocPool<GrGlyph> fPool;
68 66
69 GrFontCache* fFontCache; 67 GrFontCache* fFontCache;
70 GrAtlas* fAtlas;
71 GrMaskFormat fMaskFormat;
72 bool fUseDistanceField; 68 bool fUseDistanceField;
73 69
74 GrAtlas::ClientPlotUsage fPlotUsage; 70 GrAtlas::ClientPlotUsage fPlotUsage;
75 71
76 GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler); 72 GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler);
77 73
78 friend class GrFontCache; 74 friend class GrFontCache;
79 }; 75 };
80 76
81 class GrFontCache { 77 class GrFontCache {
82 public: 78 public:
83 GrFontCache(GrGpu*); 79 GrFontCache(GrGpu*);
84 ~GrFontCache(); 80 ~GrFontCache();
85 81
86 inline GrTextStrike* getStrike(GrFontScaler*, bool useDistanceField); 82 inline GrTextStrike* getStrike(GrFontScaler*, bool useDistanceField);
87 83
84 // add to texture atlas that matches this format
85 GrPlot* addToAtlas(GrMaskFormat format, GrAtlas::ClientPlotUsage* usage,
86 int width, int height, const void* image,
87 SkIPoint16* loc);
88
88 void freeAll(); 89 void freeAll();
89 90
90 // make an unused plot available 91 // make an unused plot available for this glyph
91 bool freeUnusedPlot(GrTextStrike* preserveStrike); 92 bool freeUnusedPlot(GrTextStrike* preserveStrike, const GrGlyph* glyph);
92 93
93 // testing 94 // testing
94 int countStrikes() const { return fCache.count(); } 95 int countStrikes() const { return fCache.count(); }
95 GrTextStrike* getHeadStrike() const { return fHead; } 96 GrTextStrike* getHeadStrike() const { return fHead; }
96 97
97 void updateTextures() { 98 void updateTextures() {
98 for (int i = 0; i < kAtlasCount; ++i) { 99 for (int i = 0; i < kAtlasCount; ++i) {
99 if (fAtlases[i]) { 100 if (fAtlases[i]) {
100 fAtlases[i]->uploadPlotsToTexture(); 101 fAtlases[i]->uploadPlotsToTexture();
101 } 102 }
(...skipping 27 matching lines...) Expand all
129 130
130 GrGpu* fGpu; 131 GrGpu* fGpu;
131 GrAtlas* fAtlases[kAtlasCount]; 132 GrAtlas* fAtlases[kAtlasCount];
132 133
133 GrTextStrike* generateStrike(GrFontScaler*); 134 GrTextStrike* generateStrike(GrFontScaler*);
134 inline void detachStrikeFromList(GrTextStrike*); 135 inline void detachStrikeFromList(GrTextStrike*);
135 void purgeStrike(GrTextStrike* strike); 136 void purgeStrike(GrTextStrike* strike);
136 }; 137 };
137 138
138 #endif 139 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrFontScaler.cpp ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698