Hi, my first patch broke test programs in dw2/test/ (as they don't use clear_double_buffer() as dillo-fltk does). Corrected patch attached. Sorry for that, Johannes On Sat, Apr 05, 2008 at 05:01:52PM +0200, Johannes Hofmann wrote:
Hi,
I stumbled across this post on fltk.bugs: http://fltk.org/newsgroups.php?s5281+gfltk.bugs+v5290+T0
This is great for us, as it allows us to implement efficient double buffering without X11 specific hacks. Attached is a patch that enables double buffering for partial screen redraws (this is where the flickering is most annoying). You will need at least version r6079 of fltk2 to test.
Cheers, Johannes
diff -r 0949076de1d4 configure.in --- a/configure.in Sat Apr 05 13:33:25 2008 +0200 +++ b/configure.in Sat Apr 05 16:48:27 2008 +0200 @@ -21,6 +21,7 @@ AC_ARG_ENABLE(ansi, [ --enable-ansi AC_ARG_ENABLE(ansi, [ --enable-ansi Try to compile and run with ANSI flags], , enable_ansi=no) AC_ARG_ENABLE(rtfl, [ --enable-rtfl Build with rtfl messages], enable_rtfl=yes) +AC_ARG_ENABLE(doublebuffer, [ --disable-doublebuffer Disable double buffering for drawing], disable_doublebuffer=yes)
AC_PROG_CXX AM_PROG_CC_STDC @@ -61,6 +62,9 @@ if test "x$enable_rtfl" = "xyes" ; then if test "x$enable_rtfl" = "xyes" ; then CXXFLAGS="$CXXFLAGS -DDBG_RTFL" fi +if test "x$disable_doublebuffer" = "xyes" ; then + CXXFLAGS="$CXXFLAGS -DNO_DOUBLEBUFFER" +fi
dnl ----------------------- dnl Checks for header files diff -r 0949076de1d4 dw/fltkviewbase.cc --- a/dw/fltkviewbase.cc Sat Apr 05 13:33:25 2008 +0200 +++ b/dw/fltkviewbase.cc Sat Apr 05 16:48:27 2008 +0200 @@ -38,6 +38,8 @@ namespace dw { namespace dw { namespace fltk {
+::fltk::Image *FltkViewBase::backBuffer; + FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label): Group (x, y, w, h, label) { @@ -46,13 +48,17 @@ FltkViewBase::FltkViewBase (int x, int y bgColor = WHITE; lastDraw = time(0); drawDelay = 2; /* in seconds */ +#ifndef NO_DOUBLEBUFFER + if (!backBuffer) { + backBuffer = new Image (); + } +#endif }
FltkViewBase::~FltkViewBase () { cancelQueueDraw (); } -
void FltkViewBase::draw () { @@ -78,9 +84,27 @@ void FltkViewBase::draw ()
if (!viewRect.empty ()) { push_clip (viewRect); +#ifndef NO_DOUBLEBUFFER + { + GSave gsave; + + backBuffer->setsize (viewRect.w (), viewRect.h ()); + backBuffer->make_current (); + translate (-viewRect.x () , -viewRect.y ()); + + setcolor (bgColor); + fillrect (viewRect); + theLayout->expose (this, rect); + } + + make_current (); + backBuffer->draw (Rectangle (0, 0, viewRect.w (), viewRect.h ()), + viewRect); +#else setcolor (bgColor); fillrect (viewRect); theLayout->expose (this, rect); +#endif pop_clip (); } } diff -r 0949076de1d4 dw/fltkviewbase.hh --- a/dw/fltkviewbase.hh Sat Apr 05 13:33:25 2008 +0200 +++ b/dw/fltkviewbase.hh Sat Apr 05 16:48:27 2008 +0200 @@ -2,6 +2,7 @@ #define __DW_FLTKVIEWBASE_HH__
#include <fltk/Group.h> +#include <fltk/Image.h> #include <fltk/Scrollbar.h>
#include "fltkcore.hh" @@ -15,6 +16,7 @@ private: private: int bgColor; core::Region drawRegion; + static ::fltk::Image *backBuffer;
void drawChildWidgets ();