X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fgrab-ximage.c;h=49e7a8e7d0fca228119fec6fc56ea958c645b0ee;hb=d6b0217f2417bd19187f0ebc389d6c5c2233b11c;hp=653fe4ba9a322ce33d1ee884ee3e4479e9e61c3d;hpb=f0261d8acab611f3433160e4f07367b870439739;p=xscreensaver diff --git a/hacks/glx/grab-ximage.c b/hacks/glx/grab-ximage.c index 653fe4ba..49e7a8e7 100644 --- a/hacks/glx/grab-ximage.c +++ b/hacks/glx/grab-ximage.c @@ -18,10 +18,15 @@ #include #include -#ifdef HAVE_COCOA +#ifdef HAVE_ANDROID +#include +#endif + +#ifdef HAVE_JWXYZ # include "jwxyz.h" -# include -# include +# ifndef HAVE_JWZGLES +# include +# endif #else # include # include @@ -30,6 +35,10 @@ # include /* for glXMakeCurrent() */ #endif +#ifdef HAVE_JWZGLES +# include "jwzgles.h" +#endif /* HAVE_JWZGLES */ + #include "grab-ximage.h" #include "grabscreen.h" #include "visual.h" @@ -65,7 +74,7 @@ extern char *progname; #include -#ifdef HAVE_COCOA +#ifdef HAVE_JWXYZ # include "jwxyz.h" #else # include @@ -94,7 +103,8 @@ bigendian (void) /* Given a bitmask, returns the position and width of the field. */ static void -decode_mask (unsigned int mask, unsigned int *pos_ret, unsigned int *size_ret) +decode_mask (unsigned long mask, unsigned long *pos_ret, + unsigned long *size_ret) { int i; for (i = 0; i < 32; i++) @@ -137,10 +147,10 @@ convert_ximage_to_rgba32 (Screen *screen, XImage *image) Visual *visual = DefaultVisualOfScreen (screen); int x, y; - unsigned int crpos=0, cgpos=0, cbpos=0, capos=0; /* bitfield positions */ - unsigned int srpos=0, sgpos=0, sbpos=0; - unsigned int srmsk=0, sgmsk=0, sbmsk=0; - unsigned int srsiz=0, sgsiz=0, sbsiz=0; + unsigned long crpos=0, cgpos=0, cbpos=0, capos=0; /* bitfield positions */ + unsigned long srpos=0, sgpos=0, sbpos=0; + unsigned long srmsk=0, sgmsk=0, sbmsk=0; + unsigned long srsiz=0, sgsiz=0, sbsiz=0; XColor *colors = 0; unsigned char spread_map[3][256]; @@ -149,10 +159,10 @@ convert_ximage_to_rgba32 (Screen *screen, XImage *image) */ XImage *from = image; XImage *to = XCreateImage (dpy, visual, 32, /* depth */ - ZPixmap, 0, 0, from->width, from->height + 2, + ZPixmap, 0, 0, from->width, from->height, 32, /* bitmap pad */ 0); - to->data = (char *) calloc (to->height, to->bytes_per_line); + to->data = (char *) calloc (to->height + 2, to->bytes_per_line); /* Set the bit order in the XImage structure to whatever the local host's native bit order is. @@ -524,15 +534,11 @@ double_time (void) /* return the next larger power of 2. */ static int -to_pow2 (int i) +to_pow2 (int value) { - static const unsigned int pow2[] = { - 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, - 2048, 4096, 8192, 16384, 32768, 65536 }; - int j; - for (j = 0; j < countof(pow2); j++) - if (pow2[j] >= i) return pow2[j]; - abort(); /* too big! */ + int i = 1; + while (i < value) i <<= 1; + return i; } @@ -587,7 +593,7 @@ ximage_to_texture (XImage *ximage, progname, ximage->width, ximage->height, tex_width, tex_height); - glTexImage2D (GL_TEXTURE_2D, 0, 3, tex_width, tex_height, 0, + glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, tex_width, tex_height, 0, format, type, 0); err = glGetError(); @@ -729,7 +735,7 @@ load_texture_async_cb (Screen *screen, Window window, Drawable drawable, if (geometry->width <= 0 || geometry->height <= 0) { /* This can happen if an old version of xscreensaver-getimage - is installed. */ + is installed. Or if we have no image (checkerboard). */ geometry->x = 0; geometry->y = 0; geometry->width = dd.pix_width;