racket/draw: avoid callback-based PNG writing

Doc rendering has been occasionally crashing in Pixman/Cairo. It might
have something to do with a non-atomic callback, so let's try avoiding
that, first. (If that doesn't work, the next step is to avoid using
Cairo in a multi-threaded way, for which this is a first step, too.)
This commit is contained in:
Matthew Flatt 2012-06-27 12:28:36 -06:00
parent 5f3f3e8c54
commit ec6f3fd610
2 changed files with 6 additions and 5 deletions

View File

@ -545,10 +545,10 @@
(let ([w (create-png-writer out width height #t #f)]) (let ([w (create-png-writer out width height #t #f)])
(write-png w rows) (write-png w rows)
(destroy-png-writer w)))] (destroy-png-writer w)))]
[(and (not alpha-channel?) [else #;(and (not alpha-channel?)
loaded-mask loaded-mask
(= width (send loaded-mask get-width)) (= width (send loaded-mask get-width))
(= height (send loaded-mask get-height))) (= height (send loaded-mask get-height)))
(let ([bstr (make-bytes (* width height 4))]) (let ([bstr (make-bytes (* width height 4))])
(get-argb-pixels 0 0 width height bstr) (get-argb-pixels 0 0 width height bstr)
(when loaded-mask (when loaded-mask
@ -568,6 +568,7 @@
(let ([w (create-png-writer out width height #f #t)]) (let ([w (create-png-writer out width height #f #t)])
(write-png w rows) (write-png w rows)
(destroy-png-writer w))))] (destroy-png-writer w))))]
#;
[else [else
;; Use Cairo built-in support: ;; Use Cairo built-in support:
(let ([proc (lambda (ignored bstr len) (let ([proc (lambda (ignored bstr len)

View File

@ -306,7 +306,7 @@
-> _int) -> _int)
(_pointer = #f) (_pointer = #f)
-> _cairo_surface_t/null)) -> _cairo_surface_t/null))
;; Not recommended, unless it makes sense to make the allback atomic:
(define-cairo cairo_surface_write_to_png_stream (_fun _cairo_surface_t (define-cairo cairo_surface_write_to_png_stream (_fun _cairo_surface_t
(_fun _pointer (_fun _pointer
(s : _pointer) (s : _pointer)