[Swfdec] Two problems I'm having with swfdec

Benjamin Otte otte at gnome.org
Fri Feb 27 06:38:08 PST 2009


On Fri, Feb 27, 2009 at 12:20 AM, Cakemeister <cakemeister at comcast.net> wrote:
> My first problem is that the previous frame doesn't appear to erase when the
> current frame is drawn. This leaves artifacts on the screen. I must be
> missing something in the process of rendering each frame.
>
Swfdec does not erase any previous content. You have to do it
yourself. This is because Swfdec support an alpha channel. So you are
supposed to prepare the background.
If you do not want to use an alpha channel, you should prerender the
image with the Flash file's background color, that you can query with
swfdec_player_get_background_color().

> My second problem is that my application that uses this code is very slow.
> Is there some kind of "invalid rect" that I can use to just transfer the
> portion of the frame that has changed to the final OpenGL texture? I'm
> getting really slow frame rates, like 4 fps.
>
Yes, the general idea is that you connect to the "invalidate" signal,
keep track of the regions that change and only render those.
The general way of doing this is to collect the invalid rectangles and
clipping the cairo context before rendering. It'd look something like
this in code:
for (i = 0; i < n_rects; i++) {
  cairo_rectangle (cr, rects[i].x, rects[i].y, rects[i].w, rects[i].h);
}
cairo_clip (cr);
/* clear background here */
swfdec_player_render (player, cr);

This will not get you above 4fps when a lot of stuff changes in frames
(you gotta wait for a supported cairo GL backend, people seem to be
hacking on those), but for the average case, it saves a lot of
performance.

Cheers,
Benjamin


More information about the Swfdec mailing list