Skip to content

Commit

Permalink
do reject vertical lines if they are outside of the clip
Browse files Browse the repository at this point in the history
Bug: skia:7981
Change-Id: Icae11ac2934bc6db5a5c3ad0f17aaf615efa2fe5
Reviewed-on: https://skia-review.googlesource.com/149291
Auto-Submit: Mike Reed <reed@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
  • Loading branch information
reed-at-google authored and Skia Commit-Bot committed Aug 25, 2018
1 parent 95be425 commit 3054989
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/SkLineClipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ bool SkLineClipper::IntersectLine(const SkPoint src[2], const SkRect& clip,
}

// check for quick-reject in X again, now that we may have been chopped
if ((tmp[index1].fX <= clip.fLeft || tmp[index0].fX >= clip.fRight) &&
tmp[index0].fX < tmp[index1].fX) {
// only reject if we have a non-zero width
return false;
if ((tmp[index1].fX <= clip.fLeft || tmp[index0].fX >= clip.fRight)) {
// usually we will return false, but we don't if the line is vertical and coincident
// with the clip.
if (tmp[0].fX != tmp[1].fX || tmp[0].fX < clip.fLeft || tmp[0].fX > clip.fRight) {
return false;
}
}

if (tmp[index0].fX < clip.fLeft) {
Expand Down
11 changes: 11 additions & 0 deletions tests/ClipperTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,14 @@ DEF_TEST(Clipper, reporter) {
test_edgeclipper();
test_hairclipping(reporter);
}

#include "SkLineClipper.h"

DEF_TEST(LineClipper_skbug_7981, r) {
SkPoint src[] = {{ -5.77698802E+17f, -1.81758057E+23f}, {38127, 2}};
SkPoint dst[2];
SkRect clip = { -32767, -32767, 32767, 32767 };

SkLineClipper::IntersectLine(src, clip, dst);
}

0 comments on commit 3054989

Please sign in to comment.