diff --git a/collects/mred/private/wx/cocoa/canvas.rkt b/collects/mred/private/wx/cocoa/canvas.rkt index 03fa4dac..b691eb25 100644 --- a/collects/mred/private/wx/cocoa/canvas.rkt +++ b/collects/mred/private/wx/cocoa/canvas.rkt @@ -717,16 +717,7 @@ (cons win r))))))) (define/public (register-collecting-blit x y w h on off on-x on-y off-x off-y) - (let ([on (if (and (zero? on-x) - (zero? on-y) - (= (send on get-width) w) - (= (send on get-height) h)) - on - (let ([bm (make-object bitmap% w h)]) - (let ([dc (make-object bitmap-dc% on)]) - (send dc draw-bitmap-section on 0 0 on-x on-y w h) - (send dc set-bitmap #f) - bm)))]) + (let ([on (fix-bitmap-size on w h on-x on-y)]) (let ([img (bitmap->image on)]) (atomically (set! blits (cons (list x y w h img) blits)) diff --git a/collects/mred/private/wx/common/canvas-mixin.rkt b/collects/mred/private/wx/common/canvas-mixin.rkt index 97309496..cd1a3280 100644 --- a/collects/mred/private/wx/common/canvas-mixin.rkt +++ b/collects/mred/private/wx/common/canvas-mixin.rkt @@ -1,9 +1,11 @@ #lang racket/base (require racket/class + racket/draw "backing-dc.rkt") (provide canvas-autoscroll-mixin - canvas-mixin) + canvas-mixin + fix-bitmap-size) ;; Implements canvas autoscroll, applied *before* platform-specific canvas ;; methods: @@ -160,3 +162,16 @@ (when (or paint-queued (not (send (get-dc) can-backing-flush?))) (do-on-paint #f #f))))) + +;; useful for fixing the size of a collecting blit: +(define (fix-bitmap-size on w h on-x on-y) + (if (and (zero? on-x) + (zero? on-y) + (= (send on get-width) w) + (= (send on get-height) h)) + on + (let ([bm (make-object bitmap% w h)]) + (let ([dc (make-object bitmap-dc% on)]) + (send dc draw-bitmap-section on 0 0 on-x on-y w h) + (send dc set-bitmap #f) + bm)))) diff --git a/collects/mred/private/wx/gtk/canvas.rkt b/collects/mred/private/wx/gtk/canvas.rkt index 6fadee01..8393b6de 100644 --- a/collects/mred/private/wx/gtk/canvas.rkt +++ b/collects/mred/private/wx/gtk/canvas.rkt @@ -560,23 +560,12 @@ (cons win r)))))) (define/public (register-collecting-blit x y w h on off on-x on-y off-x off-y) - (let ([fix-size (lambda (on on-x on-y) - (if (and (zero? on-x) - (zero? on-y) - (= (send on get-width) w) - (= (send on get-height) h)) - on - (let ([bm (make-object bitmap% w h)]) - (let ([dc (make-object bitmap-dc% on)]) - (send dc draw-bitmap-section on 0 0 on-x on-y w h) - (send dc set-bitmap #f) - bm))))]) - (let ([on (fix-size on on-x on-y)] - [off (fix-size off off-x off-y)]) - (let ([on-pixbuf (bitmap->pixbuf on)] - [off-pixbuf (bitmap->pixbuf off)]) - (atomically - (set! reg-blits (cons (register-one-blit x y w h on-pixbuf off-pixbuf) reg-blits))))))) + (let ([on (fix-bitmap-size on w h on-x on-y)] + [off (fix-bitmap-size off w h off-x off-y)]) + (let ([on-pixbuf (bitmap->pixbuf on)] + [off-pixbuf (bitmap->pixbuf off)]) + (atomically + (set! reg-blits (cons (register-one-blit x y w h on-pixbuf off-pixbuf) reg-blits)))))) (define/public (unregister-collecting-blits) (atomically