Re: [AD] Using memmove in blit()? |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Friday 10 March 2006 22:56, Peter Wang wrote:
> > +#define USE_MEMMOVE
> > +
>
> Would this be better off at the top of the file?
Yes. Corrected, and added a few lines of comments as well.
> Please either unindent the #-lines or indent the code further one step.
Ok.
> Why is the #undef there?
There was a bug I'd failed to track down in the original patch that made
overlapping blits not work properly. Now corrected.
Commited the attached updated patch instead.
Evert
Index: src/c/cblit.h
===================================================================
--- src/c/cblit.h (revision 5785)
+++ src/c/cblit.h (working copy)
@@ -18,6 +18,23 @@
#ifndef __bma_cblit_h
#define __bma_cblit_h
+
+
+/* Define USE_MEMMOVE to use libc's memmove command for doing blits.
+ * This helps some machines, while it doesn't seem to do much for others.
+ * Left as a define so the older blit version can be easily reactivated for
+ * testing.
+ */
+#define USE_MEMMOVE
+
+
+
+#ifdef USE_MEMMOVE
+ #include <string.h>
+#endif
+
+
+
/* _linear_clear_to_color:
* Fills a linear bitmp with the specified color.
*/
@@ -60,6 +77,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);
+#ifndef USE_MEMMOVE
for (x = w - 1; x >= 0; INC_PIXEL_PTR(s), INC_PIXEL_PTR(d), x--) {
unsigned long c;
@@ -69,6 +87,9 @@
bmp_select(dst);
PUT_PIXEL(d, c);
}
+#else
+ memmove(d, s, w * sizeof *s);
+#endif
}
bmp_unwrite_line(src);
@@ -89,6 +110,7 @@
ASSERT(dst);
for (y = h - 1; y >= 0; y--) {
+#ifndef USE_MEMMOVE
PIXEL_PTR s = OFFSET_PIXEL_PTR(bmp_read_line(src, sy + y), sx + w - 1);
PIXEL_PTR d = OFFSET_PIXEL_PTR(bmp_write_line(dst, dy + y), dx + w - 1);
@@ -101,6 +123,12 @@
bmp_select(dst);
PUT_PIXEL(d, c);
}
+#else
+ 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);
+#endif
}
bmp_unwrite_line(src);