[cairo] Flickering on some scaling-values
spitzak at gmail.com
Thu Aug 21 15:39:50 PDT 2014
The actual code clears the surface and then draws the shapes atop it,
which will blink because you see the blank surface before the shapes draw.
However if the edges of the filled rectangle are not on pixel
boundaries, I think this triggers the image fallback. This is slower but
also acts like double buffering, so it removes the flickering.
The rectangle edges will be on pixel boundaries if the scale is even.
This is because the 0.5,0.5 translate is multiplied by the scale to get
an integer, and the other size is rect.width/height (since it was
divided and then remultiplied by the scale).
I am not sure what the best way to fix this is. You probably want to
turn on double buffering, but I don't know if gdk can be made to do
this. Also if the image fallback is triggered, you will have triple
buffering and are wasting memory. Maybe there is a way to force the
image fallback all the time.
On 08/21/2014 02:44 AM, Andreas Wittmann wrote:
> Hi Mailinglist!
> I'm new to cairo so this is maybe a simple question but i haven't found
> any answers using the internet. I'm using Linux/Debian and the newest
> cairo-release 1.12.16 (But my/this problem will also occur on previous
> wxWidgets is also used, i'm using a simple render-function which looks
> like this and which is called from the wxWidgets-framework:
> void BasicDrawPane::render(wxDC& dc2)
> cairo_t* cairo_image = gdk_cairo_create((GdkWindow*)dc.GetHandle());
> cairo_t *cr = cairo_image;
> cairo_scale(cr, global_scale_x, global_scale_y);
> cairo_translate(cr, 0.5, 0.5);
> cairo_rectangle(cr, 0.0, 0.0, rect.width / global_scale_x,
> rect.height / global_scale_y);
> cairo_set_source_rgb(cr, 255, 255, 255);
> // drawing some shapes ...
> The shapes will be drawn (eg. from a mouse-event) without any flickering
> if the global-scales (global_scale_x, global_scale_y) are NOT 2.0, 4.0,
> 6.0, 8.0, 10.0, ... and so on. A value of eg. 2.1 would work without any
> Could anybody please give me some direction on how to solve this problem
> or why it happens?
> The translation is used for drawing thin lines.
More information about the cairo