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:
parent
57bc3ea6fa
commit
164f6ecb84
@ -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)
|
||||
|
@ -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>();
|
||||
}
|
||||
|
@ -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 {}
|
||||
|
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user