Re: [AD] problem with Chris' X primitives patch

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


I wrote:
I'll continue to work on the patch and let you know when I get it fixed.

This patch should do it. The drawing mode is retained when the mode is swtched (like it has been), though now the gfx driver gets re-notified after a mode change, and everything should draw right.

- Kitty Cat
Index: src/x/xvtable.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xvtable.c,v
retrieving revision 1.12
diff -u -r1.12 xvtable.c
--- src/x/xvtable.c	18 Aug 2004 13:03:45 -0000	1.12
+++ src/x/xvtable.c	29 Aug 2004 06:44:08 -0000
@@ -54,6 +54,9 @@
 /* True if the GC is using the proper drawing mode */
 static int _xwin_drawmode_ok = TRUE;
 
+/* The drawing mode the current GC is actually in */
+static int _xwin_real_drawmode = GXcopy;
+
 /* A counter for the number of locks held on the X display */
 static int _xwin_lock_count = 0;
 
@@ -64,20 +67,28 @@
  */
 void _xwin_drawing_mode(void)
 {
-   int gc_func;
+   if (!_xwin.matching_formats) {
+      if (_drawing_mode == DRAW_MODE_SOLID)
+	 _xwin_drawmode_ok = TRUE;
+      else
+	 _xwin_drawmode_ok = FALSE;
+
+      _xwin_real_drawmode = GXcopy;
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
+      return;
+   }
 
+   _xwin_drawmode_ok = TRUE;
    if(_drawing_mode == DRAW_MODE_SOLID)
-      gc_func = GXcopy;
+      _xwin_real_drawmode = GXcopy;
    else if (_drawing_mode == DRAW_MODE_XOR)
-      gc_func = GXxor;
-   else
-   {
+      _xwin_real_drawmode = GXxor;
+   else {
       _xwin_drawmode_ok = FALSE;
-      return;
+      _xwin_real_drawmode = GXcopy;
    }
 
-   _xwin_drawmode_ok = TRUE;
-   XSetState(_xwin.display, _xwin.gc, 0, 0, gc_func, -1);
+   XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -430,7 +441,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.blit_from_memory(src, dst, sx, sy, dx, dy, w, h);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dx, dy, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -449,7 +465,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.blit_to_self_backward(src, dst, sx, sy, dx, dy, w, h);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dx, dy, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -468,7 +489,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.masked_blit(src, dst, sx, sy, dx, dy, w, h);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dx, dy, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -523,7 +549,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_sprite(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -545,7 +576,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_256_sprite(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -567,7 +603,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_sprite_v_flip(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -589,7 +630,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_sprite_h_flip(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -611,7 +657,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_sprite_vh_flip(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -633,7 +684,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_trans_sprite(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -655,7 +711,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_trans_rgba_sprite(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -677,7 +738,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_lit_sprite(dst, src, dx, dy, color);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -699,7 +765,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_character(dst, src, dx, dy, color, bg);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -721,7 +792,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_glyph(dst, src, dx, dy, color, bg);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -743,7 +819,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_rle_sprite(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -765,7 +846,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_trans_rle_sprite(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -787,7 +873,12 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_trans_rgba_rle_sprite(dst, src, dx, dy);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
 
 
@@ -809,6 +900,10 @@
    _xwin_in_gfx_call = 1;
    _xwin_vtable.draw_lit_rle_sprite(dst, src, dx, dy, color);
    _xwin_in_gfx_call = 0;
+
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
    _xwin_update_video_bitmap(dst, dxbeg, dybeg, w, h);
+   if (_xwin_real_drawmode != GXcopy)
+      XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin_real_drawmode, -1);
 }
-
Index: src/graphics.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/graphics.c,v
retrieving revision 1.56
diff -u -r1.56 graphics.c
--- src/graphics.c	28 Dec 2003 21:37:51 -0000	1.56
+++ src/graphics.c	29 Aug 2004 06:44:08 -0000
@@ -816,6 +816,10 @@
    else
       _wait_for_vsync = TRUE;
 
+   /* Give the gfx driver an opportunity to set the drawing mode */
+   if ((gfx_driver->drawing_mode) && (!_dispsw_status))
+      gfx_driver->drawing_mode();
+
    clear_bitmap(screen);
 
    /* set up the default colors */


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