[AD] new_api_branch: al_create_display and blit patch |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Two patches attached. The first removes the v_w and v_h parameters from
al_create_display, conforming more to the original design. For the
compatibility layer this means that set_gfx_mode() now ignores the last
two parameters completely. I don't think it's really important in
practice.
The second one is a moderately tweaked update of my previous blit patch
that I still hadn't applied. Since I may have a bit of time to work on
this in the next few days, I'll probably commit it tomorrow (unless
someone objects).
Evert
Index: src/compat/cogfx.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/compat/Attic/cogfx.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 cogfx.c
--- src/compat/cogfx.c 2 Feb 2005 19:45:59 -0000 1.1.2.1
+++ src/compat/cogfx.c 14 May 2005 22:52:29 -0000
@@ -24,7 +24,7 @@
{
al_destroy_display(al_main_display);
- al_create_display(card, 0, get_color_depth(), w, h, v_w, v_h);
+ al_create_display(card, AL_UPDATE_NONE, get_color_depth(), w, h);
if (!al_main_display) {
return -1;
}
Index: src/display.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/Attic/display.c,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 display.c
--- src/display.c 20 Mar 2005 02:04:47 -0000 1.1.2.6
+++ src/display.c 14 May 2005 22:52:31 -0000
@@ -1102,12 +1102,13 @@
* Create a new Allegro display object, return NULL on failure
* The first display object created becomes the al_main_display
*/
-AL_DISPLAY *al_create_display(int driver, int flags, int depth, int w, int h, int v_w, int v_h)
+AL_DISPLAY *al_create_display(int driver, int flags, int depth, int w, int h)
{
AL_DISPLAY *new_display;
AL_DISPLAY **new_display_ptr;
int c;
-
+ int v_w = 0, v_h = 0;
+
ASSERT(system_driver);
/* It's an error to select more than one update method */
Index: include/allegro/display.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/Attic/display.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 display.h
--- include/allegro/display.h 2 Feb 2005 19:45:57 -0000 1.1.2.1
+++ include/allegro/display.h 14 May 2005 22:52:31 -0000
@@ -65,7 +65,7 @@
AL_FUNC(int, al_request_video_bitmap, (AL_DISPLAY *display, BITMAP *bitmap));
AL_FUNC(int, al_enable_triple_buffer, (AL_DISPLAY *display));
-AL_FUNC(AL_DISPLAY *, al_create_display, (int driver, int flags, int depth, int w, int h, int v_w, int v_h));
+AL_FUNC(AL_DISPLAY *, al_create_display, (int driver, int flags, int depth, int w, int h));
AL_FUNC(int, al_set_update_method, (AL_DISPLAY *display, int method));
AL_FUNC(void, al_destroy_display, (AL_DISPLAY *display));
? allegro.log
? src/compat/coblit.c
Index: makefile.lst
===================================================================
RCS file: /cvsroot/alleg/allegro/makefile.lst,v
retrieving revision 1.102.2.14
diff -u -r1.102.2.14 makefile.lst
--- makefile.lst 25 Apr 2005 03:59:37 -0000 1.102.2.14
+++ makefile.lst 14 May 2005 22:53:26 -0000
@@ -70,6 +70,7 @@
src/vtable24.c \
src/vtable32.c \
src/vtable8.c \
+ src/compat/coblit.c \
src/compat/cogfx.c \
src/compat/cojoy.c \
src/compat/cokeybd.c \
Index: include/allegro/draw.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/draw.h,v
retrieving revision 1.4.4.2
diff -u -r1.4.4.2 draw.h
--- include/allegro/draw.h 9 Mar 2005 23:40:47 -0000 1.4.4.2
+++ include/allegro/draw.h 14 May 2005 22:53:26 -0000
@@ -52,12 +52,21 @@
AL_FUNC(void, calc_spline, (AL_CONST int points[8], int npts, int *x, int *y));
AL_FUNC(void, _soft_spline, (struct BITMAP *bmp, AL_CONST int points[8], int color));
AL_FUNC(void, _soft_floodfill, (struct BITMAP *bmp, int x, int y, int color));
+AL_FUNC(void, stretch_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int w, int h));
+AL_FUNC(void, _soft_draw_gouraud_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4));
+
+/* Blitting flags */
+#define AL_MASK_SOURCE 0x0001
+AL_FUNC(void, al_blit, (int flags, struct BITMAP *source, struct BITMAP *dest, int dest_x, int dest_y));
+AL_FUNC(void, al_blit_region, (int flags, struct BITMAP *source, int source_x, int source_y, int source_w, int source_h, struct BITMAP *dest, int dest_x, int dest_y));
+AL_FUNC(void, al_blit_scaled, (int flags, struct BITMAP *source, int source_x, int source_y, int source_w, int source_h, struct BITMAP *dest, int dest_x, int dest_y, int dest_w, int dest_h));
+
+
+/* Compatibility stuff */
AL_FUNC(void, blit, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height));
AL_FUNC(void, masked_blit, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height));
AL_FUNC(void, stretch_blit, (struct BITMAP *s, struct BITMAP *d, int s_x, int s_y, int s_w, int s_h, int d_x, int d_y, int d_w, int d_h));
AL_FUNC(void, masked_stretch_blit, (struct BITMAP *s, struct BITMAP *d, int s_x, int s_y, int s_w, int s_h, int d_x, int d_y, int d_w, int d_h));
-AL_FUNC(void, stretch_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int w, int h));
-AL_FUNC(void, _soft_draw_gouraud_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4));
#ifdef __cplusplus
}
Index: src/blit.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/blit.c,v
retrieving revision 1.13.2.2
diff -u -r1.13.2.2 blit.c
--- src/blit.c 9 Mar 2005 23:40:50 -0000 1.13.2.2
+++ src/blit.c 14 May 2005 22:53:27 -0000
@@ -691,19 +691,32 @@
-/* blit:
- * Copies an area of the source bitmap to the destination bitmap. s_x and
- * s_y give the top left corner of the area of the source bitmap to copy,
- * and d_x and d_y give the position in the destination bitmap. w and h
- * give the size of the area to blit. This routine respects the clipping
- * rectangle of the destination bitmap, and will work correctly even when
- * the two memory areas overlap (ie. src and dest are the same).
+/* al_blit:
+ * Copies a rectangular area of the source bitmap to the destination bitmap.
+ * The dest_x and dest_y are the coordinates of the top-left corner in the
+ * destination bitmap where the source bitmap will be drawn.
*/
-void blit(BITMAP *src, BITMAP *dest, int s_x, int s_y, int d_x, int d_y, int w, int h)
+void al_blit(int flags, BITMAP *src, BITMAP *dest, int d_x, int d_y)
{
+ int w, h;
+ int s_x = 0, s_y = 0;
ASSERT(src);
ASSERT(dest);
+
+ /* If flags!=0, then bitmaps must be of the same colour depth */
+ ASSERT(flags !=0 || src->vtable->color_depth == dest->vtable->color_depth);
+
+ w = src->w;
+ h = src->h;
BLIT_CLIP();
+
+
+
+ /* Masked blit */
+ if (flags == AL_MASK_SOURCE) {
+ dest->vtable->masked_blit(src, dest, s_x, s_y, d_x, d_y, w, h);
+ return;
+ }
if (src->vtable->color_depth != dest->vtable->color_depth) {
/* need to do a color conversion */
@@ -740,21 +753,61 @@
}
}
-END_OF_FUNCTION(blit);
+END_OF_FUNCTION(al_blit);
-
-/* masked_blit:
- * Version of blit() that skips zero pixels. The source must be a memory
- * bitmap, and the source and dest regions must not overlap.
+/* al_blit_region:
+ * Copies a rectangular area of the source bitmap to the destination bitmap.
+ * The dest_x and dest_y are the coordinates of the top-left corner in the
+ * destination bitmap where the source bitmap will be drawn.
*/
-void masked_blit(BITMAP *src, BITMAP *dest, int s_x, int s_y, int d_x, int d_y, int w, int h)
+void al_blit_region(int flags, BITMAP *src, int s_x, int s_y, int w, int h, BITMAP *dest, int d_x, int d_y)
{
ASSERT(src);
ASSERT(dest);
- ASSERT(src->vtable->color_depth == dest->vtable->color_depth);
-
BLIT_CLIP();
+
+ /* Masked blit */
+ if (flags == AL_MASK_SOURCE) {
+ ASSERT(src->vtable->color_depth == dest->vtable->color_depth);
- dest->vtable->masked_blit(src, dest, s_x, s_y, d_x, d_y, w, h);
+ dest->vtable->masked_blit(src, dest, s_x, s_y, d_x, d_y, w, h);
+ return;
+ }
+
+ if (src->vtable->color_depth != dest->vtable->color_depth) {
+ /* need to do a color conversion */
+ dest->vtable->blit_between_formats(src, dest, s_x, s_y, d_x, d_y, w, h);
+ }
+ else if (is_same_bitmap(src, dest)) {
+ /* special handling for overlapping regions */
+ blit_to_self(src, dest, s_x, s_y, d_x, d_y, w, h);
+ }
+ else if (is_video_bitmap(dest)) {
+ /* drawing onto video bitmaps */
+ if (is_video_bitmap(src))
+ dest->vtable->blit_to_self(src, dest, s_x, s_y, d_x, d_y, w, h);
+ else if (is_system_bitmap(src))
+ dest->vtable->blit_from_system(src, dest, s_x, s_y, d_x, d_y, w, h);
+ else
+ dest->vtable->blit_from_memory(src, dest, s_x, s_y, d_x, d_y, w, h);
+ }
+ else if (is_system_bitmap(dest)) {
+ /* drawing onto system bitmaps */
+ if (is_video_bitmap(src))
+ src->vtable->blit_to_system(src, dest, s_x, s_y, d_x, d_y, w, h);
+ else if (is_system_bitmap(src))
+ dest->vtable->blit_to_self(src, dest, s_x, s_y, d_x, d_y, w, h);
+ else
+ dest->vtable->blit_from_memory(src, dest, s_x, s_y, d_x, d_y, w, h);
+ }
+ else {
+ /* drawing onto memory bitmaps */
+ if ((is_video_bitmap(src)) || (is_system_bitmap(src)))
+ src->vtable->blit_to_memory(src, dest, s_x, s_y, d_x, d_y, w, h);
+ else
+ dest->vtable->blit_to_self(src, dest, s_x, s_y, d_x, d_y, w, h);
+ }
}
+
+END_OF_FUNCTION(al_blit_region);
Index: src/graphics.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/graphics.c,v
retrieving revision 1.56.2.2
diff -u -r1.56.2.2 graphics.c
--- src/graphics.c 2 Feb 2005 19:45:58 -0000 1.56.2.2
+++ src/graphics.c 14 May 2005 22:53:29 -0000
@@ -268,7 +268,7 @@
void set_color_depth(int depth)
{
_color_depth = depth;
-
+
switch (depth) {
case 8: palette_color = _palette_color8; break;
case 15: palette_color = _palette_color15; break;
Index: src/c/cstretch.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/c/cstretch.c,v
retrieving revision 1.12.2.2
diff -u -r1.12.2.2 cstretch.c
--- src/c/cstretch.c 9 Mar 2005 23:40:51 -0000 1.12.2.2
+++ src/c/cstretch.c 14 May 2005 22:53:29 -0000
@@ -236,13 +236,11 @@
-/*
- * Stretch blit work-horse.
+/* al_blit_scaled:
+ * Bitmap scaling function.
*/
-static void _al_stretch_blit(BITMAP *src, BITMAP *dst,
- int sx, int sy, int sw, int sh,
- int dx, int dy, int dw, int dh,
- int masked)
+void al_blit_scaled(int flags, BITMAP *src, int sx, int sy, int sw, int sh,
+ BITMAP *dst, int dx, int dy, int dw, int dh)
{
int x, y, fixup;
int i1, i2, dd;
@@ -251,9 +249,12 @@
int dybeg, dyend;
int sxofs, dxofs;
void (*stretch_line)(uintptr_t dptr, unsigned char *sptr);
+ int masked;
ASSERT(src);
ASSERT(dst);
+
+ masked = (flags&AL_MASK_SOURCE) == AL_MASK_SOURCE;
/* vtable hook */
if (src->vtable->do_stretch_blit) {
@@ -434,49 +435,3 @@
}
bmp_unwrite_line(dst);
}
-
-
-
-/* stretch_blit:
- * Opaque bitmap scaling function.
- */
-void stretch_blit(BITMAP *src, BITMAP *dst, int sx, int sy, int sw, int sh,
- int dx, int dy, int dw, int dh)
-{
- ASSERT(src);
- ASSERT(dst);
-
- #ifdef ALLEGRO_MPW
- if (is_system_bitmap(src) && is_system_bitmap(dst))
- system_stretch_blit(src, dst, sx, sy, sw, sh, dx, dy, dw, dh);
- else
- #endif
- _al_stretch_blit(src, dst, sx, sy, sw, sh, dx, dy, dw, dh, 0);
-}
-
-
-
-/* masked_stretch_blit:
- * Masked bitmap scaling function.
- */
-void masked_stretch_blit(BITMAP *src, BITMAP *dst, int sx, int sy, int sw, int sh,
- int dx, int dy, int dw, int dh)
-{
- ASSERT(src);
- ASSERT(dst);
-
- _al_stretch_blit(src, dst, sx, sy, sw, sh, dx, dy, dw, dh, 1);
-}
-
-
-
-/* stretch_sprite:
- * Masked version of stretch_blit().
- */
-void stretch_sprite(BITMAP *dst, BITMAP *src, int x, int y, int w, int h)
-{
- ASSERT(src);
- ASSERT(dst);
-
- _al_stretch_blit(src, dst, 0, 0, src->w, src->h, x, y, w, h, 1);
-}
Index: src/i386/istretch.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/i386/istretch.c,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 istretch.c
--- src/i386/istretch.c 20 Mar 2005 02:04:48 -0000 1.7.2.2
+++ src/i386/istretch.c 14 May 2005 22:53:30 -0000
@@ -457,30 +457,15 @@
-/* stretch_blit:
- * Opaque bitmap scaling function.
+/* al_blit_scaled:
+ * Bitmap scaling function.
*/
-void stretch_blit(BITMAP *s, BITMAP *d, int s_x, int s_y, int s_w, int s_h, int d_x, int d_y, int d_w, int d_h)
+void al_blit_scaled(int flags, struct BITMAP *s, int s_x, int s_y, int s_w, int s_h, struct BITMAP *d, int d_x, int d_y, int d_w, int d_h)
{
- do_stretch_blit(s, d, s_x, s_y, s_w, s_h, d_x, d_y, d_w, d_h, 0);
-}
-
-
-
-/* masked_stretch_blit:
- * Masked bitmap scaling function.
- */
-void masked_stretch_blit(BITMAP *s, BITMAP *d, int s_x, int s_y, int s_w, int s_h, int d_x, int d_y, int d_w, int d_h)
-{
- do_stretch_blit(s, d, s_x, s_y, s_w, s_h, d_x, d_y, d_w, d_h, 1);
-}
-
-
-
-/* stretch_sprite:
- * Masked version of stretch_blit().
- */
-void stretch_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int w, int h)
-{
- do_stretch_blit(sprite, bmp, 0, 0, sprite->w, sprite->h, x, y, w, h, 1);
+ if (flags == AL_MASK_SOURCE) {
+ do_stretch_blit(s, d, s_x, s_y, s_w, s_h, d_x, d_y, d_w, d_h, 1);
+ }
+ else {
+ do_stretch_blit(s, d, s_x, s_y, s_w, s_h, d_x, d_y, d_w, d_h, 0);
+ }
}