Home Overview FAQ Documentation Download Mailing List Geomview For Windows? Support Users Development Bug Reporting Contributing Contact Us Sponsors
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Update REQ 5246]: X-geomview 1.5.0 visual support
> I would be quite interested in looking at your code. I was > considering writing code to support 16bit visuals, but I only had > one example of one -- a NeXT running coXist. It's visual uses a > color weighting of 444, which is atypical. We now have a linux > box which can run in 16bit mode, so we should be able to start > working on this. Unfortunately my machine at home has a cirrus > card which doesn't want to do linear mapping, otherwise I would > have worked on this before. Below are the diffs for the changes. I haven't had much time to work on it so please excuse my sloppy and incomplete changes. I tested the changes with mgexample. It looks like geomview does it's own x11 setup, so that would still need to be changed to get geomview working. I've put in code to mgx11windows.c to query the server about what visuals it supports. It first looks for the TrueColor visual with the most bit planes; if it finds one with > 8 bit planes it will choose that. Otherwise it looks for the PseudoColor visual with the most bit planes. I've added some fields to the mgx11context structure to record info about the visual. Then I find what pixmap formats the server supports and place info on that format into some more new fields in the mgx11context structure. (My code doesn't use all of these fields yet--but an optimized version would use the information.) I've modified the mgx11render24.c code to support all TrueColor visuals. I did this by using XPutPixel, which will be a bit of a performance hit (I haven't quantified this yet, though). Many of the changes I made are still untested. I only rendered the data file in the mgexample directory (it work to 8 bit TrueColor (3/3/2) 16 bit TrueColor (5/6/5) and 8 bit PseudoColor). Future work might involve restoring mgx11render24.c to its former efficient self with a modified RGBtoVal routine so it would support all servers with 32 bits per pixel in their pixmap format. Then versions for other numbers of bits per pixel could be written as desired. Support for PseudoColor visuals could be rolled into this code by modifying RGBtoVal to lookup the colormap entry from a table. The dithering code could also be rolled in and generalized so that TrueColor visuals without very many colors could use dithered colors. I am interested in continuing to help with the X11 support in geomview, so let me know what else I can do (but I am limited by not being able to compile and run geomview itself as well as by my current workload with other projects so turnaround time for code to get written will be long). Are there any plans to convert geomview to C++. Seems like geomview is naturally suited to an OO approach. If so, would you start with Fresco, some other existing widget hierarchy, or start from scratch? Curt ===================== diffs ========================= diff -ur Geomview/src/lib/mg/x11/mgx11P.h /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11/mgx11P.h --- Geomview/src/lib/mg/x11/mgx11P.h Wed Dec 7 19:07:49 1994 +++ /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11/mgx11P.h Sun Feb 19 18:19:18 1995 @@ -94,6 +94,21 @@ enum sortmethod sortmethod; /* MG_NONE, MG_DEPTH, MG_ZBUFFER */ int dither; /* Should we dither? */ int bitdepth; /* what bit depth ... 24, 8, or 1? */ + + /* Members for pixmaps. */ + int bits_per_pixel; + int scanline_pad; + int swap_bytes; /* 1 if the server's byte order is swapped. */ + + /* Members for decomposed visuals. */ + int decomposed; /* Are RGB decomposed in this visual? */ + int red_max; /* The largest value for red. */ + int red_shift; /* The number of bits red is shifted. */ + int green_max; /* The largest value for green. */ + int green_shift; /* The number of bits green is shifted. */ + int blue_max; /* The largest value for blue. */ + int blue_shift; /* The number of bits blue is shifted. */ + Visual *visual; /* visual for window */ int shm; /* Do we use shared memory? */ int xmin, xmax, ymin, ymax; Only in /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11: mgx11P.h~ diff -ur Geomview/src/lib/mg/x11/mgx11render24.c /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11/mgx11render24.c --- Geomview/src/lib/mg/x11/mgx11render24.c Tue Oct 25 11:08:34 1994 +++ /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11/mgx11render24.c Mon Feb 20 23:08:27 1995 @@ -23,9 +23,6 @@ static endPoint *mug=NULL; static mugSize = 0; -static int redmask; -static int greenmask; -static int bluemask; #ifdef __GNUC__ inline @@ -33,31 +30,14 @@ static int RGBtoVal(int r, int g, int b) { - return ((redmask & (r|(r<<8)|(r<<16)|(r<<24))) | - (greenmask& (g|(g<<8)|(g<<16)|(g<<24))) | - (bluemask & (b|(b<<8)|(b<<16)|(b<<24)))); -} - -static int -swap32(unsigned long word) -{ - return (word >> 24) | (word >> 8) & 0xFF00 | ((word&0xFF00) << 8) | ((word&0xFF) << 24); + return (_mgx11c->red_max*r + 127)/255 << _mgx11c->red_shift + |(_mgx11c->green_max*g + 127)/255 << _mgx11c->green_shift + |(_mgx11c->blue_max*b + 127)/255 << _mgx11c->blue_shift; } void -Xmgr_24init(int rmask, int gmask, int bmask) +Xmgr_24init() { - long word = 1; - if((*(char *)&word != 0) == (ImageByteOrder(_mgx11c->mgx11display) == LSBFirst)) { - redmask = rmask; - greenmask = gmask; - bluemask = bmask; - } else { - /* Flip byte order to server's own format. */ - redmask = swap32(rmask); - greenmask = swap32(gmask); - bluemask = swap32(bmask); - } } @@ -68,8 +48,8 @@ int width, int height, int *color, int flag, int fullclear, int xmin, int ymin, int xmax, int ymax) { - int *ptr = (int *)buf; - int i, fill, end, x, length, pos; + XImage *image = _mgx11c->myxwin->image; + int i, j, fill, end, x, length, pos; fill = RGBtoVal(color[0], color[1], color[2]); if (mug==NULL) @@ -86,8 +66,9 @@ if (fullclear) { end = (width*height)/4; - for (i=0; i<end; i++) - ptr[i] = fill; + for (i=0; i<width; i++) + for (j=0; j<height; j++) + XPutPixel(image, i, j, fill); if (flag) for (i=0; i<zwidth*height; i++) @@ -100,9 +81,8 @@ ymax = MIN(height-1,ymax); for (i=ymin; i<=ymax; i++) { - ptr = (int *)(buf+width*i+xmin*4); for (x=0; x<length; x++) - ptr[x] = fill; + XPutPixel(image, x + xmin, i, fill); } length = MIN(zwidth-1,xmax)-xmin+1; if (flag) @@ -122,11 +102,11 @@ wideline(unsigned char *buf, float *zbuf, int zwidth, int width, int height, int x1, int y1, int x2, int y2, int lwidth, int *color) { + XImage *image = _mgx11c->myxwin->image; register int d, x, y, ax, ay, sx, sy, dx, dy; int i, end; int col = RGBtoVal(color[0], color[1], color[2]); int width4 = width>>2; - int *ptr = (int *)buf; dx = x2-x1; dy = y2-y1; @@ -146,7 +126,8 @@ { if ((x>=0) && (x<zwidth)) for (i=MAX(0,y-lwidth/2), end=MIN(height-1,y-lwidth/2+lwidth); i<end; i++) - ptr[i*width4+x] = col; + /* ptr[i*width4+x] = col; */ + XPutPixel(image, x, i, col); if (x==x2) break; if (d>=0) { @@ -164,7 +145,8 @@ { if ((y>=0) && (y<height)) for (i=MAX(0,x-lwidth/2), end=MIN(zwidth-1,x-lwidth/2+lwidth); i<end; i++) - ptr[y*width4+i] = col; + /* ptr[y*width4+i] = col; */ + XPutPixel(image, i, y, col); if (y==y2) break; if (d>=0) { @@ -182,6 +164,7 @@ Xmgr_24line(unsigned char *buf, float *zbuf, int zwidth, int width, int height, int x1, int y1, float z1, int x2, int y2, float z2, int lwidth, int *color) { + XImage *image = _mgx11c->myxwin->image; int d, x, y, ax, ay, sx, sy, dx, dy; int width4 = width>>2; int *ptr=(int *)(buf+y1*width+4*x1); @@ -211,7 +194,8 @@ for (;;) { if ((x>=0) && (x<zwidth) && (y>=0) && (y<height)) - *ptr = col; + /* *ptr = col; */ + XPutPixel(image, y, x, col); if (x==x2) return; if (d>=0) { @@ -233,7 +217,8 @@ for (;;) { if ((x>=0) && (x<zwidth) && (y>=0) && (y<height)) - *ptr = col; + /* *ptr = col; */ + XPutPixel(image, y, x, col); if (y==y2) return; if (d>=0) { @@ -257,6 +242,7 @@ int x1, int y1, float z1, int x2, int y2, float z2, int lwidth, int *color) { + XImage *image = _mgx11c->myxwin->image; register int d, x, y, ax, ay, sx, sy, dx, dy; float delta=0, z; int jumps, total; @@ -295,7 +281,8 @@ { if ((z<zbuf[i*zwidth+x]) && (z>-1.0)) { - ptr[i*width4+x] = col; + /* ptr[i*width4+x] = col; */ + XPutPixel(image, x, i, col); zbuf[i*zwidth+x] = z; } } @@ -323,7 +310,8 @@ { if ((z<zbuf[y*zwidth+i]) && (z>-1.0)) { - ptr[y*width4+i] = col; + /* ptr[y*width4+i] = col; */ + XPutPixel(image, i, y, col); zbuf[y*zwidth+i] = z; } } @@ -347,6 +335,7 @@ int x1, int y1, float z1, int x2, int y2, float z2, int lwidth, int *color) { + XImage *image = _mgx11c->myxwin->image; register int d, x, y, ax, ay, sx, sy, dx, dy; int width4=width>>2; int *ptr=(int *)(buf+y1*width+4*x1); @@ -388,7 +377,8 @@ if ((x>=0) && (x<zwidth) && (y>=0) && (y<height) && (z<zbuf[y*zwidth+x]) && (z>-1.0)) { - *ptr = col; + /* *ptr = col; */ + XPutPixel(image, x, y, col); zbuf[y*zwidth+x] = z; } if (x==x2) break; @@ -416,7 +406,8 @@ if ((x>=0) && (x<zwidth) && (y>=0) && (y<height) && (z<zbuf[y*zwidth+x]) && (z>-1.0)) { - *ptr = col; + /* *ptr = col; */ + XPutPixel(image, x, y, col); zbuf[y*zwidth+x] = z; } if (y==y2) break; @@ -444,6 +435,7 @@ int x1, int y1, double z1, int r1, int g1, int b1, int x2, int y2, double z2, int r2, int g2, int b2, int lwidth) { + XImage *image = _mgx11c->myxwin->image; register int d, x, y, ax, ay, sx, dx, dy; double r, g, b, rdelta, gdelta, bdelta; int total, i, end; @@ -474,7 +466,8 @@ { if ((x >= 0) && (x < width)) for (i=MAX(0,y-lwidth/2), end=MIN(height-1,y-lwidth/2+lwidth); i<end; i++) - ptr[i*width4+x] = RGBtoVal(r, g, b); + /* ptr[i*width4+x] = RGBtoVal(r, g, b); */ + XPutPixel(image, x, i, RGBtoVal(r, g, b)); if (x==x2) break; if (d>=0) { @@ -494,7 +487,8 @@ { if ((y>=0) && (y<height)) for (i=MAX(0,x-lwidth/2), end=MIN(width-1,x-lwidth/2+lwidth); i<end; i++) - ptr[y*width4+i] = RGBtoVal(r, g, b); + /* ptr[y*width4+i] = RGBtoVal(r, g, b); */ + XPutPixel(image, i, y, RGBtoVal(r, g, b)); if (y==y2) break; if (d>=0) { @@ -513,6 +507,7 @@ Xmgr_24Gline(unsigned char *buf, float *zbuf, int zwidth, int width, int height, CPoint3 *p1, CPoint3 *p2, int lwidth) { + XImage *image = _mgx11c->myxwin->image; register int d, x, y, ax, ay, sx, dx, dy; int width4 = width>>2; int *ptr; @@ -568,7 +563,8 @@ { if (y>=height) return; if ((x>=0) && (x<width) && (y>=0)) - *ptr = RGBtoVal(r, g, b); + /* *ptr = RGBtoVal(r, g, b); */ + XPutPixel(image, x, y, RGBtoVal(r,g,b)); if (x==x2) break; if (d>=0) { @@ -590,7 +586,8 @@ { if (y>=height) return; if ((x>=0) && (x<width) && (y>=0)) - *ptr = RGBtoVal(r, g, b); + /* *ptr = RGBtoVal(r, g, b); */ + XPutPixel(image, x, y, RGBtoVal(r,g,b)); if (y==y2) break; if (d>=0) { @@ -613,6 +610,7 @@ int x1, int y1, double z1, int r1, int g1, int b1, int x2, int y2, double z2, int r2, int g2, int b2, int lwidth) { + XImage *image = _mgx11c->myxwin->image; register int d, x, y, ax, ay, sx, dx, dy; double delta=0, z; double r, g, b, rdelta, gdelta, bdelta; @@ -649,7 +647,8 @@ { if ((z<zbuf[i*zwidth+x]) && (z>-1.0)) { - ptr[i*width4+x] = RGBtoVal(r, g, b); + /* ptr[i*width4+x] = RGBtoVal(r, g, b); */ + XPutPixel(image, x, i, RGBtoVal(r, g, b)); zbuf[i*zwidth+x] = z; } } @@ -678,7 +677,8 @@ { if ((z<zbuf[y*zwidth+i]) && (z>-1.0)) { - ptr[y*width4+i] = RGBtoVal(r, g, b); + /* ptr[y*width4+i] = RGBtoVal(r, g, b); */ + XPutPixel(image, i, y, RGBtoVal(r,g,b)); zbuf[y*zwidth+i] = z; } } @@ -703,6 +703,7 @@ Xmgr_24GZline(unsigned char *buf, float *zbuf, int zwidth, int width, int height, CPoint3 *p1, CPoint3 *p2, int lwidth) { + XImage *image = _mgx11c->myxwin->image; register int d, x, y, ax, ay, sx, dx, dy; int width4 = width>>2; int *ptr; @@ -762,7 +763,8 @@ if (y>=height) return; if ((x>=0) && (x<width) && (y>=0) && (z<*zptr) && (z>-1.0)) { - *ptr = RGBtoVal(r, g, b); + /* *ptr = RGBtoVal(r, g, b); */ + XPutPixel(image, x, y, RGBtoVal(r, g, b)); *zptr = z; } if (x==x2) break; @@ -791,7 +793,8 @@ if (y>=height) return; if ((x>=0) && (x<width) && (y>=0) && (z<*zptr) && (z>-1.0)) { - *ptr = RGBtoVal(r, g, b); + /* *ptr = RGBtoVal(r, g, b); */ + XPutPixel(image, x, y, RGBtoVal(r, g, b)); *zptr = z; } if (y==y2) break; @@ -822,7 +825,7 @@ Xmgr_doLines(unsigned char *buf, float *zbuf, int zwidth, int width, int height, int miny, int maxy, int *color, endPoint *mug) { - register int *ptr; /* pixel pointers */ + XImage *image = _mgx11c->myxwin->image; register int i, x2; /* dithering junk */ int y, x1; /* current line */ int col=RGBtoVal(color[0], color[1], color[2]); @@ -837,9 +840,10 @@ x2 = zwidth-1; else x2 = mug[y].P2x; - ptr = (int *)(buf+width*y+x1*4); - for (i=x1; i<=x2; i++, ptr++) - *ptr = col; + /* ptr = (int *)(buf+width*y+x1*4); */ + for (i=x1; i<=x2; i++) + /* *ptr = col; */ + XPutPixel(image, i, y, col); } } @@ -847,6 +851,7 @@ Xmgr_ZdoLines(unsigned char *buf, float *zbuf, int zwidth, int width, int height, int miny, int maxy, int *color, endPoint *mug) { + XImage *image = _mgx11c->myxwin->image; register int *ptr; /* pixel pointers */ register float *zptr; /* zbuff pointers */ register int i, x2; /* dithering junk */ @@ -887,7 +892,8 @@ for (i=x1; i<=x2; i++, z+=zdelta, zptr++, ptr++) if ((z < *zptr) && (z>-1.0)) { - *ptr = col; + /* *ptr = col; */ + XPutPixel(image, i, y, col); *zptr = z; } } @@ -895,7 +901,8 @@ for (i=x1; i<=x2; i++, z+=zdelta, zptr++, ptr++) if (z < *zptr) { - *ptr = col; + /* *ptr = col; */ + XPutPixel(image, i, y, col); *zptr = z; } } @@ -905,6 +912,7 @@ Xmgr_GdoLines(unsigned char *buf, float *zbuf, int zwidth, int width, int height, int miny, int maxy, endPoint *mug) { + XImage *image = _mgx11c->myxwin->image; int *ptr; /* pixel pointers */ register int i, x2; /* dithering junk */ int y, x1; /* current line */ @@ -958,7 +966,8 @@ ptr = (int *)(buf+width*y+x1*4); for (i=x1; i<=x2; i++, ptr++) { - *ptr = RGBtoVal(r, g, b); + /* *ptr = RGBtoVal(r, g, b); */ + XPutPixel(image, i, y, RGBtoVal(r, g, b)); if (dx) { while (er>0) { @@ -985,6 +994,7 @@ Xmgr_GZdoLines(unsigned char *buf, float *zbuf, int zwidth, int width, int height, int miny, int maxy, endPoint *mug) { + XImage *image = _mgx11c->myxwin->image; int *ptr; /* pixel pointers */ register float *zptr; /* zbuff pointers */ register int i, x2; /* dithering junk */ @@ -1052,7 +1062,8 @@ { if ((z < *zptr) && (z>-1.0)) { - *ptr = RGBtoVal(r, g, b); + /* *ptr = RGBtoVal(r, g, b); */ + XPutPixel(image, i, y, RGBtoVal(r,g,b)); *zptr = z; } if (dx) { @@ -1079,7 +1090,8 @@ { if (z < *zptr) { - *ptr = RGBtoVal(r, g, b); + /* *ptr = RGBtoVal(r, g, b); */ + XPutPixel(image, i, y, RGBtoVal(r, g, b)); *zptr = z; } if (dx) { Only in /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11: mgx11render24.c~ diff -ur Geomview/src/lib/mg/x11/mgx11render24.h /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11/mgx11render24.h --- Geomview/src/lib/mg/x11/mgx11render24.h Thu Oct 13 07:06:14 1994 +++ /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11/mgx11render24.h Sun Feb 19 18:26:11 1995 @@ -13,7 +13,7 @@ #define MGX11RENDER24 void -Xmgr_24init(int rmask, int gmask, int bmask); +Xmgr_24init(); void Xmgr_24clear(unsigned char *buf, float *zbuf, int zwidth, Only in /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11: mgx11render24.h~ diff -ur Geomview/src/lib/mg/x11/mgx11windows.c /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11/mgx11windows.c --- Geomview/src/lib/mg/x11/mgx11windows.c Wed Dec 14 16:05:05 1994 +++ /usr/people/janssen/src/graphics/Geomview/src/lib/mg/x11/mgx11windows.c Mon Feb 20 22:51:43 1995 @@ -36,6 +36,99 @@ /* X Error stuff */ static int globalXError; +static void +set_color_max_and_shift(unsigned mask, int *max, int *shift) +{ + int i; + for (i=0; i<32; i++) { + if (mask & 1) { + *max = mask; + *shift = i; + return; + } + mask = mask>>1; + } + fprintf(stderr, "color mask was 0\n"); + abort(); +} + +static Visual * +visual_with_most_planes(Display *display, int class, XVisualInfo *info) +{ + int num_vis; + XVisualInfo *vlist, vinfo_template, *v; + vinfo_template.class = class; + + vlist = XGetVisualInfo(display, + VisualClassMask, + &vinfo_template, + &num_vis); + if (vlist && num_vis) { + XVisualInfo *best = vlist; + Visual *bestvisual; + for (v = vlist + 1; v < vlist + num_vis; v++) { + if (v->depth > best->depth) best = v; + } + if (info) { + *info = *best; + } + bestvisual = best->visual; + XFree((char*)vlist); + return bestvisual; + } + + return 0; +} + +static Visual* +get_best_visual(Display *display, XVisualInfo *infoarg) +{ + int i; + int classes[] = { TrueColor, PseudoColor }; + char *classnames[] = { "TrueColor", "PseudoColor" }; + XVisualInfo info; + XVisualInfo *infoptr; + + if (infoarg) { + infoptr = infoarg; + } + else { + infoptr = &info; + } + + /* Loop through the visual classes in order of desirability. */ + for (i=0; i<2; i++) { + Visual *result; + fprintf(stderr, "Looking for %s visuals.\n", classnames[i]); + result = visual_with_most_planes(display, classes[i], infoptr); + /* Go on to PseudoColor if an 8 bit TrueColor is found. */ + if (classes[i] == TrueColor && infoptr->depth <= 8) continue; + if (result) return result; + } + + fprintf(stderr, "Couldn't find any visuals\n"); + abort(); + return 0; +} + +void +visual_to_visualinfo(Display *display, Visual *visual, XVisualInfo* info) +{ + int num_vis; + XVisualInfo vinfo_template, *v; + + vinfo_template.visualid = XVisualIDFromVisual(visual); + + v = XGetVisualInfo(display, VisualIDMask, &vinfo_template, &num_vis); + if (!num_vis || !v) { + fprintf(stderr,"problem with visual_to_visualinfo\n"); + abort(); + } + + *info = *v; + XFree(v); +} + /* Function: myXErrorHandler Description: handle error if shared memory is unavailable @@ -54,12 +147,15 @@ */ void Xmg_setx11display(Display *dpy) { + long testword = 1; XColor col; - int colfail = 1, i; + int colfail = 1, i, n; unsigned int nplanes = 0; unsigned long planemasks[1]; int rgbmap[216][3]; int cube; + XVisualInfo info; + XPixmapFormatValues *pmf; _mgx11c->mgx11display = dpy; @@ -68,10 +164,44 @@ mgx11display = dpy; + if (!_mgx11c->visual) { + int screen; + screen = DefaultScreen(mgx11display); + + _mgx11c->visual = get_best_visual(mgx11display, 0); + } + + visual_to_visualinfo(mgx11display, _mgx11c->visual, &info); + _mgx11c->bitdepth = info.depth; + if (info.class == TrueColor || info.class == DirectColor) { + _mgx11c->decomposed = 1; + set_color_max_and_shift(info.red_mask, + &_mgx11c->red_max, &_mgx11c->red_shift); + set_color_max_and_shift(info.green_mask, + &_mgx11c->green_max, &_mgx11c->green_shift); + set_color_max_and_shift(info.blue_mask, + &_mgx11c->blue_max, &_mgx11c->blue_shift); + } + + pmf = XListPixmapFormats (dpy, &n); + if (pmf) { + for (i = 0; i < n; i++) { + if (pmf[i].depth == _mgx11c->bitdepth) { + _mgx11c->bits_per_pixel = pmf[i].bits_per_pixel; + _mgx11c->scanline_pad = pmf[i].scanline_pad; + break; + } + } + XFree ((char *) pmf); + } + + _mgx11c->swap_bytes = (*(char *)&testword != 0) + != (ImageByteOrder(_mgx11c->mgx11display) == LSBFirst); + if (_mgx11c->bitdepth == 1) /* We are on a black and white screen! */ return; - if (_mgx11c->bitdepth == 24) /* We are on a TrueColor screen! */ + if (_mgx11c->decomposed) { colorlevels = 0; return; @@ -153,6 +283,7 @@ _mgx11c->mysort = mgx11sort; _mgx11c->myxwin = NULL; _mgx11c->bitdepth = 0; + _mgx11c->decomposed = 0; _mgx11c->visual = NULL; _mgx11c->noclear = 0; return 1; @@ -183,15 +314,25 @@ int bitmap_pad; XErrorHandler handler; - if (!_mgx11c->bitdepth) - _mgx11c->bitdepth = 8; - - if (!mgx11display) - Xmg_setx11display(XOpenDisplay(NULL)); + if (!mgx11display) { + Xmg_setx11display(XOpenDisplay(NULL)); + } - if (!_mgx11c->visual) - _mgx11c->visual = DefaultVisual(mgx11display, - DefaultScreen(mgx11display)); + fprintf(stderr," mgx11display = 0x%x\n", mgx11display); + fprintf(stderr," _mgx11c->visual = 0x%x\n", _mgx11c->visual); + fprintf(stderr," _mgx11c->bitdepth = %d\n", _mgx11c->bitdepth); + fprintf(stderr," _mgx11c->bits_per_pixel %d\n", _mgx11c->bits_per_pixel); + fprintf(stderr," _mgx11c->scanline_pad %d\n", _mgx11c->scanline_pad); + fprintf(stderr," _mgx11c->swap_bytes = %d\n", _mgx11c->swap_bytes); + fprintf(stderr," _mgx11c->decomposed = %d\n", _mgx11c->decomposed); + if (_mgx11c->decomposed) { + fprintf(stderr," _mgx11c->red_max = %d\n", _mgx11c->red_max); + fprintf(stderr," _mgx11c->red_shift = %d\n", _mgx11c->red_shift); + fprintf(stderr," _mgx11c->green_max = %d\n", _mgx11c->green_max); + fprintf(stderr," _mgx11c->green_shift = %d\n", _mgx11c->green_shift); + fprintf(stderr," _mgx11c->blue_max = %d\n", _mgx11c->blue_max); + fprintf(stderr," _mgx11c->blue_shift = %d\n", _mgx11c->blue_shift); + } border_color = WhitePixel(_mgx11c->mgx11display, DefaultScreen(_mgx11c->mgx11display)); @@ -204,9 +345,26 @@ _mgx11c->myxwin = (mgx11win *)malloc(sizeof(mgx11win)); current = _mgx11c->myxwin; - current->window = XCreateSimpleWindow(_mgx11c->mgx11display, - DefaultRootWindow(_mgx11c->mgx11display), 0, 0, TWIDTH, - THEIGHT, border_width, border_color, bg_color); + if (!_mgx11c->decomposed) { + current->window = XCreateSimpleWindow(_mgx11c->mgx11display, + DefaultRootWindow(_mgx11c->mgx11display), 0, 0, TWIDTH, + THEIGHT, border_width, border_color, bg_color); + } + else { + XSetWindowAttributes attrib; + unsigned long attribmask; + attribmask = CWBackPixel|CWBorderPixel|CWColormap; + attrib.border_pixel = bg_color; + attrib.background_pixel = bg_color; + attrib.colormap = XCreateColormap(_mgx11c->mgx11display, + DefaultRootWindow(_mgx11c->mgx11display), + _mgx11c->visual, AllocNone); + current->window = XCreateWindow(_mgx11c->mgx11display, + DefaultRootWindow(_mgx11c->mgx11display), + 0, 0, TWIDTH, THEIGHT, border_width, + _mgx11c->bitdepth, InputOutput, + _mgx11c->visual, attribmask, &attrib); + } XStoreName(_mgx11c->mgx11display, current->window, id); current->xswa.colormap = DefaultColormap(_mgx11c->mgx11display, @@ -227,6 +385,7 @@ current->image = NULL; if (XShmQueryExtension(_mgx11c->mgx11display) == True) { + fprintf(stderr, "XShmCreateImage(1)\n"); current->image = XShmCreateImage(_mgx11c->mgx11display, _mgx11c->visual, _mgx11c->bitdepth, ZPixmap, NULL, &(current->shminf), @@ -264,17 +423,10 @@ shm_message_shown = 1; } - switch (_mgx11c->bitdepth) - { - case 1: - case 8: bitmap_pad = 8; break; - case 24: bitmap_pad = 32; break; - default: fprintf(stderr, "Unknown bit depth %d\n", _mgx11c->bitdepth); - } current->image = XCreateImage(_mgx11c->mgx11display, _mgx11c->visual, _mgx11c->bitdepth, ZPixmap, 0, NULL, TWIDTH, THEIGHT, - bitmap_pad, 0); + _mgx11c->scanline_pad, 0); current->buf = (unsigned char *)malloc(current->image->bytes_per_line * current->image->height); current->image->data = (char *) current->buf; @@ -762,7 +914,7 @@ /* Choose functions */ - if (_mgx11c->bitdepth == 8) + if (_mgx11c->bitdepth == 8 && !_mgx11c->decomposed) { clear = Xmgr_8clear; if (_mgx11c->sortmethod == MG_ZBUFFER) @@ -802,11 +954,9 @@ } } } - else if (_mgx11c->bitdepth == 24) + else if (_mgx11c->decomposed) { - Xmgr_24init(_mgx11c->visual->red_mask, - _mgx11c->visual->green_mask, - _mgx11c->visual->blue_mask); + Xmgr_24init(); clear = Xmgr_24clear; if (_mgx11c->sortmethod == MG_ZBUFFER) { @@ -855,6 +1005,7 @@ if (_mgx11c->sortmethod == MG_ZBUFFER) { +#if 0 /* I don't understand this bit yet. */ switch (_mgx11c->bitdepth) { case 24: @@ -872,6 +1023,14 @@ return; break; } +#else + if (_mgx11c->bitdepth == 8) { + wantedzsize = w*h; + } + else { + wantedzsize = zwidth*h; + } +#endif if (wantedzsize > mgx11zsize) { @@ -1038,7 +1197,6 @@ int bytes_per_line; mgx11win *current=_mgx11c->myxwin; XErrorHandler handler; - int bitmap_pad; /* fprintf(stderr,"X11: Get Window Size\n"); */ if (_mgx11c->visible) @@ -1086,6 +1244,7 @@ current->image = NULL; if (XShmQueryExtension(_mgx11c->mgx11display) == True) { + fprintf(stderr, "XShmCreateImage(2)\n"); current->image = XShmCreateImage(_mgx11c->mgx11display, _mgx11c->visual, _mgx11c->bitdepth, @@ -1126,20 +1285,12 @@ shm_message_shown = 1; } - switch (_mgx11c->bitdepth) - { - case 1: - case 8: bitmap_pad = 8; break; - case 24: bitmap_pad = 32; break; - default: fprintf(stderr, "Unknown bit depth %d\n", _mgx11c->bitdepth); - } current->image = XCreateImage(_mgx11c->mgx11display, _mgx11c->visual, _mgx11c->bitdepth, ZPixmap, 0, NULL, width, height, - bitmap_pad, 0); + _mgx11c->scanline_pad, 0); if((bytes_per_line = current->image->bytes_per_line) == 0) { - int bpp = _mgx11c->bitdepth == 24 ? 32 : _mgx11c->bitdepth; - bytes_per_line = ((bpp * width + 31) >> 5) << 2; + bytes_per_line = width*_mgx11c->scanline_pad/8; } current->buf = (unsigned char *) malloc(bytes_per_line * height); ===================== end of diffs =========================
|
||
Home | Overview | FAQ | Documentation | Support | Download | Mailing List Windows? | Development | Bug Reporting | Contributing | Contact Us | Sponsors |
|||
site hosted by |