mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-02-19 01:50:50 +01:00
[stroker] fix _compute_normalized_device_slope to return correct sign
The optimization to avoid sqrt() for horizontal/vertical lines in _compute_normalized_device_slope was causing us to return a negative magnitude with a positive slope for left-to-right and bottom-to-top lines, instead of always returning a positive magnitude and a slope with an appropriate sign.
This commit is contained in:
parent
8fb624dbf2
commit
f2d21e7382
1 changed files with 14 additions and 4 deletions
|
|
@ -601,13 +601,23 @@ _compute_normalized_device_slope (double *dx, double *dy, cairo_matrix_t *ctm_in
|
|||
}
|
||||
|
||||
if (dx0 == 0.0) {
|
||||
mag = dy0;
|
||||
*dx = 0.0;
|
||||
*dy = 1.0;
|
||||
if (dy0 > 0.0) {
|
||||
mag = dy0;
|
||||
*dy = 1.0;
|
||||
} else {
|
||||
mag = -dy0;
|
||||
*dy = -1.0;
|
||||
}
|
||||
} else if (dy0 == 0.0) {
|
||||
mag = dx0;
|
||||
*dx = 1.0;
|
||||
*dy = 0.0;
|
||||
if (dx0 > 0.0) {
|
||||
mag = dx0;
|
||||
*dx = 1.0;
|
||||
} else {
|
||||
mag = -dx0;
|
||||
*dx = -1.0;
|
||||
}
|
||||
} else {
|
||||
mag = sqrt (dx0 * dx0 + dy0 * dy0);
|
||||
*dx = dx0 / mag;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue