[cairo] Cairo and FLTK?
Kai-Uwe Behrmann
ku.b at gmx.de
Mon Oct 29 12:08:40 PDT 2007
Date: Mon, 29 Oct 2007 12:00:58 +0000
From: Bill Spitzak
> The following code should return a cairo surfact_t that can be used to
> draw into an fltk window. You would call this inside your
> window/widget's draw() function:
Neighter inside or outside FLTK(1)'s draw() gives more speed in the Fl_Box
my app uses. Drawing in a image surface is much quicker for me.
> /** Fltk cairo create surface function accepting a Window* as input */
> cairo_surface_t* fltk::cairo_create_surface(Window* wi) {
> XWindow window = fltk::xid(wi);
> cairo_surface_t* surface = cairo_xlib_surface_create(xdisplay, window,
> xvisual->visual, wi->w(), wi->h());
> cairo_xlib_surface_set_size(surface, wi->w(), wi->h());
> return surface;
> }
My test app show much flickering even though it is a Fl_Double_Window.
Alternatively using a Xrender surface brings me lots of errors for the
first of following variants:
Fl_Window *wi = cc->box->window();
Window window = fl_xid(wi);
Screen *scr = XDefaultScreenOfDisplay (fl_display);
#if defined(CAIRO_HAS_XLIB_XRENDER_SURFACE)
XRenderPictFormat * rf = XRenderFindStandardFormat( fl_display,
PictStandardARGB32 );
cc->surface = cairo_xlib_surface_create_with_xrender_format ( fl_display,
window, scr, rf,
w,h );
cairo_status_t status = cairo_surface_status ( cc->surface );
#else
cc->surface = cairo_xlib_surface_create( fl_display, window,
fl_visual->visual, cc->box->w(), cc->box->h() );
cairo_xlib_surface_set_size( cc->surface, w, h );
#endif
message:
XRequest.157: BadMatch (invalid parameter attributes) 0x0
XRequest.157: RenderBadPicture (invalid Picture parameter) 0x4c00005
XRequest.157: RenderBadPicture (invalid Picture parameter) 0x4c00005
...
XRequest.157: RenderBadPicture (invalid Picture parameter) 0x4c00956
XRequest.157: RenderBadPicture (invalid Picture parameter) 0x4c00956
XRequest.157: BadMatch (invalid parameter attributes) 0x4c00956
XRequest.157: RenderBadPicture (invalid Picture parameter) 0x4c00a0e
XRequest.157: RenderBadPicture (invalid Picture parameter) 0x4c00a0e
...
A working Cairo (X/Xrender/Quartz/...) in FLTK1 example would be a
desired thing.
One other thing, which made me wonder, is the need for a swap of the RGB
channels coming from a
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w,h) created image
surface before using fl_draw_image() in myFl_Box::draw().
Is this normal behaviour?
kind regards
Kai-Uwe Behrmann
--
developing for colour management
www.behrmann.name + www.oyranos.org
More information about the cairo
mailing list