Revert "use GrFPArgs for maskfilters"

This reverts commit a99b393995.

Reason for revert: try to unblock android roller

Original change's description:
> use GrFPArgs for maskfilters
> 
> Bug: skia:
> Change-Id: I8516a3b0f6d8301c51f0861c65b9fe8f692fc5e5
> Reviewed-on: https://skia-review.googlesource.com/97260
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,reed@google.com

Change-Id: Iefe8ed19bba75df86173dec53f5ed4f1ea8724d0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/97581
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2018-01-20 14:49:21 +00:00 committed by Skia Commit-Bot
parent 3d628fe00a
commit 4f7f197c09
6 changed files with 27 additions and 54 deletions

View File

@ -6,6 +6,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
#ifndef SkMaskFilter_DEFINED #ifndef SkMaskFilter_DEFINED
#define SkMaskFilter_DEFINED #define SkMaskFilter_DEFINED
@ -17,7 +18,6 @@
class GrClip; class GrClip;
class GrContext; class GrContext;
struct GrFPArgs;
class GrRenderTargetContext; class GrRenderTargetContext;
class GrPaint; class GrPaint;
class GrFragmentProcessor; class GrFragmentProcessor;
@ -69,18 +69,16 @@ public:
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
/** /**
* Returns a processor if the filter can be expressed a single-pass GrProcessor without * Returns true if the filter can be expressed a single-pass GrProcessor without requiring an
* requiring an explicit input mask. Per-pixel, the effect receives the incoming mask's * explicit input mask. Per-pixel, the effect receives the incoming mask's coverage as
* coverage as the input color and outputs the filtered covereage value. This means that each * the input color and outputs the filtered covereage value. This means that each pixel's
* pixel's filtered coverage must only depend on the unfiltered mask value for that pixel and * filtered coverage must only depend on the unfiltered mask value for that pixel and not on
* not on surrounding values. * surrounding values.
*
* If effect is non-NULL, a new GrProcessor instance is stored in it. The caller assumes
* ownership of the effect and must unref it.
*/ */
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs& args) const; virtual bool asFragmentProcessor(GrFragmentProcessor**) const { return false; }
/**
* Returns true iff asFragmentProcessor() will return a processor
*/
bool hasFragmentProcessor() const;
/** /**
* If asFragmentProcessor() fails the filter may be implemented on the GPU by a subclass * If asFragmentProcessor() fails the filter may be implemented on the GPU by a subclass
@ -181,11 +179,6 @@ public:
protected: protected:
SkMaskFilter() {} SkMaskFilter() {}
#if SK_SUPPORT_GPU
virtual std::unique_ptr<GrFragmentProcessor> onAsFragmentProcessor(const GrFPArgs&) const;
virtual bool onHasFragmentProcessor() const;
#endif
enum FilterReturn { enum FilterReturn {
kFalse_FilterReturn, kFalse_FilterReturn,
kTrue_FilterReturn, kTrue_FilterReturn,

View File

@ -17,7 +17,6 @@
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "GrTextureProxy.h" #include "GrTextureProxy.h"
#include "GrFragmentProcessor.h"
#endif #endif
SkMaskFilter::NinePatch::~NinePatch() { SkMaskFilter::NinePatch::~NinePatch() {
@ -302,24 +301,6 @@ SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&,
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkMaskFilter::asFragmentProcessor(const GrFPArgs& args) const {
auto fp = this->onAsFragmentProcessor(args);
if (fp) {
SkASSERT(this->hasFragmentProcessor());
} else {
SkASSERT(!this->hasFragmentProcessor());
}
return fp;
}
bool SkMaskFilter::hasFragmentProcessor() const {
return this->onHasFragmentProcessor();
}
std::unique_ptr<GrFragmentProcessor> SkMaskFilter::onAsFragmentProcessor(const GrFPArgs&) const {
return nullptr;
}
bool SkMaskFilter::onHasFragmentProcessor() const { return false; }
bool SkMaskFilter::canFilterMaskGPU(const SkRRect& devRRect, bool SkMaskFilter::canFilterMaskGPU(const SkRRect& devRRect,
const SkIRect& clipBounds, const SkIRect& clipBounds,
const SkMatrix& ctm, const SkMatrix& ctm,

View File

@ -32,17 +32,16 @@ public:
bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
SkIPoint* margin) const override; SkIPoint* margin) const override;
#if SK_SUPPORT_GPU
bool asFragmentProcessor(GrFragmentProcessor**) const override;
#endif
SK_TO_STRING_OVERRIDE() SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRRectsGaussianEdgeMaskFilterImpl) SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRRectsGaussianEdgeMaskFilterImpl)
protected: protected:
void flatten(SkWriteBuffer&) const override; void flatten(SkWriteBuffer&) const override;
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> onAsFragmentProcessor(const GrFPArgs& args) const override;
bool onHasFragmentProcessor() const override { return true; }
#endif
private: private:
SkRRect fFirst; SkRRect fFirst;
SkRRect fSecond; SkRRect fSecond;
@ -510,10 +509,12 @@ private:
}; };
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
bool SkRRectsGaussianEdgeMaskFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp) const {
if (fp) {
*fp = RRectsGaussianEdgeFP::Make(fFirst, fSecond, fRadius).release();
}
std::unique_ptr<GrFragmentProcessor> return true;
SkRRectsGaussianEdgeMaskFilterImpl::onAsFragmentProcessor(const GrFPArgs& args) const {
return RRectsGaussianEdgeFP::Make(fFirst, fSecond, fRadius);
} }
#endif #endif

View File

@ -298,7 +298,7 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
} }
GrAA aa = GrAA(paint.isAntiAlias()); GrAA aa = GrAA(paint.isAntiAlias());
SkMaskFilter* mf = paint.getMaskFilter(); SkMaskFilter* mf = paint.getMaskFilter();
if (mf && !mf->hasFragmentProcessor()) { if (mf && !mf->asFragmentProcessor(nullptr)) {
// The MaskFilter wasn't already handled in SkPaintToGrPaint // The MaskFilter wasn't already handled in SkPaintToGrPaint
draw_path_with_mask_filter(context, renderTargetContext, clip, std::move(grPaint), aa, draw_path_with_mask_filter(context, renderTargetContext, clip, std::move(grPaint), aa,
viewMatrix, mf, style, path, pathIsMutable); viewMatrix, mf, style, path, pathIsMutable);

View File

@ -403,10 +403,8 @@ void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
} }
SkMaskFilter* mf = paint.getMaskFilter(); SkMaskFilter* mf = paint.getMaskFilter();
if (mf) { if (mf && mf->asFragmentProcessor(nullptr)) {
if (mf->hasFragmentProcessor()) { mf = nullptr; // already handled in SkPaintToGrPaint
mf = nullptr; // already handled in SkPaintToGrPaint
}
} }
GrStyle style(paint); GrStyle style(paint);

View File

@ -375,8 +375,6 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
// Convert SkPaint color to 4f format, including optional linearizing and gamut conversion. // Convert SkPaint color to 4f format, including optional linearizing and gamut conversion.
GrColor4f origColor = SkColorToUnpremulGrColor4f(skPaint.getColor(), colorSpaceInfo); GrColor4f origColor = SkColorToUnpremulGrColor4f(skPaint.getColor(), colorSpaceInfo);
const GrFPArgs fpArgs(context, &viewM, nullptr, skPaint.getFilterQuality(), &colorSpaceInfo);
// Setup the initial color considering the shader, the SkPaint color, and the presence or not // Setup the initial color considering the shader, the SkPaint color, and the presence or not
// of per-vertex colors. // of per-vertex colors.
std::unique_ptr<GrFragmentProcessor> shaderFP; std::unique_ptr<GrFragmentProcessor> shaderFP;
@ -384,7 +382,8 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
if (shaderProcessor) { if (shaderProcessor) {
shaderFP = std::move(*shaderProcessor); shaderFP = std::move(*shaderProcessor);
} else if (const auto* shader = as_SB(skPaint.getShader())) { } else if (const auto* shader = as_SB(skPaint.getShader())) {
shaderFP = shader->asFragmentProcessor(fpArgs); shaderFP = shader->asFragmentProcessor(GrFPArgs(
context, &viewM, nullptr, skPaint.getFilterQuality(), &colorSpaceInfo));
} }
} }
@ -479,8 +478,9 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
SkMaskFilter* maskFilter = skPaint.getMaskFilter(); SkMaskFilter* maskFilter = skPaint.getMaskFilter();
if (maskFilter) { if (maskFilter) {
if (auto mfFP = maskFilter->asFragmentProcessor(fpArgs)) { GrFragmentProcessor* mfFP;
grPaint->addCoverageFragmentProcessor(std::move(mfFP)); if (maskFilter->asFragmentProcessor(&mfFP)) {
grPaint->addCoverageFragmentProcessor(std::unique_ptr<GrFragmentProcessor>(mfFP));
} }
} }