[teklib-general] teklib: X11 Display: fixed drawbuffer() sometimes converting a b...
Timm S. Mueller
tmueller at neoscientists.org
Thu Nov 27 18:37:25 CET 2008
details: http://hg.teklib.org/teklib/rev/a7ff2e7d888e
changeset: 206:a7ff2e7d888e
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Wed Nov 26 01:22:15 2008 +0100
description:
X11 Display: fixed drawbuffer() sometimes converting a buffer over itself with
different modulos, reenabled 15 bit modes, fixed/improved/simplified
drawbuffer() with modulo; RawFB: Flush now handles a rectangle
diffs (truncated from 450 to 100 lines):
diff -r 8378a449a783 -r a7ff2e7d888e src/display_rawfb/display_rawfb_api.c
--- a/src/display_rawfb/display_rawfb_api.c Fri Nov 21 18:22:16 2008 +0100
+++ b/src/display_rawfb/display_rawfb_api.c Wed Nov 26 01:22:15 2008 +0100
@@ -151,16 +151,30 @@
LOCAL void
rawfb_flush(TMOD_RAWFB *mod, struct TVRawFBRequest *req)
{
- VISUAL *v = req->tvr_Op.SetInput.Instance;
+ VISUAL *v = req->tvr_Op.Flush.Instance;
if (v->subinst)
{
+ TINT x0 = req->tvr_Op.Flush.Rect[0];
+ TINT y0 = req->tvr_Op.Flush.Rect[1];
+ TINT x1 = req->tvr_Op.Flush.Rect[2];
+ TINT y1 = req->tvr_Op.Flush.Rect[3];
+ TINT w = x1 - x0 + 1;
+ TINT h = y1 - y0 + 1;
+ TINT tw = v->width + v->modulo;
+ if (req->tvr_Op.Flush.Rect[0] < 0)
+ {
+ x0 = 0;
+ y0 = 0;
+ w = v->width;
+ h = v->height;
+ }
v->subreq->tvr_Req.io_Command = TVCMD_DRAWBUFFER;
v->subreq->tvr_Op.DrawBuffer.Instance = v->subinst;
- v->subreq->tvr_Op.DrawBuffer.Buf = v->bufptr;
- v->subreq->tvr_Op.DrawBuffer.RRect[0] = 0;
- v->subreq->tvr_Op.DrawBuffer.RRect[1] = 0;
- v->subreq->tvr_Op.DrawBuffer.RRect[2] = v->width;
- v->subreq->tvr_Op.DrawBuffer.RRect[3] = v->height;
+ v->subreq->tvr_Op.DrawBuffer.RRect[0] = x0;
+ v->subreq->tvr_Op.DrawBuffer.RRect[1] = y0;
+ v->subreq->tvr_Op.DrawBuffer.RRect[2] = w;
+ v->subreq->tvr_Op.DrawBuffer.RRect[3] = h;
+ v->subreq->tvr_Op.DrawBuffer.Buf = v->bufptr + (y0 * tw + x0) * 4;
v->subreq->tvr_Op.DrawBuffer.TotWidth = v->width + v->modulo;
v->subreq->tvr_Op.DrawBuffer.Tags = TNULL;
TExecDoIO(mod->rawfb_ExecBase, &v->subreq->tvr_Req);
diff -r 8378a449a783 -r a7ff2e7d888e src/display_rawfb/display_rawfb_mod.h
--- a/src/display_rawfb/display_rawfb_mod.h Fri Nov 21 18:22:16 2008 +0100
+++ b/src/display_rawfb/display_rawfb_mod.h Wed Nov 26 01:22:15 2008 +0100
@@ -15,7 +15,7 @@
#include <tek/proto/exec.h>
#include <tek/proto/time.h>
-#include <tek/mod/rawfb.h>
+#include <tek/mod/display/rawfb.h>
/*****************************************************************************/
diff -r 8378a449a783 -r a7ff2e7d888e src/display_x11/display_x11_api.c
--- a/src/display_x11/display_x11_api.c Fri Nov 21 18:22:16 2008 +0100
+++ b/src/display_x11/display_x11_api.c Wed Nov 26 01:22:15 2008 +0100
@@ -1069,6 +1069,8 @@
TINT h = req->tvr_Op.DrawBuffer.RRect[3];
TINT totw = req->tvr_Op.DrawBuffer.TotWidth;
TAPTR buf = req->tvr_Op.DrawBuffer.Buf;
+ TUINT dfmt = (mod->x11_Depth << 9) + (mod->x11_PixFmt << 1) +
+ (mod->x11_Flags & TVISF_SWAPBYTEORDER);
if (mod->x11_Depth <= 0)
return; /* unsupported */
@@ -1122,30 +1124,22 @@
if (!v->image)
{
- TBOOL okay = TTRUE;
-
- if (v->tempbuf)
+ TBOOL success = TFALSE;
+ v->image = XCreateImage(mod->x11_Display, mod->x11_Visual,
+ mod->x11_Depth, ZPixmap, 0, NULL, w, h, mod->x11_BPP * 8, 0);
+ if (v->image)
{
- TExecFree(exec, v->tempbuf);
- v->tempbuf = NULL;
- }
-
- if (!(((mod->x11_Depth << 9) + (mod->x11_PixFmt << 1) +
- (mod->x11_Flags & TVISF_SWAPBYTEORDER)) == (24 << 9) +
- (PIXFMT_RGB << 1) + 0))
- {
- /* formats differ, need tempbuf */
- TINT sz = w * h * mod->x11_BPP * 8;
- v->tempbuf = TExecAlloc(exec, TNULL, sz);
- if (v->tempbuf == TNULL) okay = TFALSE;
- }
-
- if (okay)
- {
- void *bufp = v->tempbuf ? v->tempbuf : (char *) buf;
- v->image = XCreateImage(mod->x11_Display, mod->x11_Visual,
- mod->x11_Depth, ZPixmap, 0, bufp, w, h, mod->x11_BPP * 8, 0);
- if (v->image)
+ success = TTRUE;
+ if (dfmt != (24 << 9) + (PIXFMT_RGB << 1) + 0 ||
+ v->image->bytes_per_line != totw * 4)
+ {
More information about the teklib-general
mailing list