Chromium Code Reviews| Index: src/gpu/text/GrStencilAndCoverTextContext.cpp |
| diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp |
| index 38bd1f7d5db5aa10ae099b44fc052019bb32dca4..8a45638f2906cb2f420b3a33f2669f6980dff079 100644 |
| --- a/src/gpu/text/GrStencilAndCoverTextContext.cpp |
| +++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp |
| @@ -36,16 +36,14 @@ template<typename T> static void delete_hash_table_entry(T* val) { |
| delete *val; |
| } |
| -GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrContext* context) |
| - : INHERITED(context), |
| - fCacheSize(0) { |
| +GrStencilAndCoverTextContext::GrStencilAndCoverTextContext() |
| + : fCacheSize(0) { |
| } |
| GrStencilAndCoverTextContext* |
| -GrStencilAndCoverTextContext::Create(GrContext* context) { |
| - GrStencilAndCoverTextContext* textContext = |
| - new GrStencilAndCoverTextContext(context); |
| - textContext->fFallbackTextContext = GrAtlasTextContext::Create(context); |
| +GrStencilAndCoverTextContext::Create() { |
| + GrStencilAndCoverTextContext* textContext = new GrStencilAndCoverTextContext(); |
| + textContext->fFallbackTextContext = GrAtlasTextContext::Create(); |
| return textContext; |
| } |
| @@ -72,33 +70,34 @@ bool GrStencilAndCoverTextContext::internalCanDraw(const SkPaint& skPaint) { |
| return SkPaint::kStroke_Style != skPaint.getStyle() || 0 != skPaint.getStrokeWidth(); |
| } |
| -void GrStencilAndCoverTextContext::drawText(GrDrawContext* dc, |
| +void GrStencilAndCoverTextContext::drawText(GrContext* context, GrDrawContext* dc, |
| const GrClip& clip, const GrPaint& paint, |
| const SkPaint& skPaint, const SkMatrix& viewMatrix, |
| const SkSurfaceProps& props, |
| const char text[], size_t byteLength, |
| SkScalar x, SkScalar y, const SkIRect& clipBounds) { |
| - if (fContext->abandoned()) { |
| + if (context->abandoned()) { |
| return; |
| } else if (this->canDraw(skPaint, viewMatrix)) { |
| TextRun run(skPaint); |
| GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip); |
| run.setText(text, byteLength, x, y); |
|
robertphillips
2016/02/10 19:44:39
can this guy just take a resource provider ?
|
| - run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0, |
| + run.draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0, |
| clipBounds, fFallbackTextContext, skPaint); |
| return; |
| - } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props)) { |
| - fFallbackTextContext->drawText(dc, clip, paint, skPaint, viewMatrix, props, text, |
| + } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props, |
| + *context->caps()->shaderCaps())) { |
| + fFallbackTextContext->drawText(context, dc, clip, paint, skPaint, viewMatrix, props, text, |
| byteLength, x, y, clipBounds); |
| return; |
| } |
| // fall back to drawing as a path |
| - GrTextUtils::DrawTextAsPath(fContext, dc, clip, skPaint, viewMatrix, text, byteLength, x, y, |
| + GrTextUtils::DrawTextAsPath(context, dc, clip, skPaint, viewMatrix, text, byteLength, x, y, |
| clipBounds); |
| } |
| -void GrStencilAndCoverTextContext::drawPosText(GrDrawContext* dc, |
| +void GrStencilAndCoverTextContext::drawPosText(GrContext* context, GrDrawContext* dc, |
| const GrClip& clip, |
| const GrPaint& paint, |
| const SkPaint& skPaint, |
| @@ -110,53 +109,54 @@ void GrStencilAndCoverTextContext::drawPosText(GrDrawContext* dc, |
| int scalarsPerPosition, |
| const SkPoint& offset, |
| const SkIRect& clipBounds) { |
| - if (fContext->abandoned()) { |
| + if (context->abandoned()) { |
| return; |
| } else if (this->canDraw(skPaint, viewMatrix)) { |
| TextRun run(skPaint); |
| GrPipelineBuilder pipelineBuilder(paint, dc->accessRenderTarget(), clip); |
| run.setPosText(text, byteLength, pos, scalarsPerPosition, offset); |
| - run.draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0, |
| + run.draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, 0, 0, |
| clipBounds, fFallbackTextContext, skPaint); |
| return; |
| - } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props)) { |
| - fFallbackTextContext->drawPosText(dc, clip, paint, skPaint, viewMatrix, props, |
| + } else if (fFallbackTextContext->canDraw(skPaint, viewMatrix, props, |
| + *context->caps()->shaderCaps())) { |
| + fFallbackTextContext->drawPosText(context, dc, clip, paint, skPaint, viewMatrix, props, |
| text, byteLength, pos, |
| scalarsPerPosition, offset, clipBounds); |
| return; |
| } |
| // fall back to drawing as a path |
| - GrTextUtils::DrawPosTextAsPath(fContext, dc, props, clip, skPaint, viewMatrix, text, |
| + GrTextUtils::DrawPosTextAsPath(context, dc, props, clip, skPaint, viewMatrix, text, |
| byteLength, pos, scalarsPerPosition, offset, clipBounds); |
| } |
| -void GrStencilAndCoverTextContext::drawTextBlob(GrDrawContext* dc, |
| +void GrStencilAndCoverTextContext::drawTextBlob(GrContext* context, GrDrawContext* dc, |
| const GrClip& clip, const SkPaint& skPaint, |
| const SkMatrix& viewMatrix, |
| const SkSurfaceProps& props, |
| const SkTextBlob* skBlob, SkScalar x, SkScalar y, |
| SkDrawFilter* drawFilter, |
| const SkIRect& clipBounds) { |
| - if (fContext->abandoned()) { |
| + if (context->abandoned()) { |
| return; |
| } |
| if (!this->internalCanDraw(skPaint)) { |
| - fFallbackTextContext->drawTextBlob(dc, clip, skPaint, viewMatrix, props, skBlob, x, y, |
| - drawFilter, clipBounds); |
| + fFallbackTextContext->drawTextBlob(context, dc, clip, skPaint, viewMatrix, props, skBlob, |
| + x, y, drawFilter, clipBounds); |
| return; |
| } |
| if (drawFilter || skPaint.getPathEffect()) { |
| // This draw can't be cached. |
| - fFallbackTextContext->drawTextBlob(dc, clip, skPaint, viewMatrix, props, skBlob, x, y, |
| - drawFilter, clipBounds); |
| + fFallbackTextContext->drawTextBlob(context, dc, clip, skPaint, viewMatrix, props, skBlob, |
| + x, y, drawFilter, clipBounds); |
| return; |
| } |
| GrPaint paint; |
| - if (!SkPaintToGrPaint(fContext, skPaint, viewMatrix, &paint)) { |
| + if (!SkPaintToGrPaint(context, skPaint, viewMatrix, &paint)) { |
| return; |
| } |
| @@ -165,7 +165,7 @@ void GrStencilAndCoverTextContext::drawTextBlob(GrDrawContext* dc, |
| TextBlob::Iter iter(blob); |
| for (TextRun* run = iter.get(); run; run = iter.next()) { |
| - run->draw(fContext, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, x, y, |
| + run->draw(context, dc, &pipelineBuilder, paint.getColor(), viewMatrix, props, x, y, |
| clipBounds, fFallbackTextContext, skPaint); |
| run->releaseGlyphCache(); |
| } |
| @@ -560,8 +560,9 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx, |
| fallbackSkPaint.setStrokeWidth(fStroke.getWidth() * fTextRatio); |
| } |
| - fallbackTextContext->drawTextBlob(dc, pipelineBuilder->clip(), fallbackSkPaint, viewMatrix, |
| - props, fFallbackTextBlob, x, y, nullptr, clipBounds); |
| + fallbackTextContext->drawTextBlob(ctx, dc, pipelineBuilder->clip(), fallbackSkPaint, |
| + viewMatrix, props, fFallbackTextBlob, x, y, nullptr, |
| + clipBounds); |
| } |
| } |