aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-07-26 13:11:51 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-26 17:52:00 +0000
commit1a2a7abe96d258399cca111ea55594599b461c33 (patch)
tree84e6a556766931cb8df890b8fa03c981fddac42e /src/gpu/effects
parentdf6660f64e4d915de7471c3daa67f9b68037ff3f (diff)
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>
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp14
-rw-r--r--src/gpu/effects/GrNonlinearColorSpaceXformEffect.h3
-rw-r--r--src/gpu/effects/GrRRectEffect.cpp13
-rw-r--r--src/gpu/effects/GrSRGBEffect.cpp2
-rw-r--r--src/gpu/effects/GrSRGBEffect.h2
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp18
-rw-r--r--src/gpu/effects/GrTextureDomain.h3
7 files changed, 53 insertions, 2 deletions
diff --git a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
index c0573e915a..8153725460 100644
--- a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
+++ b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.cpp
@@ -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) {
diff --git a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.h b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.h
index 02b57e475c..f57c64b93b 100644
--- a/src/gpu/effects/GrNonlinearColorSpaceXformEffect.h
+++ b/src/gpu/effects/GrNonlinearColorSpaceXformEffect.h
@@ -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;
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 56dc2eec43..edf8eb6c37 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -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;
diff --git a/src/gpu/effects/GrSRGBEffect.cpp b/src/gpu/effects/GrSRGBEffect.cpp
index 294e7f4551..ed924b35ff 100644
--- a/src/gpu/effects/GrSRGBEffect.cpp
+++ b/src/gpu/effects/GrSRGBEffect.cpp
@@ -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;
diff --git a/src/gpu/effects/GrSRGBEffect.h b/src/gpu/effects/GrSRGBEffect.h
index 13d8bc3cb9..ef6fd28800 100644
--- a/src/gpu/effects/GrSRGBEffect.h
+++ b/src/gpu/effects/GrSRGBEffect.h
@@ -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);
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index f2b78586d7..17ad223c2c 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -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;
}
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index f6970ea46e..c74a9919c4 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -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;