Add JMiller's new X graphics primitives.
authorChris Hanson <org/chris-hanson/cph>
Tue, 2 Jul 1991 18:18:50 +0000 (18:18 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 2 Jul 1991 18:18:50 +0000 (18:18 +0000)
v7/src/microcode/unxutl/ymkfile
v7/src/microcode/version.h
v7/src/microcode/x11.h
v7/src/microcode/x11base.c
v7/src/microcode/x11graph.c
v8/src/microcode/version.h

index 0228a2905dfc0122acae4968330969ab1d1ba038..76810339a52388612f1ec0bc10b1a8cefdbe1519 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/unxutl/Attic/ymkfile,v 1.44 1991/06/15 00:41:05 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/unxutl/Attic/ymkfile,v 1.45 1991/07/02 18:18:50 cph Exp $
 
 Copyright (c) 1989-91 Massachusetts Institute of Technology
 
@@ -144,8 +144,8 @@ TERMCAP_SOURCES = tterm.c
 TERMCAP_LIBS = LIBS_TERMCAP
 
 #ifdef HAVE_X_WINDOWS
-X_SOURCES = x11base.c x11term.c x11graph.c 
-X_OBJECTS = x11base.o x11term.o x11graph.o
+X_SOURCES = x11base.c x11term.c x11graph.c x11color.c
+X_OBJECTS = x11base.o x11term.o x11graph.o x11color.o
 X_LIB = LIBX11_MACHINE LIBX11_SYSTEM -lX11
 #endif /* HAVE_X_WINDOWS */
 
@@ -299,6 +299,7 @@ char.c \
 comutl.c \
 daemon.c \
 debug.c \
+dfloat.c \
 error.c \
 extern.c \
 fasdump.c \
@@ -382,6 +383,7 @@ char.o \
 comutl.o \
 daemon.o \
 debug.o \
+dfloat.o \
 error.o \
 extern.o \
 fasload.o \
@@ -596,7 +598,7 @@ fixnum.o : scheme.touch prims.h mul.c
 
 storage.o : scheme.touch gctype.c
 
-char.o string.o : scheme.touch prims.h
+char.o string.o dfloat.o : scheme.touch prims.h
 tterm.o : scheme.touch prims.h osterm.h
 
 boot.o : scheme.touch prims.h version.h option.h ostop.h
@@ -625,7 +627,8 @@ Ppband.o : ansidecl.h config.h errors.h types.h const.h object.h \
 dmpwrld.o : scheme.touch prims.h ux.h osfs.h \
        unexec.c unexhp9k800.c getpagesize.h
 
-x11base.o x11graph.o x11term.o starbasex.o : scheme.touch prims.h x11.h
+x11base.o x11color.o x11graph.o x11term.o starbasex.o : scheme.touch prims.h \
+       x11.h
 x11base.o : ux.h uxselect.h
 starbase.o : scheme.touch prims.h
 
index ca6714d6d63c534d88c80ded3dc9cf1146433a83..4b9e5fc86b7fcfb424b1f7e9cefb294282da1462 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.84 1991/06/22 19:29:11 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.85 1991/07/02 18:18:24 cph Exp $
 
 Copyright (c) 1988-91 Massachusetts Institute of Technology
 
@@ -46,5 +46,5 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     84
+#define SUBVERSION     85
 #endif
index 15805b12514073b2728dee80dbe09e9320a05fdf..530a2a73775ee236ef1103e2705ce48285f0b25d 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11.h,v 1.8 1990/10/02 22:52:22 cph Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11.h,v 1.9 1991/07/02 18:18:29 cph Exp $
 
-Copyright (c) 1989, 1990 Massachusetts Institute of Technology
+Copyright (c) 1989-91 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -165,10 +165,24 @@ struct xwindow
 #define FONT_HEIGHT(f) (((f) -> ascent) + ((f) -> descent))
 #define FONT_BASE(f)    ((f) -> ascent)
 \f
+struct ximage
+{
+  unsigned int allocation_index;
+  XImage *image;
+};
+
+#define XI_ALLOCATION_INDEX(xi) ((xi) -> allocation_index)
+#define XI_IMAGE(xi) ((xi -> image))
+
+#define XI_TO_OBJECT(xi) (LONG_TO_UNSIGNED_FIXNUM (XI_ALLOCATION_INDEX (xi)))
+
+#define XV_TO_OBJECT(xv) (LONG_TO_UNSIGNED_FIXNUM (xv))
+\f
 extern int x_debug;
 
 extern struct xdisplay * EXFUN (x_display_arg, (unsigned int arg));
 extern struct xwindow * EXFUN (x_window_arg, (unsigned int arg));
+extern struct ximage * EXFUN (x_image_arg, (unsigned int arg));
 extern PTR EXFUN (x_malloc, (unsigned int size));
 extern PTR EXFUN (x_realloc, (PTR ptr, unsigned int size));
 extern SCHEME_OBJECT EXFUN (x_window_to_object, (struct xwindow * xw));
@@ -196,3 +210,6 @@ extern struct xwindow * EXFUN
     struct drawing_attributes * attributes,
     struct xwindow_methods * methods,
     unsigned int extra));
+
+extern Visual * EXFUN (x_visual_arg, (unsigned int arg));
+extern struct ximage * EXFUN (x_image_arg, (unsigned int arg));
index ee18e18dfcf5e69e56a2d1760d7f52785118997b..329365d7e74eb4a4de2a8768a7504b87b49a45fd 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11base.c,v 1.21 1991/05/09 03:49:05 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11base.c,v 1.22 1991/07/02 18:18:34 cph Exp $
 
 Copyright (c) 1989-91 Massachusetts Institute of Technology
 
@@ -77,6 +77,8 @@ struct allocation_table
 
 static struct allocation_table x_display_table;
 static struct allocation_table x_window_table;
+static struct allocation_table x_image_table;
+static struct allocation_table x_visual_table;
 
 static void
 DEFUN (allocation_table_initialize, (table), struct allocation_table * table)
@@ -148,6 +150,20 @@ DEFUN (x_window_arg, (arg), unsigned int arg)
   INITIALIZE_ONCE ();
   return (allocation_item_arg (arg, (&x_window_table)));
 }
+
+struct ximage *
+DEFUN (x_image_arg, (arg), unsigned int arg)
+{
+  INITIALIZE_ONCE ();
+  return (allocation_item_arg (arg, (&x_image_table)));
+}
+
+Visual *
+DEFUN (x_visual_arg, (arg), unsigned int arg)
+{
+  INITIALIZE_ONCE ();
+  return (allocation_item_arg (arg, (&x_visual_table)));
+}
 \f
 static int
 DEFUN (x_io_error_handler, (display), Display * display)
@@ -388,7 +404,8 @@ DEFUN (x_window_to_xw, (window), Window window)
     }
   return (0);
 }
-
+extern void x_destroy_image ();
+    
 static void
 DEFUN (x_close_window, (xw), struct xwindow * xw)
 {
@@ -757,6 +774,7 @@ DEFUN_VOID (initialize_once)
 {
   allocation_table_initialize (&x_display_table);
   allocation_table_initialize (&x_window_table);
+  allocation_table_initialize (&x_image_table);
   XSetErrorHandler (x_error_handler);
   XSetIOErrorHandler (x_io_error_handler);
   add_reload_cleanup (x_close_all_displays);
@@ -1182,3 +1200,29 @@ DEFINE_PRIMITIVE ("X-WINDOW-SET-ICON-NAME", Prim_x_window_set_icon_name, 2, 2,
   }
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
+\f
+/* Support routines for visual and image handling */
+
+extern unsigned int allocate_x_window (xw)
+struct xwindow * xw;
+{ return allocate_table_index((&x_window_table), xw);
+}
+
+extern unsigned int allocate_x_visual (xv)
+Visual * xv;
+{ return allocate_table_index((&x_visual_table), xv);
+}
+
+extern unsigned int allocate_x_image (xi)
+struct ximage * xi;
+{ return allocate_table_index((&x_image_table), xi);
+}
+
+void x_destroy_image (xi)
+struct ximage * xi;
+{ XImage * image = XI_IMAGE (xi);
+  ((x_image_table . items) [XI_ALLOCATION_INDEX (xi)]) = 0;
+  free (image -> data);
+  XDestroyImage (image);
+  free (xi);
+}
index b9bbb206d851f059634781f4a752053331acd682..044337ac072031ac8d0e24c694ec98308d960fdf 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.10 1991/06/21 03:40:23 gjs Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.11 1991/07/02 18:18:43 cph Exp $
 
 Copyright (c) 1989-91 Massachusetts Institute of Technology
 
@@ -282,19 +282,6 @@ DEFUN (wm_set_size_hint, (xw, geometry_mask, x, y),
   (size_hints . min_height) = extra;
   XSetNormalHints ((XW_DISPLAY (xw)), (XW_WINDOW (xw)), (&size_hints));
 }
-
-#define MAKE_GC(gc, fore, back)                                                \ \
-{                                                                      \ \
-  XGCValues gcv;                                                       \ \
-  (gcv . font) = fid;                                                  \ \
-  (gcv . foreground) = (fore);                                         \ \
-  (gcv . background) = (back);                                         \ \
-  (gc) =                                                               \ \
-    (XCreateGC (display,                                               \ \
-               window,                                                 \ \
-               (GCFont | GCForeground | GCBackground),                 \ \
-               (& gcv)));                                              \ \
-}
 \f
 DEFINE_PRIMITIVE ("X-GRAPHICS-OPEN-WINDOW", Prim_x_graphics_open_window, 3, 3,
   "(X-GRAPHICS-OPEN-WINDOW DISPLAY GEOMETRY SUPPRESS-MAP?)\n\
@@ -531,6 +518,135 @@ DEFINE_PRIMITIVE ("X-GRAPHICS-SET-DASHES", Prim_x_graphics_set_dashes, 3, 3, 0)
   }
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
+\f
+DEFINE_PRIMITIVE ("X-CREATE-IMAGE", Prim_x_create_image, 3, 3, 0)
+{
+  /* Arguments: Window, width, height
+     Returns:   A Scheme image
+
+     The window is used to find the Display, Visual, and Depth
+     information needed to crate an XImage structure.  */
+  extern allocate_x_image ();
+  PRIMITIVE_HEADER (3);
+  {
+    struct xwindow * xw = (x_window_arg (1));
+    Window window = (XW_WINDOW (xw));
+    Display * dpy = (XW_DISPLAY (xw));
+    unsigned int width = (arg_nonnegative_integer (2));
+    unsigned int height = (arg_nonnegative_integer (3));
+    unsigned int bitmap_pad = (BitmapPad (dpy));
+    unsigned int byte_pad = (bitmap_pad / CHAR_BIT);
+    unsigned int bytes_per_line =
+      (((width + (byte_pad - 1)) / byte_pad) * byte_pad);
+    XWindowAttributes attrs;
+    XGetWindowAttributes (dpy, window, (&attrs));
+    {
+      struct ximage * xi = (x_malloc (sizeof (struct ximage)));
+      (XI_ALLOCATION_INDEX (xi)) = (allocate_x_image (xi));
+      (XI_IMAGE (xi)) =
+       (XCreateImage
+        (dpy,
+         (DefaultVisualOfScreen (attrs . screen)),
+         (attrs . depth),
+         ZPixmap,
+         0,
+         ((char *)
+          (x_malloc (height
+                     * bytes_per_line
+                     * ((((attrs . depth) - 1) / 8) + 1)))),
+         width,
+         height,
+         bitmap_pad,
+         bytes_per_line));
+      return (XI_TO_OBJECT (xi));
+    }
+  }
+}
+
+DEFINE_PRIMITIVE("X-GET-PIXEL-FROM-IMAGE", Prim_x_get_image_pixel, 3, 3, 0)
+{
+  PRIMITIVE_HEADER (3);
+  PRIMITIVE_RETURN
+    (long_to_integer
+     (XGetPixel ((XI_IMAGE (x_image_arg (1))),
+                (arg_nonnegative_integer (2)),
+                (arg_nonnegative_integer (3)))));
+}
+
+DEFINE_PRIMITIVE("X-SET-PIXEL-IN-IMAGE", Prim_x_set_image_pixel, 4, 4, 0)
+{ PRIMITIVE_HEADER (4);
+  { struct ximage * xi = x_image_arg(1);
+    long XCoord = arg_integer(2);
+    long YCoord = arg_integer(3);
+    long Pixel = arg_integer(4);
+
+    XPutPixel (XI_IMAGE(xi), XCoord, YCoord, Pixel);
+    PRIMITIVE_RETURN (UNSPECIFIC);
+  }
+}
+
+DEFINE_PRIMITIVE ("X-DESTROY-IMAGE", Prim_x_destroy_image, 1, 1, 0)
+{ extern void x_destroy_image ();
+  PRIMITIVE_HEADER (1);
+  { struct ximage * xi = x_image_arg (1);
+    x_destroy_image (xi);
+    PRIMITIVE_RETURN (UNSPECIFIC);
+  }
+}
+
+DEFINE_PRIMITIVE ("X-DISPLAY-IMAGE", Prim_x_display_image, 8, 8, 0)
+{ /* Called with Image, X-offset in image, Y-offset in image,
+     Window, X-offset in window, Y-offset in window,
+     Width, Height
+  */
+  PRIMITIVE_HEADER (8);
+  { struct ximage * xi = x_image_arg (1);
+    long XImageOffset = arg_integer(2);
+    long YImageOffset = arg_integer(3);
+    struct xwindow * xw = x_window_arg (4);
+    long XWindowOffset = arg_integer(5);
+    long YWindowOffset = arg_integer(6);
+    long Width = arg_integer(7);
+    long Height = arg_integer(8);
+
+    XPutImage(XW_DISPLAY(xw), XW_WINDOW(xw), XW_NORMAL_GC(xw),
+             XI_IMAGE(xi), XImageOffset, YImageOffset,
+             XWindowOffset, YWindowOffset,
+             Width, Height);
+    PRIMITIVE_RETURN (UNSPECIFIC);
+  }
+}
+
+DEFINE_PRIMITIVE ("X-READ-IMAGE", Prim_x_read_image, 8, 8, 0)
+{ /* Called with Image, X-offset in image, Y-offset in image,
+     Window, X-offset in window, Y-offset in window,
+     Width, Height
+  */
+  PRIMITIVE_HEADER (8);
+  { struct ximage * xi = x_image_arg (1);
+    long XImageOffset = arg_integer(2);
+    long YImageOffset = arg_integer(3);
+    struct xwindow * xw = x_window_arg(4);
+    long XWindowOffset = arg_integer(5);
+    long YWindowOffset = arg_integer(6);
+    long Width = arg_integer(7);
+    long Height = arg_integer(8);
+
+    XGetSubImage(XW_DISPLAY(xw), XW_WINDOW(xw), XWindowOffset, YWindowOffset,
+                Width, Height, -1, ZPixmap,
+                XI_IMAGE(xi), XImageOffset, YImageOffset);
+    PRIMITIVE_RETURN (UNSPECIFIC);
+  }
+}
+
+DEFINE_PRIMITIVE ("X-WINDOW-DEPTH", Prim_x_window_depth, 1, 1, 0)
+{ struct xwindow * xw = x_window_arg (1);
+  XWindowAttributes attrs;
+
+  PRIMITIVE_HEADER (1);
+  XGetWindowAttributes(XW_DISPLAY(xw), XW_WINDOW(xw), &attrs);
+  PRIMITIVE_RETURN (long_to_integer (attrs.depth));
+}
 
 DEFINE_PRIMITIVE ("X-GRAPHICS-MAP-X-COORDINATE", Prim_x_graphics_map_x_coordinate, 2, 2, 0)
 {
index 57d348aaa2294dcfd546c2b418bdcc1b47329025..21750ffad17cea2c1f92743301733bc5d67b5209 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.84 1991/06/22 19:29:11 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.85 1991/07/02 18:18:24 cph Exp $
 
 Copyright (c) 1988-91 Massachusetts Institute of Technology
 
@@ -46,5 +46,5 @@ MIT in each case. */
 #define VERSION                11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     84
+#define SUBVERSION     85
 #endif