*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Thu, 28 Feb 2002 15:40:51 +0100
changeset 3609 5742cce8a004
parent 3608 6ac2b6c8fbd8
child 3610 072b9b097c9f
*** empty log message ***
XWorkstation.st
--- a/XWorkstation.st	Wed Feb 27 11:23:27 2002 +0100
+++ b/XWorkstation.st	Thu Feb 28 15:40:51 2002 +0100
@@ -3926,6 +3926,128 @@
     self primitiveFailedOrClosedConnection
 !
 
+primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth msb:msb masks:maskArray padding:bitPadding
+                             extent:imageExtent sourceOrigin:srcOrg
+                               into:aDrawableId 
+                  destinationOrigin:dstOrg extent:dstExtent 
+                               with:aGCId
+
+    <context: #return>
+
+    |imageWidth imageHeight rm gm bm srcx srcy dstx dsty w h|
+
+    imageWidth := imageExtent x.
+    imageHeight := imageExtent y.
+    rm := maskArray at:1.
+    gm := maskArray at:2.
+    bm := maskArray at:3.
+    srcx := srcOrg x.
+    srcy := srcOrg y.
+    dstx := dstOrg x.
+    dsty := dstOrg y.
+    w := dstExtent x.
+    h := dstExtent y.
+
+    "since XPutImage may allocate huge amount of stack space 
+     (some implementations use alloca), this must run with unlimited stack."
+
+%{  /* UNLIMITEDSTACK */
+
+    /*
+     * need unlimited stack, since some Xlibs do a huge alloca in
+     * XPutImage
+     */
+    GC gc;
+    Window win;
+    XImage image;
+    int imgWdth;
+
+    if (ISCONNECTED
+     && __isExternalAddress(aGCId)
+     && __isExternalAddress(aDrawableId)
+     && __bothSmallInteger(srcx, srcy)
+     && __bothSmallInteger(dstx, dsty)
+     && __bothSmallInteger(w, h)
+     && __bothSmallInteger(imageWidth, imageHeight)
+     && __bothSmallInteger(imageDepth, bitsPerPixel)
+     && __isSmallInteger(bitPadding)
+     && __bothSmallInteger(rm, gm)
+     && __isSmallInteger(bm)
+     && __isByteArray(imageBits)) {
+        Display *dpy = myDpy;
+        int pad = __intVal(bitPadding);
+
+        gc = __GCVal(aGCId);
+        win = __WindowVal(aDrawableId);
+        if (! gc || !win) 
+            goto fail;
+#ifdef ARGDEBUG
+        printf("args ok\n");
+#endif
+        image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element;
+        image.width = imgWdth = __intVal(imageWidth);
+        image.height = __intVal(imageHeight);
+        image.xoffset = 0;
+        image.format = ZPixmap;
+        image.byte_order = (msb == true) ? MSBFirst : LSBFirst;
+        image.bitmap_unit = 8;
+        image.bitmap_bit_order = MSBFirst;
+        image.bitmap_pad = pad;
+        image.depth = __intVal(imageDepth);
+        image.bits_per_pixel = __intVal(bitsPerPixel);
+        image.red_mask = __intVal(rm);
+        image.green_mask = __intVal(gm);
+        image.blue_mask = __intVal(bm);
+
+        image.bytes_per_line = ((((imgWdth * image.bits_per_pixel) + (pad-1)) / pad) * pad) / 8;
+
+        switch (image.bits_per_pixel) {
+            case 1:
+            case 2:
+            case 4:
+            case 8:
+            case 16:
+            case 24:
+            case 32:
+                break;
+
+            default:
+#ifdef ARGDEBUG
+                printf("bits_per_pixel=%d\n",image.bits_per_pixel);
+#endif
+                goto fail;
+        }
+
+        /* ENTER_XLIB(); */
+        XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy),
+                                        __intVal(dstx), __intVal(dsty),
+                                        __intVal(w), __intVal(h));
+        /* LEAVE_XLIB(); */
+
+        RETURN ( true );
+    }
+#ifdef ARGDEBUG
+    if (!! __isExternalAddress(aGCId)) printf("GC\n");
+    if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n");
+    if (!! __isSmallInteger(srcx)) printf("srcx\n");
+    if (!! __isSmallInteger(srcy)) printf("srcy\n");
+    if (!! __isSmallInteger(dstx)) printf("dstx\n");
+    if (!! __isSmallInteger(dsty)) printf("dsty\n");
+    if (!! __isSmallInteger(w)) printf("w\n");
+    if (!! __isSmallInteger(h)) printf("h\n");
+    if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n");
+    if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n");
+    if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n");
+    if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n");
+    if (!! __isByteArray(imageBits)) printf("imageBits\n");
+#endif
+
+fail: ;
+%}
+.
+    ^ false
+!
+
 primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth msb:msb padding:bitPadding
 			      width:imageWidth height:imageHeight 
 				  x:srcx y:srcy
@@ -11652,6 +11774,6 @@
 !XWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.405 2002-02-27 10:23:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.406 2002-02-28 14:40:51 cg Exp $'
 ! !
 XWorkstation initialize!