| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| 10 #include "GrTextContext.h" | 10 #include "GrTextContext.h" |
| 11 #include "GrAtlas.h" | 11 #include "GrAtlas.h" |
| 12 #include "GrContext.h" | 12 #include "GrContext.h" |
| 13 #include "GrDrawTarget.h" | 13 #include "GrDrawTarget.h" |
| 14 #include "GrFontScaler.h" | 14 #include "GrFontScaler.h" |
| 15 #include "GrIndexBuffer.h" | 15 #include "GrIndexBuffer.h" |
| 16 #include "GrTextStrike.h" | 16 #include "GrTextStrike.h" |
| 17 #include "GrTextStrike_impl.h" | 17 #include "GrTextStrike_impl.h" |
| 18 #include "SkPath.h" | 18 #include "SkPath.h" |
| 19 #include "SkRTConf.h" |
| 19 #include "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
| 20 #include "effects/GrCustomCoordsTextureEffect.h" | 21 #include "effects/GrCustomCoordsTextureEffect.h" |
| 21 | 22 |
| 22 static const int kGlyphCoordsAttributeIndex = 1; | 23 static const int kGlyphCoordsAttributeIndex = 1; |
| 23 | 24 |
| 25 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
| 26 "Dump the contents of the font cache before every purge."); |
| 27 |
| 24 void GrTextContext::flushGlyphs() { | 28 void GrTextContext::flushGlyphs() { |
| 25 if (NULL == fDrawTarget) { | 29 if (NULL == fDrawTarget) { |
| 26 return; | 30 return; |
| 27 } | 31 } |
| 28 | 32 |
| 29 GrDrawState* drawState = fDrawTarget->drawState(); | 33 GrDrawState* drawState = fDrawTarget->drawState(); |
| 30 GrDrawState::AutoRestoreEffects are(drawState); | 34 GrDrawState::AutoRestoreEffects are(drawState); |
| 31 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); | 35 drawState->setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
| 32 | 36 |
| 33 if (fCurrVertex > 0) { | 37 if (fCurrVertex > 0) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { | 158 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { |
| 155 goto HAS_ATLAS; | 159 goto HAS_ATLAS; |
| 156 } | 160 } |
| 157 | 161 |
| 158 // try to clear out an unused plot before we flush | 162 // try to clear out an unused plot before we flush |
| 159 fContext->getFontCache()->freePlotExceptFor(fStrike); | 163 fContext->getFontCache()->freePlotExceptFor(fStrike); |
| 160 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { | 164 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { |
| 161 goto HAS_ATLAS; | 165 goto HAS_ATLAS; |
| 162 } | 166 } |
| 163 | 167 |
| 168 if (c_DumpFontCache) { |
| 169 #ifdef SK_DEVELOPER |
| 170 fContext->getFontCache()->dump(); |
| 171 #endif |
| 172 } |
| 173 |
| 164 // before we purge the cache, we must flush any accumulated draws | 174 // before we purge the cache, we must flush any accumulated draws |
| 165 this->flushGlyphs(); | 175 this->flushGlyphs(); |
| 166 fContext->flush(); | 176 fContext->flush(); |
| 167 | 177 |
| 168 // try to purge | 178 // try to purge |
| 169 fContext->getFontCache()->purgeExceptFor(fStrike); | 179 fContext->getFontCache()->purgeExceptFor(fStrike); |
| 170 // need to use new flush count here | 180 // need to use new flush count here |
| 171 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { | 181 if (fStrike->getGlyphAtlas(glyph, scaler, drawToken)) { |
| 172 goto HAS_ATLAS; | 182 goto HAS_ATLAS; |
| 173 } | 183 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 SkFixedToFloat(vx + width), | 259 SkFixedToFloat(vx + width), |
| 250 SkFixedToFloat(vy + height), | 260 SkFixedToFloat(vy + height), |
| 251 2 * sizeof(SkPoint)); | 261 2 * sizeof(SkPoint)); |
| 252 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed
X(tx)), | 262 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed
X(tx)), |
| 253 SkFixedToFloat(texture->normalizeFixed
Y(ty)), | 263 SkFixedToFloat(texture->normalizeFixed
Y(ty)), |
| 254 SkFixedToFloat(texture->normalizeFixed
X(tx + width)), | 264 SkFixedToFloat(texture->normalizeFixed
X(tx + width)), |
| 255 SkFixedToFloat(texture->normalizeFixed
Y(ty + height)), | 265 SkFixedToFloat(texture->normalizeFixed
Y(ty + height)), |
| 256 2 * sizeof(SkPoint)); | 266 2 * sizeof(SkPoint)); |
| 257 fCurrVertex += 4; | 267 fCurrVertex += 4; |
| 258 } | 268 } |
| OLD | NEW |