Anomalous drawing whilst scrolling :without-bar (XP, Vista)
Hi again, fellow LispWorkers,
The test code below demonstrates a problem I am having with my application,
relating to :without-bar scrolling (I am only
working on WinXP currently). Notice that the top pane, when scrolled, seems to
'bleed' the just-exposed region. With
clipped drawing the problem does go away, but even though my actual application
draws only to the just-exposed region
the problem still occurs. I am just wondering what type of problem this might
be, as I've been fighting with it for a few
weeks, to no avail. Is it simply an issue relating to the amount of data being
drawn? I have known (and would expect)
unoptimized drawing to produce slow scrolling, but not an effect like this. Any
thoughts?
I have tested this on two XP boxes, and a Vista laptop, with the same results.
My app draws waveforms, and the code
below is a very, *VERY* crude approximation to my actual drawing code, which
does quite a bit of pre-drawing calculation. I get
the problem when combining scrolling my waveform data pane simultaneously with a
ruler, which measures time, placed above it
within a larger grid-layout. The waveform exhibits the identical effect
demonstrated here, but interestingly - and oddly - if
the ruler is placed below the waveform the waveform scrolls perfectly, but the
ruler is then affected.
(defpackage :test
(:add-use-defaults t)
(:use :capi))
(in-package :test)
(progn
(defparameter *max* (make-array 2048
:initial-contents
(loop repeat 2048
collect (+ (random 150) 150))))
(defparameter *min* (make-array 2048
:initial-contents
(loop repeat 2048
collect (random 150))))
nil)
(define-interface test ()
()
(:panes
(pane-1 output-pane
:scroll-width 2048
:horizontal-scroll :without-bar
:visible-max-height 300
:display-callback 'draw-data)
(pane-2 output-pane
:scroll-width 2048
:horizontal-scroll t
:scroll-callback 'on-scroll
:visible-max-height 300
:display-callback 'draw-data)) ; Clipping here removes the problem.
(:layouts
(main-layout column-layout
'(pane-1 pane-2)
:default t))
(:default-initargs
:best-width 800
:best-height 630))
(defun draw-data (pane x y width height)
(declare (optimize (speed 3) (safety 0) (fixnum-safety 0))
(ignore x y width height))
(loop for i fixnum from 0 below 2048
for min fixnum across *min*
for max fixnum across *max*
append (list i min i max) into coords
finally (gp:draw-lines pane coords)))
; This does clipped drawing.
(defun %draw-data (pane x y width height)
(declare (optimize (speed 3) (safety 0) (fixnum-safety 0))
(ignore y height))
(loop for i fixnum from x below (+ x (1- width))
for min fixnum = (aref *min* i)
for max fixnum = (aref *max* i)
append (list i min i max) into coords
finally (gp:draw-lines pane coords)))
(defun on-scroll (pane dimension operation value
&key &allow-other-keys)
(declare (ignore dimension operation value))
(with-slots (pane-1) (top-level-interface pane)
(set-horizontal-scroll-parameters pane-1
:slug-position (get-horizontal-scroll-parameters pane :slug-position))))
(defun test ()
(contain (make-instance 'test)))
(compile 'draw-data)
(compile 'on-scroll)
(compile 'test)