| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "GrStencilAndCoverTextContext.h" | 8 #include "GrStencilAndCoverTextContext.h" |
| 9 #include "GrAtlasTextContext.h" | 9 #include "GrAtlasTextContext.h" |
| 10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const GrClip& clip, const GrPaint& p
aint, | 75 const GrClip& clip, const GrPaint& p
aint, |
| 76 const SkPaint& skPaint, const SkMatr
ix& viewMatrix, | 76 const SkPaint& skPaint, const SkMatr
ix& viewMatrix, |
| 77 const SkSurfaceProps& props, | 77 const SkSurfaceProps& props, |
| 78 const char text[], size_t byteLength
, | 78 const char text[], size_t byteLength
, |
| 79 SkScalar x, SkScalar y, const SkIRec
t& clipBounds) { | 79 SkScalar x, SkScalar y, const SkIRec
t& clipBounds) { |
| 80 if (context->abandoned()) { | 80 if (context->abandoned()) { |
| 81 return; | 81 return; |
| 82 } else if (this->canDraw(skPaint, viewMatrix)) { | 82 } else if (this->canDraw(skPaint, viewMatrix)) { |
| 83 if (skPaint.getTextSize() > 0) { | 83 if (skPaint.getTextSize() > 0) { |
| 84 TextRun run(skPaint); | 84 TextRun run(skPaint); |
| 85 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), c
lip); | 85 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), c
lip, |
| 86 run.isAntiAlias()); |
| 86 run.setText(text, byteLength, x, y); | 87 run.setText(text, byteLength, x, y); |
| 87 run.draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix
, props, 0, 0, | 88 run.draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix
, props, 0, 0, |
| 88 clipBounds, fFallbackTextContext, skPaint); | 89 clipBounds, fFallbackTextContext, skPaint); |
| 89 } | 90 } |
| 90 return; | 91 return; |
| 91 } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props, | 92 } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props, |
| 92 *context->caps()->shaderCaps())) { | 93 *context->caps()->shaderCaps())) { |
| 93 fFallbackTextContext->drawText(context, dc, clip, paint, skPaint, viewMa
trix, props, text, | 94 fFallbackTextContext->drawText(context, dc, clip, paint, skPaint, viewMa
trix, props, text, |
| 94 byteLength, x, y, clipBounds); | 95 byteLength, x, y, clipBounds); |
| 95 return; | 96 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 110 size_t byteLength, | 111 size_t byteLength, |
| 111 const SkScalar pos[], | 112 const SkScalar pos[], |
| 112 int scalarsPerPosition, | 113 int scalarsPerPosition, |
| 113 const SkPoint& offset, | 114 const SkPoint& offset, |
| 114 const SkIRect& clipBounds) { | 115 const SkIRect& clipBounds) { |
| 115 if (context->abandoned()) { | 116 if (context->abandoned()) { |
| 116 return; | 117 return; |
| 117 } else if (this->canDraw(skPaint, viewMatrix)) { | 118 } else if (this->canDraw(skPaint, viewMatrix)) { |
| 118 if (skPaint.getTextSize() > 0) { | 119 if (skPaint.getTextSize() > 0) { |
| 119 TextRun run(skPaint); | 120 TextRun run(skPaint); |
| 120 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), c
lip); | 121 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), c
lip, |
| 122 run.isAntiAlias()); |
| 121 run.setPosText(text, byteLength, pos, scalarsPerPosition, offset); | 123 run.setPosText(text, byteLength, pos, scalarsPerPosition, offset); |
| 122 run.draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix
, props, 0, 0, | 124 run.draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix
, props, 0, 0, |
| 123 clipBounds, fFallbackTextContext, skPaint); | 125 clipBounds, fFallbackTextContext, skPaint); |
| 124 } | 126 } |
| 125 return; | 127 return; |
| 126 } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props, | 128 } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props, |
| 127 *context->caps()->shaderCaps())) { | 129 *context->caps()->shaderCaps())) { |
| 128 fFallbackTextContext->drawPosText(context, dc, clip, paint, skPaint, vie
wMatrix, props, | 130 fFallbackTextContext->drawPosText(context, dc, clip, paint, skPaint, vie
wMatrix, props, |
| 129 text, byteLength, pos, | 131 text, byteLength, pos, |
| 130 scalarsPerPosition, offset, clipBounds
); | 132 scalarsPerPosition, offset, clipBounds
); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 GrPaint paint; | 224 GrPaint paint; |
| 223 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), &p
aint)) { | 225 if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), &p
aint)) { |
| 224 return; | 226 return; |
| 225 } | 227 } |
| 226 | 228 |
| 227 const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint); | 229 const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint); |
| 228 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip); | 230 GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip); |
| 229 | 231 |
| 230 TextBlob::Iter iter(blob); | 232 TextBlob::Iter iter(blob); |
| 231 for (TextRun* run = iter.get(); run; run = iter.next()) { | 233 for (TextRun* run = iter.get(); run; run = iter.next()) { |
| 234 pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, run->isAn
tiAlias()); |
| 232 run->draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix, p
rops, x, y, | 235 run->draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix, p
rops, x, y, |
| 233 clipBounds, fFallbackTextContext, skPaint); | 236 clipBounds, fFallbackTextContext, skPaint); |
| 234 run->releaseGlyphCache(); | 237 run->releaseGlyphCache(); |
| 235 } | 238 } |
| 236 } | 239 } |
| 237 | 240 |
| 238 const GrStencilAndCoverTextContext::TextBlob& | 241 const GrStencilAndCoverTextContext::TextBlob& |
| 239 GrStencilAndCoverTextContext::findOrCreateTextBlob(const SkTextBlob* skBlob, | 242 GrStencilAndCoverTextContext::findOrCreateTextBlob(const SkTextBlob* skBlob, |
| 240 const SkPaint& skPaint) { | 243 const SkPaint& skPaint) { |
| 241 // The font-related parameters are baked into the text blob and will overrid
e this skPaint, so | 244 // The font-related parameters are baked into the text blob and will overrid
e this skPaint, so |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 const SkMatrix& viewMatrix, | 579 const SkMatrix& viewMatrix, |
| 577 const SkSurfaceProps& props, | 580 const SkSurfaceProps& props, |
| 578 SkScalar x, SkScalar y, | 581 SkScalar x, SkScalar y, |
| 579 const SkIRect& clipBounds, | 582 const SkIRect& clipBounds, |
| 580 GrAtlasTextContext* fallbackTex
tContext, | 583 GrAtlasTextContext* fallbackTex
tContext, |
| 581 const SkPaint& originalSkPaint)
const { | 584 const SkPaint& originalSkPaint)
const { |
| 582 SkASSERT(fInstanceData); | 585 SkASSERT(fInstanceData); |
| 583 SkASSERT(dc->accessRenderTarget()->isStencilBufferMultisampled() || !fFont.i
sAntiAlias()); | 586 SkASSERT(dc->accessRenderTarget()->isStencilBufferMultisampled() || !fFont.i
sAntiAlias()); |
| 584 | 587 |
| 585 if (fInstanceData->count()) { | 588 if (fInstanceData->count()) { |
| 586 pipelineBuilder->setState(GrPipelineBuilder::kHWAntialias_Flag, fFont.is
AntiAlias()); | |
| 587 | |
| 588 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, | 589 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
| 589 kZero_StencilOp, | 590 kZero_StencilOp, |
| 590 kKeep_StencilOp, | 591 kKeep_StencilOp, |
| 591 kNotEqual_StencilFunc, | 592 kNotEqual_StencilFunc, |
| 592 0xffff, | 593 0xffff, |
| 593 0x0000, | 594 0x0000, |
| 594 0xffff); | 595 0xffff); |
| 595 | 596 |
| 596 *pipelineBuilder->stencil() = kStencilPass; | 597 *pipelineBuilder->stencil() = kStencilPass; |
| 597 | 598 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 } | 704 } |
| 704 | 705 |
| 705 const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfNeed
ed(int *count) { | 706 const SkTextBlob* GrStencilAndCoverTextContext::FallbackBlobBuilder::buildIfNeed
ed(int *count) { |
| 706 *count = fCount; | 707 *count = fCount; |
| 707 if (fCount) { | 708 if (fCount) { |
| 708 this->flush(); | 709 this->flush(); |
| 709 return fBuilder->build(); | 710 return fBuilder->build(); |
| 710 } | 711 } |
| 711 return nullptr; | 712 return nullptr; |
| 712 } | 713 } |
| OLD | NEW |