diff options
author | 2016-10-20 09:40:55 -0400 | |
---|---|---|
committer | 2016-10-20 14:06:52 +0000 | |
commit | a29a956d0e27819b97592404ae1ec6cc8e7b1045 (patch) | |
tree | 1e5d884a5d0f7f881a2e8fd5579672edd80fc2a9 /src/gpu | |
parent | e1d6ff172e219d3be61949b0e44091f4c85de2ad (diff) |
Add SkRRectsGaussianEdgeMaskFilter
SkRRectsGaussianEdgeShader will be removed once the usage of the
MaskFilter flavor has been propagated to Android
I will complete the raster implementation in a follow up CL.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3632
Change-Id: I42470b17308582b040a5db1a7283c3d717405345
Reviewed-on: https://skia-review.googlesource.com/3632
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrBlurUtils.cpp | 6 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 26 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 9 |
3 files changed, 25 insertions, 16 deletions
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp index 5f575e3c84..a167101c8c 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -285,9 +285,11 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, return; } - if (paint.getMaskFilter()) { + SkMaskFilter* mf = paint.getMaskFilter(); + if (mf && !mf->asFragmentProcessor(nullptr, nullptr, viewMatrix)) { + // The MaskFilter wasn't already handled in SkPaintToGrPaint draw_path_with_mask_filter(context, drawContext, clip, &grPaint, viewMatrix, - paint.getMaskFilter(), style, + mf, style, path, pathIsMutable); } else { drawContext->drawPath(clip, grPaint, viewMatrix, *path, style); diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 0957412697..8164f4a247 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -419,32 +419,30 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, return; } + SkMaskFilter* mf = paint.getMaskFilter(); + if (mf && mf->asFragmentProcessor(nullptr, nullptr, *draw.fMatrix)) { + mf = nullptr; // already handled in SkPaintToGrPaint + } + GrStyle style(paint); - if (paint.getMaskFilter()) { + if (mf) { // try to hit the fast path for drawing filtered round rects SkRRect devRRect; if (rrect.transform(*draw.fMatrix, &devRRect)) { if (devRRect.allCornersCircular()) { SkRect maskRect; - if (paint.getMaskFilter()->canFilterMaskGPU(devRRect, - draw.fRC->getBounds(), - *draw.fMatrix, - &maskRect)) { + if (mf->canFilterMaskGPU(devRRect, draw.fRC->getBounds(), + *draw.fMatrix, &maskRect)) { SkIRect finalIRect; maskRect.roundOut(&finalIRect); if (draw.fRC->quickReject(finalIRect)) { // clipped out return; } - if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext, - fDrawContext.get(), - &grPaint, - fClip, - *draw.fMatrix, - style.strokeRec(), - rrect, - devRRect)) { + if (mf->directFilterRRectMaskGPU(fContext, fDrawContext.get(), &grPaint, fClip, + *draw.fMatrix, style.strokeRec(), rrect, + devRRect)) { return; } } @@ -453,7 +451,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, } } - if (paint.getMaskFilter() || style.pathEffect()) { + if (mf || style.pathEffect()) { // The only mask filter the native rrect drawing code could've handle was taken // care of above. // A path effect will presumably transform this rrect into something else. diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 0eb9ee496e..7c008bea17 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -25,6 +25,7 @@ #include "SkConfig8888.h" #include "SkCanvas.h" #include "SkData.h" +#include "SkMaskFilter.h" #include "SkMessageBus.h" #include "SkMipMap.h" #include "SkPixelRef.h" @@ -684,6 +685,14 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context, } } + SkMaskFilter* maskFilter = skPaint.getMaskFilter(); + if (maskFilter) { + GrFragmentProcessor* mfFP; + if (maskFilter->asFragmentProcessor(&mfFP, nullptr, viewM)) { + grPaint->addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor>(mfFP)); + } + } + // When the xfermode is null on the SkPaint (meaning kSrcOver) we need the XPFactory field on // the GrPaint to also be null (also kSrcOver). SkASSERT(!grPaint->getXPFactory()); |