use unsigned to allow for using all 32bits for approx distance
Bug:757146 Change-Id: If783f1b36fc70c443d0808947275acf003a872ee Reviewed-on: https://skia-review.googlesource.com/57109 Commit-Queue: Mike Reed <reed@google.com> Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
37387c80cc
commit
c4b015ad5f
@ -196,7 +196,7 @@ void SkScan::HairRect(const SkRect& rect, const SkRasterClip& clip,
|
|||||||
#define kMaxCubicSubdivideLevel 9
|
#define kMaxCubicSubdivideLevel 9
|
||||||
#define kMaxQuadSubdivideLevel 5
|
#define kMaxQuadSubdivideLevel 5
|
||||||
|
|
||||||
static int compute_int_quad_dist(const SkPoint pts[3]) {
|
static uint32_t compute_int_quad_dist(const SkPoint pts[3]) {
|
||||||
// compute the vector between the control point ([1]) and the middle of the
|
// compute the vector between the control point ([1]) and the middle of the
|
||||||
// line connecting the start and end ([0] and [2])
|
// line connecting the start and end ([0] and [2])
|
||||||
SkScalar dx = SkScalarHalf(pts[0].fX + pts[2].fX) - pts[1].fX;
|
SkScalar dx = SkScalarHalf(pts[0].fX + pts[2].fX) - pts[1].fX;
|
||||||
@ -204,9 +204,11 @@ static int compute_int_quad_dist(const SkPoint pts[3]) {
|
|||||||
// we want everyone to be positive
|
// we want everyone to be positive
|
||||||
dx = SkScalarAbs(dx);
|
dx = SkScalarAbs(dx);
|
||||||
dy = SkScalarAbs(dy);
|
dy = SkScalarAbs(dy);
|
||||||
// convert to whole pixel values (use ceiling to be conservative)
|
// convert to whole pixel values (use ceiling to be conservative).
|
||||||
int idx = SkScalarCeilToInt(dx);
|
// assign to unsigned so we can safely add 1/2 of the smaller and still fit in
|
||||||
int idy = SkScalarCeilToInt(dy);
|
// uint32_t, since SkScalarCeilToInt() returns 31 bits at most.
|
||||||
|
uint32_t idx = SkScalarCeilToInt(dx);
|
||||||
|
uint32_t idy = SkScalarCeilToInt(dy);
|
||||||
// use the cheap approx for distance
|
// use the cheap approx for distance
|
||||||
if (idx > idy) {
|
if (idx > idy) {
|
||||||
return idx + (idy >> 1);
|
return idx + (idy >> 1);
|
||||||
@ -404,7 +406,7 @@ static inline void haircubic(const SkPoint pts[4], const SkRegion* clip, const S
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int compute_quad_level(const SkPoint pts[3]) {
|
static int compute_quad_level(const SkPoint pts[3]) {
|
||||||
int d = compute_int_quad_dist(pts);
|
uint32_t d = compute_int_quad_dist(pts);
|
||||||
/* quadratics approach the line connecting their start and end points
|
/* quadratics approach the line connecting their start and end points
|
||||||
4x closer with each subdivision, so we compute the number of
|
4x closer with each subdivision, so we compute the number of
|
||||||
subdivisions to be the minimum need to get that distance to be less
|
subdivisions to be the minimum need to get that distance to be less
|
||||||
|
Loading…
Reference in New Issue
Block a user