[AD] memmove blit

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


There is a bug in blitting code with 24 bpp bitmaps, memmove enabled and ASM disabled. You can see the consequences in this thread:
http://www.allegro.cc/forums/thread/582857

The attached patch fixes it.


--
Milan Mimica
http://sparklet.sf.net
Index: src/c/cdefs24.h
===================================================================
--- src/c/cdefs24.h	(revision 5792)
+++ src/c/cdefs24.h	(working copy)
@@ -21,6 +21,7 @@
 #define PP_DEPTH               24
 
 #define PIXEL_PTR              unsigned char*
+#define PTR_PER_PIXEL          3
 #define OFFSET_PIXEL_PTR(p,x)  ((PIXEL_PTR) (p) + 3 * (x))
 #define INC_PIXEL_PTR(p)       ((p) += 3)
 #define DEC_PIXEL_PTR(p)       ((p) -= 3)
Index: src/c/cblit.h
===================================================================
--- src/c/cblit.h	(revision 5792)
+++ src/c/cblit.h	(working copy)
@@ -88,7 +88,7 @@
 	 PUT_PIXEL(d, c);
       }
 #else
-      memmove(d, s, w * sizeof *s);
+      memmove(d, s, w * sizeof(*s) * PTR_PER_PIXEL);
 #endif
    }
 
@@ -127,7 +127,7 @@
       PIXEL_PTR s = OFFSET_PIXEL_PTR(bmp_read_line(src, sy + y), sx);
       PIXEL_PTR d = OFFSET_PIXEL_PTR(bmp_write_line(dst, dy + y), dx);
 
-      memmove(d, s, w * sizeof *s);
+      memmove(d, s, w * sizeof(*s) * PTR_PER_PIXEL);
 #endif
    }
 
Index: src/c/cdefs32.h
===================================================================
--- src/c/cdefs32.h	(revision 5792)
+++ src/c/cdefs32.h	(working copy)
@@ -21,6 +21,7 @@
 #define PP_DEPTH               32
 
 #define PIXEL_PTR              uint32_t*
+#define PTR_PER_PIXEL          1
 #define OFFSET_PIXEL_PTR(p,x)  ((PIXEL_PTR) (p) + (x))
 #define INC_PIXEL_PTR(p)       ((p)++)
 #define DEC_PIXEL_PTR(p)       ((p)--)
Index: src/c/cdefs16.h
===================================================================
--- src/c/cdefs16.h	(revision 5792)
+++ src/c/cdefs16.h	(working copy)
@@ -21,6 +21,7 @@
 #define PP_DEPTH               16
 
 #define PIXEL_PTR              unsigned short*
+#define PTR_PER_PIXEL          1
 #define OFFSET_PIXEL_PTR(p,x)  ((PIXEL_PTR) (p) + (x))
 #define INC_PIXEL_PTR(p)       ((p)++)
 #define DEC_PIXEL_PTR(p)       ((p)--)
Index: src/c/cdefs8.h
===================================================================
--- src/c/cdefs8.h	(revision 5792)
+++ src/c/cdefs8.h	(working copy)
@@ -21,6 +21,7 @@
 #define PP_DEPTH               8
 
 #define PIXEL_PTR              unsigned char*
+#define PTR_PER_PIXEL          1
 #define OFFSET_PIXEL_PTR(p,x)  ((PIXEL_PTR) (p) + (x))
 #define INC_PIXEL_PTR(p)       ((p)++)
 #define DEC_PIXEL_PTR(p)       ((p)--)


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/