aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-05-11 10:23:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-11 14:52:56 +0000
commit1c4c1144c980e672b6744adb3f30e11cb2d54750 (patch)
treed7e6073b4538477d521a3e98ec446400c581bb78
parent6a4dc66990f73b9443816e69054f101386197593 (diff)
Fix transparent ambient for perspective shadows
When splitting the long edges for the ambient code, I wasn't adding the corresponding triangle for the new point into the center region for transparent occluders. Change-Id: Ie2d1dcffbd701c0750d5da95e9d673b700a0e85a Reviewed-on: https://skia-review.googlesource.com/16492 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
-rwxr-xr-xsrc/utils/SkShadowTessellator.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utils/SkShadowTessellator.cpp b/src/utils/SkShadowTessellator.cpp
index 9a82ec3bfa..d8990d344a 100755
--- a/src/utils/SkShadowTessellator.cpp
+++ b/src/utils/SkShadowTessellator.cpp
@@ -449,6 +449,16 @@ SkAmbientShadowTessellator::SkAmbientShadowTessellator(const SkPath& path,
*fIndices.push() = fPositions.count() - 1;
*fIndices.push() = fPositions.count() - 2;
+ // if transparent, add point to first one in array and add to center fan
+ if (fTransparent) {
+ fPositions[0] += centerPoint;
+ ++fCentroidCount;
+
+ *fIndices.push() = 0;
+ *fIndices.push() = fPrevUmbraIndex;
+ *fIndices.push() = fPositions.count() - 2;
+ }
+
fPrevUmbraIndex = fPositions.count() - 2;
}
@@ -479,6 +489,7 @@ SkAmbientShadowTessellator::SkAmbientShadowTessellator(const SkPath& path,
// finalize centroid
if (fTransparent) {
fPositions[0] *= SkScalarFastInvert(fCentroidCount);
+ fColors[0] = this->umbraColor(fTransformedHeightFunc(fPositions[0]));
*fIndices.push() = 0;
*fIndices.push() = fPrevUmbraIndex;
@@ -606,6 +617,16 @@ void SkAmbientShadowTessellator::addEdge(const SkPoint& nextPoint, const SkVecto
*fIndices.push() = fPositions.count() - 3;
}
+ // if transparent, add point to first one in array and add to center fan
+ if (fTransparent) {
+ fPositions[0] += centerPoint;
+ ++fCentroidCount;
+
+ *fIndices.push() = 0;
+ *fIndices.push() = fPrevUmbraIndex;
+ *fIndices.push() = fPositions.count() - 2;
+ }
+
fPrevUmbraIndex = fPositions.count() - 2;
}