fixed small bug in draw check; eliminated the 'equal' optimization
svn: r17649
This commit is contained in:
parent
485900bfa6
commit
be76ed2add
|
@ -73,12 +73,14 @@
|
|||
;; effect: set value to v if distinct, also display it if pb exists
|
||||
(define/public (set tag v)
|
||||
(define nw (coerce tag v))
|
||||
(if (equal? value nw)
|
||||
#t
|
||||
(begin
|
||||
(set! value nw)
|
||||
(when pb (show-state))
|
||||
#f)))
|
||||
;; this is the old Robby "optimization" for not triggering draw
|
||||
;; when the world doesn't change
|
||||
;if (equal? value nw)
|
||||
; #t
|
||||
(begin
|
||||
(set! value nw)
|
||||
(when pb (show-state))
|
||||
#f))
|
||||
|
||||
;; -> ok?
|
||||
(define/public (get) value)
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
i
|
||||
(if (1:image? i)
|
||||
(check-result tname 1:scene? "scene" i (image-pins i))
|
||||
(check-result tname #f "scene" i))))
|
||||
(check-result tname (lambda _ #f) "scene" i))))
|
||||
|
||||
(define (image-pins i)
|
||||
(format "image with pinhole at (~s,~s)" (1:pinhole-x i) (1:pinhole-y i)))
|
||||
|
|
|
@ -233,39 +233,40 @@
|
|||
(broadcast (package-message nw))
|
||||
(set! nw (package-world nw)))
|
||||
(if (stop-the-world? nw)
|
||||
(begin
|
||||
(set! nw (stop-the-world-world nw))
|
||||
(send world set tag nw)
|
||||
(when last-picture
|
||||
(set! draw last-picture))
|
||||
(when draw (pdraw))
|
||||
(callback-stop! 'name)
|
||||
(enable-images-button))
|
||||
(begin
|
||||
(set! nw (stop-the-world-world nw))
|
||||
(send world set tag nw)
|
||||
(when last-picture
|
||||
(set! draw last-picture))
|
||||
(when draw (pdraw))
|
||||
(callback-stop! 'name)
|
||||
(enable-images-button))
|
||||
(let ([changed-world? (send world set tag nw)])
|
||||
(unless changed-world?
|
||||
(when draw
|
||||
(cond
|
||||
[(not drawing)
|
||||
(set! drawing #t)
|
||||
(let ([b (box d)])
|
||||
(set! w (cons b w))
|
||||
;; low priority, otherwise it's too fast
|
||||
(queue-callback (lambda () ((unbox b))) #f))]
|
||||
[(< draw# 0)
|
||||
(set-draw#!)
|
||||
(for-each (lambda (b) (set-box! b void)) w)
|
||||
(set! w '())
|
||||
;; high!! the scheduled callback didn't fire
|
||||
(queue-callback (lambda () (d)) #t)]
|
||||
[else
|
||||
(set! draw# (- draw# 1))]))
|
||||
(when (pstop)
|
||||
(when last-picture
|
||||
(set! draw last-picture)
|
||||
(pdraw))
|
||||
(callback-stop! 'name)
|
||||
(enable-images-button)))
|
||||
changed-world?)))))))
|
||||
;; this is the old "Robby optimization" see checked-cell:
|
||||
; unless changed-world?
|
||||
(when draw
|
||||
(cond
|
||||
[(not drawing)
|
||||
(set! drawing #t)
|
||||
(let ([b (box d)])
|
||||
(set! w (cons b w))
|
||||
;; low priority, otherwise it's too fast
|
||||
(queue-callback (lambda () ((unbox b))) #f))]
|
||||
[(< draw# 0)
|
||||
(set-draw#!)
|
||||
(for-each (lambda (b) (set-box! b void)) w)
|
||||
(set! w '())
|
||||
;; high!! the scheduled callback didn't fire
|
||||
(queue-callback (lambda () (d)) #t)]
|
||||
[else
|
||||
(set! draw# (- draw# 1))]))
|
||||
(when (pstop)
|
||||
(when last-picture
|
||||
(set! draw last-picture)
|
||||
(pdraw))
|
||||
(callback-stop! 'name)
|
||||
(enable-images-button))
|
||||
changed-world?)))))))
|
||||
|
||||
;; tick, tock : deal with a tick event for this world
|
||||
(def/pub-cback (ptock) tick)
|
||||
|
@ -314,8 +315,9 @@
|
|||
(define/public (start!)
|
||||
(queue-callback
|
||||
(lambda ()
|
||||
(when draw (show-canvas))
|
||||
(when register (register-with-host)))))
|
||||
(with-handlers ([exn? (handler #t)])
|
||||
(when draw (show-canvas))
|
||||
(when register (register-with-host))))))
|
||||
|
||||
(define/public (stop! w)
|
||||
(set! live #f)
|
||||
|
|
Loading…
Reference in New Issue
Block a user