More GrFragmentProcessor::clone() implementations.

GrSRGBEffect
EllipticalRRectEffect
CircularRRectEffect
GrNonlinearColorSpaceXformEffect
GrDeviceSpaceTextureDecalFragmentProcessor

Change-Id: I701fb7ed36e66414adba2eea73f6eed306691b49
Reviewed-on: https://skia-review.googlesource.com/26942
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2017-07-26 13:11:51 -04:00 committed by Skia Commit-Bot
parent df6660f64e
commit 1a2a7abe96
7 changed files with 53 additions and 2 deletions

View File

@ -164,6 +164,20 @@ GrNonlinearColorSpaceXformEffect::GrNonlinearColorSpaceXformEffect(
fDstTransferFnCoeffs[6] = dstTransferFn.fG;
}
GrNonlinearColorSpaceXformEffect::GrNonlinearColorSpaceXformEffect(
const GrNonlinearColorSpaceXformEffect& that)
: INHERITED(kPreservesOpaqueInput_OptimizationFlag)
, fGamutXform(that.fGamutXform)
, fOps(that.fOps) {
this->initClassID<GrNonlinearColorSpaceXformEffect>();
memcpy(fSrcTransferFnCoeffs, that.fSrcTransferFnCoeffs, sizeof(fSrcTransferFnCoeffs));
memcpy(fDstTransferFnCoeffs, that.fDstTransferFnCoeffs, sizeof(fDstTransferFnCoeffs));
}
sk_sp<GrFragmentProcessor> GrNonlinearColorSpaceXformEffect::clone() const {
return sk_sp<GrFragmentProcessor>(new GrNonlinearColorSpaceXformEffect(*this));
}
bool GrNonlinearColorSpaceXformEffect::onIsEqual(const GrFragmentProcessor& s) const {
const GrNonlinearColorSpaceXformEffect& other = s.cast<GrNonlinearColorSpaceXformEffect>();
if (other.fOps != fOps) {

View File

@ -31,6 +31,8 @@ public:
const char* name() const override { return "NonlinearColorSpaceXform"; }
sk_sp<GrFragmentProcessor> clone() const override;
static const int kNumTransferFnCoeffs = 7;
/**
@ -54,6 +56,7 @@ private:
const SkColorSpaceTransferFn& srcTransferFn,
const SkColorSpaceTransferFn& dstTransferFn,
const SkMatrix44& gamutXform);
GrNonlinearColorSpaceXformEffect(const GrNonlinearColorSpaceXformEffect&);
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;

View File

@ -52,6 +52,8 @@ public:
const char* name() const override { return "CircularRRect"; }
sk_sp<GrFragmentProcessor> clone() const override;
const SkRRect& getRRect() const { return fRRect; }
uint32_t getCircularCornerFlags() const { return fCircularCornerFlags; }
@ -95,6 +97,11 @@ CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t
this->initClassID<CircularRRectEffect>();
}
sk_sp<GrFragmentProcessor> CircularRRectEffect::clone() const {
return sk_sp<GrFragmentProcessor>(
new CircularRRectEffect(fEdgeType, fCircularCornerFlags, fRRect));
}
bool CircularRRectEffect::onIsEqual(const GrFragmentProcessor& other) const {
const CircularRRectEffect& crre = other.cast<CircularRRectEffect>();
// The corner flags are derived from fRRect, so no need to check them.
@ -390,6 +397,8 @@ public:
const char* name() const override { return "EllipticalRRect"; }
sk_sp<GrFragmentProcessor> clone() const override;
const SkRRect& getRRect() const { return fRRect; }
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
@ -426,6 +435,10 @@ EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const
this->initClassID<EllipticalRRectEffect>();
}
sk_sp<GrFragmentProcessor> EllipticalRRectEffect::clone() const {
return sk_sp<GrFragmentProcessor>(new EllipticalRRectEffect(fEdgeType, fRRect));
}
bool EllipticalRRectEffect::onIsEqual(const GrFragmentProcessor& other) const {
const EllipticalRRectEffect& erre = other.cast<EllipticalRRectEffect>();
return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect;

View File

@ -85,6 +85,8 @@ GrSRGBEffect::GrSRGBEffect(Mode mode, Alpha alpha)
this->initClassID<GrSRGBEffect>();
}
sk_sp<GrFragmentProcessor> GrSRGBEffect::clone() const { return Make(fMode, fAlpha); }
bool GrSRGBEffect::onIsEqual(const GrFragmentProcessor& s) const {
const GrSRGBEffect& other = s.cast<GrSRGBEffect>();
return other.fMode == fMode;

View File

@ -34,6 +34,8 @@ public:
Mode mode() const { return fMode; }
Alpha alpha() const { return fAlpha; }
sk_sp<GrFragmentProcessor> clone() const override;
private:
GrSRGBEffect(Mode mode, Alpha);

View File

@ -344,6 +344,20 @@ GrDeviceSpaceTextureDecalFragmentProcessor::GrDeviceSpaceTextureDecalFragmentPro
this->initClassID<GrDeviceSpaceTextureDecalFragmentProcessor>();
}
GrDeviceSpaceTextureDecalFragmentProcessor::GrDeviceSpaceTextureDecalFragmentProcessor(
const GrDeviceSpaceTextureDecalFragmentProcessor& that)
: INHERITED(kCompatibleWithCoverageAsAlpha_OptimizationFlag)
, fTextureSampler(that.fTextureSampler)
, fTextureDomain(that.fTextureDomain)
, fDeviceSpaceOffset(that.fDeviceSpaceOffset) {
this->initClassID<GrDeviceSpaceTextureDecalFragmentProcessor>();
this->addTextureSampler(&fTextureSampler);
}
sk_sp<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::clone() const {
return sk_sp<GrFragmentProcessor>(new GrDeviceSpaceTextureDecalFragmentProcessor(*this));
}
GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLSLInstance() const {
class GLSLProcessor : public GrGLSLFragmentProcessor {
public:
@ -401,8 +415,8 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS
bool GrDeviceSpaceTextureDecalFragmentProcessor::onIsEqual(const GrFragmentProcessor& fp) const {
const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp =
fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
return dstdfp.fTextureSampler.proxy()->underlyingUniqueID() ==
fTextureSampler.proxy()->underlyingUniqueID() &&
return dstdfp.fTextureSampler.proxy()->underlyingUniqueID() ==
fTextureSampler.proxy()->underlyingUniqueID() &&
dstdfp.fDeviceSpaceOffset == fDeviceSpaceOffset &&
dstdfp.fTextureDomain == fTextureDomain;
}

View File

@ -211,6 +211,8 @@ public:
return str;
}
sk_sp<GrFragmentProcessor> clone() const override;
private:
TextureSampler fTextureSampler;
GrTextureDomain fTextureDomain;
@ -218,6 +220,7 @@ private:
GrDeviceSpaceTextureDecalFragmentProcessor(sk_sp<GrTextureProxy>,
const SkIRect&, const SkIPoint&);
GrDeviceSpaceTextureDecalFragmentProcessor(const GrDeviceSpaceTextureDecalFragmentProcessor&);
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;