jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrBitmapTextContext.h" |
| 9 | #include "GrAtlas.h" |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 10 | #include "GrDefaultGeoProcFactory.h" |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 11 | #include "GrDrawTarget.h" |
jvanverth | 787cdf9 | 2014-12-04 10:46:50 -0800 | [diff] [blame] | 12 | #include "GrFontCache.h" |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 13 | #include "GrFontScaler.h" |
| 14 | #include "GrIndexBuffer.h" |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 15 | #include "GrStrokeInfo.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 16 | #include "GrTexturePriv.h" |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 17 | |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 18 | #include "SkAutoKern.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 19 | #include "SkColorPriv.h" |
commit-bot@chromium.org | 9f94b91 | 2014-01-30 15:22:54 +0000 | [diff] [blame] | 20 | #include "SkDraw.h" |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 21 | #include "SkDrawProcs.h" |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 22 | #include "SkGlyphCache.h" |
| 23 | #include "SkGpuDevice.h" |
| 24 | #include "SkGr.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 25 | #include "SkPath.h" |
| 26 | #include "SkRTConf.h" |
| 27 | #include "SkStrokeRec.h" |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 28 | #include "SkTextMapStateProc.h" |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 29 | |
egdaniel | 309e346 | 2014-12-09 10:35:58 -0800 | [diff] [blame] | 30 | #include "effects/GrBitmapTextGeoProc.h" |
joshualitt | 5478d42 | 2014-11-14 16:00:38 -0800 | [diff] [blame] | 31 | #include "effects/GrSimpleTextureEffect.h" |
| 32 | |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 33 | SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, |
| 34 | "Dump the contents of the font cache before every purge."); |
| 35 | |
bsalomon | 594069f | 2014-06-06 06:16:34 -0700 | [diff] [blame] | 36 | namespace { |
egdaniel | ed3af66 | 2014-10-31 06:55:45 -0700 | [diff] [blame] | 37 | static const size_t kLCDTextVASize = 2 * sizeof(SkPoint); |
| 38 | |
| 39 | // position + local coord |
egdaniel | ed3af66 | 2014-10-31 06:55:45 -0700 | [diff] [blame] | 40 | static const size_t kColorTextVASize = 2 * sizeof(SkPoint); |
egdaniel | 7b3d5ee | 2014-08-28 05:41:14 -0700 | [diff] [blame] | 41 | |
egdaniel | ed3af66 | 2014-10-31 06:55:45 -0700 | [diff] [blame] | 42 | static const size_t kGrayTextVASize = 2 * sizeof(SkPoint) + sizeof(GrColor); |
egdaniel | 7b3d5ee | 2014-08-28 05:41:14 -0700 | [diff] [blame] | 43 | |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 44 | static const int kVerticesPerGlyph = 4; |
| 45 | static const int kIndicesPerGlyph = 6; |
bsalomon | 594069f | 2014-06-06 06:16:34 -0700 | [diff] [blame] | 46 | }; |
| 47 | |
skia.committer@gmail.com | e5d7015 | 2014-01-29 07:01:48 +0000 | [diff] [blame] | 48 | GrBitmapTextContext::GrBitmapTextContext(GrContext* context, |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 49 | const SkDeviceProperties& properties) |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 50 | : GrTextContext(context, properties) { |
| 51 | fStrike = NULL; |
| 52 | |
| 53 | fCurrTexture = NULL; |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 54 | fEffectTextureUniqueID = SK_InvalidUniqueID; |
| 55 | |
| 56 | fVertices = NULL; |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 57 | fCurrVertex = 0; |
| 58 | fAllocVertexCount = 0; |
| 59 | fTotalVertexCount = 0; |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 60 | |
commit-bot@chromium.org | 3ae0e6c | 2014-02-11 18:24:25 +0000 | [diff] [blame] | 61 | fVertexBounds.setLargestInverted(); |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 62 | } |
| 63 | |
jvanverth | 8c27a18 | 2014-10-14 08:45:50 -0700 | [diff] [blame] | 64 | GrBitmapTextContext* GrBitmapTextContext::Create(GrContext* context, |
| 65 | const SkDeviceProperties& props) { |
| 66 | return SkNEW_ARGS(GrBitmapTextContext, (context, props)); |
| 67 | } |
| 68 | |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 69 | bool GrBitmapTextContext::canDraw(const SkPaint& paint, const SkMatrix& viewMatrix) { |
| 70 | return !SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix); |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 71 | } |
| 72 | |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 73 | inline void GrBitmapTextContext::init(const GrPaint& paint, const SkPaint& skPaint) { |
| 74 | GrTextContext::init(paint, skPaint); |
| 75 | |
| 76 | fStrike = NULL; |
| 77 | |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 78 | fCurrTexture = NULL; |
jvanverth | 63b9dc8 | 2014-08-28 10:39:40 -0700 | [diff] [blame] | 79 | fCurrVertex = 0; |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 80 | |
| 81 | fVertices = NULL; |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 82 | fAllocVertexCount = 0; |
| 83 | fTotalVertexCount = 0; |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 84 | } |
| 85 | |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 86 | void GrBitmapTextContext::onDrawText(const GrPaint& paint, const SkPaint& skPaint, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 87 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 88 | const char text[], size_t byteLength, |
| 89 | SkScalar x, SkScalar y) { |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 90 | SkASSERT(byteLength == 0 || text != NULL); |
| 91 | |
| 92 | // nothing to draw |
| 93 | if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) { |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | this->init(paint, skPaint); |
| 98 | |
| 99 | SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); |
| 100 | |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 101 | SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 102 | SkGlyphCache* cache = autoCache.getCache(); |
| 103 | GrFontScaler* fontScaler = GetGrFontScaler(cache); |
| 104 | |
| 105 | // transform our starting point |
| 106 | { |
| 107 | SkPoint loc; |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 108 | viewMatrix.mapXY(x, y, &loc); |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 109 | x = loc.fX; |
| 110 | y = loc.fY; |
| 111 | } |
| 112 | |
| 113 | // need to measure first |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 114 | int numGlyphs; |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 115 | if (fSkPaint.getTextAlign() != SkPaint::kLeft_Align) { |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 116 | SkVector stopVector; |
| 117 | numGlyphs = MeasureText(cache, glyphCacheProc, text, byteLength, &stopVector); |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 118 | |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 119 | SkScalar stopX = stopVector.fX; |
| 120 | SkScalar stopY = stopVector.fY; |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 121 | |
| 122 | if (fSkPaint.getTextAlign() == SkPaint::kCenter_Align) { |
| 123 | stopX = SkScalarHalf(stopX); |
| 124 | stopY = SkScalarHalf(stopY); |
| 125 | } |
| 126 | x -= stopX; |
| 127 | y -= stopY; |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 128 | } else { |
| 129 | numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 130 | } |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 131 | fTotalVertexCount = kVerticesPerGlyph*numGlyphs; |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 132 | |
| 133 | const char* stop = text + byteLength; |
| 134 | |
| 135 | SkAutoKern autokern; |
| 136 | |
| 137 | SkFixed fxMask = ~0; |
| 138 | SkFixed fyMask = ~0; |
| 139 | SkFixed halfSampleX, halfSampleY; |
| 140 | if (cache->isSubpixel()) { |
| 141 | halfSampleX = halfSampleY = (SK_FixedHalf >> SkGlyph::kSubBits); |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 142 | SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(viewMatrix); |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 143 | if (kX_SkAxisAlignment == baseline) { |
| 144 | fyMask = 0; |
| 145 | halfSampleY = SK_FixedHalf; |
| 146 | } else if (kY_SkAxisAlignment == baseline) { |
| 147 | fxMask = 0; |
| 148 | halfSampleX = SK_FixedHalf; |
| 149 | } |
| 150 | } else { |
| 151 | halfSampleX = halfSampleY = SK_FixedHalf; |
| 152 | } |
| 153 | |
| 154 | SkFixed fx = SkScalarToFixed(x) + halfSampleX; |
| 155 | SkFixed fy = SkScalarToFixed(y) + halfSampleY; |
| 156 | |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 157 | if (!fPaint.localCoordChangeInverse(viewMatrix)) { |
| 158 | SkDebugf("Cannot invert viewmatrix\n"); |
| 159 | } |
jvanverth | aab626c | 2014-10-16 08:04:39 -0700 | [diff] [blame] | 160 | |
| 161 | while (text < stop) { |
| 162 | const SkGlyph& glyph = glyphCacheProc(cache, &text, fx & fxMask, fy & fyMask); |
| 163 | |
| 164 | fx += autokern.adjust(glyph); |
| 165 | |
| 166 | if (glyph.fWidth) { |
| 167 | this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 168 | glyph.getSubXFixed(), |
| 169 | glyph.getSubYFixed()), |
| 170 | SkFixedFloorToFixed(fx), |
| 171 | SkFixedFloorToFixed(fy), |
| 172 | fontScaler); |
| 173 | } |
| 174 | |
| 175 | fx += glyph.fAdvanceX; |
| 176 | fy += glyph.fAdvanceY; |
| 177 | } |
| 178 | |
| 179 | this->finish(); |
| 180 | } |
| 181 | |
jvanverth | 8c27a18 | 2014-10-14 08:45:50 -0700 | [diff] [blame] | 182 | void GrBitmapTextContext::onDrawPosText(const GrPaint& paint, const SkPaint& skPaint, |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 183 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 184 | const char text[], size_t byteLength, |
| 185 | const SkScalar pos[], int scalarsPerPosition, |
| 186 | const SkPoint& offset) { |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 187 | SkASSERT(byteLength == 0 || text != NULL); |
| 188 | SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); |
| 189 | |
| 190 | // nothing to draw |
| 191 | if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) { |
| 192 | return; |
| 193 | } |
| 194 | |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 195 | this->init(paint, skPaint); |
| 196 | |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 197 | SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); |
| 198 | |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 199 | SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &viewMatrix); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 200 | SkGlyphCache* cache = autoCache.getCache(); |
| 201 | GrFontScaler* fontScaler = GetGrFontScaler(cache); |
| 202 | |
| 203 | // store original matrix before we reset, so we can use it to transform positions |
joshualitt | 5531d51 | 2014-12-17 15:50:11 -0800 | [diff] [blame] | 204 | SkMatrix ctm = viewMatrix; |
| 205 | if (!fPaint.localCoordChangeInverse(viewMatrix)) { |
| 206 | SkDebugf("Cannot invert viewmatrix\n"); |
| 207 | } |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 208 | |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 209 | int numGlyphs = fSkPaint.textToGlyphs(text, byteLength, NULL); |
| 210 | fTotalVertexCount = kVerticesPerGlyph*numGlyphs; |
| 211 | |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 212 | const char* stop = text + byteLength; |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 213 | SkTextAlignProc alignProc(fSkPaint.getTextAlign()); |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 214 | SkTextMapStateProc tmsProc(ctm, offset, scalarsPerPosition); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 215 | SkFixed halfSampleX = 0, halfSampleY = 0; |
| 216 | |
| 217 | if (cache->isSubpixel()) { |
| 218 | // maybe we should skip the rounding if linearText is set |
| 219 | SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(ctm); |
| 220 | |
| 221 | SkFixed fxMask = ~0; |
| 222 | SkFixed fyMask = ~0; |
| 223 | if (kX_SkAxisAlignment == baseline) { |
| 224 | fyMask = 0; |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 225 | halfSampleY = SK_FixedHalf; |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 226 | } else if (kY_SkAxisAlignment == baseline) { |
| 227 | fxMask = 0; |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 228 | halfSampleX = SK_FixedHalf; |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { |
| 232 | while (text < stop) { |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 233 | SkPoint tmsLoc; |
| 234 | tmsProc(pos, &tmsLoc); |
| 235 | SkFixed fx = SkScalarToFixed(tmsLoc.fX) + halfSampleX; |
| 236 | SkFixed fy = SkScalarToFixed(tmsLoc.fY) + halfSampleY; |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 237 | |
| 238 | const SkGlyph& glyph = glyphCacheProc(cache, &text, |
| 239 | fx & fxMask, fy & fyMask); |
| 240 | |
| 241 | if (glyph.fWidth) { |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 242 | this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 243 | glyph.getSubXFixed(), |
| 244 | glyph.getSubYFixed()), |
| 245 | SkFixedFloorToFixed(fx), |
| 246 | SkFixedFloorToFixed(fy), |
| 247 | fontScaler); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 248 | } |
| 249 | pos += scalarsPerPosition; |
| 250 | } |
| 251 | } else { |
| 252 | while (text < stop) { |
| 253 | const char* currentText = text; |
| 254 | const SkGlyph& metricGlyph = glyphCacheProc(cache, &text, 0, 0); |
| 255 | |
| 256 | if (metricGlyph.fWidth) { |
| 257 | SkDEBUGCODE(SkFixed prevAdvX = metricGlyph.fAdvanceX;) |
| 258 | SkDEBUGCODE(SkFixed prevAdvY = metricGlyph.fAdvanceY;) |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 259 | SkPoint tmsLoc; |
| 260 | tmsProc(pos, &tmsLoc); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 261 | SkIPoint fixedLoc; |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 262 | alignProc(tmsLoc, metricGlyph, &fixedLoc); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 263 | |
| 264 | SkFixed fx = fixedLoc.fX + halfSampleX; |
| 265 | SkFixed fy = fixedLoc.fY + halfSampleY; |
| 266 | |
| 267 | // have to call again, now that we've been "aligned" |
| 268 | const SkGlyph& glyph = glyphCacheProc(cache, ¤tText, |
| 269 | fx & fxMask, fy & fyMask); |
| 270 | // the assumption is that the metrics haven't changed |
| 271 | SkASSERT(prevAdvX == glyph.fAdvanceX); |
| 272 | SkASSERT(prevAdvY == glyph.fAdvanceY); |
| 273 | SkASSERT(glyph.fWidth); |
| 274 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 275 | this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 276 | glyph.getSubXFixed(), |
| 277 | glyph.getSubYFixed()), |
| 278 | SkFixedFloorToFixed(fx), |
| 279 | SkFixedFloorToFixed(fy), |
| 280 | fontScaler); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 281 | } |
| 282 | pos += scalarsPerPosition; |
| 283 | } |
| 284 | } |
| 285 | } else { // not subpixel |
| 286 | |
| 287 | if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { |
| 288 | while (text < stop) { |
| 289 | // the last 2 parameters are ignored |
| 290 | const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 291 | |
| 292 | if (glyph.fWidth) { |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 293 | SkPoint tmsLoc; |
| 294 | tmsProc(pos, &tmsLoc); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 295 | |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 296 | SkFixed fx = SkScalarToFixed(tmsLoc.fX) + SK_FixedHalf; //halfSampleX; |
| 297 | SkFixed fy = SkScalarToFixed(tmsLoc.fY) + SK_FixedHalf; //halfSampleY; |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 298 | this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 299 | glyph.getSubXFixed(), |
| 300 | glyph.getSubYFixed()), |
| 301 | SkFixedFloorToFixed(fx), |
| 302 | SkFixedFloorToFixed(fy), |
| 303 | fontScaler); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 304 | } |
| 305 | pos += scalarsPerPosition; |
| 306 | } |
| 307 | } else { |
| 308 | while (text < stop) { |
| 309 | // the last 2 parameters are ignored |
| 310 | const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0); |
| 311 | |
| 312 | if (glyph.fWidth) { |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 313 | SkPoint tmsLoc; |
| 314 | tmsProc(pos, &tmsLoc); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 315 | |
| 316 | SkIPoint fixedLoc; |
kkinnunen | cb9a2c8 | 2014-06-12 23:06:28 -0700 | [diff] [blame] | 317 | alignProc(tmsLoc, glyph, &fixedLoc); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 318 | |
| 319 | SkFixed fx = fixedLoc.fX + SK_FixedHalf; //halfSampleX; |
| 320 | SkFixed fy = fixedLoc.fY + SK_FixedHalf; //halfSampleY; |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 321 | this->appendGlyph(GrGlyph::Pack(glyph.getGlyphID(), |
| 322 | glyph.getSubXFixed(), |
| 323 | glyph.getSubYFixed()), |
| 324 | SkFixedFloorToFixed(fx), |
| 325 | SkFixedFloorToFixed(fy), |
| 326 | fontScaler); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 327 | } |
| 328 | pos += scalarsPerPosition; |
| 329 | } |
| 330 | } |
| 331 | } |
commit-bot@chromium.org | cbbc481 | 2014-01-30 22:05:47 +0000 | [diff] [blame] | 332 | |
| 333 | this->finish(); |
commit-bot@chromium.org | e8612d9 | 2014-01-28 22:02:07 +0000 | [diff] [blame] | 334 | } |
| 335 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 336 | static size_t get_vertex_stride(GrMaskFormat maskFormat) { |
| 337 | switch (maskFormat) { |
| 338 | case kA8_GrMaskFormat: |
| 339 | return kGrayTextVASize; |
| 340 | case kARGB_GrMaskFormat: |
| 341 | return kColorTextVASize; |
| 342 | default: |
| 343 | return kLCDTextVASize; |
| 344 | } |
| 345 | } |
| 346 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 347 | static void* alloc_vertices(GrDrawTarget* drawTarget, |
| 348 | int numVertices, |
| 349 | GrMaskFormat maskFormat) { |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 350 | if (numVertices <= 0) { |
| 351 | return NULL; |
| 352 | } |
| 353 | |
| 354 | // set up attributes |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 355 | void* vertices = NULL; |
| 356 | bool success = drawTarget->reserveVertexAndIndexSpace(numVertices, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 357 | get_vertex_stride(maskFormat), |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 358 | 0, |
| 359 | &vertices, |
| 360 | NULL); |
| 361 | GrAlwaysAssert(success); |
| 362 | return vertices; |
| 363 | } |
| 364 | |
jvanverth | 787cdf9 | 2014-12-04 10:46:50 -0800 | [diff] [blame] | 365 | inline bool GrBitmapTextContext::uploadGlyph(GrGlyph* glyph, GrFontScaler* scaler) { |
| 366 | if (!fStrike->glyphTooLargeForAtlas(glyph)) { |
| 367 | if (fStrike->addGlyphToAtlas(glyph, scaler)) { |
| 368 | return true; |
| 369 | } |
| 370 | |
| 371 | // try to clear out an unused plot before we flush |
| 372 | if (fContext->getFontCache()->freeUnusedPlot(fStrike, glyph) && |
| 373 | fStrike->addGlyphToAtlas(glyph, scaler)) { |
| 374 | return true; |
| 375 | } |
| 376 | |
| 377 | if (c_DumpFontCache) { |
| 378 | #ifdef SK_DEVELOPER |
| 379 | fContext->getFontCache()->dump(); |
| 380 | #endif |
| 381 | } |
| 382 | |
| 383 | // before we purge the cache, we must flush any accumulated draws |
| 384 | this->flush(); |
| 385 | fContext->flush(); |
| 386 | |
| 387 | // we should have an unused plot now |
| 388 | if (fContext->getFontCache()->freeUnusedPlot(fStrike, glyph) && |
| 389 | fStrike->addGlyphToAtlas(glyph, scaler)) { |
| 390 | return true; |
| 391 | } |
| 392 | |
| 393 | // we should never get here |
| 394 | SkASSERT(false); |
| 395 | } |
| 396 | |
| 397 | return false; |
| 398 | } |
| 399 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 400 | void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed, |
| 401 | SkFixed vx, SkFixed vy, |
| 402 | GrFontScaler* scaler) { |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 403 | if (NULL == fDrawTarget) { |
| 404 | return; |
| 405 | } |
| 406 | |
| 407 | if (NULL == fStrike) { |
| 408 | fStrike = fContext->getFontCache()->getStrike(scaler, false); |
| 409 | } |
| 410 | |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 411 | GrGlyph* glyph = fStrike->getGlyph(packed, scaler); |
| 412 | if (NULL == glyph || glyph->fBounds.isEmpty()) { |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | vx += SkIntToFixed(glyph->fBounds.fLeft); |
| 417 | vy += SkIntToFixed(glyph->fBounds.fTop); |
| 418 | |
| 419 | // keep them as ints until we've done the clip-test |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 420 | SkFixed width = glyph->fBounds.width(); |
| 421 | SkFixed height = glyph->fBounds.height(); |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 422 | |
| 423 | // check if we clipped out |
| 424 | if (true || NULL == glyph->fPlot) { |
| 425 | int x = vx >> 16; |
| 426 | int y = vy >> 16; |
| 427 | if (fClipRect.quickReject(x, y, x + width, y + height)) { |
| 428 | // SkCLZ(3); // so we can set a break-point in the debugger |
| 429 | return; |
| 430 | } |
| 431 | } |
| 432 | |
joshualitt | c262582 | 2014-12-18 16:40:54 -0800 | [diff] [blame^] | 433 | // If the glyph is too large we fall back to paths |
jvanverth | 787cdf9 | 2014-12-04 10:46:50 -0800 | [diff] [blame] | 434 | if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 435 | if (NULL == glyph->fPath) { |
| 436 | SkPath* path = SkNEW(SkPath); |
| 437 | if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
| 438 | // flag the glyph as being dead? |
| 439 | delete path; |
| 440 | return; |
| 441 | } |
| 442 | glyph->fPath = path; |
| 443 | } |
| 444 | |
bsalomon | ec87dc6 | 2014-10-14 10:52:00 -0700 | [diff] [blame] | 445 | // flush any accumulated draws before drawing this glyph as a path. |
| 446 | this->flush(); |
| 447 | |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 448 | SkMatrix translate; |
| 449 | translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds.fLeft)), |
| 450 | SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds.fTop))); |
joshualitt | c262582 | 2014-12-18 16:40:54 -0800 | [diff] [blame^] | 451 | SkPath tmpPath(*glyph->fPath); |
| 452 | tmpPath.transform(translate); |
egdaniel | d58a0ba | 2014-06-11 10:30:05 -0700 | [diff] [blame] | 453 | GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); |
joshualitt | c262582 | 2014-12-18 16:40:54 -0800 | [diff] [blame^] | 454 | fContext->drawPath(fPaint, SkMatrix::I(), tmpPath, strokeInfo); |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 455 | |
| 456 | // remove this glyph from the vertices we need to allocate |
| 457 | fTotalVertexCount -= kVerticesPerGlyph; |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 458 | return; |
| 459 | } |
| 460 | |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 461 | SkASSERT(glyph->fPlot); |
| 462 | GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); |
| 463 | glyph->fPlot->setDrawToken(drawToken); |
| 464 | |
| 465 | // now promote them to fixed (TODO: Rethink using fixed pt). |
| 466 | width = SkIntToFixed(width); |
| 467 | height = SkIntToFixed(height); |
| 468 | |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 469 | // the current texture/maskformat must match what the glyph needs |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 470 | GrTexture* texture = glyph->fPlot->texture(); |
| 471 | SkASSERT(texture); |
| 472 | |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 473 | if (fCurrTexture != texture || fCurrVertex + kVerticesPerGlyph > fAllocVertexCount) { |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 474 | this->flush(); |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 475 | fCurrTexture = texture; |
| 476 | fCurrTexture->ref(); |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 477 | fCurrMaskFormat = glyph->fMaskFormat; |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 478 | } |
| 479 | |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 480 | if (NULL == fVertices) { |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 481 | int maxQuadVertices = kVerticesPerGlyph * fContext->getQuadIndexBuffer()->maxQuads(); |
| 482 | fAllocVertexCount = SkMin32(fTotalVertexCount, maxQuadVertices); |
egdaniel | ed3af66 | 2014-10-31 06:55:45 -0700 | [diff] [blame] | 483 | fVertices = alloc_vertices(fDrawTarget, fAllocVertexCount, fCurrMaskFormat); |
Mike Klein | 6a25bd0 | 2014-08-29 10:03:59 -0400 | [diff] [blame] | 484 | } |
| 485 | |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 486 | SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); |
| 487 | SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 488 | |
commit-bot@chromium.org | 3ae0e6c | 2014-02-11 18:24:25 +0000 | [diff] [blame] | 489 | SkRect r; |
| 490 | r.fLeft = SkFixedToFloat(vx); |
| 491 | r.fTop = SkFixedToFloat(vy); |
| 492 | r.fRight = SkFixedToFloat(vx + width); |
| 493 | r.fBottom = SkFixedToFloat(vy + height); |
| 494 | |
reed | 10d0327 | 2014-10-01 09:24:12 -0700 | [diff] [blame] | 495 | fVertexBounds.joinNonEmptyArg(r); |
commit-bot@chromium.org | 3ae0e6c | 2014-02-11 18:24:25 +0000 | [diff] [blame] | 496 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 497 | size_t vertSize = get_vertex_stride(fCurrMaskFormat); |
bsalomon | 594069f | 2014-06-06 06:16:34 -0700 | [diff] [blame] | 498 | |
| 499 | SkPoint* positions = reinterpret_cast<SkPoint*>( |
| 500 | reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex); |
| 501 | positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize); |
| 502 | |
| 503 | // The texture coords are last in both the with and without color vertex layouts. |
| 504 | SkPoint* textureCoords = reinterpret_cast<SkPoint*>( |
| 505 | reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint)); |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 506 | textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx)), |
| 507 | SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty)), |
| 508 | SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx + width)), |
| 509 | SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + height)), |
bsalomon | 594069f | 2014-06-06 06:16:34 -0700 | [diff] [blame] | 510 | vertSize); |
egdaniel | ed3af66 | 2014-10-31 06:55:45 -0700 | [diff] [blame] | 511 | if (kA8_GrMaskFormat == fCurrMaskFormat) { |
bsalomon | 594069f | 2014-06-06 06:16:34 -0700 | [diff] [blame] | 512 | // color comes after position. |
| 513 | GrColor* colors = reinterpret_cast<GrColor*>(positions + 1); |
| 514 | for (int i = 0; i < 4; ++i) { |
| 515 | *colors = fPaint.getColor(); |
| 516 | colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors) + vertSize); |
| 517 | } |
| 518 | } |
jvanverth@google.com | c7a40fa | 2013-10-16 18:15:34 +0000 | [diff] [blame] | 519 | fCurrVertex += 4; |
| 520 | } |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 521 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 522 | void GrBitmapTextContext::flush() { |
| 523 | if (NULL == fDrawTarget) { |
| 524 | return; |
| 525 | } |
| 526 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 527 | if (fCurrVertex > 0) { |
joshualitt | 780b11e | 2014-11-18 09:40:40 -0800 | [diff] [blame] | 528 | GrDrawState drawState; |
| 529 | drawState.setFromPaint(fPaint, SkMatrix::I(), fContext->getRenderTarget()); |
| 530 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 531 | // setup our sampler state for our text texture/atlas |
| 532 | SkASSERT(SkIsAlign4(fCurrVertex)); |
| 533 | SkASSERT(fCurrTexture); |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 534 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 535 | SkASSERT(fStrike); |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 536 | GrColor color = fPaint.getColor(); |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 537 | switch (fCurrMaskFormat) { |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 538 | // Color bitmap text |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 539 | case kARGB_GrMaskFormat: { |
| 540 | int a = fSkPaint.getAlpha(); |
| 541 | color = SkColorSetARGB(a, a, a, a); |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 542 | break; |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 543 | } |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 544 | // LCD text |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 545 | case kA565_GrMaskFormat: { |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 546 | // TODO: move supportsRGBCoverage check to setupCoverageEffect and only add LCD |
| 547 | // processor if the xp can support it. For now we will simply assume that if |
| 548 | // fUseLCDText is true, then we have a known color output. |
| 549 | if (!drawState.getXPFactory()->supportsRGBCoverage(0, kRGBA_GrColorComponentFlags)) { |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 550 | SkDebugf("LCD Text will not draw correctly.\n"); |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 551 | } |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 552 | break; |
| 553 | } |
| 554 | // Grayscale/BW text |
| 555 | case kA8_GrMaskFormat: |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 556 | break; |
| 557 | default: |
jvanverth | 294c326 | 2014-10-10 11:36:12 -0700 | [diff] [blame] | 558 | SkFAIL("Unexpected mask format."); |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 559 | } |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 560 | |
| 561 | GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode); |
| 562 | // TODO cache these GPs |
| 563 | if (kARGB_GrMaskFormat == fCurrMaskFormat) { |
| 564 | uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
| 565 | if (textureUniqueID != fEffectTextureUniqueID || |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 566 | fCachedGeometryProcessor->color() != color) { |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 567 | uint32_t flags = GrDefaultGeoProcFactory::kLocalCoord_GPType; |
| 568 | fCachedGeometryProcessor.reset(GrDefaultGeoProcFactory::Create(color, flags)); |
| 569 | fCachedTextureProcessor.reset(GrSimpleTextureEffect::Create(fCurrTexture, |
| 570 | SkMatrix::I(), |
| 571 | params)); |
| 572 | } |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 573 | drawState.addColorProcessor(fCachedTextureProcessor.get()); |
| 574 | } else { |
| 575 | uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
| 576 | if (textureUniqueID != fEffectTextureUniqueID || |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 577 | fCachedGeometryProcessor->color() != color) { |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 578 | bool hasColor = kA8_GrMaskFormat == fCurrMaskFormat; |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 579 | bool opaqueVertexColors = GrColorIsOpaque(fPaint.getColor()); |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 580 | fCachedGeometryProcessor.reset(GrBitmapTextGeoProc::Create(color, |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 581 | fCurrTexture, |
| 582 | params, |
| 583 | hasColor, |
| 584 | opaqueVertexColors)); |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 585 | fEffectTextureUniqueID = textureUniqueID; |
| 586 | } |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 587 | } |
| 588 | |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 589 | int nGlyphs = fCurrVertex / kVerticesPerGlyph; |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 590 | fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 591 | fDrawTarget->drawIndexedInstances(&drawState, |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 592 | fCachedGeometryProcessor.get(), |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 593 | kTriangles_GrPrimitiveType, |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 594 | nGlyphs, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 595 | kVerticesPerGlyph, |
| 596 | kIndicesPerGlyph, |
| 597 | &fVertexBounds); |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 598 | |
| 599 | fDrawTarget->resetVertexSource(); |
| 600 | fVertices = NULL; |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 601 | fAllocVertexCount = 0; |
| 602 | // reset to be those that are left |
| 603 | fTotalVertexCount -= fCurrVertex; |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 604 | fCurrVertex = 0; |
| 605 | fVertexBounds.setLargestInverted(); |
| 606 | SkSafeSetNull(fCurrTexture); |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | inline void GrBitmapTextContext::finish() { |
| 611 | this->flush(); |
jvanverth | 73f1053 | 2014-10-23 11:57:12 -0700 | [diff] [blame] | 612 | fTotalVertexCount = 0; |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 613 | |
| 614 | GrTextContext::finish(); |
| 615 | } |
| 616 | |