diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-02-09 17:01:22 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-13 14:49:09 +0000 |
commit | 3865711259e25a90a1d72480f848863ada202067 (patch) | |
tree | 4fc40848238f7d38123fa19032513751923e6bea /src/effects | |
parent | b34727f1a3150de2e3e95beb79900a0a848a984c (diff) |
Replaced all calls to fragmentPosition() with sk_FragCoord
Change-Id: I2ed4558aea74b3ae7ee11dfe4736cdbcb16ae49e
Reviewed-on: https://skia-review.googlesource.com/8278
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/GrCircleBlurFragmentProcessor.cpp | 8 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 10 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 16 | ||||
-rw-r--r-- | src/effects/SkRRectsGaussianEdgeMaskFilter.cpp | 5 |
4 files changed, 12 insertions, 27 deletions
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp index d161195a64..c54a71c809 100644 --- a/src/effects/GrCircleBlurFragmentProcessor.cpp +++ b/src/effects/GrCircleBlurFragmentProcessor.cpp @@ -47,7 +47,6 @@ void GrCircleBlurFragmentProcessor::GLSLProcessor::emitCode(EmitArgs& args) { &dataName); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; - const char *fragmentPos = fragBuilder->fragmentPosition(); if (args.fInputColor) { fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); @@ -57,9 +56,9 @@ void GrCircleBlurFragmentProcessor::GLSLProcessor::emitCode(EmitArgs& args) { // We just want to compute "(length(vec) - %s.z + 0.5) * %s.w" but need to rearrange // for precision. - fragBuilder->codeAppendf("vec2 vec = vec2( (%s.x - %s.x) * %s.w , (%s.y - %s.y) * %s.w );", - fragmentPos, dataName, dataName, - fragmentPos, dataName, dataName); + fragBuilder->codeAppendf("vec2 vec = vec2( (sk_FragCoord.x - %s.x) * %s.w, " + "(sk_FragCoord.y - %s.y) * %s.w );", + dataName, dataName, dataName, dataName); fragBuilder->codeAppendf("float dist = length(vec) + (0.5 - %s.z) * %s.w;", dataName, dataName); @@ -96,7 +95,6 @@ GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(const SkRect& circl , fBlurProfileSampler(blurProfile, GrSamplerParams::kBilerp_FilterMode) { this->initClassID<GrCircleBlurFragmentProcessor>(); this->addTextureSampler(&fBlurProfileSampler); - this->setWillReadFragmentPosition(); } GrGLSLFragmentProcessor* GrCircleBlurFragmentProcessor::onCreateGLSLInstance() const { diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 225d6f67cc..f41648dc4b 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -904,7 +904,6 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) { &profileSizeName); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; - const char *fragmentPos = fragBuilder->fragmentPosition(); if (args.fInputColor) { fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); @@ -912,8 +911,8 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) { fragBuilder->codeAppendf("vec4 src=vec4(1);"); } - fragBuilder->codeAppendf("%s vec2 translatedPos = %s.xy - %s.xy;", precisionString.c_str(), - fragmentPos, rectName); + fragBuilder->codeAppendf("%s vec2 translatedPos = sk_FragCoord.xy - %s.xy;", + precisionString.c_str(), rectName); fragBuilder->codeAppendf("%s float width = %s.z - %s.x;", precisionString.c_str(), rectName, rectName); fragBuilder->codeAppendf("%s float height = %s.w - %s.y;", precisionString.c_str(), rectName, @@ -984,7 +983,6 @@ GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture* b , fPrecision(precision) { this->initClassID<GrRectBlurEffect>(); this->addTextureSampler(&fBlurProfileSampler); - this->setWillReadFragmentPosition(); } void GrRectBlurEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, @@ -1218,7 +1216,6 @@ GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur , fNinePatchSampler(ninePatchTexture) { this->initClassID<GrRRectBlurEffect>(); this->addTextureSampler(&fNinePatchSampler); - this->setWillReadFragmentPosition(); } bool GrRRectBlurEffect::onIsEqual(const GrFragmentProcessor& other) const { @@ -1286,12 +1283,11 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) { &blurRadiusName); GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; - const char* fragmentPos = fragBuilder->fragmentPosition(); // warp the fragment position to the appropriate part of the 9patch blur texture fragBuilder->codeAppendf("vec2 rectCenter = (%s.xy + %s.zw)/2.0;", rectName, rectName); - fragBuilder->codeAppendf("vec2 translatedFragPos = %s.xy - %s.xy;", fragmentPos, rectName); + fragBuilder->codeAppendf("vec2 translatedFragPos = sk_FragCoord.xy - %s.xy;", rectName); fragBuilder->codeAppendf("float threshold = %s + 2.0*%s;", cornerRadiusName, blurRadiusName); fragBuilder->codeAppendf("vec2 middle = %s.zw - %s.xy - 2.0*threshold;", rectName, rectName); diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 92057f0802..fc7b29b490 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -770,8 +770,6 @@ public: virtual bool isEqual(const SkImageFilterLight& other) const { return fColor == other.fColor; } - // Called to know whether the generated GrGLLight will require access to the fragment position. - virtual bool requiresFragmentPosition() const = 0; virtual SkImageFilterLight* transform(const SkMatrix& matrix) const = 0; // Defined below SkLight's subclasses. @@ -820,7 +818,6 @@ public: return nullptr; #endif } - bool requiresFragmentPosition() const override { return false; } bool isEqual(const SkImageFilterLight& other) const override { if (other.type() != kDistant_LightType) { @@ -879,7 +876,6 @@ public: return nullptr; #endif } - bool requiresFragmentPosition() const override { return true; } bool isEqual(const SkImageFilterLight& other) const override { if (other.type() != kPoint_LightType) { return false; @@ -993,7 +989,6 @@ public: return nullptr; #endif } - bool requiresFragmentPosition() const override { return true; } LightType type() const override { return kSpot_LightType; } const SkPoint3& location() const { return fLocation; } const SkPoint3& target() const { return fTarget; } @@ -1715,9 +1710,6 @@ GrLightingEffect::GrLightingEffect(GrTexture* texture, , fBoundaryMode(boundaryMode) , fDomain(create_domain(texture, srcBounds, GrTextureDomain::kDecal_Mode)) { fLight->ref(); - if (light->requiresFragmentPosition()) { - this->setWillReadFragmentPosition(); - } } GrLightingEffect::~GrLightingEffect() { @@ -2102,8 +2094,8 @@ void GrGLPointLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler, fLocationUni = uniformHandler->addUniform(kFragment_GrShaderFlag, kVec3f_GrSLType, kDefault_GrSLPrecision, "LightLocation", &loc); - fragBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))", - loc, fragBuilder->fragmentPosition(), z); + fragBuilder->codeAppendf("normalize(%s - vec3(sk_FragCoord.xy, %s))", + loc, z); } /////////////////////////////////////////////////////////////////////////////// @@ -2129,8 +2121,8 @@ void GrGLSpotLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler, kVec3f_GrSLType, kDefault_GrSLPrecision, "LightLocation", &location); - fragBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))", - location, fragBuilder->fragmentPosition(), z); + fragBuilder->codeAppendf("normalize(%s - vec3(sk_FragCoord.xy, %s))", + location, z); } void GrGLSpotLight::emitLightColor(GrGLSLUniformHandler* uniformHandler, diff --git a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp index f6b2ce31b5..223887bab9 100644 --- a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp +++ b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp @@ -209,7 +209,6 @@ public: RRectsGaussianEdgeFP(const SkRRect& first, const SkRRect& second, SkScalar radius) : INHERITED(kNone_OptimizationFlags), fFirst(first), fSecond(second), fRadius(radius) { this->initClassID<RRectsGaussianEdgeFP>(); - this->setWillReadFragmentPosition(); fFirstMode = ComputeMode(fFirst); fSecondMode = ComputeMode(fSecond); @@ -233,8 +232,8 @@ public: // Positive distance is towards the center of the circle. // Map all the cases to the lower right quadrant. - fragBuilder->codeAppendf("vec2 delta = abs(%s.xy - %s.%s);", - fragBuilder->fragmentPosition(), posName, indices); + fragBuilder->codeAppendf("vec2 delta = abs(sk_FragCoord.xy - %s.%s);", + posName, indices); switch (mode) { case kCircle_Mode: |