aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuqian Li <liyuqian@google.com>2018-04-23 13:14:43 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-23 17:39:40 +0000
commit5cf172683c231db05e16833a83f783826e80e908 (patch)
tree3ebee83ee380fcfbd70b9454aa08e03c4073ebb4 /src
parent1849ffdc583f42d46cb9793553dc96f4cec8052e (diff)
Clip the SkAntiRect because of possible tilings
Otherwise, the AndroidShadow will crash or draw incorrectly for the threaded backend with # tiles >= 3. Bug: skia: Change-Id: If3c3b41f3576b1c44178d6343626e99be64e766b Reviewed-on: https://skia-review.googlesource.com/122953 Commit-Queue: Yuqian Li <liyuqian@google.com> Auto-Submit: Yuqian Li <liyuqian@google.com> Reviewed-by: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBlitter.cpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index d8cea8f17b..e53a523084 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -115,10 +115,39 @@ void SkBlitter::blitCoverageDeltas(SkCoverageDeltaList* deltas, const SkIRect& c
int top = SkTMax(deltas->top(), clip.fTop);
int bottom = SkTMin(deltas->bottom(), clip.fBottom);
for(int y = top; y < bottom; ++y) {
- // If antiRect is non-empty and we're at its top row, blit it and skip to the bottom
- if (antiRect.fHeight && y == antiRect.fY) {
- this->blitAntiRect(antiRect.fX, antiRect.fY, antiRect.fWidth, antiRect.fHeight,
- antiRect.fLeftAlpha, antiRect.fRightAlpha);
+ // If antiRect is non-empty and we're in it, blit it and skip to the bottom
+ if (y >= antiRect.fY && y < antiRect.fY + antiRect.fHeight) {
+ // Clip the antiRect because of possible tilings (e.g., the threaded backend)
+ int leftOverClip = clip.fLeft - antiRect.fX;
+ int rightOverClip = antiRect.fX + antiRect.fWidth - clip.fRight;
+ int topOverClip = clip.fTop - antiRect.fY;
+ int botOverClip = antiRect.fY + antiRect.fHeight - clip.fBottom;
+
+ int x = antiRect.fX;
+ int y = antiRect.fY;
+ int width = antiRect.fWidth;
+ int height = antiRect.fHeight;
+ SkAlpha leftAlpha = antiRect.fLeftAlpha;
+ SkAlpha rightAlpha = antiRect.fRightAlpha;
+
+ if (leftOverClip > 0) {
+ x = clip.fLeft;
+ width -= leftOverClip;
+ leftAlpha = 0xFF;
+ }
+ if (rightOverClip > 0) {
+ width -= rightOverClip;
+ rightAlpha = 0xFF;
+ }
+ if (topOverClip > 0) {
+ y = clip.fTop;
+ height -= topOverClip;
+ }
+ if (botOverClip > 0) {
+ height -= botOverClip;
+ }
+
+ this->blitAntiRect(x, y, width, height, leftAlpha, rightAlpha);
y += antiRect.fHeight - 1; // -1 because ++y in the for loop
continue;
}