[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: [AD] memmove blit
- From: Milan Mimica <milan.mimica@xxxxxxxxxx>
- Date: Fri, 05 May 2006 22:00:17 +0200
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:subject:content-type; b=bq7R7ZNx/c6DyuoQBkVRzokJCJ2hExWHDxc0Wjv1QjPvWLosV/XeAAmReiJgo301o09Ybb3LZB9XxJdO3zGsJfHEIlTQWNw6iOnaR80chfOXvkTr7zqiuNgNjUwG5X2w9cvQ0epM4pBE3GpFFTkAxjj+ESxFBTzDlrCZX6P8nJc=
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)--)