Re: [AD] XOR drawing under X11 (and what is _xwin_in_gfx_call) |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: Re: [AD] XOR drawing under X11 (and what is _xwin_in_gfx_call)
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Thu, 25 Nov 2004 17:04:12 -0800
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:return-path:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:x-enigmail-version:x-enigmail-supports:content-type; b=SyGrXRHn4M4YMPuRMuuCqOZEtbp7ftSwip2SLTETKhygqTH7esZtq8nbIZn1Vm8bhTTvy85FWhVW8cUr9wFGmeACaB5QXt6nUHFSEfRb5zMLExa1kKA3ZRInw8pVPFuM5+0b2XnsTyQrYNOg2BjPi4vv3lpgDskQedmUi6/6sD4=
Perhaps I should attach a proper patch. Sorry about that.
Index: src/x/xvtable.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xvtable.c,v
retrieving revision 1.17
diff -u -r1.17 xvtable.c
--- src/x/xvtable.c 30 Oct 2004 22:44:57 -0000 1.17
+++ src/x/xvtable.c 26 Nov 2004 01:05:31 -0000
@@ -61,28 +61,159 @@
*/
void _xwin_drawing_mode(void)
{
- if (!_xwin.matching_formats) {
- if (_drawing_mode == DRAW_MODE_SOLID)
- _xwin.drawing_mode_ok = TRUE;
- else
- _xwin.drawing_mode_ok = FALSE;
-
- _xwin.real_drawing_mode = GXcopy;
- XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
- return;
- }
-
- _xwin.drawing_mode_ok = TRUE;
- if(_drawing_mode == DRAW_MODE_SOLID)
- _xwin.real_drawing_mode = GXcopy;
- else if (_drawing_mode == DRAW_MODE_XOR)
- _xwin.real_drawing_mode = GXxor;
- else {
+ /* Only SOLID can be handled directly by X11. */
+ if(_xwin.matching_formats && _drawing_mode == DRAW_MODE_SOLID)
+ _xwin.drawing_mode_ok = TRUE;
+ else
_xwin.drawing_mode_ok = FALSE;
- _xwin.real_drawing_mode = GXcopy;
- }
+}
+
+
+
+/* Direct X11 version of the function. */
+static inline int _xwin_direct_putpixel(BITMAP *dst, int dx, int dy, int color)
+{
+ if (!_xwin.drawing_mode_ok)
+ return 0;
+
+ dx += dst->x_ofs - _xwin.scroll_x;
+ dy += dst->y_ofs - _xwin.scroll_y;
+
+ if((dx >= _xwin.screen_width) || (dx < 0) ||
+ (dy >= _xwin.screen_height) || (dy < 0))
+ return 1;
+
+ XLOCK();
+ XSetForeground(_xwin.display, _xwin.gc, color);
+ XDrawPoint(_xwin.display, _xwin.window, _xwin.gc, dx, dy);
+ XUNLOCK();
+
+ return 1;
+}
+
+
+
+/* Direct X11 version of the function. */
+static inline int _xwin_direct_hline(BITMAP *dst, int dx1, int dy, int dx2, int color)
+{
+ if (!_xwin.drawing_mode_ok)
+ return 0;
+
+ dx1 += dst->x_ofs - _xwin.scroll_x;
+ dx2 += dst->x_ofs - _xwin.scroll_x;
+ dy += dst->y_ofs - _xwin.scroll_y;
+
+ if (dx1 < 0)
+ dx1 = 0;
+ if (dx2 >= _xwin.screen_width)
+ dx2 = _xwin.screen_width - 1;
+ if ((dx1 > dx2) || (dy < 0) || (dy >= _xwin.screen_height))
+ return 1;
+
+ XLOCK();
+ XSetForeground(_xwin.display, _xwin.gc, color);
+ XDrawLine(_xwin.display, _xwin.window, _xwin.gc, dx1, dy, dx2, dy);
+ XUNLOCK();;
+
+ return 1;
+}
+
+
+
+/* Direct X11 version of the function. */
+static inline int _xwin_direct_vline(BITMAP *dst, int dx, int dy1, int dy2, int color)
+{
+ if (!_xwin.drawing_mode_ok)
+ return 0;
+
+ dx += dst->x_ofs - _xwin.scroll_x;
+ dy1 += dst->y_ofs - _xwin.scroll_y;
+ dy2 += dst->y_ofs - _xwin.scroll_y;
+
+ if (dy1 < 0)
+ dy1 = 0;
+ if (dy2 >= _xwin.screen_height)
+ dy2 = _xwin.screen_height - 1;
+ if ((dy1 > dy2) || (dx < 0) || (dx >= _xwin.screen_width))
+ return 1;
+
+ XLOCK();
+ XSetForeground(_xwin.display, _xwin.gc, color);
+ XDrawLine(_xwin.display, _xwin.window, _xwin.gc, dx, dy1, dx, dy2);
+ XUNLOCK();
+
+ return 1;
+}
+
+
+
+/* Direct X11 version of the function. */
+static inline int _xwin_direct_rectfill(BITMAP *dst, int dx1, int dy1, int dx2, int dy2, int color)
+{
+ if (!_xwin.drawing_mode_ok)
+ return 0;
+
+ dx1 += dst->x_ofs - _xwin.scroll_x;
+ dx2 += dst->x_ofs - _xwin.scroll_x;
+ dy1 += dst->y_ofs - _xwin.scroll_y;
+ dy2 += dst->y_ofs - _xwin.scroll_y;
+
+ if (dx1 < 0)
+ dx1 = 0;
+ if (dx2 >= _xwin.screen_width)
+ dx2 = _xwin.screen_width - 1;
+ if (dx1 > dx2)
+ return 1;
+
+ if (dy1 < 0)
+ dy1 = 0;
+ if (dy2 >= _xwin.screen_height)
+ dy2 = _xwin.screen_height - 1;
+ if (dy1 > dy2)
+ return 1;
+
+ XLOCK();
+ XSetForeground(_xwin.display, _xwin.gc, color);
+ XFillRectangle(_xwin.display, _xwin.window, _xwin.gc, dx1, dy1, dx2-dx1+1, dy2-dy1+1);
+ XUNLOCK();
- XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin.real_drawing_mode, -1);
+ return 1;
+}
+
+
+
+/* Direct X11 version of the function. */
+static inline int _xwin_direct_clear_to_color(BITMAP *dst, int color)
+{
+ int dx1, dy1, dx2, dy2;
+ if (!_xwin.drawing_mode_ok)
+ return 0;
+
+ dx1 = dst->cl + dst->x_ofs - _xwin.scroll_x;
+ dx2 = dst->cr + dst->x_ofs - 1 - _xwin.scroll_x;
+ dy1 = dst->ct + dst->y_ofs - _xwin.scroll_y;
+ dy2 = dst->cb + dst->y_ofs - 1 - _xwin.scroll_y;
+
+ if (dx1 < 0)
+ dx1 = 0;
+ if (dx2 >= _xwin.screen_width)
+ dx2 = _xwin.screen_width - 1;
+ if (dx1 > dx2)
+ return 1;
+
+ if (dy1 < 0)
+ dy1 = 0;
+ if (dy2 >= _xwin.screen_height)
+ dy2 = _xwin.screen_height - 1;
+ if (dy1 > dy2)
+ return 1;
+
+ XLOCK();
+ XSetForeground(_xwin.display, _xwin.gc, color);
+ XFillRectangle(_xwin.display, _xwin.window, _xwin.gc, dx1, dy1, dx2-dx1+1, dy2-dy1+1);
+ XUNLOCK();
+
+ return 1;
}
@@ -152,13 +283,7 @@
*/
static void _xwin_update_video_bitmap(BITMAP *dst, int x, int y, int w, int h)
{
- if (_xwin.real_drawing_mode != GXcopy)
- XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
-
_xwin_update_screen(x + dst->x_ofs, y + dst->y_ofs, w, h);
-
- if (_xwin.real_drawing_mode != GXcopy)
- XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin.real_drawing_mode, -1);
}
@@ -180,22 +305,10 @@
_xwin_vtable.putpixel(dst, dx, dy, color);
_xwin_in_gfx_call = 0;
- if (_xwin.matching_formats && _xwin.drawing_mode_ok)
- {
- dx += dst->x_ofs - _xwin.scroll_x;
- dy += dst->y_ofs - _xwin.scroll_y;
-
- if((dx >= _xwin.screen_width) || (dx < 0) ||
- (dy >= _xwin.screen_height) || (dy < 0))
- return;
+ if (_xwin_direct_putpixel(dst, dx, dy, color))
+ return;
- _xwin_lock(NULL);
- XSetForeground(_xwin.display, _xwin.gc, color);
- XDrawPoint(_xwin.display, _xwin.window, _xwin.gc, dx, dy);
- _xwin_unlock(NULL);
- }
- else
- _xwin_update_video_bitmap(dst, dx, dy, 1, 1);
+ _xwin_update_video_bitmap(dst, dx, dy, 1, 1);
}
@@ -229,25 +342,10 @@
_xwin_vtable.hline(dst, dx1, dy, dx2, color);
_xwin_in_gfx_call = 0;
- if (_xwin.matching_formats && _xwin.drawing_mode_ok) {
- dx1 += dst->x_ofs - _xwin.scroll_x;
- dx2 += dst->x_ofs - _xwin.scroll_x;
- dy += dst->y_ofs - _xwin.scroll_y;
-
- if (dx1 < 0)
- dx1 = 0;
- if (dx2 >= _xwin.screen_width)
- dx2 = _xwin.screen_width - 1;
- if ((dx1 > dx2) || (dy < 0) || (dy >= _xwin.screen_height))
- return;
+ if (_xwin_direct_hline(dst, dx1, dy, dx2, color))
+ return;
- _xwin_lock(NULL);
- XSetForeground(_xwin.display, _xwin.gc, color);
- XDrawLine(_xwin.display, _xwin.window, _xwin.gc, dx1, dy, dx2, dy);
- _xwin_unlock(NULL);
- }
- else
- _xwin_update_video_bitmap(dst, dx1, dy, dx2 - dx1 + 1, 1);
+ _xwin_update_video_bitmap(dst, dx1, dy, dx2 - dx1 + 1, 1);
}
@@ -281,25 +379,10 @@
_xwin_vtable.vline(dst, dx, dy1, dy2, color);
_xwin_in_gfx_call = 0;
- if (_xwin.matching_formats && _xwin.drawing_mode_ok) {
- dx += dst->x_ofs - _xwin.scroll_x;
- dy1 += dst->y_ofs - _xwin.scroll_y;
- dy2 += dst->y_ofs - _xwin.scroll_y;
-
- if (dy1 < 0)
- dy1 = 0;
- if (dy2 >= _xwin.screen_height)
- dy2 = _xwin.screen_height - 1;
- if ((dy1 > dy2) || (dx < 0) || (dx >= _xwin.screen_width))
- return;
+ if (_xwin_direct_vline(dst, dx, dy1, dy2, color))
+ return;
- _xwin_lock(NULL);
- XSetForeground(_xwin.display, _xwin.gc, color);
- XDrawLine(_xwin.display, _xwin.window, _xwin.gc, dx, dy1, dx, dy2);
- _xwin_unlock(NULL);
- }
- else
- _xwin_update_video_bitmap(dst, dx, dy1, 1, dy2 - dy1 + 1);
+ _xwin_update_video_bitmap(dst, dx, dy1, 1, dy2 - dy1 + 1);
}
@@ -346,33 +429,10 @@
_xwin_vtable.rectfill(dst, dx1, dy1, dx2, dy2, color);
_xwin_in_gfx_call = 0;
- if (_xwin.matching_formats && _xwin.drawing_mode_ok) {
- dx1 += dst->x_ofs - _xwin.scroll_x;
- dx2 += dst->x_ofs - _xwin.scroll_x;
- dy1 += dst->y_ofs - _xwin.scroll_y;
- dy2 += dst->y_ofs - _xwin.scroll_y;
-
- if (dx1 < 0)
- dx1 = 0;
- if (dx2 >= _xwin.screen_width)
- dx2 = _xwin.screen_width - 1;
- if (dx1 > dx2)
- return;
-
- if (dy1 < 0)
- dy1 = 0;
- if (dy2 >= _xwin.screen_height)
- dy2 = _xwin.screen_height - 1;
- if (dy1 > dy2)
- return;
+ if (_xwin_direct_rectfill(dst, dx1, dy1, dx2, dy2, color))
+ return;
- _xwin_lock(NULL);
- XSetForeground(_xwin.display, _xwin.gc, color);
- XFillRectangle(_xwin.display, _xwin.window, _xwin.gc, dx1, dy1, dx2-dx1+1, dy2-dy1+1);
- _xwin_unlock(NULL);
- }
- else
- _xwin_update_video_bitmap(dst, dx1, dy1, dx2 - dx1 + 1, dy2 - dy1 + 1);
+ _xwin_update_video_bitmap(dst, dx1, dy1, dx2 - dx1 + 1, dy2 - dy1 + 1);
}
@@ -391,33 +451,10 @@
_xwin_vtable.clear_to_color(dst, color);
_xwin_in_gfx_call = 0;
- if (_xwin.matching_formats && (_drawing_mode == DRAW_MODE_SOLID)) {
- int dx1 = dst->cl + dst->x_ofs - _xwin.scroll_x;
- int dx2 = dst->cr + dst->x_ofs - 1 - _xwin.scroll_x;
- int dy1 = dst->ct + dst->y_ofs - _xwin.scroll_y;
- int dy2 = dst->cb + dst->y_ofs - 1 - _xwin.scroll_y;
-
- if (dx1 < 0)
- dx1 = 0;
- if (dx2 >= _xwin.screen_width)
- dx2 = _xwin.screen_width - 1;
- if (dx1 > dx2)
- return;
-
- if (dy1 < 0)
- dy1 = 0;
- if (dy2 >= _xwin.screen_height)
- dy2 = _xwin.screen_height - 1;
- if (dy1 > dy2)
- return;
+ if (_xwin_direct_clear_to_color(dst, color))
+ return;
- _xwin_lock(NULL);
- XSetForeground(_xwin.display, _xwin.gc, color);
- XFillRectangle(_xwin.display, _xwin.window, _xwin.gc, dx1, dy1, dx2-dx1+1, dy2-dy1+1);
- _xwin_unlock(NULL);
- }
- else
- _xwin_update_video_bitmap(dst, dst->cl, dst->ct, dst->cr - dst->cl, dst->cb - dst->ct);
+ _xwin_update_video_bitmap(dst, dst->cl, dst->ct, dst->cr - dst->cl, dst->cb - dst->ct);
}
Index: src/x/xwin.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xwin.c,v
retrieving revision 1.81
diff -u -r1.81 xwin.c
--- src/x/xwin.c 20 Nov 2004 16:42:42 -0000 1.81
+++ src/x/xwin.c 26 Nov 2004 01:05:32 -0000
@@ -136,7 +136,6 @@
XWIN_DEFAULT_APPLICATION_NAME, /* application_name */
XWIN_DEFAULT_APPLICATION_CLASS, /* application_class */
- GXcopy, /* real_drawing_mode */
TRUE, /* drawing_mode_ok */
#ifdef ALLEGRO_MULTITHREADED
@@ -2313,11 +2312,9 @@
(*_xwin_mouse_interrupt)(0, 0, 0, mouse_buttons);
break;
case Expose:
- XSetState(_xwin.display, _xwin.gc, 0, 0, GXcopy, -1);
/* Request to redraw part of the window. */
(*_xwin_window_redrawer)(event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height);
- XSetState(_xwin.display, _xwin.gc, 0, 0, _xwin.real_drawing_mode, -1);
break;
case MappingNotify:
/* Keyboard mapping changed. */
Index: include/xalleg.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/xalleg.h,v
retrieving revision 1.21
diff -u -r1.21 xalleg.h
--- include/xalleg.h 30 Oct 2004 23:00:54 -0000 1.21
+++ include/xalleg.h 26 Nov 2004 01:05:32 -0000
@@ -132,7 +132,6 @@
char application_name[1024];
char application_class[1024];
- int real_drawing_mode;
int drawing_mode_ok;
#ifdef ALLEGRO_MULTITHREADED