From c2625821b34d89e8df2ba89cc84db6957189f250 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Thu, 18 Dec 2014 16:40:54 -0800 Subject: [PATCH] Remove the low hanging fruit with coord change matrices BUG=skia: Review URL: https://codereview.chromium.org/793013003 --- expectations/gm/ignored-tests.txt | 4 ++++ include/gpu/GrPaint.h | 5 ++--- src/effects/SkBlurMaskFilter.cpp | 20 ++++++++++---------- src/gpu/GrBitmapTextContext.cpp | 7 ++++--- src/gpu/GrDistanceFieldTextContext.cpp | 11 ++++++----- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt index 44577413b8..56d37c356b 100644 --- a/expectations/gm/ignored-tests.txt +++ b/expectations/gm/ignored-tests.txt @@ -59,3 +59,7 @@ drawbitmapmatrix #junov skbug.com/3176 pictureimagefilter + +#joshualitt +bleed +bigblurs diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h index 6862d9dc55..41b838cb35 100644 --- a/include/gpu/GrPaint.h +++ b/include/gpu/GrPaint.h @@ -148,9 +148,8 @@ public: bool isOpaqueAndConstantColor(GrColor* constantColor) const; /** - * Called when the source coord system from which geometry is rendered changes. It ensures that - * the local coordinates seen by effects remains unchanged. oldToNew gives the transformation - * from the previous coord system to the new coord system. + * DO NOT USE THESE + * TODO Remove remaining use cases and delete these */ void localCoordChange(const SkMatrix& oldToNew) { for (int i = 0; i < fColorStages.count(); ++i) { diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index b4c020f5e7..aa576697e3 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -860,13 +860,13 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context, return false; } - if (!grp->localCoordChangeInverse(viewMatrix)) { - return false; - } - grp->addCoverageProcessor(fp); - context->drawRect(*grp, SkMatrix::I(), rect); + SkMatrix inverse; + if (!viewMatrix.invert(&inverse)) { + return false; + } + context->drawNonAARectWithLocalMatrix(*grp, SkMatrix::I(), rect, inverse); return true; } @@ -1142,13 +1142,13 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context, return false; } - if (!grp->localCoordChangeInverse(viewMatrix)) { - return false; - } - grp->addCoverageProcessor(fp); - context->drawRect(*grp, SkMatrix::I(), proxy_rect); + SkMatrix inverse; + if (!viewMatrix.invert(&inverse)) { + return false; + } + context->drawNonAARectWithLocalMatrix(*grp, SkMatrix::I(), proxy_rect, inverse); return true; } diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp index 921c198eeb..732a514c4f 100755 --- a/src/gpu/GrBitmapTextContext.cpp +++ b/src/gpu/GrBitmapTextContext.cpp @@ -430,6 +430,7 @@ void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed, } } + // If the glyph is too large we fall back to paths if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { if (NULL == glyph->fPath) { SkPath* path = SkNEW(SkPath); @@ -447,10 +448,10 @@ void GrBitmapTextContext::appendGlyph(GrGlyph::PackedID packed, SkMatrix translate; translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds.fLeft)), SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds.fTop))); - GrPaint tmpPaint(fPaint); - tmpPaint.localCoordChange(translate); + SkPath tmpPath(*glyph->fPath); + tmpPath.transform(translate); GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); - fContext->drawPath(tmpPaint, translate, *glyph->fPath, strokeInfo); + fContext->drawPath(fPaint, SkMatrix::I(), tmpPath, strokeInfo); // remove this glyph from the vertices we need to allocate fTotalVertexCount -= kVerticesPerGlyph; diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp index a6cb285a70..8d993fa203 100755 --- a/src/gpu/GrDistanceFieldTextContext.cpp +++ b/src/gpu/GrDistanceFieldTextContext.cpp @@ -535,6 +535,8 @@ bool GrDistanceFieldTextContext::appendGlyph(GrGlyph::PackedID packed, if (NULL == glyph->fPlot) { // needs to be a separate conditional to avoid over-optimization // on Nexus 7 and Nexus 10 + + // If the glyph is too large we fall back to paths if (!uploadGlyph(glyph, scaler)) { if (NULL == glyph->fPath) { SkPath* path = SkNEW(SkPath); @@ -552,13 +554,12 @@ bool GrDistanceFieldTextContext::appendGlyph(GrGlyph::PackedID packed, SkMatrix ctm; ctm.setScale(fTextRatio, fTextRatio); ctm.postTranslate(sx - dx, sy - dy); - GrPaint tmpPaint(fPaint); - tmpPaint.localCoordChange(ctm); - SkMatrix viewM = fViewMatrix; - viewM.preConcat(ctm); + SkPath tmpPath(*glyph->fPath); + tmpPath.transform(ctm); + GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); - fContext->drawPath(tmpPaint, viewM, *glyph->fPath, strokeInfo); + fContext->drawPath(fPaint, fViewMatrix, tmpPath, strokeInfo); // remove this glyph from the vertices we need to allocate fTotalVertexCount -= kVerticesPerGlyph; -- 2.34.1