fix use of color bitmap as mask when drawing after previous use

This commit is contained in:
Matthew Flatt 2010-12-16 21:02:11 -07:00
parent 6f114b318b
commit 8a10c3d3db
4 changed files with 31 additions and 10 deletions

View File

@ -50,6 +50,7 @@
(exact->inexact (send bm get-height)))))
(define/override (get-cr) c)
(define/override (release-cr cr) (when bm (send bm drop-alpha-s)))
(define/override (end-cr) (void))

View File

@ -190,7 +190,7 @@
;; Use for non-alpha color bitmaps when they are used as a mask:
(define alpha-s #f)
(define alpha-s-up-to-date? #f)
(define/private (drop-alpha-s)
(define/public (drop-alpha-s)
(set! alpha-s-up-to-date? #f)
(when alpha-s
(let ([s2 alpha-s])
@ -681,7 +681,8 @@
[(and set-alpha?
(not alpha-channel?))
;; Set alphas:
(set-alphas-as-mask x y w h bstr (* 4 w) 0)]))
(set-alphas-as-mask x y w h bstr (* 4 w) 0)])
(drop-alpha-s))
(define/public (get-alphas-as-mask x y w h bstr)
(let ([data (cairo_image_surface_get_data (if (or b&w? alpha-channel?)

View File

@ -12,6 +12,7 @@
get-cairo-alpha-surface
release-bitmap-storage
get-bitmap-gl-context
drop-alpha-s
;; bitmap-dc%
internal-get-bitmap

View File

@ -235,7 +235,7 @@
255 0 0 0
255 255 255 255))
(send u set-loaded-mask mu)
(define (try-draw nonce-color b&w?)
(define (try-draw nonce-color b&w? changed?)
(let* ((bm (make-object bitmap% 2 2 b&w?))
(dc (make-object bitmap-dc% bm)))
(send dc clear)
@ -254,15 +254,33 @@
0 255 255 255
0 255 255 255
0 255 255 255)
(if changed?
(bytes 255 255 255 255
255 0 0 0
255 255 255 255
255 255 255 255)
(bytes 255 100 0 0
255 255 255 255
255 255 255 255
255 255 255 255))
255 255 255 255)))
'masked-draw
s))))
(try-draw (make-object color% "green") #f)
(try-draw (make-object color%) #f)
(try-draw (make-object color%) #t))
(try-draw (make-object color% "green") #f #f)
(try-draw (make-object color%) #f #f)
(try-draw (make-object color%) #t #f)
(send mu set-argb-pixels 0 0 2 2
(bytes 255 255 255 255
255 0 0 0
255 255 255 255
255 0 0 0))
(try-draw (make-object color%) #f #t)
(let ([dc (make-object bitmap-dc% mu)])
(send dc erase)
(send dc set-pen "white" 1 'transparent)
(send dc set-brush "black" 'solid)
(send dc draw-rectangle 0 0 1 1)
(send dc set-bitmap #f))
(try-draw (make-object color%) #f #f))
;; ----------------------------------------