| OLD | NEW |
| 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 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // for easy removal from list | 65 // for easy removal from list |
| 66 GrTextStrike* fPrev; | 66 GrTextStrike* fPrev; |
| 67 GrTextStrike* fNext; | 67 GrTextStrike* fNext; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 SkTDynamicHash<GrGlyph, GrGlyph::PackedID> fCache; | 70 SkTDynamicHash<GrGlyph, GrGlyph::PackedID> fCache; |
| 71 const GrFontDescKey* fFontScalerKey; | 71 const GrFontDescKey* fFontScalerKey; |
| 72 SkVarAlloc fPool; | 72 SkVarAlloc fPool; |
| 73 | 73 |
| 74 GrFontCache* fFontCache; | 74 GrFontCache* fFontCache; |
| 75 bool fUseDistanceField; | |
| 76 | 75 |
| 77 GrAtlas::ClientPlotUsage fPlotUsage; | 76 GrAtlas::ClientPlotUsage fPlotUsage; |
| 78 | 77 |
| 79 GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler); | 78 GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler); |
| 80 | 79 |
| 81 friend class GrFontCache; | 80 friend class GrFontCache; |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 class GrFontCache { | 83 class GrFontCache { |
| 85 public: | 84 public: |
| 86 GrFontCache(GrGpu*); | 85 GrFontCache(GrGpu*); |
| 87 ~GrFontCache(); | 86 ~GrFontCache(); |
| 88 | 87 |
| 89 inline GrTextStrike* getStrike(GrFontScaler* scaler, bool useDistanceField)
{ | 88 inline GrTextStrike* getStrike(GrFontScaler* scaler) { |
| 90 this->validate(); | 89 this->validate(); |
| 91 | 90 |
| 92 GrTextStrike* strike = fCache.find(*(scaler->getKey())); | 91 GrTextStrike* strike = fCache.find(*(scaler->getKey())); |
| 93 if (NULL == strike) { | 92 if (NULL == strike) { |
| 94 strike = this->generateStrike(scaler); | 93 strike = this->generateStrike(scaler); |
| 95 } else if (strike->fPrev) { | 94 } else if (strike->fPrev) { |
| 96 // Need to put the strike at the head of its dllist, since that is h
ow | 95 // Need to put the strike at the head of its dllist, since that is h
ow |
| 97 // we age the strikes for purging (we purge from the back of the lis
t) | 96 // we age the strikes for purging (we purge from the back of the lis
t) |
| 98 this->detachStrikeFromList(strike); | 97 this->detachStrikeFromList(strike); |
| 99 // attach at the head | 98 // attach at the head |
| 100 fHead->fPrev = strike; | 99 fHead->fPrev = strike; |
| 101 strike->fNext = fHead; | 100 strike->fNext = fHead; |
| 102 strike->fPrev = NULL; | 101 strike->fPrev = NULL; |
| 103 fHead = strike; | 102 fHead = strike; |
| 104 } | 103 } |
| 105 strike->fUseDistanceField = useDistanceField; | |
| 106 this->validate(); | 104 this->validate(); |
| 107 return strike; | 105 return strike; |
| 108 } | 106 } |
| 109 | 107 |
| 110 // add to texture atlas that matches this format | 108 // add to texture atlas that matches this format |
| 111 GrPlot* addToAtlas(GrMaskFormat format, GrAtlas::ClientPlotUsage* usage, | 109 GrPlot* addToAtlas(GrMaskFormat format, GrAtlas::ClientPlotUsage* usage, |
| 112 int width, int height, const void* image, | 110 int width, int height, const void* image, |
| 113 SkIPoint16* loc); | 111 SkIPoint16* loc); |
| 114 | 112 |
| 115 void freeAll(); | 113 void freeAll(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } else { | 172 } else { |
| 175 SkASSERT(fTail == strike); | 173 SkASSERT(fTail == strike); |
| 176 fTail = strike->fPrev; | 174 fTail = strike->fPrev; |
| 177 } | 175 } |
| 178 } | 176 } |
| 179 | 177 |
| 180 void purgeStrike(GrTextStrike* strike); | 178 void purgeStrike(GrTextStrike* strike); |
| 181 }; | 179 }; |
| 182 | 180 |
| 183 #endif | 181 #endif |
| OLD | NEW |