kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 "GrStencilAndCoverTextContext.h" |
jvanverth | 8c27a18 | 2014-10-14 08:45:50 -0700 | [diff] [blame] | 9 | #include "GrBitmapTextContext.h" |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 10 | #include "GrDrawTarget.h" |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 11 | #include "GrGpu.h" |
| 12 | #include "GrPath.h" |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 13 | #include "GrPathRange.h" |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 14 | #include "SkDraw.h" |
| 15 | #include "SkDrawProcs.h" |
| 16 | #include "SkGlyphCache.h" |
| 17 | #include "SkGpuDevice.h" |
| 18 | #include "SkPath.h" |
| 19 | #include "SkTextMapStateProc.h" |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 20 | #include "SkTextFormatParams.h" |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 21 | |
| 22 | GrStencilAndCoverTextContext::GrStencilAndCoverTextContext( |
| 23 | GrContext* context, const SkDeviceProperties& properties) |
| 24 | : GrTextContext(context, properties) |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 25 | , fPendingGlyphCount(0) { |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 26 | } |
| 27 | |
jvanverth | 8c27a18 | 2014-10-14 08:45:50 -0700 | [diff] [blame] | 28 | GrStencilAndCoverTextContext* GrStencilAndCoverTextContext::Create(GrContext* context, |
| 29 | const SkDeviceProperties& props) { |
| 30 | GrStencilAndCoverTextContext* textContext = SkNEW_ARGS(GrStencilAndCoverTextContext, |
| 31 | (context, props)); |
| 32 | textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, props); |
| 33 | |
| 34 | return textContext; |
| 35 | } |
| 36 | |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 37 | GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() { |
| 38 | } |
| 39 | |
jvanverth | 0fedb19 | 2014-10-08 09:07:27 -0700 | [diff] [blame] | 40 | bool GrStencilAndCoverTextContext::canDraw(const SkPaint& paint) { |
| 41 | if (paint.getRasterizer()) { |
| 42 | return false; |
| 43 | } |
| 44 | if (paint.getMaskFilter()) { |
| 45 | return false; |
| 46 | } |
| 47 | if (paint.getPathEffect()) { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | // No hairlines unless we can map the 1 px width to the object space. |
| 52 | if (paint.getStyle() == SkPaint::kStroke_Style |
| 53 | && paint.getStrokeWidth() == 0 |
| 54 | && fContext->getMatrix().hasPerspective()) { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | // No color bitmap fonts. |
| 59 | SkScalerContext::Rec rec; |
| 60 | SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec); |
| 61 | return rec.getFormat() != SkMask::kARGB32_Format; |
| 62 | } |
| 63 | |
jvanverth | 8c27a18 | 2014-10-14 08:45:50 -0700 | [diff] [blame] | 64 | void GrStencilAndCoverTextContext::onDrawPosText(const GrPaint& paint, |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 65 | const SkPaint& skPaint, |
| 66 | const char text[], |
| 67 | size_t byteLength, |
| 68 | const SkScalar pos[], |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 69 | int scalarsPerPosition, |
| 70 | const SkPoint& offset) { |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 71 | SkASSERT(byteLength == 0 || text != NULL); |
| 72 | SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); |
| 73 | |
| 74 | // nothing to draw |
| 75 | if (text == NULL || byteLength == 0/* || fRC->isEmpty()*/) { |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | // This is the fast path. Here we do not bake in the device-transform to |
| 80 | // the glyph outline or the advances. This is because we do not need to |
| 81 | // position the glyphs at all, since the caller has done the positioning. |
| 82 | // The positioning is based on SkPaint::measureText of individual |
| 83 | // glyphs. That already uses glyph cache without device transforms. Device |
| 84 | // transform is not part of SkPaint::measureText API, and thus we use the |
| 85 | // same glyphs as what were measured. |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 86 | |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 87 | this->init(paint, skPaint, byteLength, kMaxPerformance_RenderMode, offset); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 88 | |
| 89 | SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc(); |
| 90 | |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 91 | const char* stop = text + byteLength; |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 92 | |
| 93 | if (SkPaint::kLeft_Align == fSkPaint.getTextAlign()) { |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 94 | if (1 == scalarsPerPosition) { |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 95 | fTransformType = GrPathRendering::kTranslateX_PathTransformType; |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 96 | while (text < stop) { |
| 97 | const SkGlyph& glyph = glyphCacheProc(fGlyphCache, &text, 0, 0); |
| 98 | if (glyph.fWidth) { |
| 99 | this->appendGlyph(glyph.getGlyphID(), *pos); |
| 100 | } |
| 101 | pos++; |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 102 | } |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 103 | } else { |
| 104 | SkASSERT(2 == scalarsPerPosition); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 105 | fTransformType = GrPathRendering::kTranslate_PathTransformType; |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 106 | while (text < stop) { |
| 107 | const SkGlyph& glyph = glyphCacheProc(fGlyphCache, &text, 0, 0); |
| 108 | if (glyph.fWidth) { |
| 109 | this->appendGlyph(glyph.getGlyphID(), pos[0], pos[1]); |
| 110 | } |
| 111 | pos += 2; |
| 112 | } |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 113 | } |
| 114 | } else { |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 115 | fTransformType = GrPathRendering::kTranslate_PathTransformType; |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 116 | SkTextMapStateProc tmsProc(SkMatrix::I(), SkPoint::Make(0, 0), scalarsPerPosition); |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 117 | SkTextAlignProcScalar alignProc(fSkPaint.getTextAlign()); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 118 | while (text < stop) { |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 119 | const SkGlyph& glyph = glyphCacheProc(fGlyphCache, &text, 0, 0); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 120 | if (glyph.fWidth) { |
| 121 | SkPoint tmsLoc; |
| 122 | tmsProc(pos, &tmsLoc); |
| 123 | SkPoint loc; |
| 124 | alignProc(tmsLoc, glyph, &loc); |
| 125 | |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 126 | this->appendGlyph(glyph.getGlyphID(), loc.x(), loc.y()); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 127 | } |
| 128 | pos += scalarsPerPosition; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | this->finish(); |
| 133 | } |
| 134 | |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 135 | static GrPathRange* get_gr_glyphs(GrContext* ctx, |
| 136 | const SkTypeface* typeface, |
| 137 | const SkDescriptor* desc, |
| 138 | const SkStrokeRec& stroke) { |
| 139 | static const GrCacheID::Domain gGlyphsDomain = GrCacheID::GenerateDomain(); |
| 140 | |
| 141 | GrCacheID::Key key; |
| 142 | uint64_t* keyData = key.fData64; |
| 143 | keyData[0] = desc ? desc->getChecksum() : 0; |
| 144 | keyData[0] = (keyData[0] << 32) | (typeface ? typeface->uniqueID() : 0); |
| 145 | keyData[1] = GrPath::ComputeStrokeKey(stroke); |
| 146 | GrResourceKey resourceKey = GrResourceKey(GrCacheID(gGlyphsDomain, key), |
| 147 | GrPathRange::resourceType(), 0); |
| 148 | |
| 149 | SkAutoTUnref<GrPathRange> glyphs( |
| 150 | static_cast<GrPathRange*>(ctx->findAndRefCachedResource(resourceKey))); |
| 151 | if (NULL == glyphs || (NULL != desc && !glyphs->isEqualTo(*desc))) { |
| 152 | glyphs.reset(ctx->getGpu()->pathRendering()->createGlyphs(typeface, desc, stroke)); |
| 153 | ctx->addResourceToCache(resourceKey, glyphs); |
| 154 | } |
| 155 | |
| 156 | return glyphs.detach(); |
| 157 | } |
| 158 | |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 159 | void GrStencilAndCoverTextContext::init(const GrPaint& paint, |
| 160 | const SkPaint& skPaint, |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 161 | size_t textByteLength, |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 162 | RenderMode renderMode, |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 163 | const SkPoint& textTranslate) { |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 164 | GrTextContext::init(paint, skPaint); |
| 165 | |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 166 | fContextInitialMatrix = fContext->getMatrix(); |
| 167 | |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 168 | const bool otherBackendsWillDrawAsPaths = |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 169 | SkDraw::ShouldDrawTextAsPaths(skPaint, fContextInitialMatrix); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 170 | |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 171 | fNeedsDeviceSpaceGlyphs = !otherBackendsWillDrawAsPaths && |
| 172 | kMaxAccuracy_RenderMode == renderMode && |
| 173 | SkToBool(fContextInitialMatrix.getType() & |
| 174 | (SkMatrix::kScale_Mask | SkMatrix::kAffine_Mask)); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 175 | |
| 176 | if (fNeedsDeviceSpaceGlyphs) { |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 177 | // SkDraw::ShouldDrawTextAsPaths takes care of perspective transforms. |
| 178 | SkASSERT(!fContextInitialMatrix.hasPerspective()); |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 179 | SkASSERT(textTranslate.isZero()); // TODO: Handle textTranslate in device-space usecase. |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 180 | |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 181 | fTextRatio = fTextInverseRatio = 1.0f; |
| 182 | |
| 183 | // Glyphs loaded by GPU path rendering have an inverted y-direction. |
| 184 | SkMatrix m; |
| 185 | m.setScale(1, -1); |
| 186 | fContext->setMatrix(m); |
| 187 | |
| 188 | // Post-flip the initial matrix so we're left with just the flip after |
| 189 | // the paint preConcats the inverse. |
| 190 | m = fContextInitialMatrix; |
| 191 | m.postScale(1, -1); |
| 192 | fPaint.localCoordChangeInverse(m); |
| 193 | |
| 194 | // The whole shape (including stroke) will be baked into the glyph outlines. Make |
| 195 | // NVPR just fill the baked shapes. |
| 196 | fGlyphCache = fSkPaint.detachCache(&fDeviceProperties, &fContextInitialMatrix, false); |
| 197 | fGlyphs = get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->getTypeface(), |
| 198 | &fGlyphCache->getDescriptor(), |
| 199 | SkStrokeRec(SkStrokeRec::kFill_InitStyle)); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 200 | } else { |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 201 | // Don't bake strokes into the glyph outlines. We will stroke the glyphs |
| 202 | // using the GPU instead. This is the fast path. |
| 203 | SkStrokeRec gpuStroke = SkStrokeRec(fSkPaint); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 204 | fSkPaint.setStyle(SkPaint::kFill_Style); |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 205 | |
| 206 | if (gpuStroke.isHairlineStyle()) { |
| 207 | // Approximate hairline stroke. |
| 208 | SkScalar strokeWidth = SK_Scalar1 / |
| 209 | (SkVector::Make(fContextInitialMatrix.getScaleX(), |
| 210 | fContextInitialMatrix.getSkewY()).length()); |
| 211 | gpuStroke.setStrokeStyle(strokeWidth, false /*strokeAndFill*/); |
| 212 | |
| 213 | } else if (fSkPaint.isFakeBoldText() && |
| 214 | #ifdef SK_USE_FREETYPE_EMBOLDEN |
| 215 | kMaxPerformance_RenderMode == renderMode && |
| 216 | #endif |
| 217 | SkStrokeRec::kStroke_Style != gpuStroke.getStyle()) { |
| 218 | |
| 219 | // Instead of baking fake bold into the glyph outlines, do it with the GPU stroke. |
| 220 | SkScalar fakeBoldScale = SkScalarInterpFunc(fSkPaint.getTextSize(), |
| 221 | kStdFakeBoldInterpKeys, |
| 222 | kStdFakeBoldInterpValues, |
| 223 | kStdFakeBoldInterpLength); |
| 224 | SkScalar extra = SkScalarMul(fSkPaint.getTextSize(), fakeBoldScale); |
| 225 | gpuStroke.setStrokeStyle(gpuStroke.needToApply() ? gpuStroke.getWidth() + extra : extra, |
| 226 | true /*strokeAndFill*/); |
| 227 | |
| 228 | fSkPaint.setFakeBoldText(false); |
| 229 | } |
| 230 | |
| 231 | bool canUseRawPaths; |
| 232 | |
| 233 | if (otherBackendsWillDrawAsPaths || kMaxPerformance_RenderMode == renderMode) { |
| 234 | // We can draw the glyphs from canonically sized paths. |
| 235 | fTextRatio = fSkPaint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; |
| 236 | fTextInverseRatio = SkPaint::kCanonicalTextSizeForPaths / fSkPaint.getTextSize(); |
| 237 | |
| 238 | // Compensate for the glyphs being scaled by fTextRatio. |
| 239 | if (!gpuStroke.isFillStyle()) { |
| 240 | gpuStroke.setStrokeStyle(gpuStroke.getWidth() / fTextRatio, |
| 241 | SkStrokeRec::kStrokeAndFill_Style == gpuStroke.getStyle()); |
| 242 | } |
| 243 | |
| 244 | fSkPaint.setLinearText(true); |
| 245 | fSkPaint.setLCDRenderText(false); |
| 246 | fSkPaint.setAutohinted(false); |
| 247 | fSkPaint.setHinting(SkPaint::kNo_Hinting); |
| 248 | fSkPaint.setSubpixelText(true); |
| 249 | fSkPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths)); |
| 250 | |
| 251 | canUseRawPaths = SK_Scalar1 == fSkPaint.getTextScaleX() && |
| 252 | 0 == fSkPaint.getTextSkewX() && |
| 253 | !fSkPaint.isFakeBoldText() && |
| 254 | !fSkPaint.isVerticalText(); |
| 255 | } else { |
| 256 | fTextRatio = fTextInverseRatio = 1.0f; |
| 257 | canUseRawPaths = false; |
| 258 | } |
| 259 | |
| 260 | SkMatrix textMatrix; |
fmalita | 05c4a43 | 2014-09-29 06:29:53 -0700 | [diff] [blame] | 261 | textMatrix.setTranslate(textTranslate.x(), textTranslate.y()); |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 262 | // Glyphs loaded by GPU path rendering have an inverted y-direction. |
| 263 | textMatrix.preScale(fTextRatio, -fTextRatio); |
| 264 | fPaint.localCoordChange(textMatrix); |
| 265 | fContext->concatMatrix(textMatrix); |
| 266 | |
| 267 | fGlyphCache = fSkPaint.detachCache(&fDeviceProperties, NULL, false); |
| 268 | fGlyphs = canUseRawPaths ? |
| 269 | get_gr_glyphs(fContext, fSkPaint.getTypeface(), NULL, gpuStroke) : |
| 270 | get_gr_glyphs(fContext, fGlyphCache->getScalerContext()->getTypeface(), |
| 271 | &fGlyphCache->getDescriptor(), gpuStroke); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 272 | } |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 273 | |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 274 | fStateRestore.set(fDrawTarget->drawState()); |
| 275 | |
| 276 | fDrawTarget->drawState()->setFromPaint(fPaint, fContext->getMatrix(), |
| 277 | fContext->getRenderTarget()); |
| 278 | |
| 279 | GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
| 280 | kZero_StencilOp, |
| 281 | kZero_StencilOp, |
| 282 | kNotEqual_StencilFunc, |
| 283 | 0xffff, |
| 284 | 0x0000, |
| 285 | 0xffff); |
| 286 | |
| 287 | *fDrawTarget->drawState()->stencil() = kStencilPass; |
| 288 | |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 289 | SkASSERT(0 == fPendingGlyphCount); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 290 | } |
| 291 | |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 292 | inline void GrStencilAndCoverTextContext::appendGlyph(uint16_t glyphID, float x) { |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 293 | SkASSERT(GrPathRendering::kTranslateX_PathTransformType == fTransformType); |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 294 | |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 295 | if (fPendingGlyphCount >= kGlyphBufferSize) { |
| 296 | this->flush(); |
| 297 | } |
| 298 | |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 299 | fIndexBuffer[fPendingGlyphCount] = glyphID; |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 300 | fTransformBuffer[fPendingGlyphCount] = fTextInverseRatio * x; |
| 301 | |
| 302 | ++fPendingGlyphCount; |
| 303 | } |
| 304 | |
| 305 | inline void GrStencilAndCoverTextContext::appendGlyph(uint16_t glyphID, float x, float y) { |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 306 | SkASSERT(GrPathRendering::kTranslate_PathTransformType == fTransformType); |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 307 | |
| 308 | if (fPendingGlyphCount >= kGlyphBufferSize) { |
| 309 | this->flush(); |
| 310 | } |
| 311 | |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 312 | fIndexBuffer[fPendingGlyphCount] = glyphID; |
| 313 | fTransformBuffer[2 * fPendingGlyphCount] = fTextInverseRatio * x; |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 314 | fTransformBuffer[2 * fPendingGlyphCount + 1] = -fTextInverseRatio * y; |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 315 | |
| 316 | ++fPendingGlyphCount; |
| 317 | } |
| 318 | |
| 319 | void GrStencilAndCoverTextContext::flush() { |
| 320 | if (0 == fPendingGlyphCount) { |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 321 | return; |
| 322 | } |
| 323 | |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 324 | fDrawTarget->drawPaths(fGlyphs, fIndexBuffer, fPendingGlyphCount, |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 325 | fTransformBuffer, fTransformType, SkPath::kWinding_FillType); |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 326 | |
| 327 | fPendingGlyphCount = 0; |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | void GrStencilAndCoverTextContext::finish() { |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 331 | this->flush(); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 332 | |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 333 | fGlyphs->unref(); |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 334 | fGlyphs = NULL; |
cdalton | 855d83f | 2014-09-18 13:51:53 -0700 | [diff] [blame] | 335 | |
| 336 | SkGlyphCache::AttachCache(fGlyphCache); |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 337 | fGlyphCache = NULL; |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 338 | |
| 339 | fDrawTarget->drawState()->stencil()->setDisabled(); |
| 340 | fStateRestore.set(NULL); |
cdalton | b2808cd | 2014-07-25 14:13:57 -0700 | [diff] [blame] | 341 | fContext->setMatrix(fContextInitialMatrix); |
kkinnunen | c6cb56f | 2014-06-24 00:12:27 -0700 | [diff] [blame] | 342 | GrTextContext::finish(); |
| 343 | } |
| 344 | |