#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include "mb_types.h"
#include "mb_shapes.h"
#include "mb_tools.h"
#include "mb_redraw_man.h"
#include "mb_observer.h"
Go to the source code of this file.
Defines | |
#define | sh_attach_geo(sh, g) |
#define | sh_detach_geo(sh) |
#define | sh_get_geo(sh) ((sh)->geo) |
#define | sh_attach_coord(sh, coord) do { (sh)->coord = coord; } while(0) |
#define | sh_detach_coord(sh) do { (sh)->coord = NULL; } while(0) |
#define | rdman_is_dirty(rdman) |
#define | OK 0 |
#define | ERR -1 |
#define | ARRAY_EXT_SZ 64 |
#define | SWAP(a, b, t) do { t c; c = a; a = b; b = c; } while(0) |
#define | FORCHILDREN(coord, child) |
#define | NEXT_CHILD(child) STAILQ_NEXT(coord_t, sibling, child) |
#define | ADD_CHILD(parent, child) STAILQ_INS_TAIL((parent)->children, coord_t, sibling, (child)) |
#define | RM_CHILD(parent, child) STAILQ_REMOVE((parent)->children, coord_t, sibling, (child)) |
#define | FIRST_CHILD(parent) STAILQ_HEAD((parent)->children) |
#define | FORMEMBERS(coord, member) |
#define | NEXT_MEMBER(member) STAILQ_NEXT(geo_t, coord_next, (member)) |
#define | ADD_MEMBER(coord, member) STAILQ_INS_TAIL((coord)->members, geo_t, coord_next, (member)) |
#define | RM_MEMBER(coord, member) STAILQ_REMOVE((coord)->members, geo_t, coord_next, (member)) |
#define | FIRST_MEMBER(coord) STAILQ_HEAD((coord)->members) |
#define | FORPAINTMEMBERS(paint, member) |
#define | RM_PAINTMEMBER(paint, member) STAILQ_REMOVE((paint)->members, shnode_t, next, member) |
#define | RM_PAINT(rdman, paint) STAILQ_REMOVE((rdman)->paints, paint_t, pnt_next, paint) |
#define | ADD_DATA(sttype, field, v) |
DARRAY to implement dirty & free lists. | |
#define | ASSERT(x) |
Functions | |
static subject_t * | ob_subject_alloc (ob_factory_t *factory) |
static void | ob_subject_free (ob_factory_t *factory, subject_t *subject) |
static observer_t * | ob_observer_alloc (ob_factory_t *factory) |
static void | ob_observer_free (ob_factory_t *factory, observer_t *observer) |
static subject_t * | ob_get_parent_subject (ob_factory_t *factory, subject_t *cur_subject) |
static void | _insert_sort (void **elms, int num, int off) |
Sort a list of element by a unsigned integer. | |
DARRAY_DEFINE (coords, coord_t *) | |
DARRAY_DEFINE (geos, geo_t *) | |
DARRAY_DEFINE (areas, area_t *) | |
static int | add_dirty_coord (redraw_man_t *rdman, coord_t *coord) |
static int | add_dirty_geo (redraw_man_t *rdman, geo_t *geo) |
static int | add_dirty_area (redraw_man_t *rdman, area_t *area) |
static int | add_free_obj (redraw_man_t *rdman, void *obj, free_func_t free_func) |
static void | free_free_objs (redraw_man_t *rdman) |
static void | free_objs_destroy (redraw_man_t *rdman) |
static void | area_to_positions (area_t *area, co_aix(*poses)[2]) |
static cairo_t * | new_canvas (redraw_man_t *rdman) |
static void | free_canvas (cairo_t *canvas) |
static int | geo_off_in_coord (geo_t *geo, coord_t *coord) |
static void | geo_attach_coord (geo_t *geo, coord_t *coord) |
static void | geo_detach_coord (geo_t *geo, coord_t *coord) |
int | redraw_man_init (redraw_man_t *rdman, cairo_t *cr, cairo_t *backend) |
void | redraw_man_destroy (redraw_man_t *rdman) |
int | rdman_add_shape (redraw_man_t *rdman, shape_t *shape, coord_t *coord) |
int | rdman_shape_free (redraw_man_t *rdman, shape_t *shape) |
Remove a shape object from redraw manager. | |
shnode_t * | shnode_new (redraw_man_t *rdman, shape_t *shape) |
int | rdman_paint_free (redraw_man_t *rdman, paint_t *paint) |
void | _rdman_paint_real_remove_child (redraw_man_t *rdman, paint_t *paint, shape_t *shape) |
coord_t * | rdman_coord_new (redraw_man_t *rdman, coord_t *parent) |
int | rdman_coord_free (redraw_man_t *rdman, coord_t *coord) |
Free a coord of a redraw_man_t object. | |
int | rdman_coord_subtree_free (redraw_man_t *rdman, coord_t *subtree) |
int | rdman_coord_changed (redraw_man_t *rdman, coord_t *coord) |
Mark a coord is changed. | |
static int | _rdman_shape_changed (redraw_man_t *rdman, shape_t *shape) |
int | rdman_shape_changed (redraw_man_t *rdman, shape_t *shape) |
Mark a shape is changed. | |
int | rdman_paint_changed (redraw_man_t *rdman, paint_t *paint) |
static int | is_coord_subtree_hidden (coord_t *coord) |
static void | clean_shape (shape_t *shape) |
static void | setup_canvas (redraw_man_t *rdman, coord_t *coord) |
Setup canvas for the coord. | |
static int | clean_coord (redraw_man_t *rdman, coord_t *coord) |
static int | clean_rdman_coords (redraw_man_t *rdman) |
Clean coord_t objects. | |
static int | clean_rdman_geos (redraw_man_t *rdman) |
static int | clean_rdman_dirties (redraw_man_t *rdman) |
static void | set_shape_stroke_param (shape_t *shape, cairo_t *cr) |
static void | fill_path_preserve (redraw_man_t *rdman) |
static void | fill_path (redraw_man_t *rdman) |
static void | stroke_path (redraw_man_t *rdman) |
static void | draw_shape (redraw_man_t *rdman, cairo_t *cr, shape_t *shape) |
static void | clean_canvas (cairo_t *cr) |
static void | clean_canvas_black (cairo_t *cr) |
static void | make_clip (cairo_t *cr, int n_dirty_areas, area_t **dirty_areas) |
static void | reset_clip (redraw_man_t *rdman) |
static void | copy_cr_2_backend (redraw_man_t *rdman, int n_dirty_areas, area_t **dirty_areas) |
static int | is_geo_in_areas (geo_t *geo, int n_areas, area_t **areas) |
static void | update_canvas_2_parent (redraw_man_t *rdman, coord_t *coord) |
static int | draw_coord_shapes_in_areas (redraw_man_t *rdman, coord_t *coord, int n_areas, area_t **areas) |
static void | draw_shapes_in_areas (redraw_man_t *rdman, int n_areas, area_t **areas) |
int | rdman_redraw_changed (redraw_man_t *rdman) |
Re-draw all changed shapes or shapes affected by changed coords. | |
int | rdman_redraw_all (redraw_man_t *rdman) |
int | rdman_redraw_area (redraw_man_t *rdman, co_aix x, co_aix y, co_aix w, co_aix h) |
geo_t * | rdman_geos (redraw_man_t *rdman, geo_t *last) |
int | rdman_force_clean (redraw_man_t *rdman) |
#define ADD_CHILD | ( | parent, | |||
child | ) | STAILQ_INS_TAIL((parent)->children, coord_t, sibling, (child)) |
Definition at line 59 of file redraw_man.c.
#define ADD_DATA | ( | sttype, | |||
field, | |||||
v | ) |
#define ADD_MEMBER | ( | coord, | |||
member | ) | STAILQ_INS_TAIL((coord)->members, geo_t, coord_next, (member)) |
Definition at line 71 of file redraw_man.c.
#define ARRAY_EXT_SZ 64 |
Definition at line 36 of file redraw_man.c.
#define ASSERT | ( | x | ) |
Definition at line 367 of file redraw_man.c.
#define ERR -1 |
Definition at line 34 of file redraw_man.c.
#define FIRST_CHILD | ( | parent | ) | STAILQ_HEAD((parent)->children) |
Definition at line 63 of file redraw_man.c.
#define FIRST_MEMBER | ( | coord | ) | STAILQ_HEAD((coord)->members) |
Definition at line 75 of file redraw_man.c.
#define FORCHILDREN | ( | coord, | |||
child | ) |
Value:
for((child) = STAILQ_HEAD((coord)->children); \ (child) != NULL; \ (child) = STAILQ_NEXT(coord_t, sibling, (child)))
Definition at line 54 of file redraw_man.c.
#define FORMEMBERS | ( | coord, | |||
member | ) |
Value:
for((member) = STAILQ_HEAD((coord)->members); \ (member) != NULL; \ (member) = STAILQ_NEXT(geo_t, coord_next, (member)))
Definition at line 66 of file redraw_man.c.
#define FORPAINTMEMBERS | ( | paint, | |||
member | ) |
Value:
for((member) = STAILQ_HEAD((paint)->members); \ (member) != NULL; \ (member) = STAILQ_NEXT(paint_t, next, member))
Definition at line 78 of file redraw_man.c.
#define NEXT_CHILD | ( | child | ) | STAILQ_NEXT(coord_t, sibling, child) |
Definition at line 58 of file redraw_man.c.
#define NEXT_MEMBER | ( | member | ) | STAILQ_NEXT(geo_t, coord_next, (member)) |
Definition at line 70 of file redraw_man.c.
#define OK 0 |
Definition at line 33 of file redraw_man.c.
#define rdman_is_dirty | ( | rdman | ) |
Value:
((rdman)->dirty_coords.num != 0 || \ (rdman)->dirty_geos.num != 0 || \ (rdman)->dirty_areas.num != 0)
Definition at line 28 of file redraw_man.c.
#define RM_CHILD | ( | parent, | |||
child | ) | STAILQ_REMOVE((parent)->children, coord_t, sibling, (child)) |
Definition at line 61 of file redraw_man.c.
#define RM_MEMBER | ( | coord, | |||
member | ) | STAILQ_REMOVE((coord)->members, geo_t, coord_next, (member)) |
Definition at line 73 of file redraw_man.c.
#define RM_PAINT | ( | rdman, | |||
paint | ) | STAILQ_REMOVE((rdman)->paints, paint_t, pnt_next, paint) |
Definition at line 84 of file redraw_man.c.
#define RM_PAINTMEMBER | ( | paint, | |||
member | ) | STAILQ_REMOVE((paint)->members, shnode_t, next, member) |
Definition at line 82 of file redraw_man.c.
#define sh_attach_coord | ( | sh, | |||
coord | ) | do { (sh)->coord = coord; } while(0) |
Definition at line 26 of file redraw_man.c.
#define sh_attach_geo | ( | sh, | |||
g | ) |
Value:
do { \ (sh)->geo = g; \ (g)->shape = (shape_t *)(sh); \ } while(0)
Definition at line 15 of file redraw_man.c.
#define sh_detach_coord | ( | sh | ) | do { (sh)->coord = NULL; } while(0) |
Definition at line 27 of file redraw_man.c.
#define sh_detach_geo | ( | sh | ) |
Value:
do { \ (sh)->geo->shape = NULL; \ (sh)->geo = NULL; \ } while(0)
Definition at line 20 of file redraw_man.c.
#define sh_get_geo | ( | sh | ) | ((sh)->geo) |
Definition at line 25 of file redraw_man.c.
Definition at line 38 of file redraw_man.c.
static void _insert_sort | ( | void ** | elms, | |
int | num, | |||
int | off | |||
) | [static] |
Sort a list of element by a unsigned integer.
The result is in ascend order. The unsigned integers is at offset specified by 'off' from start address of elemnts.
Definition at line 92 of file redraw_man.c.
void _rdman_paint_real_remove_child | ( | redraw_man_t * | rdman, | |
paint_t * | paint, | |||
shape_t * | shape | |||
) |
Definition at line 497 of file redraw_man.c.
static int _rdman_shape_changed | ( | redraw_man_t * | rdman, | |
shape_t * | shape | |||
) | [static] |
Definition at line 672 of file redraw_man.c.
static int add_dirty_area | ( | redraw_man_t * | rdman, | |
area_t * | area | |||
) | [static] |
Definition at line 131 of file redraw_man.c.
static int add_dirty_coord | ( | redraw_man_t * | rdman, | |
coord_t * | coord | |||
) | [static] |
Definition at line 121 of file redraw_man.c.
static int add_dirty_geo | ( | redraw_man_t * | rdman, | |
geo_t * | geo | |||
) | [static] |
Definition at line 126 of file redraw_man.c.
static int add_free_obj | ( | redraw_man_t * | rdman, | |
void * | obj, | |||
free_func_t | free_func | |||
) | [static] |
Definition at line 135 of file redraw_man.c.
Definition at line 173 of file redraw_man.c.
static void clean_canvas | ( | cairo_t * | cr | ) | [static] |
static void clean_canvas_black | ( | cairo_t * | cr | ) | [static] |
static int clean_coord | ( | redraw_man_t * | rdman, | |
coord_t * | coord | |||
) | [static] |
Definition at line 769 of file redraw_man.c.
static int clean_rdman_coords | ( | redraw_man_t * | rdman | ) | [static] |
static int clean_rdman_dirties | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 865 of file redraw_man.c.
static int clean_rdman_geos | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 840 of file redraw_man.c.
static void clean_shape | ( | shape_t * | shape | ) | [static] |
Definition at line 720 of file redraw_man.c.
static void copy_cr_2_backend | ( | redraw_man_t * | rdman, | |
int | n_dirty_areas, | |||
area_t ** | dirty_areas | |||
) | [static] |
Definition at line 985 of file redraw_man.c.
DARRAY_DEFINE | ( | areas | , | |
area_t * | ||||
) |
DARRAY_DEFINE | ( | geos | , | |
geo_t * | ||||
) |
DARRAY_DEFINE | ( | coords | , | |
coord_t * | ||||
) |
static int draw_coord_shapes_in_areas | ( | redraw_man_t * | rdman, | |
coord_t * | coord, | |||
int | n_areas, | |||
area_t ** | areas | |||
) | [static] |
Definition at line 1033 of file redraw_man.c.
static void draw_shape | ( | redraw_man_t * | rdman, | |
cairo_t * | cr, | |||
shape_t * | shape | |||
) | [static] |
Definition at line 914 of file redraw_man.c.
static void draw_shapes_in_areas | ( | redraw_man_t * | rdman, | |
int | n_areas, | |||
area_t ** | areas | |||
) | [static] |
Definition at line 1077 of file redraw_man.c.
static void fill_path | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 893 of file redraw_man.c.
static void fill_path_preserve | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 889 of file redraw_man.c.
static void free_canvas | ( | cairo_t * | canvas | ) | [static] |
Definition at line 199 of file redraw_man.c.
static void free_free_objs | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 157 of file redraw_man.c.
static void free_objs_destroy | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 168 of file redraw_man.c.
Definition at line 217 of file redraw_man.c.
Definition at line 222 of file redraw_man.c.
Definition at line 205 of file redraw_man.c.
static int is_coord_subtree_hidden | ( | coord_t * | coord | ) | [static] |
Definition at line 711 of file redraw_man.c.
Definition at line 1007 of file redraw_man.c.
static void make_clip | ( | cairo_t * | cr, | |
int | n_dirty_areas, | |||
area_t ** | dirty_areas | |||
) | [static] |
Definition at line 969 of file redraw_man.c.
static cairo_t* new_canvas | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 180 of file redraw_man.c.
static subject_t * ob_get_parent_subject | ( | ob_factory_t * | factory, | |
subject_t * | cur_subject | |||
) | [static] |
Definition at line 1375 of file redraw_man.c.
static observer_t * ob_observer_alloc | ( | ob_factory_t * | factory | ) | [static] |
Definition at line 1358 of file redraw_man.c.
static void ob_observer_free | ( | ob_factory_t * | factory, | |
observer_t * | observer | |||
) | [static] |
Definition at line 1368 of file redraw_man.c.
static subject_t * ob_subject_alloc | ( | ob_factory_t * | factory | ) | [static] |
Definition at line 1341 of file redraw_man.c.
static void ob_subject_free | ( | ob_factory_t * | factory, | |
subject_t * | subject | |||
) | [static] |
Definition at line 1351 of file redraw_man.c.
int rdman_add_shape | ( | redraw_man_t * | rdman, | |
shape_t * | shape, | |||
coord_t * | coord | |||
) |
Definition at line 390 of file redraw_man.c.
int rdman_coord_changed | ( | redraw_man_t * | rdman, | |
coord_t * | coord | |||
) |
Mark a coord is changed.
A changed coord_t object is marked as dirty and put into dirty_coords list. rdman_coord_changed() should be called for a coord after it been changed to notify redraw manager to redraw shapes grouped by it.
Definition at line 644 of file redraw_man.c.
int rdman_coord_free | ( | redraw_man_t * | rdman, | |
coord_t * | coord | |||
) |
Free a coord of a redraw_man_t object.
coord | is a coord_t without children and members. |
Definition at line 557 of file redraw_man.c.
coord_t* rdman_coord_new | ( | redraw_man_t * | rdman, | |
coord_t * | parent | |||
) |
int rdman_coord_subtree_free | ( | redraw_man_t * | rdman, | |
coord_t * | subtree | |||
) |
Definition at line 610 of file redraw_man.c.
int rdman_force_clean | ( | redraw_man_t * | rdman | ) |
Definition at line 1245 of file redraw_man.c.
geo_t* rdman_geos | ( | redraw_man_t * | rdman, | |
geo_t * | last | |||
) |
Definition at line 1221 of file redraw_man.c.
int rdman_paint_changed | ( | redraw_man_t * | rdman, | |
paint_t * | paint | |||
) |
Definition at line 697 of file redraw_man.c.
int rdman_paint_free | ( | redraw_man_t * | rdman, | |
paint_t * | paint | |||
) |
Definition at line 467 of file redraw_man.c.
int rdman_redraw_all | ( | redraw_man_t * | rdman | ) |
Definition at line 1180 of file redraw_man.c.
int rdman_redraw_area | ( | redraw_man_t * | rdman, | |
co_aix | x, | |||
co_aix | y, | |||
co_aix | w, | |||
co_aix | h | |||
) |
Definition at line 1205 of file redraw_man.c.
int rdman_redraw_changed | ( | redraw_man_t * | rdman | ) |
Re-draw all changed shapes or shapes affected by changed coords.
A coord object has a geo to keep track the range that it's members will draw on. Geo of a coord should be recomputed when the coord is changed. Geo of a coord used to accelerate finding overlay shape objects of a specified geo. A coord object also must be recomputed when one of it's members is changed.
New and old geo values of a coord object that is recomputed for changing of it-self must be used to find overlay shape objects. New and old geo values of a shape should also be used to find overlay shape objects, too. If a shape's coord is changed, shape's geo object is not used to find overlay shape objects any more.
steps:
dirty flag of coord objects is cleared after update. dirty flag of geo objects is also cleared after recomputing. Clean dirty flag can prevent redundant computing for geo and corod objects.
Draw shapes in preorder of coord tree and support opacity rules.
Definition at line 1116 of file redraw_man.c.
int rdman_shape_changed | ( | redraw_man_t * | rdman, | |
shape_t * | shape | |||
) |
Mark a shape is changed.
The geo_t object of a changed shape is mark as dirty and put into dirty_geos list.
Definition at line 693 of file redraw_man.c.
int rdman_shape_free | ( | redraw_man_t * | rdman, | |
shape_t * | shape | |||
) |
Remove a shape object from redraw manager.
Removing shapes or coords when a rdman is dirty, removing is postponsed.
Definition at line 421 of file redraw_man.c.
void redraw_man_destroy | ( | redraw_man_t * | rdman | ) |
Definition at line 318 of file redraw_man.c.
int redraw_man_init | ( | redraw_man_t * | rdman, | |
cairo_t * | cr, | |||
cairo_t * | backend | |||
) |
Definition at line 238 of file redraw_man.c.
static void reset_clip | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 981 of file redraw_man.c.
static void set_shape_stroke_param | ( | shape_t * | shape, | |
cairo_t * | cr | |||
) | [static] |
Definition at line 885 of file redraw_man.c.
static void setup_canvas | ( | redraw_man_t * | rdman, | |
coord_t * | coord | |||
) | [static] |
Setup canvas for the coord.
Own a canvas or inherit it from parent.
Definition at line 751 of file redraw_man.c.
shnode_t* shnode_new | ( | redraw_man_t * | rdman, | |
shape_t * | shape | |||
) |
Definition at line 456 of file redraw_man.c.
static void stroke_path | ( | redraw_man_t * | rdman | ) | [static] |
Definition at line 897 of file redraw_man.c.
static void update_canvas_2_parent | ( | redraw_man_t * | rdman, | |
coord_t * | coord | |||
) | [static] |
Definition at line 1019 of file redraw_man.c.