[Clg-devel] please keep those gdk draw- functions
Brought to you by:
espen
From: Chisheng H. <cp...@ch...> - 2007-10-16 22:39:54
|
Hi, The following comment is from gdk/gdk.lisp: ;;; Drawable -- all the draw- functions are deprecated and will be ;;; removed, use cairo for drawing instead. I'd like to plea to keep the support of these draw- functions in GDK as long as they are officially supported. The index of deprecated symbols of GDK Reference Manual only listed 4 drawing functions: gdk_draw_pixmap, gdk_draw_string, gdk_draw_text, and gdk_draw_text_wc. Cairo is nice but is just too slow for statistical graphics. To draw 25,000 circles, GDK:DRAW-ARC takes 0.07 seconds and Cairo takes 6.01 seconds. Timing code is attached at the end. Please keep the GDK draw- functions as long as they are officially supported. Thanks. -cph (defvar *da*) (let* ((da (make-instance 'gtk:drawing-area :width-request 300 :height-request 300)) (w (make-instance 'gtk:window :child da))) (setf *da* da) (gtk:widget-show-all w)) (defvar *centers*) (null (setf *centers* (loop repeat 50000 collect (+ 10 (random 280))))) (gffi:defbinding gc-new () gdk:gc (drawable gdk:drawable)) (defun gdk-circles (centers) (let* ((drawable (gtk:widget-window *da*)) (gc (gc-new drawable))) (loop for x in centers by #'cddr for y in (cdr centers) by #'cddr do (gdk:draw-arc drawable gc nil x y 10 10 0 23040)))) (defun cairo-circles (centers) (gdk:with-cairo-context (cr (gtk:widget-window *da*)) (setf (cairo:line-width cr) 1.0d0) (loop for x in centers by #'cddr for y in (cdr centers) by #'cddr with 2pi = (* 2 pi) do (cairo:arc cr x y 5 0 2pi) (cairo:stroke cr)))) ;; make sure to compile GDK-CIRCLES before you do timing. (time (gdk-circles *centers*)) ; Evaluation took: ; 0.07 seconds of real time ; 0.020001 seconds of user run time ; 0.0 seconds of system run time ; 141,341,821 CPU cycles ; 0 page faults and ; 768 bytes consed. ;; make sure to compile CAIRO-CIRCLES before you do timing. (time (cairo-circles *centers*)) ; Evaluation took: ; 6.01 seconds of real time ; 4.172261 seconds of user run time ; 0.024002 seconds of system run time ; 12,596,945,906 CPU cycles ; [Run times include 0.03 seconds GC run time] ; 0 page faults and ; 1,619,920 bytes consed. I even wrote a C function that just received a Cairo contex and a vector of circle centers from CMUCL and did the drawing all in C. The C function and the necessary binding were about as slow as CAIRO-CIRCLES. Note, if we define CAIRO-CIRCLES as (defun cairo-circles (centers) (gdk:with-cairo-context (cr (gtk:widget-window *da*)) (setf (cairo:line-width cr) 1.0d0) (loop for x in centers by #'cddr for y in (cdr centers) by #'cddr with 2pi = (* 2 pi) do (cairo:arc cr x y 5 0 2pi) (cairo:new-sub-path cr)) (cairo:stroke cr))) this version of CAIRO-CIRCLES will kill CMUCL immediately when the length of CENTERS is 3000 or bigger. |