The following change in how WIN32 graphics devices are flushed gives
authorStephen Adams <edu/mit/csail/zurich/adams>
Fri, 26 Sep 1997 19:53:02 +0000 (19:53 +0000)
committerStephen Adams <edu/mit/csail/zurich/adams>
Fri, 26 Sep 1997 19:53:02 +0000 (19:53 +0000)
non-flickering update almost like double-buffering for programs which
have to draw multiple frames from scratch.

If graphics buffering is enabled, then a GRAPHICS-FLUSH operation
comes from the user's program.  The change is to synchronously redraw
the screen in this (i.e. buffered+flush) case.  Subsequent operations
can clear and draw without an asynchronous redraw operation copying
the subsequent partial image to the screen.

This is not quite double-buffering since forced redisplay during the
buffered drawing (for example, uncovering part of the window) will
cause the partly draw backing bitmap to be copied to the screen.

User programs with buffering and frequent explicit flushes are likely
to be slower.

v7/src/win32/graphics.scm
v7/src/win32/win32.pkg

index 5e34b8b9ae20559f9a8ee6ff0e36fc7601132f6c..57f708f0d2d1e11cb5f35aade061e8f4b8c6219d 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: graphics.scm,v 1.12 1997/05/15 03:11:58 cph Exp $
+$Id: graphics.scm,v 1.13 1997/09/26 19:52:52 adams Exp $
 
 Copyright (c) 1993-97 Massachusetts Institute of Technology
 
@@ -163,7 +163,7 @@ MIT in each case. |#
      ((= msg WM_PAINT)
       ;; flush here so that uncovering parts of a buffered window causes
       ;; other visible buffered parts to be updated
-      (win32-device/flush window)
+      (win32-device/flush window #T)
       (let*  ((hdc      (begin-paint hwnd ps))
              (palette  (win32-device/palette window))
              )
@@ -245,7 +245,7 @@ MIT in each case. |#
                  0)))))
 
     ((= msg WM_NCLBUTTONDOWN)
-      (win32-device/flush window)
+      (win32-device/flush window #F)
       (default))
 
     (else
@@ -493,21 +493,26 @@ MIT in each case. |#
 (define-integrable (win32-device/invalidate! window)
   (set-win32-device/invalid?!  window #t))
 
-(define (win32-device/flush window)
+(define (win32-device/flush window immediate-update?)
   (if (win32-device/invalid? window)
-    (let ((hwnd   (win32-device/hwnd window)))
-      (set-win32-device/invalid?! window #f)
-      (if hwnd
-         (begin
-           (invalidate-rect hwnd #f #f)
-           unspecific)
-         (graphics-error
-          "Attempt to use deleted Scheme Graphics window" window)))))
+      (let ((hwnd   (win32-device/hwnd window)))
+       (set-win32-device/invalid?! window #f)
+       (if hwnd
+           (begin
+             (invalidate-rect hwnd #f #f)
+             (if immediate-update?
+                 (update-window hwnd))
+             unspecific)
+           (graphics-error
+            "Attempt to use deleted Scheme Graphics window" window)))))
 
 (define (win32-graphics/flush device)
-  (win32-device/flush (graphics-device/descriptor device)))
+  ;; If we are in buffered mode, GRAPHICS-FLUSH was called explicitly
+  ;; by the programmer.  If we redraw synchronously, then we get most
+  ;; of the benefits of double-buffering.
+  (win32-device/flush (graphics-device/descriptor device)
+                     (graphics-device/buffer? device)))
 
-    
 
 (define (win32-device/clear window)
   (win32-device/validate-pen window)
@@ -525,8 +530,7 @@ MIT in each case. |#
     unspecific))
 
 (define (win32-graphics/clear device)
-  (win32-device/clear (graphics-device/descriptor device))
-  (win32-graphics/flush device))
+  (win32-device/clear (graphics-device/descriptor device)))
 
 (define (win32-graphics/draw-line device x1 y1 x2 y2)
   (let* ((window (graphics-device/descriptor device))
@@ -1008,4 +1012,4 @@ MIT in each case. |#
       (protection-list/for-each-info close-descriptor device-protection-list)))
   unspecific)
 
-(define win32-graphics-device-type)
\ No newline at end of file
+(define win32-graphics-device-type)
index 590b7baa397f57620903b6d6afeb716dcb2baa3c..557200f855838fdb423902fa147b0d110122bfe3 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: win32.pkg,v 1.9 1996/10/07 18:17:08 cph Exp $
+$Id: win32.pkg,v 1.10 1997/09/26 19:53:02 adams Exp $
 
 Copyright (c) 1993-96 Massachusetts Institute of Technology
 
@@ -88,6 +88,7 @@ MIT in each case. |#
          dib-set-pixels-unaligned
          delete-dib)
   (import (runtime graphics)
+         graphics-device/buffer?
          make-image-type)
   (initialization (initialize-package!))
 )