gtk: Add gdk-window-create-similar-surface and -image-surface.
authorMatt Birkholz <matt@birchwood-abbey.net>
Mon, 28 Aug 2017 19:47:11 +0000 (12:47 -0700)
committerMatt Birkholz <matt@birchwood-abbey.net>
Mon, 28 Aug 2017 19:47:11 +0000 (12:47 -0700)
src/gtk/Includes/gdkcairo.cdecl
src/gtk/Includes/gdkwindow.cdecl
src/gtk/gdk.scm
src/gtk/gtk.pkg

index 15e6470fb264cec0e11254bdeb10a991a10e0d38..0ed19e85780c6a47127c572f76b6f1302d8e7fa6 100644 (file)
@@ -4,6 +4,19 @@ gdk/gdkcairo.h |#
 
 ;(include "pangocairo")
 
+(typedef cairo_content_t
+  (enum _cairo_content
+    (CAIRO_CONTENT_COLOR)
+    (CAIRO_CONTENT_ALPHA)
+    (CAIRO_CONTENT_COLOR_ALPHA))) 
+
+(typedef cairo_format_t
+  (enum _cairo_format
+    (CAIRO_FORMAT_ARGB32)
+    (CAIRO_FORMAT_RGB24)
+    (CAIRO_FORMAT_A8)
+    (CAIRO_FORMAT_A1)))
+
 (extern void gdk_cairo_set_source_pixbuf
        (cr (* cairo_t))
        (pixbuf (* (const GdkPixbuf)))
index e5012c1a2996a46900b51ac6487c74a72f9113ba..9a4a64996637392864382a9116d6abaf5d660e0f 100644 (file)
@@ -147,6 +147,9 @@ gdk/gdkwindow.h |#
        (window (* GdkWindow))
        (x gint) (y gint) (width gint) (height gint))
 
+(extern gint gdk_window_get_scale_factor
+       (window (* GdkWindow)))
+
 #;(extern (* GdkWindow) gdk_window_get_pointer
        (window (* GdkWindow))
        (x (* gint))
@@ -162,6 +165,21 @@ gdk/gdkwindow.h |#
        (window (* GdkWindow))
        (cursor (* GdkCursor)))
 
+(extern (* cairo_surface_t)
+       gdk_window_create_similar_surface
+       (window (* GdkWindow))
+       (content cairo_content_t)
+       (width int)
+       (height int))
+
+(extern (* cairo_surface_t)
+       gdk_window_create_similar_image_surface
+       (window (* GdkWindow))
+       (format cairo_format_t)
+       (width int)
+       (height int)
+       (scale int))
+
 (extern void
        gdk_window_invalidate_rect
        (window (* GdkWindow))
index 35a575636486d4ae69d6d63de4814b629d519605..3ac76fbe9a4615140d7070770b9ba615b0fa1330 100644 (file)
@@ -27,6 +27,26 @@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 (define-integrable-operator (guarantee-gdk-window object operator)
   (if (not (and (alien? object) (eq? '|GdkWindow| (alien/ctype object))))
       (error:wrong-type-argument object "a GdkWindow address" operator)))
+
+(define (gdk-window-create-similar-surface window width height)
+  (let ((surface (make-alien '|cairo_surface_t|))
+       (copy (make-alien '|cairo_surface_t|)))
+    (add-glib-cleanup surface (make-cairo-surface-cleanup copy))
+    (C-call "gdk_window_create_similar_surface" copy
+           window (C-enum "CAIRO_CONTENT_COLOR") width height)
+    (copy-alien-address! surface copy)
+    (check-cairo-surface-status surface)
+    surface))
+
+(define (gdk-window-create-similar-image-surface window width height scale)
+  (let ((surface (make-alien '|cairo_surface_t|))
+       (copy (make-alien '|cairo_surface_t|)))
+    (add-glib-cleanup surface (make-cairo-surface-cleanup copy))
+    (C-call "gdk_window_create_similar_image_surface" copy
+           window (C-enum "CAIRO_FORMAT_RGB24") width height scale)
+    (copy-alien-address! surface copy)
+    (check-cairo-surface-status surface)
+    surface))
 \f
 ;;; GdkPixbufLoaders
 
index 2679efbd43ecf8ed2c14b53bc02b6fbff297633e..819348aa8aa5b74b77123a053db7f0d8970d9668 100644 (file)
@@ -41,12 +41,17 @@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
   (files "gdk")
   ;;(depends-on "gtk-const.bin")
   (import (cairo)
-         make-cairo-cleanup check-cairo-status)
+         check-cairo-status
+         check-cairo-surface-status
+         make-cairo-cleanup
+         make-cairo-surface-cleanup)
   (import (runtime ffi)
          alien/address)
   (import (glib main)
          maybe-yield-glib)
   (export (gtk)
+         gdk-window-create-similar-surface
+         gdk-window-create-similar-image-surface
          <pixbuf-loader> make-pixbuf-loader
          load-pixbuf-from-port load-pixbuf-from-file
          pixbuf-loader-size-hook set-pixbuf-loader-size-hook!