SwfdecRenderer

## SwfdecRenderer SwfdecRenderer — provide accelerated rendering and caching abilities |

## Synopsis

    #include <swfdec/swfdec.h>

                        SwfdecRenderer;
                        SwfdecRendererClass;
    SwfdecRenderer*     swfdec_renderer_new                 (cairo_surface_t *surface);
    SwfdecRenderer*     swfdec_renderer_new_for_player      (cairo_surface_t *surface,
                                                             SwfdecPlayer *player);
    cairo_surface_t*    swfdec_renderer_get_surface         (SwfdecRenderer *renderer);

## Object Hierarchy

      GObject
       +----SwfdecRenderer

## Properties

      "surface"                  gpointer              : Read / Write / Construct Only

## Description

The SwfdecRenderer object is used internally to improve rendering done by Swfdec.

The first thing a SwfdecRenderer does is provide a way to cache data relevant to rendering. This means it will cache surfaces that are expensive to create (like decoded JPEG images) in a format most suitable to quick rendering. Therefore, it's a good idea to keep renderers around as long as any drawing to the attached surface happens.

The second thing a SwfdecRenderer does is provide access to the surface that is used for rendering, even when not in the process of rendering. This is relevant for font backends, as different surfaces provide different native fonts. See `swfdec_player_set_default_backend()` for details about this.

The third thing SwfdecRenderer does is provide a list of virtual functions for critical operations that you can optimize using subclasses to provide faster implementations. Note that a working default implementation is provided, so you only need to override the functions you care about. See SwfdecRendererClass for details about these functions.

## Details

### SwfdecRenderer

    typedef struct _SwfdecRenderer SwfdecRenderer;

The base renderer object. All its members are private.

### SwfdecRendererClass

    typedef struct {
      cairo_surface_t *	(* create_similar)		(SwfdecRenderer *	renderer,
    							 cairo_surface_t *	surface);
      cairo_surface_t *	(* create_for_data)		(SwfdecRenderer *	renderer,
    							 guint8 *		data,
    							 cairo_format_t		format,
    							 guint			width,
    							 guint			height,
    							 guint			rowstride);
    } SwfdecRendererClass;

The base class for the renderer. It contains some virtual functions that can be overridden in subclasses to accelerate certain time-critical Swfdec functions. For example, a subclass could make use of special hardware features on embedded devices.

`create_similar` () | This function imitates `cairo_surface_create_similar()`. It is supposed to create a surface with identical contents as the given surface, but tuned for usage with the given renderer.
`create_for_data` () | This function imitates `cairo_surface_create_for_data()`. It creates a surface for the given data, tuned for the given renderer. The function takes ownership of the passed in data and is responsible for freeing it with `g_free()` when it no longer needs it.

### swfdec_renderer_new ()

    SwfdecRenderer*     swfdec_renderer_new                 (cairo_surface_t *surface);

Creates a new renderer to be used with the given `surface`.

`surface` : | a cairo surface
Returns : | a new renderer

### swfdec_renderer_new_for_player ()

    SwfdecRenderer*     swfdec_renderer_new_for_player      (cairo_surface_t *surface,
                                                             SwfdecPlayer *player);

Creates a renderer to be used with the given `surface` and `player`. The renderer will use the same cache as the `player`.

`surface` : | a cairo surface
`player` : | the player this renderer should be used with
Returns : | a new renderer

### swfdec_renderer_get_surface ()

    cairo_surface_t*    swfdec_renderer_get_surface         (SwfdecRenderer *renderer);

Gets the surface that was used when creating this surface.

`renderer` : | a renderer
Returns : | the surface used by this renderer

## Property Details

### The `"surface"` property

      "surface"                  gpointer              : Read / Write / Construct Only

cairo surface in use by this renderer.