fb: Fix Bresenham algorithms for commonly used small segments.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=54168

Fix errors introducted in 863d528a9f. Said
patch does indeed remove the problematic writes to bad memory, however
it also introduces errors in the algoritm. This patch has the effect of
reverting said patch and adding an if in the proper location to catch
the out of bounds memory write without causing problems to the overall
algorithm.

Signed-off-by: Alex Orange <crazycasta@gmail.com>
Reviewed-by: Peter Harris <pharris@opentext.com>
Tested-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Alex Orange 2014-10-03 15:41:38 -06:00 committed by Keith Packard
parent ea5b2b0a2e
commit 1b94fd7779
1 changed files with 11 additions and 9 deletions

View File

@ -65,12 +65,6 @@ fbBresSolid(DrawablePtr pDrawable,
if (axis == X_AXIS) {
bits = 0;
while (len--) {
if (e >= 0) {
WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
bits = 0;
dst += dstStride;
e += e3;
}
bits |= mask;
mask = fbBresShiftMask(mask, signdx, dstBpp);
if (!mask) {
@ -80,12 +74,23 @@ fbBresSolid(DrawablePtr pDrawable,
mask = mask0;
}
e += e1;
if (e >= 0) {
if (bits) {
WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
bits = 0;
}
dst += dstStride;
e += e3;
}
}
if (bits)
WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, bits));
}
else {
while (len--) {
WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, mask));
dst += dstStride;
e += e1;
if (e >= 0) {
e += e3;
mask = fbBresShiftMask(mask, signdx, dstBpp);
@ -94,9 +99,6 @@ fbBresSolid(DrawablePtr pDrawable,
mask = mask0;
}
}
WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, mask));
dst += dstStride;
e += e1;
}
}