aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-04-19 08:44:21 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-19 19:48:14 +0000
commit33c442206af737d60b120e7acc0e2c0f4b786e2c (patch)
tree27582e80b21b4c7ae50f3350f33e031d0f13d971 /src
parent86fe5adf5cc07b6bb177d4d458f66d71ab4c1b63 (diff)
Fix double counting of coverage in analytic round capped stroked circles.
Change-Id: I28d39f8620d786180b0bf0204b18ca4d1fec597b Reviewed-on: https://skia-review.googlesource.com/122086 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 10159bba77..9dc1c91e5b 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -195,12 +195,15 @@ private:
}
fragBuilder->codeAppend("edgeAlpha *= clip;");
if (cgp.fInRoundCapCenters) {
+ // We compute coverage of the round caps as circles at the butt caps produced
+ // by the clip planes. The inverse of the clip planes is applied so that there
+ // is no double counting.
fragBuilder->codeAppendf(
"half dcap1 = circleEdge.z * (%s - length(circleEdge.xy - "
" roundCapCenters.xy));"
"half dcap2 = circleEdge.z * (%s - length(circleEdge.xy - "
" roundCapCenters.zw));"
- "half capAlpha = max(dcap1, 0) + max(dcap2, 0);"
+ "half capAlpha = (1 - clip) * (max(dcap1, 0) + max(dcap2, 0));"
"edgeAlpha = min(edgeAlpha + capAlpha, 1.0);",
capRadius.fsIn(), capRadius.fsIn());
}