Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: src/effects/SkGaussianEdgeShader.cpp

Issue 2316593003: Add GM/slide to simulate Android-style reveal clip (Closed)
Patch Set: address code review comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/GMSampleView.cpp ('k') | src/gpu/glsl/GrGLSLProgramBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkGaussianEdgeShader.cpp
diff --git a/src/effects/SkGaussianEdgeShader.cpp b/src/effects/SkGaussianEdgeShader.cpp
index d73bfadbd77bead16a7c33f836186fd313a2bde1..01b0606c01b02d09d27854ba2783d87a5aa9734b 100644
--- a/src/effects/SkGaussianEdgeShader.cpp
+++ b/src/effects/SkGaussianEdgeShader.cpp
@@ -67,17 +67,25 @@ public:
GLSLGaussianEdgeFP() {}
void emitCode(EmitArgs& args) override {
-
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
- fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor);
- fragBuilder->codeAppend("float radius = color.g*64.0;");
- fragBuilder->codeAppend("float pad = color.b*64.0;");
-
- fragBuilder->codeAppendf("float factor = 1.0 - clamp((%s.z - pad)/radius, 0.0, 1.0);",
- fragBuilder->distanceVectorName());
- fragBuilder->codeAppend("factor = exp(-factor * factor * 4.0) - 0.018;");
- fragBuilder->codeAppendf("%s = factor*vec4(0.0, 0.0, 0.0, color.r);", args.fOutputColor);
+ if (!args.fGpImplementsDistanceVector) {
+ fragBuilder->codeAppendf("// GP does not implement fsDistanceVector - "
+ " returning grey in GLSLGaussianEdgeFP\n");
+ fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppendf("%s = vec4(0, 0, 0, color.r);", args.fOutputColor);
+ } else {
+ fragBuilder->codeAppendf("vec4 color = %s;", args.fInputColor);
+ fragBuilder->codeAppend("float radius = color.g*64.0;");
+ fragBuilder->codeAppend("float pad = color.b*64.0;");
+
+ fragBuilder->codeAppendf("float factor = 1.0 - clamp((%s.z - pad)/radius,"
+ "0.0, 1.0);",
+ fragBuilder->distanceVectorName());
+ fragBuilder->codeAppend("factor = exp(-factor * factor * 4.0) - 0.018;");
+ fragBuilder->codeAppendf("%s = factor*vec4(0.0, 0.0, 0.0, color.r);",
+ args.fOutputColor);
+ }
}
static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
@@ -133,7 +141,6 @@ sk_sp<SkFlattenable> SkGaussianEdgeShaderImpl::CreateProc(SkReadBuffer& buf) {
}
void SkGaussianEdgeShaderImpl::flatten(SkWriteBuffer& buf) const {
- this->INHERITED::flatten(buf);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « samplecode/GMSampleView.cpp ('k') | src/gpu/glsl/GrGLSLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698