libtiger: Renderer

- Main Page
- Modules
- Files
- Related Pages
- Examples

# Renderer

## Detailed Description

## Functions
int | tiger_renderer_create (tiger_renderer **tr)
int | tiger_renderer_set_buffer (tiger_renderer *tr, unsigned char *ptr, int width, int height, int stride, int swap_rgb)
int | tiger_renderer_set_quality (tiger_renderer *tr, double quality)
int | tiger_renderer_destroy (tiger_renderer *tr)
int | tiger_renderer_set_surface_clear_color (tiger_renderer *tr, int clear, double r, double g, double b, double a)
int | tiger_renderer_add_event (tiger_renderer *tr, const kate_info *ki, const kate_event *ev)
int | tiger_renderer_update (tiger_renderer *tr, kate_float t, int track)
int | tiger_renderer_seek (tiger_renderer *tr, kate_float target)
int | tiger_renderer_render (tiger_renderer *tr)
int | tiger_renderer_is_dirty (const tiger_renderer *tr)
int | tiger_renderer_set_default_font_description (tiger_renderer *tr, const char *desc)
int | tiger_renderer_set_default_font (tiger_renderer *tr, const char *font)
int | tiger_renderer_set_default_font_size (tiger_renderer *tr, double size)
int | tiger_renderer_set_default_font_color (tiger_renderer *tr, double r, double g, double b, double a)
int | tiger_renderer_set_default_background_fill_color (tiger_renderer *tr, double r, double g, double b, double a)
int | tiger_renderer_set_default_font_effect (tiger_renderer *tr, tiger_font_effect effect, double strength)
int | tiger_renderer_enable_caching (tiger_renderer *tr, int enable)

## Function Documentation

int tiger_renderer_add_event | ( | tiger_renderer * | tr,
|  | const kate_info * | ki,
|  | const kate_event * | ev |
| ) |  |  |

Adds an event to the renderer

Parameters:

  | tr | the Tiger renderer to add the event to
  | ki | the kate_info for the stream this events belongs to
  | ev | the event to add to the renderer

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_create | ( | tiger_renderer ** | tr | ) |

Creates a new Tiger renderer

Parameters:

  | tr | where to store a pointer to the newly created renderer

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_destroy | ( | tiger_renderer * | tr | ) |

Destroys a previously initialized Tiger renderer

Parameters:

  | tr | the Tiger renderer to clear

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_enable_caching | ( | tiger_renderer * | tr,
|  | int | enable |
| ) |  |  |

Enables or disables internal caching of text layouts

Parameters:

  | tr | the Tiger renderer for which to enable or disable caching
  | enable | whether to enable or disable caching

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_is_dirty | ( | const tiger_renderer * | tr | ) |

Checks whether the Tiger renderer is dirty or not (eg, whether rendering a frame now would yield a different frame from the previous frame).

Parameters:

  | tr | the Tiger renderer to query

Returns:
  0 success, and the Tiger renderer is not dirrty

  !0 success, the Tiger renderer is dirty

Note:
  The client code may choose not to call tiger_renderer_render if the renderer is not dirty as an optimization. However, care should be taken if the buffer the frame was rendered onto was changed (eg, if a new video frame was drawn onto it); in this case, a new frame should be rendered on top of the video, even if the Tiger frame would be the same as the previous frame, as it would have been erased by the video.

int tiger_renderer_render | ( | tiger_renderer * | tr | ) |

Renders the current state of the renderer

Parameters:

  | tr | the Tiger renderer to update

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_seek | ( | tiger_renderer * | tr,
|  | kate_float | target |
| ) |  |  |

Registers that a seek occured

Parameters:

  | tr | the Tiger renderer on which the seek occured
  | target | the target time of the seek

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_buffer | ( | tiger_renderer * | tr,
|  | unsigned char * | ptr,
|  | int | width,
|  | int | height,
|  | int | stride,
|  | int | swap_rgb |
| ) |  |  |

Sets a buffer where to render the Kate stream. This buffer should be a linear buffer with 32 bits per pixel, with 8 bits per color component in ARGB order (or ABGR is swap_rgb is non zero) in host endianness. This buffer will be used as backing store for a Cairo surface, so any other requirement by Cairo also applies here.

Parameters:

  | tr | the Tiger renderer for which to set the buffer
  | ptr | the data to use as backing store for the Cairo surface
  | width | the width of the Cairo surface to create
  | height | the height of the Cairo surface to create
  | stride | the stride of the Cairo surface to create
  | swap_rgb | if non zero, red and blue components are swapped

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_default_background_fill_color | ( | tiger_renderer * | tr,
|  | double | r,
|  | double | g,
|  | double | b,
|  | double | a |
| ) |  |  |

Sets the default font color to use for background. The default is to not fill the background (though a Kate event may specify a background), but in cases where the text may be hard to read over a video, specifying a background fill color will allow the text to stand out more.

Parameters:

  | tr | the Tiger renderer for which to set the background fill color
  | r | the red component of the background fill color, in the 0-1 range
  | g | the green component of the background fill color, in the 0-1 range
  | b | the blue component of the background fill color, in the 0-1 range
  | a | the alpha component of the background fill color, in the 0-1 range

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_default_font | ( | tiger_renderer * | tr,
|  | const char * | font |
| ) |  |  |

Sets the default font to use if none is specified

Parameters:

  | tr | the Tiger renderer for which to set the default font
  | font | the font to use as default, a copy of which is made

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_default_font_color | ( | tiger_renderer * | tr,
|  | double | r,
|  | double | g,
|  | double | b,
|  | double | a |
| ) |  |  |

Sets the default font color to use if none is specified

Parameters:

  | tr | the Tiger renderer for which to set the default font color
  | r | the red component of the default color, in the 0-1 range
  | g | the green component of the default color, in the 0-1 range
  | b | the blue component of the default color, in the 0-1 range
  | a | the alpha component of the default color, in the 0-1 range

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_default_font_description | ( | tiger_renderer * | tr,
|  | const char * | desc |
| ) |  |  |

Sets the default font description to use if no override is specified

Parameters:

  | tr | the Tiger renderer for which to set the default font
  | desc | the font description to use as default

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_default_font_effect | ( | tiger_renderer * | tr,
|  | tiger_font_effect | effect,
|  | double | strength |
| ) |  |  |

Sets the default font effect. The default is to have no effect (tiger_font_plain).

Parameters:

  | tr | the Tiger renderer for which to set which font effect to use
  | effect | the font effect to use
  | strength | how pronounced to make the effect (effect dependent)

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_default_font_size | ( | tiger_renderer * | tr,
|  | double | size |
| ) |  |  |

Sets the default font size to use if none is specified

Parameters:

  | tr | the Tiger renderer for which to set the default font size
  | size | the font size to use as default

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_quality | ( | tiger_renderer * | tr,
|  | double | quality |
| ) |  |  |

Sets a relative quality for the rendering

Parameters:

  | tr | the Tiger renderer for which to set the quality
  | quality | rendering quality, between 0 (lowest, fastest) and 1 (highest, slowest), or negative for default quality

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_set_surface_clear_color | ( | tiger_renderer * | tr,
|  | int | clear,
|  | double | r,
|  | double | g,
|  | double | b,
|  | double | a |
| ) |  |  |

Sets whether to clear the surface before rendering, and the clearing color

Parameters:

  | tr | the Tiger renderer to modify
  | clear | whether to clear before rendering
  | r | the red value of the clear color
  | g | the green value of the clear color
  | b | the blue value of the clear color
  | a | the alpha value of the clear color

Returns:
  0 success

  TIGER_E_* error

int tiger_renderer_update | ( | tiger_renderer * | tr,
|  | kate_float | t,
|  | int | track |
| ) |  |  |

Updates the renderer at the new time

Parameters:

  | tr | the Tiger renderer to update
  | t | the time to update to renderer to
  | track | whether to update item trackers

Returns:
  0 success

  1 success, but no Kate events are currently active

  TIGER_E_* error

Note:
  Even if 0 is returned, a call to draw may not actually change the rendering surface, for instance if all active Kate events have a text with fully transparent color and no background, etc.