Implement clone() for 4 additional GrFragmentProcessor subclasses

HighContrastFilterEffect
LumaColorFilterEffect
OverdrawFragmentProcessor
RRectsGaussianEdgeFP

Change-Id: Ie843e025e49dd46e3f75a5f79d399ddd3ceba5cd
Reviewed-on: https://skia-review.googlesource.com/26660
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Brian Salomon 2017-07-25 15:32:17 -04:00 committed by Skia Commit-Bot
parent 57bc3ea6fa
commit 164f6ecb84
4 changed files with 33 additions and 11 deletions

View File

@ -174,6 +174,8 @@ public:
const SkHighContrastConfig& config() const { return fConfig; }
sk_sp<GrFragmentProcessor> clone() const override { return Make(fConfig); }
private:
HighContrastFilterEffect(const SkHighContrastConfig& config)
: INHERITED(kNone_OptimizationFlags)

View File

@ -51,6 +51,9 @@ public:
const char* name() const override { return "Luminance-to-Alpha"; }
sk_sp<GrFragmentProcessor> clone() const override { return Make(); }
private:
class GLSLProcessor : public GrGLSLFragmentProcessor {
public:
static void GenKey(const GrProcessor&, const GrShaderCaps&, GrProcessorKeyBuilder*) {}
@ -75,7 +78,6 @@ public:
typedef GrGLSLFragmentProcessor INHERITED;
};
private:
LumaColorFilterEffect() : INHERITED(kConstantOutputForConstantInput_OptimizationFlag) {
this->initClassID<LumaColorFilterEffect>();
}

View File

@ -76,6 +76,11 @@ public:
static sk_sp<GrFragmentProcessor> Make(const SkPMColor* colors);
const char* name() const override { return "Overdraw"; }
sk_sp<GrFragmentProcessor> clone() const override {
return sk_sp<GrFragmentProcessor>(new OverdrawFragmentProcessor(fColors));
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}

View File

@ -209,9 +209,22 @@ public:
return sk_sp<GrFragmentProcessor>(new RRectsGaussianEdgeFP(first, second, radius));
}
const char* name() const override { return "RRectsGaussianEdgeFP"; }
sk_sp<GrFragmentProcessor> clone() const override {
return sk_sp<GrFragmentProcessor>(new RRectsGaussianEdgeFP(*this));
}
const SkRRect& first() const { return fFirst; }
Mode firstMode() const { return fFirstMode; }
const SkRRect& second() const { return fSecond; }
Mode secondMode() const { return fSecondMode; }
SkScalar radius() const { return fRadius; }
private:
class GLSLRRectsGaussianEdgeFP : public GrGLSLFragmentProcessor {
public:
GLSLRRectsGaussianEdgeFP() { }
GLSLRRectsGaussianEdgeFP() {}
// This method emits code so that, for each shape, the distance from the edge is returned
// in 'outputName' clamped to 0..1 with positive distance being towards the center of the
@ -447,15 +460,6 @@ public:
GLSLRRectsGaussianEdgeFP::GenKey(*this, caps, b);
}
const char* name() const override { return "RRectsGaussianEdgeFP"; }
const SkRRect& first() const { return fFirst; }
Mode firstMode() const { return fFirstMode; }
const SkRRect& second() const { return fSecond; }
Mode secondMode() const { return fSecondMode; }
SkScalar radius() const { return fRadius; }
private:
RRectsGaussianEdgeFP(const SkRRect& first, const SkRRect& second, SkScalar radius)
: INHERITED(kCompatibleWithCoverageAsAlpha_OptimizationFlag)
, fFirst(first)
@ -466,6 +470,15 @@ private:
fFirstMode = ComputeMode(fFirst);
fSecondMode = ComputeMode(fSecond);
}
RRectsGaussianEdgeFP(const RRectsGaussianEdgeFP& that)
: INHERITED(kCompatibleWithCoverageAsAlpha_OptimizationFlag)
, fFirst(that.fFirst)
, fFirstMode(that.fFirstMode)
, fSecond(that.fSecond)
, fSecondMode(that.fSecondMode)
, fRadius(that.fRadius) {
this->initClassID<RRectsGaussianEdgeFP>();
}
static Mode ComputeMode(const SkRRect& rr) {
if (rr.isCircle()) {