[cairo] Cairo and animations
Pietro Incardona
asmprog32 at hotmail.com
Thu Dec 25 16:13:40 PST 2008
> What is happening is the program is uploading a large bitmap to the
> video card which is slow and bypassing any optimizations.
The code bottleneck is offscreen
The onscreen surface code is here
gdk_draw_drawable(da->window,
da->style->fg_gc[GTK_WIDGET_STATE(da)], pixmap,
// Only copy the area that was exposed.
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
and it need less than 1 milliseconds
I has flushed animations into the screen in Windows ( GDI , OpenGL D3D) and Linux with OpenGL and GtkGLExt
Now i has not done DEEP benchmark on GDK ( with animations ) , but is impossible to believe that need more
than 1 sec to flush into the screen
> Have you
> tried not rendering using threads to an ofscreen surface and instead
> going single thread and drawing on expose?
Yes i use gdk_cairo_ create and the flush into the screen has no prob of performance, if cairo use gdk to flush, i suppose that GDK don' t need 1 sec to flush into the screen;
the performance decrease when the draw on cairo became a little complex
with
(80 + 160 lines + 20 texts + 80 rectangles filled + 80 stoked + 40 rectangles semitrasparent filled)i has 1 - 2 frames / sec
Now my code is not efficient and need to be more fast for a factor of 10X - 15X, drawing is not optimized, but reading the optimizing i can do on draw
i think can reach a factor of 3X - 4X ( very optimistic ).
Now i am searching a new efficient code ( completly new ) or a guidelines to create animations
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 24 Dec 2008 23:05:44 +0200
> From: "Gerdus van Zyl"
> Subject: Re: [cairo] Cairo and animations
> To: cairo at cairographics.org
> Message-ID:
>
> Content-Type: text/plain; charset=ISO-8859-1
>
> What is happening is the program is uploading a large bitmap to the
> video card which is slow and bypassing any optimizations. Have you
> tried not rendering using threads to an ofscreen surface and instead
> going single thread and drawing on expose?
>
> ~G
>
> On Wed, Dec 24, 2008 at 8:12 PM, Pietro Incardona wrote:
>>
>> (Sorry ................ damn Linux Opera )
>>
>> Doing some benchmarks the bottleneck is located here
>>
>> struct timeb bbb1;
>> struct timeb bbb2;
>> double t = 0;
>> ftime(&bbb1);
>>
>> cairo_t *cr_pixmap = gdk_cairo_create(pixmap);
>> cairo_set_source_surface (cr_pixmap, cst, 0, 0);
>> cairo_paint(cr_pixmap);
>> cairo_destroy(cr_pixmap);
>>
>> ftime(&bbb2);
>> t = (bbb2.time - bbb1.time) + (double)(bbb2.millitm - bbb1.millitm) / 1000.0;
>> printf("do_draw bench %f \n",t);
>>
>> need 1 sec to execute the code
>>
>> ----------------------------------------
>>> Date: Wed, 24 Dec 2008 13:47:37 +0100
>>> From: bonzini at gnu.org
>>> To: asmprog32 at hotmail.com
>>> CC: cairo at cairographics.org
>>> Subject: Re: Cairo and animations
>>>
>>> Pietro Incardona wrote:
>>>>
>>>> This is the code ( it draw one rectangle but the result don' t change )
>>>
>>> I haven't looked at it, but probably the culprit is transferring the
>>> window pixels to the screen. When using OpenGL, for example, I have
>>> seen sometimes glTexImage2D taking more time than the rest of the drawing.
>>>
>>> Paolo
>>
>> _________________________________________________________________
>> Fanne di tutti i colori, personalizza la tua Hotmail!
>> http://imagine-windowslive.com/Hotmail/#0
>> _______________________________________________
>> cairo mailing list
>> cairo at cairographics.org
>> http://lists.cairographics.org/mailman/listinfo/cairo
>>
>
>
_________________________________________________________________
Fanne di tutti i colori, personalizza la tua Hotmail!
http://imagine-windowslive.com/Hotmail/#0
More information about the cairo
mailing list