- real_size = (width > height) ? width : height;
-
- size = real_size;
- /* semi-sleazy way of doing (setq size (expt 2 (ceiling (log size 2)))). */
- for (i = 31; i > 0; i--)
- if (size & (1<<i)) break;
- if (size & (~(1<<i)))
- size = (size>>i)<<(i+1);
- self = XCreatePixmap (dpy, window, size, size, depth);
- temp = XCreatePixmap (dpy, window, size, size, depth);
- mask = XCreatePixmap (dpy, window, size, size, depth);
- gcv.foreground = (depth == 1 ? 1 : (~0));
- gcv.function=GXset; SET = XCreateGC(dpy,self,GCFunction|GCForeground,&gcv);
- gcv.function=GXclear;CLR = XCreateGC(dpy,self,GCFunction|GCForeground,&gcv);
- gcv.function=GXcopy; CPY = XCreateGC(dpy,self,GCFunction|GCForeground,&gcv);
- gcv.function=GXor; IOR = XCreateGC(dpy,self,GCFunction|GCForeground,&gcv);
- gcv.function=GXand; AND = XCreateGC(dpy,self,GCFunction|GCForeground,&gcv);
- gcv.function=GXxor; XOR = XCreateGC(dpy,self,GCFunction|GCForeground,&gcv);
-
- gcv.foreground = gcv.background = bg;
- gc = XCreateGC (dpy, window, GCForeground|GCBackground, &gcv);
- /* Clear self to the background color (not to 0, which CLR does.) */
- XFillRectangle (dpy, self, gc, 0, 0, size, size);
- XSetForeground (dpy, gc, fg);
-
- XCopyArea (dpy, bitmap, self, CPY, 0, 0, width, height,
- (size - width)>>1, (size - height)>>1);
+ return st;
+}
+
+
+static void
+blitspin_init_2 (struct state *st)
+{
+ XGCValues gcv;
+
+ /* make it square */
+ st->size = (st->width < st->height) ? st->height : st->width;
+ st->size = to_pow2(st, st->size, st->scale_up); /* round up to power of 2 */
+ { /* don't exceed screen size */
+ int s = XScreenNumberOfScreen(st->xgwa.screen);
+ int w = to_pow2(st, XDisplayWidth(st->dpy, s), False);
+ int h = to_pow2(st, XDisplayHeight(st->dpy, s), False);
+ if (st->size > w) st->size = w;
+ if (st->size > h) st->size = h;
+ }
+
+ if (st->self) XFreePixmap (st->dpy, st->self);
+ if (st->temp) XFreePixmap (st->dpy, st->temp);
+ if (st->mask) XFreePixmap (st->dpy, st->mask);
+
+ st->self = XCreatePixmap (st->dpy, st->window, st->size, st->size,
+ st->xgwa.depth);
+ st->temp = XCreatePixmap (st->dpy, st->window, st->size, st->size,
+ st->xgwa.depth);
+ st->mask = XCreatePixmap (st->dpy, st->window, st->size, st->size,
+ st->xgwa.depth);
+ gcv.foreground = (st->xgwa.depth == 1 ? 1 : (~0));
+
+# ifdef USE_XCOPYAREA
+# define make_gc(op) \
+ gcv.function=GX##op; \
+ if (st->gc_##op) XFreeGC (st->dpy, st->gc_##op); \
+ st->gc_##op = XCreateGC (st->dpy, st->self, GCFunction|GCForeground, &gcv)
+ make_gc(set);
+ make_gc(clear);
+ make_gc(copy);
+ make_gc(and);
+ make_gc(or);
+ make_gc(xor);
+# endif /* USE_XCOPYAREA */
+
+ gcv.foreground = gcv.background = st->bg;
+ if (st->gc) XFreeGC (st->dpy, st->gc);
+ st->gc = XCreateGC (st->dpy, st->window, GCForeground|GCBackground, &gcv);
+ /* Clear st->self to the background color (not to 0, which 'clear' does.) */
+ XFillRectangle (st->dpy, st->self, st->gc, 0, 0, st->size, st->size);
+ XSetForeground (st->dpy, st->gc, st->fg);
+
+ XCopyArea (st->dpy, st->bitmap, st->self, st->gc, 0, 0,
+ st->width, st->height,
+ (st->size - st->width) >> 1,
+ (st->size - st->height) >> 1);
+
+ st->qwad = -1;
+ st->first_time = 1;