aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrOvalEffect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/effects/GrOvalEffect.cpp')
-rw-r--r--src/gpu/effects/GrOvalEffect.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index b64ac56859..6ad6e7b988 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -66,6 +66,7 @@ void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const {
CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar r)
: INHERITED(kModulatesInput_OptimizationFlag), fCenter(c), fRadius(r), fEdgeType(edgeType) {
this->initClassID<CircleEffect>();
+ this->setWillReadFragmentPosition();
}
bool CircleEffect::onIsEqual(const GrFragmentProcessor& other) const {
@@ -123,6 +124,7 @@ void GLCircleEffect::emitCode(EmitArgs& args) {
&circleName);
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
+ const char* fragmentPos = fragBuilder->fragmentPosition();
SkASSERT(kHairlineAA_GrProcessorEdgeType != ce.getEdgeType());
// TODO: Right now the distance to circle caclulation is performed in a space normalized to the
@@ -130,13 +132,11 @@ void GLCircleEffect::emitCode(EmitArgs& args) {
// mediump. It'd be nice to only to this on mediump devices but we currently don't have the
// caps here.
if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) {
- fragBuilder->codeAppendf("float d = (length((%s.xy - sk_FragCoord.xy) * %s.w) - 1.0) * "
- "%s.z;",
- circleName, circleName, circleName);
+ fragBuilder->codeAppendf("float d = (length((%s.xy - %s.xy) * %s.w) - 1.0) * %s.z;",
+ circleName, fragmentPos, circleName, circleName);
} else {
- fragBuilder->codeAppendf("float d = (1.0 - length((%s.xy - sk_FragCoord.xy) * %s.w)) * "
- "%s.z;",
- circleName, circleName, circleName);
+ fragBuilder->codeAppendf("float d = (1.0 - length((%s.xy - %s.xy) * %s.w)) * %s.z;",
+ circleName, fragmentPos, circleName, circleName);
}
if (GrProcessorEdgeTypeIsAA(ce.getEdgeType())) {
fragBuilder->codeAppend("d = clamp(d, 0.0, 1.0);");
@@ -237,6 +237,7 @@ EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkS
, fRadii(SkVector::Make(rx, ry))
, fEdgeType(edgeType) {
this->initClassID<EllipseEffect>();
+ this->setWillReadFragmentPosition();
}
bool EllipseEffect::onIsEqual(const GrFragmentProcessor& other) const {
@@ -308,9 +309,10 @@ void GLEllipseEffect::emitCode(EmitArgs& args) {
}
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
+ const char* fragmentPos = fragBuilder->fragmentPosition();
// d is the offset to the ellipse center
- fragBuilder->codeAppendf("vec2 d = sk_FragCoord.xy - %s.xy;", ellipseName);
+ fragBuilder->codeAppendf("vec2 d = %s.xy - %s.xy;", fragmentPos, ellipseName);
if (scaleName) {
fragBuilder->codeAppendf("d *= %s.y;", scaleName);
}