void GrStencilAndCoverTextContext::flush() { if (fQueuedGlyphCount > 0) { SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(fPaint.getColor(), fViewMatrix, fLocalMatrix)); // We should only be flushing about once every run. However, if this impacts performance // we could move the creation of the GrPipelineBuilder earlier. GrPipelineBuilder pipelineBuilder(fPaint, fRenderTarget, fClip); SkASSERT(fRenderTarget->isStencilBufferMultisampled() || !fPaint.isAntiAlias()); pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, fPaint.isAntiAlias()); GR_STATIC_CONST_SAME_STENCIL(kStencilPass, kZero_StencilOp, kZero_StencilOp, kNotEqual_StencilFunc, 0xffff, 0x0000, 0xffff); *pipelineBuilder.stencil() = kStencilPass; SkASSERT(0 == fQueuedGlyphCount); SkASSERT(kGlyphBufferSize == fFallbackGlyphsIdx); fDrawContext->drawPaths(&pipelineBuilder, pp, fGlyphs, fGlyphIndices, GrPathRange::kU16_PathIndexType, get_xy_scalar_array(fGlyphPositions), GrPathRendering::kTranslate_PathTransformType, fQueuedGlyphCount, GrPathRendering::kWinding_FillType); fQueuedGlyphCount = 0; } if (fFallbackGlyphsIdx < kGlyphBufferSize) { int fallbackGlyphCount = kGlyphBufferSize - fFallbackGlyphsIdx; GrPaint paintFallback(fPaint); SkPaint skPaintFallback(fSkPaint); if (!fUsingDeviceSpaceGlyphs) { fStroke.applyToPaint(&skPaintFallback); } skPaintFallback.setTextAlign(SkPaint::kLeft_Align); // Align has already been accounted for. skPaintFallback.setTextEncoding(SkPaint::kGlyphID_TextEncoding); SkMatrix inverse; if (this->mapToFallbackContext(&inverse)) { inverse.mapPoints(&fGlyphPositions[fFallbackGlyphsIdx], fallbackGlyphCount); } fFallbackTextContext->drawPosText(fRenderTarget, fClip, paintFallback, skPaintFallback, fViewMatrix, (char*)&fGlyphIndices[fFallbackGlyphsIdx], 2 * fallbackGlyphCount, get_xy_scalar_array(&fGlyphPositions[fFallbackGlyphsIdx]), 2, SkPoint::Make(0, 0), fRegionClipBounds); fFallbackGlyphsIdx = kGlyphBufferSize; } }
void GrStencilAndCoverTextContext::flush(GrDrawContext* dc) { if (fDraw) { SkASSERT(fDraw->count()); // We should only be flushing about once every run. However, if this impacts performance // we could move the creation of the GrPipelineBuilder earlier. GrPipelineBuilder pipelineBuilder(fPaint, fRenderTarget, fClip); SkASSERT(fRenderTarget->isStencilBufferMultisampled() || !fPaint.isAntiAlias()); pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, fPaint.isAntiAlias()); GR_STATIC_CONST_SAME_STENCIL(kStencilPass, kZero_StencilOp, kKeep_StencilOp, kNotEqual_StencilFunc, 0xffff, 0x0000, 0xffff); *pipelineBuilder.stencil() = kStencilPass; dc->drawPathsFromRange(&pipelineBuilder, fViewMatrix, fLocalMatrix, fPaint.getColor(), fDraw, GrPathRendering::kWinding_FillType); fDraw->unref(); fDraw = nullptr; } if (fFallbackIndices.count()) { SkASSERT(fFallbackPositions.count() == fFallbackIndices.count()); GrPaint paintFallback(fPaint); SkPaint skPaintFallback(fSkPaint); if (!fUsingDeviceSpaceGlyphs) { fStroke.applyToPaint(&skPaintFallback); } skPaintFallback.setTextAlign(SkPaint::kLeft_Align); // Align has already been accounted for. skPaintFallback.setTextEncoding(SkPaint::kGlyphID_TextEncoding); SkMatrix inverse; if (this->mapToFallbackContext(&inverse)) { inverse.mapPoints(fFallbackPositions.begin(), fFallbackPositions.count()); } fFallbackTextContext->drawPosText(dc, fRenderTarget, fClip, paintFallback, skPaintFallback, fViewMatrix, (char*)fFallbackIndices.begin(), sizeof(uint16_t) * fFallbackIndices.count(), get_xy_scalar_array(fFallbackPositions.begin()), 2, SkPoint::Make(0, 0), fRegionClipBounds); fFallbackIndices.reset(); fFallbackPositions.reset(); } }
void GrStencilAndCoverTextContext::flush(GrDrawContext* drawContext) { if (fQueuedGlyphCount > 0) { SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(fPaint.getColor(), fViewMatrix, fLocalMatrix)); drawContext->drawPaths(&fPipelineBuilder, pp, fGlyphs, fGlyphIndices, GrPathRange::kU16_PathIndexType, get_xy_scalar_array(fGlyphPositions), GrPathRendering::kTranslate_PathTransformType, fQueuedGlyphCount, GrPathRendering::kWinding_FillType); fQueuedGlyphCount = 0; } if (fFallbackGlyphsIdx < kGlyphBufferSize) { int fallbackGlyphCount = kGlyphBufferSize - fFallbackGlyphsIdx; GrPaint paintFallback(fPaint); SkPaint skPaintFallback(fSkPaint); if (!fUsingDeviceSpaceGlyphs) { fStroke.applyToPaint(&skPaintFallback); } skPaintFallback.setTextAlign(SkPaint::kLeft_Align); // Align has already been accounted for. skPaintFallback.setTextEncoding(SkPaint::kGlyphID_TextEncoding); SkMatrix inverse; if (this->mapToFallbackContext(&inverse)) { inverse.mapPoints(&fGlyphPositions[fFallbackGlyphsIdx], fallbackGlyphCount); } fFallbackTextContext->drawPosText(fRenderTarget, fClip, paintFallback, skPaintFallback, fViewMatrix, (char*)&fGlyphIndices[fFallbackGlyphsIdx], 2 * fallbackGlyphCount, get_xy_scalar_array(&fGlyphPositions[fFallbackGlyphsIdx]), 2, SkPoint::Make(0, 0), fRegionClipBounds); fFallbackGlyphsIdx = kGlyphBufferSize; } }