Revert "racket/draw: fix another problem with the JPEG binding"

This reverts commit c2468f1f9a.

The libjpeg documentation claims that it has no static state,
so atomic mode shouldn't be necessary. Also, the stress test is
still failing on some platforms, so there must be a different
problem than I thought.
This commit is contained in:
Matthew Flatt 2012-12-22 07:39:59 -07:00
parent 22d94193ed
commit a09c8f1857
2 changed files with 12 additions and 27 deletions

View File

@ -1,6 +1,5 @@
#lang racket/base
(require racket/class
racket/port
racket/unsafe/ops
file/convertible
(for-syntax racket/base)
@ -369,10 +368,7 @@
(install-bytes-rows s w h rows b&w? alpha? pre? #f)
(values s b&w?))))]
[(jpeg jpeg/alpha)
;; We'd like to read directly from `in', but we need to be able
;; to read in atomic mode:
(define bstr (port->bytes in))
(let ([d (create-decompress (open-input-bytes bstr))])
(let ([d (create-decompress in)])
(dynamic-wind
void
(lambda ()
@ -591,10 +587,7 @@
proc
(cairo_surface_write_to_png_stream s proc)))])]
[(jpeg)
;; We'd like to write directly to `out', but we need to be able
;; to write in atomic mode:
(define sp (open-output-bytes))
(let ([c (create-compress sp)])
(let ([c (create-compress out)])
(dynamic-wind
void
(lambda ()
@ -622,8 +615,7 @@
(bytes-set! bstr (+ ci 2) (bytes-ref dest (+ row (+ 4i B)))))))
(jpeg_write_scanlines c samps 1))))
(jpeg_finish_compress c))
(lambda () (destroy-compress c))))
(write-bytes (get-output-bytes sp) out)]
(lambda () (destroy-compress c))))]
[else (error (method-name 'bitmap% 'save-file)
"kind saving not yet implemented: ~e"
kind)])))

View File

@ -623,7 +623,7 @@
(define create-decompress
((allocator destroy-decompress)
(lambda (in) ;; `in' will be read in atomic mode!
(lambda (in)
(let ([m (ptr-cast (malloc _jpeg_decompress_struct 'raw) _jpeg_decompress_struct-pointer)]
[s (ptr-cast (malloc _jpeg_source_mgr 'raw) _jpeg_source_mgr-pointer)]
[e (ptr-cast (malloc sizeof_jpeg_error_mgr 'raw) _jpeg_error_mgr-pointer)]
@ -640,21 +640,17 @@
(set-jpeg_source_mgr-next_input_byte! s #f)
(set-jpeg_source_mgr-bytes_in_buffer! s 0)
(set-jpeg_source_mgr-init_source! s (cast init-source
(_fun #:keep funs #:atomic? #t
_j_decompress_ptr -> _void)
(_fun #:keep funs _j_decompress_ptr -> _void)
_fpointer))
(set-jpeg_source_mgr-fill_input_buffer! s (cast fill-input-buffer
(_fun #:keep funs #:atomic? #t
_j_decompress_ptr -> _jbool)
(_fun #:keep funs _j_decompress_ptr -> _jbool)
_fpointer))
(set-jpeg_source_mgr-skip_input_data! s (cast skip-input-data
(_fun #:keep funs #:atomic? #t
_j_decompress_ptr _long -> _void)
(_fun #:keep funs _j_decompress_ptr _long -> _void)
_fpointer))
(set-jpeg_source_mgr-resync_to_restart! s jpeg_resync_to_restart)
(set-jpeg_source_mgr-term_source! s (cast term-source
(_fun #:keep funs #:atomic? #t
_j_decompress_ptr -> _void)
(_fun #:keep funs _j_decompress_ptr -> _void)
_fpointer))
m))))
@ -669,7 +665,7 @@
(define create-compress
((allocator destroy-compress)
(lambda (out) ;; `out' will be written in atomic mode!
(lambda (out)
(let ([m (ptr-cast (malloc _jpeg_compress_struct 'raw) _jpeg_compress_struct-pointer)]
[d (ptr-cast (malloc _jpeg_destination_mgr 'raw) _jpeg_destination_mgr-pointer)]
[e (ptr-cast (malloc sizeof_jpeg_error_mgr 'raw) _jpeg_error_mgr-pointer)]
@ -686,16 +682,13 @@
(set-jpeg_destination_mgr-next_output_byte! d b)
(set-jpeg_destination_mgr-free_in_buffer! d BUFFER-SIZE)
(set-jpeg_destination_mgr-init_destination! d (cast init-destination
(_fun #:keep funs #:atomic? #t
_j_compress_ptr -> _void)
(_fun #:keep funs _j_compress_ptr -> _void)
_fpointer))
(set-jpeg_destination_mgr-empty_output_buffer! d (cast empty-output-buffer
(_fun #:keep funs #:atomic? #t
_j_compress_ptr -> _jbool)
(_fun #:keep funs _j_compress_ptr -> _jbool)
_fpointer))
(set-jpeg_destination_mgr-term_destination! d (cast term-destination
(_fun #:keep funs #:atomic? #t
_j_compress_ptr -> _void)
(_fun #:keep funs _j_compress_ptr -> _void)
_fpointer))
m))))