aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar dvonbeck <dvonbeck@google.com>2016-08-08 11:47:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-08 11:47:12 -0700
commit84bca78ab462314ec48614ff50315f28d5467149 (patch)
tree147b6c68d8a26d9145b645bb7059550e64208d63
parent397a517d1a5774653fcdd08172f9a6b5eea67621 (diff)
Split distance vector into direction and magnitude components
The vector was split because the vector's users need it split, and we were creating it from the split components in the first place, so it made sense to skip that step. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2223053002 Review-Url: https://codereview.chromium.org/2223053002
-rw-r--r--src/core/SkNormalBevelSource.cpp5
-rw-r--r--src/gpu/GrOvalRenderer.cpp4
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp5
3 files changed, 7 insertions, 7 deletions
diff --git a/src/core/SkNormalBevelSource.cpp b/src/core/SkNormalBevelSource.cpp
index 04faa0006f..f4bd031c4c 100644
--- a/src/core/SkNormalBevelSource.cpp
+++ b/src/core/SkNormalBevelSource.cpp
@@ -86,10 +86,9 @@ public:
}
// Here we are splitting the distance vector into length and normalized direction
- // TODO: Output these values from the geometry processor frag code instead of the vector
- fragBuilder->codeAppendf("float dv_length = length(%s);",
+ fragBuilder->codeAppendf("float dv_length = %s.z;",
fragBuilder->distanceVectorName());
- fragBuilder->codeAppendf("vec2 dv_norm = normalize(%s);",
+ fragBuilder->codeAppendf("vec2 dv_norm = %s.xy;",
fragBuilder->distanceVectorName());
// Asserting presence of necessary uniforms
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 527b96e2c6..89e35a1d70 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -139,10 +139,10 @@ public:
if (args.fDistanceVectorName) {
fragBuilder->codeAppend ("if (d == 0.0) {"); // if on the center of the circle
- fragBuilder->codeAppendf(" %s = vec2(distanceToEdge, 0.0);", // avoid normalizing
+ fragBuilder->codeAppendf(" %s = vec3(1.0, 0.0, distanceToEdge);", // no normalize
args.fDistanceVectorName);
fragBuilder->codeAppend ("} else {");
- fragBuilder->codeAppendf(" %s = normalize(%s.xy) * distanceToEdge;",
+ fragBuilder->codeAppendf(" %s = vec3(normalize(%s.xy), distanceToEdge);",
args.fDistanceVectorName, v.fsIn());
fragBuilder->codeAppend ("}");
}
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 1f28f19bb9..d0d813d4c2 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -90,8 +90,9 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
const char* distanceVectorName = nullptr;
if (this->fPipeline.usesDistanceVectorField() && proc.implementsDistanceVector()) {
distanceVectorName = fFS.distanceVectorName();
- fFS.codeAppend( "// Un-normalized vector to the closed geometric edge (in source space)\n");
- fFS.codeAppendf("vec2 %s;", distanceVectorName);
+ fFS.codeAppend( "// Normalized vector to the closest geometric edge (in source space)\n");
+ fFS.codeAppend( "// Distance to the edge encoded in the z-component\n");
+ fFS.codeAppendf("vec3 %s;", distanceVectorName);
}
// Enclose custom code in a block to avoid namespace conflicts