Re: [AD] Patch for rotate.c |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Evert Glebbeek wrote:
In other words, the patch is correct and should be applied, although the
stray pixels appearing isn't the proper reason for doing so?
Just to be sure :)
Sorry if I was unclear. What I meant was, the patch does what it was
intended to do, namely forgives the user for doing wrong (i.e., it
avoids ugly pixels when the user tries to draw outside the bitmap with
clipping turned off). I then questioned whether we should be that "nice"
to users. I think it would be good to also add an ASSERT that fails when
users try to draw outside the BITMAP with clipping turned off, so that
they can fix their programs. I attach a patch that does this. OK?
/Sven
Index: src/rotate.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/rotate.c,v
retrieving revision 1.18
diff -u -r1.18 rotate.c
--- src/rotate.c 14 Dec 2003 18:57:07 -0000 1.18
+++ src/rotate.c 30 Oct 2004 10:15:25 -0000
@@ -317,8 +317,12 @@
clip_right = (bmp->cr << 16) - 1;
}
else {
+ ASSERT(left_bmp_x >= 0 && top_bmp_x >= 0 && bottom_bmp_x >= 0
+ && right_bmp_x < (bmp->w << 16)
+ && top_bmp_x < (bmp->w << 16)
+ && bottom_bmp_x < (bmp->w << 16));
clip_left = 0;
- clip_right = bmp->w << 16;
+ clip_right = (bmp->w << 16) - 1;
}
/* Quit if we're totally outside. */
@@ -336,18 +340,24 @@
clip_bottom_i = (bottom_bmp_y + 0xffff) >> 16;
else
clip_bottom_i = (bottom_bmp_y + 0x8000) >> 16;
- if (bmp->clip)
+ if (bmp->clip) {
if (clip_bottom_i > bmp->cb)
clip_bottom_i = bmp->cb;
+ }
+ else
+ ASSERT(clip_bottom_i <= bmp->h);
/* Calculate y coordinate of first scanline. */
if (sub_pixel_accuracy)
bmp_y_i = top_bmp_y >> 16;
else
bmp_y_i = (top_bmp_y + 0x8000) >> 16;
- if (bmp->clip)
+ if (bmp->clip) {
if (bmp_y_i < bmp->ct)
bmp_y_i = bmp->ct;
+ }
+ else
+ ASSERT(bmp_y_i >= 0);
/* Sprite is above or below bottom clipping area. */
if (bmp_y_i >= clip_bottom_i)