-static Pixmap
-read_screen (Display *dpy, Window window, int *widthP, int *heightP)
-{
- Pixmap p;
- XWindowAttributes xgwa;
- XGCValues gcv;
- GC gc;
- XGetWindowAttributes (dpy, window, &xgwa);
- *widthP = xgwa.width;
- *heightP = xgwa.height;
-
- grab_screen_image(xgwa.screen, window);
- p = XCreatePixmap(dpy, window, *widthP, *heightP, xgwa.depth);
- gcv.function = GXcopy;
- gc = XCreateGC (dpy, window, GCFunction, &gcv);
- XCopyArea (dpy, window, p, gc, 0, 0, *widthP, *heightP, 0, 0);
-
- /* Reset the window's background color... */
- XSetWindowBackground (dpy, window,
- get_pixel_resource ("background", "Background",
- dpy, xgwa.colormap));
- XCopyArea (dpy, p, window, gc, 0, 0, *widthP, *heightP, 0, 0);
- XFreeGC (dpy, gc);
-
- return p;
+ if (!st->img_loader &&
+ st->start_time + st->duration < time ((time_t) 0)) {
+ /* Start it loading, but keep rotating the old image until it arrives. */
+ st->img_loader = load_image_async_simple (0, st->xgwa.screen, st->window,
+ st->bitmap, 0, 0);
+ }
+
+ if (! st->loaded_p) {
+ blitspin_init_2 (st);
+ st->loaded_p = True;
+ }
+
+ if (st->qwad == -1)
+ {
+ XFillRectangle (st->dpy, st->mask, st->CLR, 0, 0, st->size, st->size);
+ XFillRectangle (st->dpy, st->mask, st->SET, 0, 0, st->size>>1, st->size>>1);
+ st->qwad = st->size>>1;
+ }
+
+ if (st->first_time)
+ {
+ st->first_time = 0;
+ display (st, st->self);
+ return st->delay2;
+ }
+
+ /* for (st->qwad = st->size>>1; st->qwad > 0; st->qwad>>=1) */
+
+ copy_all_to (st->mask, 0, 0, st->temp, st->CPY); /* 1 */
+ copy_all_to (st->mask, 0, st->qwad, st->temp, st->IOR); /* 2 */
+ copy_all_to (st->self, 0, 0, st->temp, st->AND); /* 3 */
+ copy_all_to (st->temp, 0, 0, st->self, st->XOR); /* 4 */
+ copy_all_from(st->temp, st->qwad, 0, st->self, st->XOR); /* 5 */
+ copy_all_from(st->self, st->qwad, 0, st->self, st->IOR); /* 6 */
+ copy_all_to (st->temp, st->qwad, 0, st->self, st->XOR); /* 7 */
+ copy_all_to (st->self, 0, 0, st->temp, st->CPY); /* 8 */
+ copy_all_from(st->temp, st->qwad, st->qwad, st->self,st->XOR);/*9*/
+ copy_all_to (st->mask, 0, 0, st->temp, st->AND); /* A */
+ copy_all_to (st->temp, 0, 0, st->self, st->XOR); /* B */
+ copy_all_to (st->temp, st->qwad, st->qwad, st->self, st->XOR); /* C */
+ copy_all_from(st->mask, st->qwad>>1,st->qwad>>1,st->mask,st->AND); /* D */
+ copy_all_to (st->mask, st->qwad, 0, st->mask, st->IOR); /* E */
+ copy_all_to (st->mask, 0, st->qwad, st->mask, st->IOR); /* F */
+ display (st, st->self);
+
+ st->qwad >>= 1;
+ if (st->qwad == 0) /* done with this round */
+ {
+ st->qwad = -1;
+ this_delay = st->delay2;
+ }
+
+ return this_delay;