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