Normalize vectors in dot product for quad type calculations.
Bug: skia: Change-Id: Icb840daf1fd31afdeed387486db54283bb5b85f3 Reviewed-on: https://skia-review.googlesource.com/c/180640 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
parent
016cd021da
commit
7a8d08db55
@ -30,9 +30,7 @@ static bool dot_nearly_zero(const SkVector& e1, const SkVector& e2) {
|
||||
dotValue = dot({sign(e1.fX), sign(e1.fY)}, {sign(e2.fX), sign(e2.fY)});
|
||||
}
|
||||
|
||||
// Unfortunately must have a pretty healthy tolerance here or transformed rects that are
|
||||
// effectively rectilinear will have edge dot products of around .005
|
||||
return SkScalarNearlyZero(dotValue, 1e-2f);
|
||||
return SkScalarNearlyZero(dotValue, 5e-4f);
|
||||
}
|
||||
|
||||
// This is not the most performance critical function; code using GrQuad should rely on the faster
|
||||
@ -45,11 +43,16 @@ static bool coords_form_rect(const float xs[4], const float ys[4]) {
|
||||
}
|
||||
|
||||
static bool coords_rectilinear(const float xs[4], const float ys[4]) {
|
||||
SkVector e0{xs[1] - xs[0], ys[1] - ys[0]}; // Connects to e1 and e2(repeat)
|
||||
SkVector e0{xs[1] - xs[0], ys[1] - ys[0]}; // connects to e1 and e2(repeat)
|
||||
SkVector e1{xs[3] - xs[1], ys[3] - ys[1]}; // connects to e0(repeat) and e3
|
||||
SkVector e2{xs[0] - xs[2], ys[0] - ys[2]}; // connects to e0 and e3(repeat)
|
||||
SkVector e3{xs[2] - xs[3], ys[2] - ys[3]}; // connects to e1(repeat) and e2
|
||||
|
||||
e0.normalize();
|
||||
e1.normalize();
|
||||
e2.normalize();
|
||||
e3.normalize();
|
||||
|
||||
return dot_nearly_zero(e0, e1) && dot_nearly_zero(e1, e3) &&
|
||||
dot_nearly_zero(e2, e0) && dot_nearly_zero(e3, e2);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user