annotate src/redraw_man.c @ 1114:7451af5d63ec

Make tank and calculator works for console backend
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 08 Dec 2010 22:39:12 +0800
parents d09f603438d8
children 36cbe73813a8
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2 // vim: sw=4:ts=8:sts=4
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 #include <stdio.h>
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 #include <stdlib.h>
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 #include <string.h>
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
6 #include <math.h>
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
7 #include "mb_graph_engine.h"
186
530bb7728546 Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents: 185
diff changeset
8 #include "mb_types.h"
530bb7728546 Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents: 185
diff changeset
9 #include "mb_shapes.h"
530bb7728546 Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents: 185
diff changeset
10 #include "mb_tools.h"
530bb7728546 Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents: 185
diff changeset
11 #include "mb_redraw_man.h"
530bb7728546 Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents: 185
diff changeset
12 #include "mb_observer.h"
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
13 #include "mb_prop.h"
467
6e18550c8fa8 Header file to config graphic engine
Thinker K.F. Li <thinker@branda.to>
parents: 466
diff changeset
14 #include "config.h"
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
15
408
7f7855df2af0 Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents: 375
diff changeset
16 /* required by rdman_img_ldr_load_paint() */
7f7855df2af0 Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents: 375
diff changeset
17 #include "mb_paint.h"
7f7855df2af0 Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents: 375
diff changeset
18
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
19 /*! \page dirty Dirty geo, coord, and area.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
20 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
21 * \section dirty_of_ego Dirty of geo
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
22 * A geo is dirty when any of the shape, size or positions is changed.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
23 * It's geo and positions should be recomputed before drawing. So,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
24 * dirty geos are marked as dirty and put into redraw_man_t::dirty_geos list.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
25 * geos in the list are cleaned to compute information as a reaction for
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
26 * dirty. It recomputes size, position and other data of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
27 * repective shapes.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
28 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
29 * \section dirty_of_coord Dirty of coord
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
30 * A coord is dirty when it's transformation matrix being changed.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
31 * Dirty coords are marked as dirty and put into dirty_coords list.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
32 * Once a coord is dirty, every member geos of it are also dirty.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
33 * Because, their shape, size and positions will be changed. But,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
34 * they are not marked as dirty and put into dirty_geos list, since
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
35 * all these member geos will be recomputed for computing new current
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
36 * area of the coord. The changes of a coord also affect child
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
37 * coords. Once parent is dirty, all children are also dirty for
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
38 * their aggregate matrix out of date. Dirty coords should be
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
39 * clean in preorder of tree traversal. The redraw_man_t::dirty_coords
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
40 * list are sorted to keep ordering before cleaning.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
41 * Whenever a coord is marked dirty and put into redraw_man_t::dirty_coords
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
42 * list, all it's children should also be marked.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
43 *
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
44 * The procedure of clean coords comprises recomputing aggregated
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
45 * transform matrix and area where members spreading in. The aggregated
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
46 * transform matrix can reduce number of matrix mul to transform
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
47 * positions from space of a coord to the closest cached ancestor coord.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
48 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
49 * The list is inspected before drawing to recompute new shape, size,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
50 * and positions of member geos of coords in the list. The drity
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
51 * flag of member geos will be clean.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
52 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
53 * Clean coords should be performed before clean geos, since clean
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
54 * coords will also clean member geos.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
55 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
56 * \section dirty_of_area Dirty of area
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
57 * When an area is dirty, it is added to coord_canvas_info_t::dirty_areas
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
58 * of it's closest cached coord. Areas are created when a shape is cleaned
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
59 * for dirty. The areas where a cleaned shape occupied before and after
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
60 * cleaning should be redrawed. Areas are added to dirty area list to
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
61 * mark areas where should be redrawed. So, all shapes covered by
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
62 * dirty area list should be redrawed to update these areas. So, areas
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
63 * are added to dirty lists after cleaning geos due to changes of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
64 * shapes.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
65 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
66 * For example, when a shape is moved from location A to location B,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
67 * areas where the shape occupied for A and B are changed for moving.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
68 * Bothe areas are added into dirty list to mark these areas should
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
69 * be redrawed.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
70 */
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
71
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
72 /*! \page redraw How to Redraw Shapes?
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
73 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
74 * Coords are corresponding objects for group tags of SVG files.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
75 * In conceptional, every SVG group has a canvas, graphics of child shapes
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
76 * are drawed into the canvas, applied filters of group, and blended into
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
77 * canvas of parent of the group.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
78 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
79 * But, we don't need to create actually a surface/canvas for every coord.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
80 * We only create surface for coords their opacity value are not 1 or they
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
81 * apply filters on background. Child shapes of coords without canvas
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
82 * are drawed on canvas of nearest ancestor which have canvas. It said
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
83 * a coord owns a canvas or inherits from an ancestor. (\ref COF_OWN_CANVAS,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
84 * clean_coord()) Except, root_coord always owns a canvas.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
85 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
86 * \note Default opacity of a coord is 1.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
87 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
88 * \sa
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
89 * - rdman_redraw_all()
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
90 * - rdman_redraw_changed()
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
91 * - draw_shapes_in_areas()
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
92 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
93 * \section img_cache Image Cache
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
94 * It costs time to redraw every component in a complete graphic.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
95 * Image cache try to cache result of prviously rendering, and reusing it
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
96 * to avoid wasting CPU time on repeatitive and redundant rendering.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
97 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
98 * \ref COF_FAST_CACHE and \ref COF_PRECISE_CACHE are used to tag a
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
99 * coord that it's
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
100 * rendering result is cached in fast way or precise way. With fast cache,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
101 * MB renders descendants of a coord in once, and reuse the result until it
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
102 * being dirty. With precise cache, it alike fast cache, but it also
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
103 * performs rendering when an ancester of the coord transform it to larger
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
104 * size, in width or height.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
105 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
106 * coord_t::aggr_matrix of a cached coord is computed from aggr_matrix of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
107 * parent. But, it does not use one from parent directly. parent one is
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
108 * transformed as
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
109 * \code
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
110 * cache_scale_x = sqrt(p_matrix[0]**2 + p_matrix[3]**2);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
111 * cache_scale_y = sqrt(p_matrix[1]**2 + p_matrix[4]**2);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
112 * cache_p_matrix[0] = cache_scale_x;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
113 * cache_p_matrix[1] = 0;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
114 * cache_p_matrix[2] = range_shift_x;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
115 * cache_p_matrix[3] = 0;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
116 * cache_p_matrix[4] = cache_scale_y;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
117 * cache_p_matrix[5] = range_shift_y;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
118 * \endcode
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
119 * where p_matrix is parent one, and cache_p_matrix is one derived from
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
120 * parent one. coord_t::aggr_matrix of a cached coord is
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
121 * \code
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
122 * aggr_matrix = cache_p_matrix * matrix
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
123 * \endcode
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
124 * where matrix is the transform being installed on the cached coord.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
125 * range_shift_x and range_shift_y are defined above.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
126 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
127 * cache_p_matrix rescales sub-graphic to an appropriately size
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
128 * (cache_scale_x, cache_scale_y) and aligns left-top of the minimum
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
129 * rectangle (range_shift_x, range_shift_y) that cover the area occupied
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
130 * by sub-graphic with origin of the space.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
131 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
132 * The sub-graphic should be rendered on space defined by cache_p_matrix of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
133 * cached one. But rendering result are transformed to the space defined
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
134 * by parent with following matrix.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
135 * \code
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
136 * draw_matrix = reverse(p_matrix * reverse(cache_p_matrix))
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
137 * \endcode
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
138 * With Cairo, draw_matrix is applied on source surface (canvas)
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
139 * to draw image to parent's surface (canvas). draw_matrix is a function
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
140 * map points from parent space to the space of cached one.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
141 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
142 * Cached coords are marked for changing transformation of ancestors only if
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
143 * following condition is true.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
144 * \code
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
145 * cache_scale_x < sqrt(p_matrix[0]**2 + p_matrix[3]**2) ||
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
146 * cache_scale_y < sqrt(p_matrix[1]**2 + p_matrix[4]**2)
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
147 * \endcode
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
148 * where p_matrix is latest aggr_matrix of parent after changing
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
149 * transformation, and where cache_scale_* are ones mention above and computed
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
150 * before changing transformation of ancestors.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
151 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
152 * Cache_scale_* can be recovered by following instructions.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
153 * \code
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
154 * cache_scale_x = aggr_matrix[0] / matrix[0];
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
155 * cache_scale_y = aggr_matrix[4] / matrix[4];
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
156 * \endcode
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
157 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
158 * \section cache_area Area of cached coord
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
159 * - *_transform of shapes works as normal
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
160 * - areas of descendants of cached coord are in space defined
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
161 * by aggr_matrix of cached coord.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
162 * - descendants are marked with \ref COF_ANCESTOR_CACHE
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
163 *
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
164 * Since *_transform of shapes compute area with aggr_matrix that is
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
165 * derived from aggr_matrix of a cached ancestor, area of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
166 * \ref COF_ANCESTOR_CACHE ones should be transformed to device space in
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
167 * find_shape_at_pos() with following statement.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
168 * \code
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
169 * area_matrix = p_matrix * reverse(cache_p_matrix)
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
170 * \endcode
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
171 * where cache_p_matrix and p_matrix are corresponding matrix of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
172 * cached ancestor. We can also perform transforming in reversed
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
173 * direction to transform point to space defined by aggr_matrix of cached
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
174 * coord.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
175 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
176 * Since it is costly to transform area of \ref COF_ANCESTOR_CACHE ones to
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
177 * device space if more than one ancestor are cached, no ancestor of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
178 * cached coord can be set to cached.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
179 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
180 * \section cached_bounding Bounding box of cached coord and descendants
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
181 * Bounding box of a cached coord and it's descendants is the range that
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
182 * cached coord and descendants are rendered on canvas. It is also called
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
183 * cached-bounding.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
184 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
185 * range_shift_x and range_shift_y are computed by initailizing cache_p_matrix
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
186 * with range_shift_x == range_shift_y == 0 at first. cache_p_matrix is
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
187 * used to compute aggr_matrix and cached-bounding in turn. Then,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
188 * range_shift_x and range_shift_y are initialized to negative of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
189 * x-axis and y-axis, repectively, of left-top of cached-bounding. Then,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
190 * aggr_matrix of cached coord and descendants are updated by
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
191 * following statements.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
192 * \code
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
193 * aggr_matrix[2] += range_shift_x;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
194 * aggr_matrix[5] += range_shift_y;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
195 * \endcode
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
196 * The statements shift the spaces to make cached-bounding
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
197 * aligned to origin of coordinate system.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
198 * The purpose of range_shift_* is to reduce size of canvas used to cache
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
199 * rendering result. The canvas are shrink to size the same as bounding
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
200 * box.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
201 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
202 * \section cache_redraw How cache and redraw work together?
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
203 * When a coord and descedants are cached, the coord is flaged with
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
204 * COF_FAST_CACHE or COF_PRECISE_CACHE. When a coord is marked dirty, all
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
205 * descendants are also marked dirty by rdman except descendants of cached
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
206 * ones. But, cached ones are also marked dirty as normal ones. The
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
207 * reason to mark cached ones is giving them a chance to update their
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
208 * area.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
209 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
210 * For precise cached descendants, above rule has an exception. They should
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
211 * also be marked dirty if cached coord should be rendered in a larger
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
212 * resize factor to get better output.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
213 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
214 * coord_t::aggr_matrix and cached-bounding of cached coord must be computed
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
215 * in the way described in \ref cached_bounding. Propagating range_shift_*
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
216 * to descendants must skip cached ones and their descendants.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
217 * Range_shift_* are computed after updating descendants. So, procedure
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
218 * of clean descendants of a cached one must performed in two phases.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
219 * One for computing areas of descendants and one for propagating
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
220 * range_shift_*.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
221 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
222 * A cached coord or/and descendants are dirty only for cached coord or
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
223 * descendants being marked dirty by application. Once a cached coord or
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
224 * descendant is marked dirty, all descendants of marked one are also
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
225 * marked. redraw_man_t::dirty_areas collects areas, in device space,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
226 * that should be updated. All shapes overlaid with any area in
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
227 * redraw_man_t::dirty_areas should be redraw. Since descendants of cached
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
228 * coord compute their areas in spaces other than device space.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
229 * Separated lists should be maintained for each cached coord and it's
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
230 * descendants.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
231 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
232 * \section cache_imp Implementation of Cache
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
233 * Both cached coords and coords that opacity != 1 need a canvas to
519
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
234 * draw descendants on. Both cases are traded in the same way. Every
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
235 * of them own a canvas_info to describe canvas and related
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
236 * information. aggr_matrix of descendants must be adjusted to make
519
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
237 * left-top of bounding box just at origin (0, 0) of canvas. It saves
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
238 * space to give a canvas just enough for rending descadants. The
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
239 * process of adjusting left-top of bounding box is zeroing.
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
240 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
241 * Following is rules.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
242 * - zeroing on a cached coord is performed by adjust coord_t::aggr_matrix
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
243 * of the cached coord and descendnats.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
244 * - Clean coords works just like before without change.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
245 * - in preorder
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
246 * - never perform zeroing on root_coord.
519
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
247 * - do zeroing on cached coords marked with \ref COF_MUST_ZEROING.
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
248 * - when clean a descendant that moves out-side of it's canvas,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
249 * respective cached coord is marked with \ref COF_MUST_ZEROING.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
250 * - zeroing is performed immediately after clean coords.
519
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
251 * - zeroing will not be propagated to ancestors of a cached coord.
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
252 * - It will be stopped once a cached coord being found.
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
253 * - coord_t::cur_area and coord_t::aggr_matrix of cached coords
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
254 * must be ajdusted.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
255 * - the area of a cached coord is defined in parent space.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
256 * - areas of descendants are defined in space defined by aggr_matrix of
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
257 * cached coord.
519
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
258 * - coord_t::aggr_matrix of cached coord defines coordination of
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
259 * descendants.
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
260 * - the parent knows the area in where cached coord and descendnats will
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
261 * be draw.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
262 * - cached coords keep their private dirty area list.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
263 * - private dirty areas of a cached coord are transformed and added to
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
264 * parent cached coord.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
265 * - aggregates areas before adding to parent.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
266 * - canvas of a cached coord is updated if
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
267 * - descendants are dirty, or
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
268 * - it-self is dirty.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
269 * - change of a canvas must copy to canvas of parent space.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
270 * - a cached is updated if canvas of descendant cached coord is updated.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
271 * - updating canvas is performed by redraw dirty areas.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
272 * - since dirty areas of cached ones would be aggregated and added to
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
273 * parent, parent cached coord would copy it from cache of descedants.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
274 * - descendant cached coords must be updated before ancestor cached coords.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
275 * - add dirty areas to parent immediately after updating canvas.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
276 * - Making dirty coords is not propagated through cached ones.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
277 * - cached ones are also made dirty, but stop after that.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
278 *
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
279 * Steps:
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
280 * - SWAP coord_t::cur_area of dirty coords.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
281 * - SWAP geo_t::cur_area of dirty geos.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
282 * - clean coords
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
283 * - coord_t::aggr_matrix of cached coord is not the same as non-cached.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
284 * - see \ref img_cache
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
285 * - clean geos
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
286 * - Add canvas owner of dirty geos to redraw_man_t::zeroing_coords
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
287 * - Cached ancestors of redraw_man_t::dirty_geos
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
288 * - Cached ancestors of redraw_man_t::dirty_coords
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
289 * - Cached ancestors of zeroed ones should also be zeroed.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
290 * - zeroing
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
291 * - Add more dirty areas if canvas should be fully redrawed.
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
292 * - From leaves to root.
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
293 * - Adjust area of child cached coords.
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
294 * - add aggregated dirty areas from descendant cached coords to ancestors.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
295 * - Must include old area of cached coords if it is just clean and
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
296 * parent cached one is not just clean.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
297 * - Just clean is a coord cleaned in last time of cleaning coords.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
298 * - draw dirty areas
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
299 * - areas are rounded to N at first.
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
300 * - from leaves to root.
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
301 */
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
302
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
303 #ifndef ASSERT
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
304 #define ASSERT(x)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
305 #endif
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
306
1059
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
307 /*
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
308 * Conitions for coords.
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
309 */
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
310 #define coord_is_cached(co) ((co)->flags & COF_OWN_CANVAS)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
311 #define coord_is_always_cached(co) ((co)->flags & COF_ALWAYS_CACHE)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
312 #define coord_is_fast_cached(co) ((co)->flags & COF_FAST_MASK)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
313 #define coord_is_precise_cached(co) ((co)->flags & COF_PRECISE_MASK)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
314 #define coord_is_zeroing(co) ((co)->flags & COF_MUST_ZEROING)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
315 #define coord_set_zeroing(co) \
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
316 do { (co)->flags |= COF_MUST_ZEROING; } while(0)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
317 #define coord_clear_zeroing(co) \
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
318 do { (co)->flags &= ~COF_MUST_ZEROING; } while(0)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
319 #define coord_set_flags(co, _flags) \
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
320 do { (co)->flags |= (_flags); } while(0)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
321 #define coord_get_parent(co) ((co)->parent)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
322 #define coord_get_flags(co, _flags) ((co)->flags & (_flags))
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
323 #define coord_clear_flags(co, _flags) \
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
324 do { (co)->flags &= ~(_flags); } while(0)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
325
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
326 #define coord_get_pcache_area(coord) ((coord)->canvas_info->pcache_cur_area)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
327 #define coord_get_pcache_last_area(coord) \
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
328 ((coord)->canvas_info->pcache_last_area)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
329 #define coord_get_cached(coord) ((coord)->canvas_info->owner)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
330 #define _coord_get_dirty_areas(coord) (&(coord)->canvas_info->dirty_areas)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
331 #define _coord_get_aggr_dirty_areas(coord) \
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
332 ((coord)->canvas_info->aggr_dirty_areas)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
333 #define coord_get_2pdev(coord) ((coord)->canvas_info->cache_2_pdev)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
334 #define coord_get_2pdev_rev(coord) ((coord)->canvas_info->cache_2_pdev_rev)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
335 #define coord_get_aggr2pdev(coord) ((coord)->canvas_info->aggr_2_pdev)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
336 #define coord_get_aggr2pdev_rev(coord) ((coord)->canvas_info->aggr_2_pdev_rev)
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
337
36aef79d68e4 Move macros privated used by redraw manager to redraw_man.c
Thinker K.F. Li <thinker@codemud.net>
parents: 935
diff changeset
338
26
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
339 /* NOTE: bounding box should also consider width of stroke.
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
340 */
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
341
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
342 #define sh_attach_geo(sh, g) \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
343 do { \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
344 (sh)->geo = g; \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
345 (g)->shape = (shape_t *)(sh); \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
346 } while(0)
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
347 #define sh_detach_geo(sh) \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
348 do { \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
349 (sh)->geo->shape = NULL; \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
350 (sh)->geo = NULL; \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
351 } while(0)
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
352 #define sh_get_geo(sh) ((sh)->geo)
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
353 #define sh_attach_coord(sh, coord) do { (sh)->coord = coord; } while(0)
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
354 #define sh_detach_coord(sh) do { (sh)->coord = NULL; } while(0)
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
355 #define rdman_is_dirty(rdman) \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
356 ((rdman)->dirty_coords.num != 0 || \
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
357 (rdman)->dirty_geos.num != 0)
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
358
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
359 #define OK 0
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
360 #define ERR -1
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
361
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
362 #define ARRAY_EXT_SZ 64
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
363
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
364 #define SWAP(a, b, t) do { t c; c = a; a = b; b = c; } while(0)
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
365
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
366 #ifdef UNITTEST
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
367 typedef struct _sh_dummy sh_dummy_t;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
368
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
369 extern void sh_dummy_transform(shape_t *shape);
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
370 extern void sh_dummy_fill(shape_t *, mbe_t *);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
371 #endif /* UNITTEST */
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
372
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
373 static subject_t *observer_subject_alloc(observer_factory_t *factory);
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
374 static void observer_subject_free(observer_factory_t *factory,
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
375 subject_t *subject);
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
376 static observer_t *observer_observer_alloc(observer_factory_t *factory);
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
377 static void observer_observer_free(observer_factory_t *factory,
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
378 observer_t *observer);
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
379 static subject_t *observer_get_parent_subject(observer_factory_t *factory,
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
380 subject_t *cur_subject);
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
381 /* Functions for children. */
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
382 #define FORCHILDREN(coord, child) \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
383 for((child) = STAILQ_HEAD((coord)->children); \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
384 (child) != NULL; \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
385 (child) = STAILQ_NEXT(coord_t, sibling, (child)))
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
386 #define NEXT_CHILD(child) STAILQ_NEXT(coord_t, sibling, child)
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
387 #define ADD_CHILD(parent, child) \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
388 STAILQ_INS_TAIL((parent)->children, coord_t, sibling, (child))
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
389 #define RM_CHILD(parent, child) \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
390 STAILQ_REMOVE((parent)->children, coord_t, sibling, (child))
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
391 #define FIRST_CHILD(parent) STAILQ_HEAD((parent)->children)
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
392
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
393 /* Functions for members. */
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
394 #define FORMEMBERS(coord, member) \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
395 for((member) = STAILQ_HEAD((coord)->members); \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
396 (member) != NULL; \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
397 (member) = STAILQ_NEXT(geo_t, coord_next, (member)))
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
398 #define NEXT_MEMBER(member) STAILQ_NEXT(geo_t, coord_next, (member))
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
399 #define ADD_MEMBER(coord, member) \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
400 STAILQ_INS_TAIL((coord)->members, geo_t, coord_next, (member))
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
401 #define RM_MEMBER(coord, member) \
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
402 STAILQ_REMOVE((coord)->members, geo_t, coord_next, (member))
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
403 #define FIRST_MEMBER(coord) STAILQ_HEAD((coord)->members)
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
404
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
405 /* Functions for paint members. */
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
406 #define FORPAINTMEMBERS(paint, member) \
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
407 for((member) = STAILQ_HEAD((paint)->members); \
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
408 (member) != NULL; \
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
409 (member) = STAILQ_NEXT(paint_t, next, member))
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
410 #define RM_PAINTMEMBER(paint, member) \
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
411 STAILQ_REMOVE((paint)->members, shnode_t, next, member)
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
412
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
413 /*! \brief Sort a list of element by a unsigned integer.
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
414 *
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
415 * The result is in ascend order. The unsigned integers is
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
416 * at offset specified by 'off' from start address of elemnts.
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
417 */
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
418 static void _insert_sort(void **elms, int num, int off) {
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
419 int i, j;
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
420 unsigned int val;
121
76ba6fd61c7d More bug of insert sort.
Thinker K.F. Li <thinker@branda.to>
parents: 119
diff changeset
421 void *elm_i;
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
422
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
423 for(i = 1; i < num; i++) {
121
76ba6fd61c7d More bug of insert sort.
Thinker K.F. Li <thinker@branda.to>
parents: 119
diff changeset
424 elm_i = elms[i];
76ba6fd61c7d More bug of insert sort.
Thinker K.F. Li <thinker@branda.to>
parents: 119
diff changeset
425 val = *(unsigned int *)(elm_i + off);
119
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
426 for(j = i; j > 0; j--) {
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
427 if(*(unsigned int *)(elms[j - 1] + off) <= val)
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
428 break;
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
429 elms[j] = elms[j - 1];
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
430 }
121
76ba6fd61c7d More bug of insert sort.
Thinker K.F. Li <thinker@branda.to>
parents: 119
diff changeset
431 elms[j] = elm_i;
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
432 }
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
433 }
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
434
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
435 DARRAY_DEFINE(coords, coord_t *);
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
436 DARRAY_DEFINE(geos, geo_t *);
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
437 DARRAY_DEFINE(areas, area_t *);
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
438
235
65cabbdd5284 termporary revision
Thinker K.F. Li <thinker@branda.to>
parents: 231
diff changeset
439 int rdman_add_gen_geos(redraw_man_t *rdman, geo_t *geo) {
65cabbdd5284 termporary revision
Thinker K.F. Li <thinker@branda.to>
parents: 231
diff changeset
440 int r;
65cabbdd5284 termporary revision
Thinker K.F. Li <thinker@branda.to>
parents: 231
diff changeset
441
65cabbdd5284 termporary revision
Thinker K.F. Li <thinker@branda.to>
parents: 231
diff changeset
442 r = geos_add(rdman_get_gen_geos(rdman), geo);
65cabbdd5284 termporary revision
Thinker K.F. Li <thinker@branda.to>
parents: 231
diff changeset
443 return r;
65cabbdd5284 termporary revision
Thinker K.F. Li <thinker@branda.to>
parents: 231
diff changeset
444 }
65cabbdd5284 termporary revision
Thinker K.F. Li <thinker@branda.to>
parents: 231
diff changeset
445
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
446 /*! Use \brief DARRAY to implement dirty & free lists.
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
447 */
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
448 #define ADD_DATA(sttype, field, v) \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
449 int r; \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
450 r = sttype ## _add(&rdman->field, v); \
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
451 return r == 0? OK: ERR;
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
452
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
453
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
454 static int is_area_in_areas(area_t *area,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
455 int n_areas,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
456 area_t **areas) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
457 int i;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
458
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
459 for(i = 0; i < n_areas; i++) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
460 if(areas_are_overlay(area, areas[i]))
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
461 return 1;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
462 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
463 return 0;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
464 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
465
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
466 static int is_geo_in_areas(geo_t *geo,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
467 int n_areas,
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
468 area_t **areas) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
469 return is_area_in_areas(geo->cur_area, n_areas, areas);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
470 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
471
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
472 static void area_to_positions(area_t *area, co_aix (*poses)[2]) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
473 poses[0][0] = area->x;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
474 poses[0][1] = area->y;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
475 poses[1][0] = area->x + area->w;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
476 poses[1][1] = area->y + area->h;;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
477 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
478
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
479 /* Maintain Lists */
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
480
152
2b316b5d65f9 Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 151
diff changeset
481 static int add_dirty_coord(redraw_man_t *rdman, coord_t *coord) {
2b316b5d65f9 Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 151
diff changeset
482 coord->flags |= COF_DIRTY;
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
483 ADD_DATA(coords, dirty_coords, coord);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
484 return OK;
152
2b316b5d65f9 Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 151
diff changeset
485 }
2b316b5d65f9 Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 151
diff changeset
486
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
487 static int add_dirty_geo(redraw_man_t *rdman, geo_t *geo) {
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
488 geo->flags |= GEF_DIRTY;
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
489 ADD_DATA(geos, dirty_geos, geo);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
490 return OK;
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
491 }
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
492
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
493 static int add_dirty_area(redraw_man_t *rdman, coord_t *coord, area_t *area) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
494 int r;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
495
530
cd41d9033567 Ignore small dirty area.
Thinker K.F. Li <thinker@branda.to>
parents: 528
diff changeset
496 if(area->w < 0.01 || area->h < 0.01)
cd41d9033567 Ignore small dirty area.
Thinker K.F. Li <thinker@branda.to>
parents: 528
diff changeset
497 return OK;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
498
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
499 rdman->n_dirty_areas++;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
500 r = areas_add(_coord_get_dirty_areas(coord), area);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
501 return r == 0? OK: ERR;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
502 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
503
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
504 static int add_zeroing_coord(redraw_man_t *rdman, coord_t *coord) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
505 coord_set_zeroing(coord);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
506 ADD_DATA(coords, zeroing_coords, coord);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
507 return OK;
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
508 }
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
509
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
510 static int add_dirty_pcache_area_coord(redraw_man_t *rdman, coord_t *coord) {
836
f3ce3598612f Avoid to add a coord to dirty_pcache_area_coords twice or more
Thinker K.F. Li <thinker@codemud.net>
parents: 835
diff changeset
511 if(!coord_get_flags(coord, COF_DIRTY_PCACHE_AREA)) {
f3ce3598612f Avoid to add a coord to dirty_pcache_area_coords twice or more
Thinker K.F. Li <thinker@codemud.net>
parents: 835
diff changeset
512 coord_set_flags(coord, COF_DIRTY_PCACHE_AREA);
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
513 ADD_DATA(coords, zeroing_coords, coord);
836
f3ce3598612f Avoid to add a coord to dirty_pcache_area_coords twice or more
Thinker K.F. Li <thinker@codemud.net>
parents: 835
diff changeset
514 }
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
515 return OK;
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
516 }
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
517
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
518 static int add_free_obj(redraw_man_t *rdman, void *obj,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
519 free_func_t free_func) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
520 int max;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
521 free_obj_t *new_objs, *free_obj;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
522
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
523 if(rdman->free_objs.num >= rdman->free_objs.max) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
524 max = rdman->free_objs.num + ARRAY_EXT_SZ;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
525 new_objs = realloc(rdman->free_objs.objs,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
526 max * sizeof(free_obj_t));
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
527 if(new_objs == NULL)
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
528 return ERR;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
529 rdman->free_objs.max = max;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
530 rdman->free_objs.objs = new_objs;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
531 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
532
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
533 free_obj = rdman->free_objs.objs + rdman->free_objs.num++;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
534 free_obj->obj = obj;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
535 free_obj->free_func = free_func;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
536
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
537 return OK;
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
538 }
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
539
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
540 static void free_free_objs(redraw_man_t *rdman) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
541 int i;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
542 free_obj_t *free_obj;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
543
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
544 for(i = 0; i < rdman->free_objs.num; i++) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
545 free_obj = &rdman->free_objs.objs[i];
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
546 free_obj->free_func(rdman, free_obj->obj);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
547 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
548 rdman->free_objs.num = 0;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
549 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
550
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
551 static void free_objs_destroy(redraw_man_t *rdman) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
552 if(rdman->free_objs.objs != NULL)
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
553 free(rdman->free_objs.objs);
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
554 }
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
555
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
556 #ifdef UNITTEST
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
557 /*! \brief This is only used for unittest.
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
558 */
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
559 typedef struct {
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
560 co_aix parent_2_cache[6];
834
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
561 int w, h;
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
562 } mock_mbe_t;
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
563 #endif
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
564
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
565 static mbe_t *canvas_new(int w, int h) {
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
566 #ifndef UNITTEST
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
567 mbe_surface_t *surface;
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
568 mbe_t *cr;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
569
450
a417fd980228 Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents: 448
diff changeset
570 surface = mbe_image_surface_create(MB_IFMT_ARGB32,
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
571 w, h);
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
572 cr = mbe_create(surface);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
573
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
574 return cr;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
575 #else
834
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
576 mock_mbe_t *mbe;
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
577
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
578 mbe = malloc(sizeof(mock_mbe_t));
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
579 mbe->w = w;
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
580 mbe->h = h;
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
581
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
582 return (mbe_t *)mbe;
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
583 #endif
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
584 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
585
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
586 static void canvas_free(mbe_t *canvas) {
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
587 #ifndef UNITTEST
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
588 mbe_destroy(canvas);
825
e83956ba22d7 Make sure drawing on right cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 824
diff changeset
589 #else
e83956ba22d7 Make sure drawing on right cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 824
diff changeset
590 free(canvas);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
591 #endif
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
592 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
593
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
594 static void canvas_get_size(mbe_t *canvas, int *w, int *h) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
595 #ifndef UNITTEST
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
596 mbe_surface_t *surface;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
597
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
598 surface = mbe_get_target(canvas);
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
599 *w = mbe_image_surface_get_width(surface);
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
600 *h = mbe_image_surface_get_height(surface);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
601 #else
834
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
602 mock_mbe_t *mbe;
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
603
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
604 mbe = (mock_mbe_t *)canvas;
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
605 *w = mbe->w;
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
606 *h = mbe->h;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
607 #endif
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
608 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
609
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
610 static int geo_off_in_coord(geo_t *geo, coord_t *coord) {
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
611 int off = 0;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
612 geo_t *vgeo;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
613
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
614 FORMEMBERS(coord, vgeo) {
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
615 if(vgeo == geo)
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
616 return off;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
617 off++;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
618 }
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
619 return -1;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
620 }
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
621
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
622 static void geo_attach_coord(geo_t *geo, coord_t *coord) {
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
623 ADD_MEMBER(coord, geo);
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
624 coord->num_members++;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
625 }
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
626
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
627 static void geo_detach_coord(geo_t *geo, coord_t *coord) {
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
628 int off;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
629 coord_t *child;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
630
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
631 off = geo_off_in_coord(geo, coord);
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
632 if(off < 0)
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
633 return;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
634 FORCHILDREN(coord, child) {
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
635 if(child->before_pmem >= off)
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
636 child->before_pmem--;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
637 }
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
638
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
639 RM_MEMBER(coord, geo);
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
640 coord->num_members--;
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
641 }
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
642
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
643 /*! \brief Create a new canvas and respective info struct for a coord.
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
644 */
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
645 static coord_canvas_info_t *
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
646 coord_canvas_info_new(redraw_man_t *rdman, coord_t *coord,
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
647 mbe_t *canvas) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
648 coord_canvas_info_t *info;
851
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
649 static co_aix id[6] = {1, 0, 0, 0, 1, 0};
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
650
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
651 info = (coord_canvas_info_t *)elmpool_elm_alloc(rdman->coord_canvas_pool);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
652 if(info == NULL)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
653 return info;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
654
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
655 info->owner = coord;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
656 info->canvas = canvas;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
657 DARRAY_INIT(&info->dirty_areas);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
658
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
659 bzero(info->pcache_areas, sizeof(area_t) * 2);
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
660 info->pcache_cur_area = &info->pcache_areas[0];
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
661 info->pcache_last_area = &info->pcache_areas[1];
851
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
662 memcpy(info->cache_2_pdev, id, sizeof(co_aix) * 6);
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
663 memcpy(info->cache_2_pdev_rev, id, sizeof(co_aix) * 6);
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
664 memcpy(info->aggr_2_pdev, id, sizeof(co_aix) * 6);
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
665 memcpy(info->aggr_2_pdev_rev, id, sizeof(co_aix) * 6);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
666
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
667 return info;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
668 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
669
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
670 static void coord_canvas_info_free(redraw_man_t *rdman,
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
671 coord_canvas_info_t *info) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
672 DARRAY_DESTROY(&info->dirty_areas);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
673 elmpool_elm_free(rdman->coord_canvas_pool, info);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
674 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
675
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
676 static void mouse_event_root_dummy(event_t *evt, void *arg) {
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
677 }
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
678
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
679 int redraw_man_init(redraw_man_t *rdman, mbe_t *cr, mbe_t *backend) {
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
680 extern void redraw_man_destroy(redraw_man_t *rdman);
865
48df0f97f09e Allocate sh_path_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 864
diff changeset
681 extern int _sh_path_size;
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 865
diff changeset
682 extern int _sh_rect_size;
147
995ee8fd5f1a Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents: 146
diff changeset
683 extern int _paint_color_size;
867
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
684 extern int _paint_linear_size;
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
685 extern int _paint_radial_size;
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
686 extern int _paint_image_size;
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
687 observer_t *addrm_ob;
231
2637519e2bd7 Move mouse event handler and interpreter to src/mouse.c.
Thinker K.F. Li <thinker@branda.to>
parents: 224
diff changeset
688 extern void addrm_monitor_hdlr(event_t *evt, void *arg);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
689
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
690 memset(rdman, 0, sizeof(redraw_man_t));
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
691
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
692 DARRAY_INIT(&rdman->dirty_coords);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
693 DARRAY_INIT(&rdman->dirty_geos);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
694 DARRAY_INIT(&rdman->gen_geos);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
695 DARRAY_INIT(&rdman->zeroing_coords);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
696
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
697 rdman->geo_pool = elmpool_new(sizeof(geo_t), 128);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
698 rdman->coord_pool = elmpool_new(sizeof(coord_t), 16);
18
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
699 rdman->shnode_pool = elmpool_new(sizeof(shnode_t), 16);
865
48df0f97f09e Allocate sh_path_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 864
diff changeset
700 rdman->sh_path_pool = elmpool_new(_sh_path_size, 16);
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 865
diff changeset
701 rdman->sh_rect_pool = elmpool_new(_sh_rect_size, 16);
75
23bc382d9683 find_geo_in_pos() should return shapes that is not hidden
Thinker K.F. Li <thinker@branda.to>
parents: 73
diff changeset
702 rdman->observer_pool = elmpool_new(sizeof(observer_t), 32);
23bc382d9683 find_geo_in_pos() should return shapes that is not hidden
Thinker K.F. Li <thinker@branda.to>
parents: 73
diff changeset
703 rdman->subject_pool = elmpool_new(sizeof(subject_t), 32);
147
995ee8fd5f1a Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents: 146
diff changeset
704 rdman->paint_color_pool = elmpool_new(_paint_color_size, 64);
867
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
705 rdman->paint_linear_pool = elmpool_new(_paint_linear_size, 64);
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
706 rdman->paint_radial_pool = elmpool_new(_paint_radial_size, 64);
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
707 rdman->paint_image_pool = elmpool_new(_paint_image_size, 64);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
708 rdman->pent_pool = elmpool_new(sizeof(mb_prop_entry_t), 128);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
709 rdman->coord_canvas_pool = elmpool_new(sizeof(coord_canvas_info_t), 16);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
710 if(!(rdman->geo_pool && rdman->coord_pool && rdman->shnode_pool &&
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
711 rdman->observer_pool && rdman->subject_pool &&
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
712 rdman->paint_color_pool && rdman->coord_canvas_pool))
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
713 goto err;
146
e96a584487af Use elmpool to manage paint_color_t objects.
Thinker K.F. Li <thinker@branda.to>
parents: 141
diff changeset
714
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
715 rdman->observer_factory.subject_alloc = observer_subject_alloc;
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
716 rdman->observer_factory.subject_free = observer_subject_free;
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
717 rdman->observer_factory.observer_alloc = observer_observer_alloc;
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
718 rdman->observer_factory.observer_free = observer_observer_free;
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
719 rdman->observer_factory.get_parent_subject = observer_get_parent_subject;
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
720
154
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
721 rdman->redraw =
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
722 subject_new(&rdman->observer_factory, rdman, OBJT_RDMAN);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
723 rdman->addrm_monitor =
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
724 subject_new(&rdman->observer_factory, rdman, OBJT_RDMAN);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
725 if(!(rdman->redraw && rdman->addrm_monitor))
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
726 goto err;
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
727
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
728 addrm_ob = subject_add_observer(rdman->addrm_monitor,
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
729 addrm_monitor_hdlr, rdman);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
730 if(addrm_ob == NULL)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
731 goto err;
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
732
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
733 rdman->last_mouse_over = NULL;
154
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
734
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
735 rdman->root_coord = elmpool_elm_alloc(rdman->coord_pool);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
736 if(rdman->root_coord == NULL)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
737 redraw_man_destroy(rdman);
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
738 rdman->n_coords = 1;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
739 coord_init(rdman->root_coord, NULL);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
740 mb_prop_store_init(&rdman->root_coord->obj.props, rdman->pent_pool);
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
741 rdman->root_coord->mouse_event = subject_new(&rdman->observer_factory,
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
742 rdman->root_coord,
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
743 OBJT_COORD);
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
744 coord_set_flags(rdman->root_coord, COF_OWN_CANVAS);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
745 rdman->root_coord->canvas_info =
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
746 coord_canvas_info_new(rdman, rdman->root_coord, cr);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
747 rdman->root_coord->opacity = 1;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
748
15
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
749 rdman->cr = cr;
24
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
750 rdman->backend = backend;
15
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
751
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
752 STAILQ_INIT(rdman->shapes);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
753
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
754 /* \note To make root coord always have at leat one observer.
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
755 * It triggers mouse interpreter to be installed on root.
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
756 */
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
757 subject_set_monitor(rdman->root_coord->mouse_event,
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
758 rdman->addrm_monitor);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
759 subject_add_observer(rdman->root_coord->mouse_event,
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
760 mouse_event_root_dummy, NULL);
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
761
257
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 251
diff changeset
762 mb_prop_store_init(&rdman->props, rdman->pent_pool);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
763 return OK;
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
764
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
765 err:
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
766 if(rdman->geo_pool)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
767 elmpool_free(rdman->geo_pool);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
768 if(rdman->coord_pool)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
769 elmpool_free(rdman->coord_pool);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
770 if(rdman->shnode_pool)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
771 elmpool_free(rdman->shnode_pool);
865
48df0f97f09e Allocate sh_path_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 864
diff changeset
772 if(rdman->sh_path_pool)
48df0f97f09e Allocate sh_path_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 864
diff changeset
773 elmpool_free(rdman->sh_path_pool);
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 865
diff changeset
774 if(rdman->sh_rect_pool)
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 865
diff changeset
775 elmpool_free(rdman->sh_rect_pool);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
776 if(rdman->observer_pool)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
777 elmpool_free(rdman->observer_pool);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
778 if(rdman->subject_pool)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
779 elmpool_free(rdman->subject_pool);
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
780 if(rdman->paint_color_pool)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
781 elmpool_free(rdman->paint_color_pool);
867
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
782 if(rdman->paint_linear_pool)
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
783 elmpool_free(rdman->paint_linear_pool);
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
784 if(rdman->paint_radial_pool)
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
785 elmpool_free(rdman->paint_radial_pool);
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
786 if(rdman->paint_image_pool)
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
787 elmpool_free(rdman->paint_image_pool);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
788 if(rdman->pent_pool)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
789 elmpool_free(rdman->pent_pool);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
790 if(rdman->coord_canvas_pool)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
791 elmpool_free(rdman->coord_canvas_pool);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
792 DARRAY_DESTROY(&rdman->dirty_coords);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
793 DARRAY_DESTROY(&rdman->dirty_geos);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
794 DARRAY_DESTROY(&rdman->gen_geos);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
795 DARRAY_DESTROY(&rdman->zeroing_coords);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
796 return ERR;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
797 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
798
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
799 void redraw_man_destroy(redraw_man_t *rdman) {
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
800 coord_t *coord, *saved_coord;
769
7c73fbc8d700 Remove unused local variables
Thinker K.F. Li <thinker@codemud.net>
parents: 747
diff changeset
801 shape_t *shape;
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
802 geo_t *member;
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
803
257
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 251
diff changeset
804 mb_prop_store_destroy(&rdman->props);
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 251
diff changeset
805
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
806 free_free_objs(rdman);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
807 free_objs_destroy(rdman);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
808
489
23c7667b3ec0 Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents: 473
diff changeset
809 /* Mark rdman clean that shapes and coords can be freed
23c7667b3ec0 Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents: 473
diff changeset
810 * successfully.
23c7667b3ec0 Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents: 473
diff changeset
811 */
23c7667b3ec0 Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents: 473
diff changeset
812 DARRAY_CLEAN(&rdman->dirty_coords);
23c7667b3ec0 Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents: 473
diff changeset
813 DARRAY_CLEAN(&rdman->dirty_geos);
23c7667b3ec0 Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents: 473
diff changeset
814
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
815 coord = postorder_coord_subtree(rdman->root_coord, NULL);
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
816 while(coord) {
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
817 saved_coord = coord;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
818 coord = postorder_coord_subtree(rdman->root_coord, coord);
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
819 FORMEMBERS(saved_coord, member) {
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
820 rdman_shape_free(rdman, member->shape);
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
821 }
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
822 rdman_coord_free(rdman, saved_coord);
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
823 }
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
824 /* Resources of root_coord is free by elmpool_free() or
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
825 * caller; for canvas
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
826 */
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
827
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
828 while((shape = STAILQ_HEAD(rdman->shapes)) != NULL) {
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
829 rdman_shape_free(rdman, shape);
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
830 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
831
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
832 coord_canvas_info_free(rdman, rdman->root_coord->canvas_info);
490
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
833
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
834 /* XXX: paints are not freed, here. All resources of paints would
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
835 * be reclaimed by freeing elmpools.
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
836 */
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
837
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
838 elmpool_free(rdman->coord_pool);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
839 elmpool_free(rdman->geo_pool);
18
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
840 elmpool_free(rdman->shnode_pool);
865
48df0f97f09e Allocate sh_path_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 864
diff changeset
841 elmpool_free(rdman->sh_path_pool);
866
9a7ac4487849 Allocate sh_rect_t objects from an elmpool
Thinker K.F. Li <thinker@codemud.net>
parents: 865
diff changeset
842 elmpool_free(rdman->sh_rect_pool);
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
843 elmpool_free(rdman->observer_pool);
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
844 elmpool_free(rdman->subject_pool);
146
e96a584487af Use elmpool to manage paint_color_t objects.
Thinker K.F. Li <thinker@branda.to>
parents: 141
diff changeset
845 elmpool_free(rdman->paint_color_pool);
867
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
846 elmpool_free(rdman->paint_linear_pool);
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
847 elmpool_free(rdman->paint_radial_pool);
4f8d53be9488 Allocate linear, radial, image paints from elmpools
Thinker K.F. Li <thinker@codemud.net>
parents: 866
diff changeset
848 elmpool_free(rdman->paint_image_pool);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
849 elmpool_free(rdman->pent_pool);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
850 elmpool_free(rdman->coord_canvas_pool);
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
851
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
852 DARRAY_DESTROY(&rdman->dirty_coords);
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
853 DARRAY_DESTROY(&rdman->dirty_geos);
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
854 DARRAY_DESTROY(&rdman->gen_geos);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
855 DARRAY_DESTROY(&rdman->zeroing_coords);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
856 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
857
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
858
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
859 #define ASSERT(x)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
860 /*
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
861 * Change transformation matrix
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
862 * - update aggregated transformation matrix
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
863 * - of coord_t object been changed.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
864 * - of children coord_t objects.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
865 * - redraw members of coord_t objects.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
866 * - redraw shape objects they are overlaid with members.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
867 * - find out overlaid shape objects.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
868 * - geo_t of a coord_t object
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
869 * - can make finding more efficiency.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
870 * - fill overlay geo_t objects of members.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
871 *
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
872 * Change a shape object
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
873 * - redraw changed object.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
874 * - redraw shape objects they are overlaid with changed object.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
875 * - find out overlaid shape objects.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
876 *
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
877 * That coord and geo of shape objects are setted by user code
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
878 * give user code a chance to collect coord and geo objects together
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
879 * and gain interest of higher cache hit rate.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
880 */
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
881
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
882 int rdman_add_shape(redraw_man_t *rdman, shape_t *shape, coord_t *coord) {
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
883 geo_t *geo;
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
884 int r;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
885
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
886 geo = elmpool_elm_alloc(rdman->geo_pool);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
887 if(geo == NULL)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
888 return ERR;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
889
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
890 geo_init(geo);
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
891 geo->mouse_event = subject_new(&rdman->observer_factory, geo, OBJT_GEO);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
892 subject_set_monitor(geo->mouse_event, rdman->addrm_monitor);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
893
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
894 geo_attach_coord(geo, coord);
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
895
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
896 /* New one should be dirty to recompute it when drawing. */
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
897 r = add_dirty_geo(rdman, geo);
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
898 if(r != OK)
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
899 return ERR;
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
900
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
901 sh_attach_coord(shape, coord);
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
902 sh_attach_geo(shape, geo);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
903
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
904 return OK;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
905 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
906
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
907 /*! \brief Remove a shape object from redraw manager.
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
908 *
154
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
909 * \note Shapes should be removed after redrawing or when rdman is in clean.
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
910 * \note Removing shapes or coords when a rdman is dirty, removing
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
911 * is postponsed.
58
Thinker K.F. Li <thinker@branda.to>
parents: 57
diff changeset
912 * \todo redraw shape objects that overlaid with removed one.
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
913 */
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
914 int rdman_shape_free(redraw_man_t *rdman, shape_t *shape) {
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
915 geo_t *geo;
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
916 int r;
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
917
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
918 geo = shape->geo;
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
919
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
920 if(rdman_is_dirty(rdman) && geo != NULL) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
921 if(geo->flags & GEF_FREE)
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
922 return ERR;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
923
160
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
924 geo->flags |= GEF_FREE;
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
925 sh_hide(shape);
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
926 if(!(geo->flags & GEF_DIRTY)) {
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
927 r = add_dirty_geo(rdman, geo);
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
928 if(r != OK)
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
929 return ERR;
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
930 }
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
931 r = add_free_obj(rdman, shape, (free_func_t)rdman_shape_free);
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
932 if(r != OK)
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
933 return ERR;
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
934 return OK;
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
935 }
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
936
490
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
937 if(shape->stroke != NULL)
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
938 rdman_paint_stroke(rdman, (paint_t *)NULL, shape);
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
939 if(shape->fill != NULL)
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
940 rdman_paint_fill(rdman, (paint_t *)NULL, shape);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
941
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
942 if(geo != NULL) {
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
943 subject_free(geo->mouse_event);
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
944 geo_detach_coord(geo, shape->coord);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
945 sh_detach_coord(shape);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
946 sh_detach_geo(shape);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
947 elmpool_elm_free(rdman->geo_pool, geo);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
948 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
949 STAILQ_REMOVE(rdman->shapes, shape_t, sh_next, shape);
251
f08b3ba9c1d8 Remove potential memory address error.
Thinker K.F. Li <thinker@branda.to>
parents: 235
diff changeset
950 mb_prop_store_destroy(&shape->obj.props);
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
951 shape->free(shape);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
952
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
953 if(rdman->last_mouse_over == (mb_obj_t *)shape)
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
954 rdman->last_mouse_over = NULL;
490
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
955
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
956
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
957 return OK;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
958 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
959
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
960 shnode_t *shnode_new(redraw_man_t *rdman, shape_t *shape) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
961 shnode_t *node;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
962
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
963 node = (shnode_t *)elmpool_elm_alloc(rdman->shnode_pool);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
964 if(node) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
965 node->shape = shape;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
966 node->next = NULL;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
967 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
968 return node;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
969 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
970
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
971 int rdman_paint_free(redraw_man_t *rdman, paint_t *paint) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
972 shnode_t *shnode, *saved_shnode;
490
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
973 shape_t *shape;
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
974
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
975 if(rdman_is_dirty(rdman)) {
771
01b514800fbe Fix logic error of checking clear flag for paint.
Thinker K.F. Li <thinker@codemud.net>
parents: 769
diff changeset
976 if(paint->flags & PNTF_FREE)
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
977 return ERR;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
978 add_free_obj(rdman, paint, (free_func_t)rdman_paint_free);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
979 paint->flags |= PNTF_FREE;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
980 return OK;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
981 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
982
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
983 /* Free member shapes that using this paint. */
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
984 saved_shnode = NULL;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
985 FORPAINTMEMBERS(paint, shnode) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
986 if(saved_shnode) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
987 RM_PAINTMEMBER(paint, saved_shnode);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
988
490
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
989 shape = saved_shnode->shape;
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
990 if(shape->stroke == paint)
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
991 rdman_paint_stroke(rdman, (paint_t *)NULL, shape);
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
992 if(shape->fill == paint)
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
993 rdman_paint_fill(rdman, (paint_t *)NULL, shape);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
994
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
995 shnode_free(rdman, saved_shnode);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
996 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
997 saved_shnode = shnode;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
998 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
999 if(saved_shnode) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1000 RM_PAINTMEMBER(paint, saved_shnode);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1001
490
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
1002 shape = saved_shnode->shape;
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
1003 if(shape->stroke == paint)
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
1004 rdman_paint_stroke(rdman, (paint_t *)NULL, shape);
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
1005 if(shape->fill == paint)
5d0b2761f89c Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents: 489
diff changeset
1006 rdman_paint_fill(rdman, (paint_t *)NULL, shape);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1007
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1008 shnode_free(rdman, saved_shnode);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1009 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1010
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1011 paint->free(rdman, paint);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1012 return OK;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1013 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1014
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1015 void _rdman_paint_real_remove_child(redraw_man_t *rdman,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1016 paint_t *paint,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1017 shape_t *shape) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1018 shnode_t *shnode;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1019
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1020 FORPAINTMEMBERS(paint, shnode) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1021 if(shnode->shape == shape) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1022 RM_PAINTMEMBER(paint, shnode);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1023 shnode_free(rdman, shnode);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1024 break;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1025 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1026 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1027 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1028
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1029 coord_t *rdman_coord_new(redraw_man_t *rdman, coord_t *parent) {
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1030 coord_t *coord, *root_coord;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1031 coord_t *visit;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1032
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1033 coord = elmpool_elm_alloc(rdman->coord_pool);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1034 if(coord == NULL)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1035 return NULL;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1036
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1037 coord_init(coord, parent);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
1038 mb_prop_store_init(&coord->obj.props, rdman->pent_pool);
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
1039 coord->mouse_event = subject_new(&rdman->observer_factory,
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
1040 coord,
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
1041 OBJT_COORD);
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
1042 subject_set_monitor(coord->mouse_event, rdman->addrm_monitor);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1043 /*! \note default opacity == 1 */
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1044 coord->opacity = 1;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1045 if(parent)
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1046 coord->canvas_info = parent->canvas_info;
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1047 rdman->n_coords++;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1048
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1049 coord->order = ++rdman->next_coord_order;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1050 if(coord->order == 0) {
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1051 rdman->next_coord_order = 0;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1052 root_coord = visit = rdman->root_coord;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1053 /* skip root coord. */
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1054 visit = preorder_coord_subtree(root_coord, visit);
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1055 while(visit) {
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1056 visit->order = ++rdman->next_coord_order;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1057 visit = preorder_coord_subtree(root_coord, visit);
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1058 }
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1059 }
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1060
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
1061 coord->before_pmem = parent->num_members;
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
1062
151
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1063 /* If parent is dirty, children should be dirty. */
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1064 if(parent && (parent->flags & COF_DIRTY))
152
2b316b5d65f9 Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 151
diff changeset
1065 add_dirty_coord(rdman, coord);
151
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1066
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1067 return coord;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1068 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1069
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1070 static int rdman_coord_free_postponse(redraw_man_t *rdman, coord_t *coord) {
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1071 int r;
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1072
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1073 if(coord->flags & COF_FREE)
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1074 return ERR;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1075
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1076 coord->flags |= COF_FREE;
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1077 coord_hide(coord);
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1078 if(!(coord->flags & COF_DIRTY)) {
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1079 r = add_dirty_coord(rdman, coord);
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1080 if(r != OK)
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1081 return ERR;
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1082 }
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1083 r = add_free_obj(rdman, coord, (free_func_t)rdman_coord_free);
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1084 if(r != OK)
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1085 return ERR;
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1086 return OK;
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1087 }
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1088
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1089 /*! \brief Free a coord of a redraw_man_t object.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1090 *
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1091 * All children and members should be freed before parent being freed.
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1092 *
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1093 * \param coord is a coord_t without children and members.
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1094 * \return 0 for successful, -1 for error.
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
1095 *
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1096 * \note Free is postponsed if the coord is dirty or it has children
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1097 * or members postponsed for free.
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1098 */
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1099 int rdman_coord_free(redraw_man_t *rdman, coord_t *coord) {
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1100 coord_t *parent;
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
1101 coord_t *child;
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
1102 geo_t *member;
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1103 int cm_cnt; /* children & members counter */
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1104
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1105 parent = coord->parent;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1106 if(parent == NULL)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1107 return ERR;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1108
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1109 cm_cnt = 0;
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1110 FORCHILDREN(coord, child) {
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1111 cm_cnt++;
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1112 if(!(child->flags & COF_FREE))
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1113 return ERR;
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1114 }
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1115 FORMEMBERS(coord, member) {
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1116 cm_cnt++;
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1117 if(!(member->flags & GEF_FREE))
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
1118 return ERR;
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
1119 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1120
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1121 if(cm_cnt || rdman_is_dirty(rdman))
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1122 return rdman_coord_free_postponse(rdman, coord);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1123
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1124 /* Free canvas and canvas_info (\ref redraw) */
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1125 if(coord_is_cached(coord)) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1126 canvas_free(_coord_get_canvas(coord));
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1127 coord_canvas_info_free(rdman, coord->canvas_info);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1128 }
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1129
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
1130 RM_CHILD(parent, coord);
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
1131 subject_free(coord->mouse_event);
251
f08b3ba9c1d8 Remove potential memory address error.
Thinker K.F. Li <thinker@branda.to>
parents: 235
diff changeset
1132 mb_prop_store_destroy(&coord->obj.props);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1133 elmpool_elm_free(rdman->coord_pool, coord);
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1134 rdman->n_coords--;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1135
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1136 return OK;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1137 }
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1138
224
29e1b2bffe4c X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 196
diff changeset
1139 static int _rdman_coord_free_members(redraw_man_t *rdman, coord_t *coord) {
194
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1140 geo_t *member;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1141 shape_t *shape;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1142 int r;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1143
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1144 FORMEMBERS(coord, member) {
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1145 shape = geo_get_shape(member);
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1146 r = rdman_shape_free(rdman, shape);
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1147 if(r != OK)
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1148 return ERR;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1149 }
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1150 return OK;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1151 }
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1152
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1153 /*! \brief Free descendant coords and shapes of a coord.
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1154 *
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1155 * The specified coord is also freed.
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1156 */
154
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1157 int rdman_coord_subtree_free(redraw_man_t *rdman, coord_t *subtree) {
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1158 coord_t *coord, *prev_coord;
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1159 int r;
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1160
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1161 if(subtree == NULL)
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1162 return OK;
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1163
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1164 prev_coord = postorder_coord_subtree(subtree, NULL);
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1165 for(coord = postorder_coord_subtree(subtree, prev_coord);
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1166 coord != NULL;
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1167 coord = postorder_coord_subtree(subtree, coord)) {
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1168 if(!(prev_coord->flags & COF_FREE)) {
194
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1169 r = _rdman_coord_free_members(rdman, prev_coord);
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1170 if(r != OK)
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1171 return ERR;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1172
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1173 r = rdman_coord_free(rdman, prev_coord);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1174 if(r != OK)
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1175 return ERR;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1176 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1177 prev_coord = coord;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1178 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1179 if(!(prev_coord->flags & COF_FREE)) {
194
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1180 r = _rdman_coord_free_members(rdman, prev_coord);
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1181 if(r != OK)
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1182 return ERR;
45d9a1e2764d Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents: 192
diff changeset
1183
154
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1184 r = rdman_coord_free(rdman, prev_coord);
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1185 if(r != OK)
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1186 return ERR;
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1187 }
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1188
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1189 return OK;
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1190 }
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
1191
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1192 /*! \brief Mark a coord is changed.
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1193 *
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1194 * A changed coord_t object is marked as dirty and put
160
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
1195 * into dirty_coords list. rdman_coord_changed() should be called
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
1196 * for a coord after it been changed to notify redraw manager to
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
1197 * redraw shapes grouped by it.
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1198 *
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1199 * Once a coord is changed, all its descendants are also put marked
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1200 * dirty.
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1201 */
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1202 int rdman_coord_changed(redraw_man_t *rdman, coord_t *coord) {
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
1203 coord_t *child;
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1204
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1205 if(coord->flags & COF_DIRTY)
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1206 return OK;
151
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1207
152
2b316b5d65f9 Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 151
diff changeset
1208 add_dirty_coord(rdman, coord);
151
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1209
189
257af0ed5852 When a bullet hits a tank or wall, it shows a bang animation.
Thinker K.F. Li <thinker@branda.to>
parents: 186
diff changeset
1210 #if 0
160
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
1211 if(coord->flags & COF_HIDDEN)
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
1212 return OK;
189
257af0ed5852 When a bullet hits a tank or wall, it shows a bang animation.
Thinker K.F. Li <thinker@branda.to>
parents: 186
diff changeset
1213 #endif
160
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
1214
151
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1215 /* Make child coords dirty. */
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1216 for(child = preorder_coord_subtree(coord, coord);
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
1217 child != NULL;
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
1218 child = preorder_coord_subtree(coord, child)) {
151
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1219 if(child->flags & (COF_DIRTY | COF_HIDDEN)) {
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1220 preorder_coord_skip_subtree(child);
114
1909d53071ab Check if a coord dirty before dirty it
Thinker K.F. Li <thinker@branda.to>
parents: 104
diff changeset
1221 continue;
151
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1222 }
d11aa8fc06c7 Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents: 150
diff changeset
1223
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1224 if(coord_is_cached(child)) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1225 preorder_coord_skip_subtree(child);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1226 continue;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1227 }
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1228
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1229 add_dirty_coord(rdman, child);
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
1230 }
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1231
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1232 return OK;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1233 }
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1234
18
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1235 static int _rdman_shape_changed(redraw_man_t *rdman, shape_t *shape) {
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1236 geo_t *geo;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1237 int r;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1238
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1239 geo = shape->geo;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1240
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1241 if(geo->flags & GEF_DIRTY)
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1242 return OK;
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1243
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1244 r = add_dirty_geo(rdman, geo);
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1245 if(r == ERR)
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
1246 return ERR;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1247
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1248 return OK;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1249 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1250
18
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1251 /*! \brief Mark a shape is changed.
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1252 *
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1253 * The geo_t object of a changed shape is mark as dirty and
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1254 * put into dirty_geos list.
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1255 */
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1256 int rdman_shape_changed(redraw_man_t *rdman, shape_t *shape) {
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1257 return _rdman_shape_changed(rdman, shape);
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1258 }
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
1259
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1260 int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint) {
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1261 shnode_t *shnode;
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1262 int r;
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1263
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1264 FORPAINTMEMBERS(paint, shnode) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
1265 r = _rdman_shape_changed(rdman, shnode->shape);
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1266 if(r != OK)
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1267 return ERR;
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1268 }
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1269 return OK;
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1270 }
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
1271
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1272
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1273 /* Clean dirties */
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1274
57
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1275 static int is_coord_subtree_hidden(coord_t *coord) {
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1276 while(coord) {
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1277 if(coord->flags & COF_HIDDEN)
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1278 return 1;
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1279 coord = coord->parent;
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1280 }
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1281 return 0;
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1282 }
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1283
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1284 static void clean_shape(shape_t *shape) {
196
c234ee745ceb Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents: 194
diff changeset
1285 switch(MBO_TYPE(shape)) {
c234ee745ceb Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents: 194
diff changeset
1286 case MBO_PATH:
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1287 sh_path_transform(shape);
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1288 break;
435
2bdd4f5dd2ca Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents: 430
diff changeset
1289 #ifdef SH_TEXT
196
c234ee745ceb Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents: 194
diff changeset
1290 case MBO_TEXT:
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1291 sh_text_transform(shape);
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1292 break;
435
2bdd4f5dd2ca Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents: 430
diff changeset
1293 #endif
196
c234ee745ceb Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents: 194
diff changeset
1294 case MBO_RECT:
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
1295 sh_rect_transform(shape);
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
1296 break;
260
29acbd8a0dd0 Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents: 257
diff changeset
1297 case MBO_IMAGE:
29acbd8a0dd0 Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents: 257
diff changeset
1298 sh_image_transform(shape);
29acbd8a0dd0 Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents: 257
diff changeset
1299 break;
435
2bdd4f5dd2ca Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents: 430
diff changeset
1300 #ifdef SH_STEXT
424
585baa462778 Make sh_stext_transform() pass first test case for him.
Thinker K.F. Li <thinker@branda.to>
parents: 408
diff changeset
1301 case MBO_STEXT:
430
bec538d361e9 Fix typo in redraw_man.c when adding sh_stext object type.
Thinker K.F. Li <thinker@branda.to>
parents: 427
diff changeset
1302 sh_stext_transform(shape);
424
585baa462778 Make sh_stext_transform() pass first test case for him.
Thinker K.F. Li <thinker@branda.to>
parents: 408
diff changeset
1303 break;
435
2bdd4f5dd2ca Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents: 430
diff changeset
1304 #endif
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1305 #ifdef UNITTEST
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1306 default:
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1307 sh_dummy_transform(shape);
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1308 break;
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1309 #endif /* UNITTEST */
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1310 }
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1311 shape->geo->flags &= ~GEF_DIRTY;
57
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1312
747
d2f2ed27b84d Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents: 541
diff changeset
1313 if(sh_get_flags(shape, GEF_HIDDEN) ||
d2f2ed27b84d Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents: 541
diff changeset
1314 is_coord_subtree_hidden(shape->coord))
d2f2ed27b84d Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents: 541
diff changeset
1315 sh_set_flags(shape, GEF_NOT_SHOWED);
57
ab028c9f0930 Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents: 38
diff changeset
1316 else
747
d2f2ed27b84d Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents: 541
diff changeset
1317 sh_clear_flags(shape, GEF_NOT_SHOWED);
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1318 }
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1319
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1320 /*! \brief Setup canvas_info for the coord.
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1321 *
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1322 * Own a canvas or inherit it from parent.
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1323 * \sa
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1324 * - \ref redraw
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1325 */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1326 static void setup_canvas_info(redraw_man_t *rdman, coord_t *coord) {
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1327 if(coord->parent == NULL)
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1328 return;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1329
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
1330 if(coord->opacity != 1 || coord_is_always_cached(coord)) {
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1331 if(!coord_is_cached(coord)) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1332 /* canvas is assigned latter, in zeroing_coord() */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1333 coord->canvas_info = coord_canvas_info_new(rdman, coord, NULL);
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1334 coord_set_flags(coord, COF_OWN_CANVAS);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1335 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1336 } else {
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1337 if(coord_is_cached(coord)) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1338 canvas_free(_coord_get_canvas(coord));
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1339 coord_canvas_info_free(rdman, coord->canvas_info);
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1340 coord_clear_flags(coord, COF_OWN_CANVAS);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1341 }
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1342 /* This must here to keep coords that do not own canvas
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1343 * can always point to right canvas_info. Since, they
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1344 * don't know when will parent change it's canvas_info.
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1345 */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1346 coord->canvas_info = coord->parent->canvas_info;
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1347 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1348 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
1349
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1350 /* \brief Compute matrix from cached canvas to parent device space.
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1351 */
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1352 static void compute_cached_2_pdev_matrix(coord_t *coord) {
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1353 co_aix *canvas2pdev_matrix = coord_get_2pdev(coord);
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1354 coord_t *parent;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1355 co_aix *aggr;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1356 co_aix *matrix, *paggr;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1357 co_aix scale_x, scale_y;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1358 co_aix shift_x, shift_y;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1359 co_aix canvas2p[6];
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1360
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1361 aggr = coord_get_aggr_matrix(coord);
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1362 matrix = coord->matrix;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1363 parent = coord->parent;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1364 paggr = coord_get_aggr_matrix(parent);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1365
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1366 scale_x = matrix[0] / aggr[0];
818
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
1367 scale_y = matrix[4] / aggr[4];
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1368 shift_x = matrix[2] - scale_x * aggr[2];
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1369 shift_y = matrix[5] - scale_y * aggr[5];
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1370
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1371 canvas2p[0] = scale_x;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1372 canvas2p[1] = 0;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1373 canvas2p[2] = shift_x;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1374 canvas2p[3] = 0;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1375 canvas2p[4] = scale_y;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1376 canvas2p[5] = shift_y;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1377
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1378 matrix_mul(paggr, canvas2p, canvas2pdev_matrix);
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1379
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1380 compute_reverse(canvas2pdev_matrix, coord_get_2pdev_rev(coord));
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1381 }
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1382
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1383 /*! \brief Compute area in parent cached coord for a cached coord.
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1384 *
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1385 * The coordination system of cached coord and descendants is resized,
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1386 * and shifted. It makes all descendants bound by a box, canvas box,
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1387 * at 0, 0 and size is the same as the canvas.
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1388 *
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1389 * The bounding box where the canvas would be draw on the canvas on
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1390 * ancestral cached coord can be retreived by shifting and resizing
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1391 * canvas box in reverse and transform to coordination system of
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1392 * ancestral cached coord.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1393 */
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1394 static void compute_pcache_area(coord_t *coord) {
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1395 co_aix *cached2pdev = coord_get_2pdev(coord);
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1396 int c_w, c_h;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1397 canvas_t *canvas;
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1398 coord_canvas_info_t *canvas_info;
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1399 co_aix poses[4][2];
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1400
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1401 canvas_info = coord->canvas_info;
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1402 SWAP(canvas_info->pcache_cur_area, canvas_info->pcache_last_area,
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1403 area_t *);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1404
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1405 canvas = _coord_get_canvas(coord);
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1406 canvas_get_size(canvas, &c_w, &c_h);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1407
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1408 poses[0][0] = 0;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1409 poses[0][1] = 0;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1410 poses[1][0] = c_w;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1411 poses[1][1] = c_h;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1412 poses[2][0] = 0;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1413 poses[2][1] = c_h;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1414 poses[3][0] = c_w;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1415 poses[3][1] = 0;
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1416 matrix_trans_pos(cached2pdev, &poses[0][0], &poses[0][1]);
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1417 matrix_trans_pos(cached2pdev, &poses[1][0], &poses[1][1]);
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1418 matrix_trans_pos(cached2pdev, &poses[2][0], &poses[2][1]);
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1419 matrix_trans_pos(cached2pdev, &poses[3][0], &poses[3][1]);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1420
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1421 area_init(coord_get_pcache_area(coord), 4, poses);
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1422
834
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
1423 coord_clear_flags(coord, COF_DIRTY_PCACHE_AREA);
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1424 }
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1425
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1426 /*! \brief Compute area of a coord.
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1427 */
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1428 static int
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1429 compute_area(coord_t *coord) {
864
6eaeec6806f2 Fix the issue of potential to free a wild pointer
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1430 static co_aix (*poses)[2] = NULL;
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1431 static int max_poses = 0;
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1432 geo_t *geo;
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1433 int cnt, pos_cnt;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1434
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1435 cnt = 0;
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1436 FORMEMBERS(coord, geo) {
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1437 cnt++;
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1438 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1439
147
995ee8fd5f1a Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents: 146
diff changeset
1440 if(max_poses < (cnt * 2)) {
864
6eaeec6806f2 Fix the issue of potential to free a wild pointer
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1441 if(poses)
6eaeec6806f2 Fix the issue of potential to free a wild pointer
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1442 free(poses);
147
995ee8fd5f1a Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents: 146
diff changeset
1443 max_poses = cnt * 2;
995ee8fd5f1a Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents: 146
diff changeset
1444 poses = (co_aix (*)[2])malloc(sizeof(co_aix [2]) * max_poses);
995ee8fd5f1a Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents: 146
diff changeset
1445 if(poses == NULL)
995ee8fd5f1a Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents: 146
diff changeset
1446 return ERR;
995ee8fd5f1a Use local static variable to hold position array to reduce using malloc().
Thinker K.F. Li <thinker@branda.to>
parents: 146
diff changeset
1447 }
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1448
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1449 pos_cnt = 0;
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
1450 FORMEMBERS(coord, geo) {
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1451 area_to_positions(geo->cur_area, poses + pos_cnt);
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1452 pos_cnt += 2;
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1453 }
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1454
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1455 area_init(coord_get_area(coord), pos_cnt, poses);
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1456
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1457 return OK;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1458 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1459
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1460 static int coord_clean_members_n_compute_area(coord_t *coord) {
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1461 geo_t *geo;
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1462 int r;
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1463 /*! \note poses is shared by invokings, it is not support reentrying. */
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1464
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1465 /* Clean member shapes. */
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1466 FORMEMBERS(coord, geo) {
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1467 clean_shape(geo->shape);
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1468 }
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1469
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1470 r = compute_area(coord);
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1471 if(r != OK)
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1472 return ERR;
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1473
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1474 return OK;
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1475 }
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1476
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1477 /*! \brief Clean dirty coords.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1478 *
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1479 * This function compute aggregation matrix and area for dirty
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1480 * coords. But, aggregation matrix of a cached coord is different from
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1481 * normal one. (see compute_aggr_of_cached_coord()).
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1482 *
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1483 * \note coords their opacity != 1 are also traded as cached ones.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1484 */
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1485 static int clean_coord(redraw_man_t *rdman, coord_t *coord) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1486 int r;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1487
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1488 setup_canvas_info(rdman, coord);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1489
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1490 compute_aggr(coord);
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1491
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1492 /* Areas of cached coords are computed in two phase.
534
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
1493 * Phase 1 works like other normal ones. Phase 2, collects
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1494 * all areas of descendants to compute a minimum covering area.
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1495 * Phase 2 is performed by zeroing_coord().
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1496 */
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1497 r = coord_clean_members_n_compute_area(coord);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1498 if(r != OK)
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1499 return ERR;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1500
835
51da337879bd Do not add dirty area for cached coords
Thinker K.F. Li <thinker@codemud.net>
parents: 834
diff changeset
1501 /* Dirty areas of cached one is added after update pcache_areas.
51da337879bd Do not add dirty area for cached coords
Thinker K.F. Li <thinker@codemud.net>
parents: 834
diff changeset
1502 */
839
a3be0162bf44 Move decision of dirty pcache_area to one place.
Thinker K.F. Li <thinker@codemud.net>
parents: 837
diff changeset
1503 add_dirty_area(rdman, coord, coord->cur_area);
a3be0162bf44 Move decision of dirty pcache_area to one place.
Thinker K.F. Li <thinker@codemud.net>
parents: 837
diff changeset
1504 add_dirty_area(rdman, coord, coord->last_area);
a3be0162bf44 Move decision of dirty pcache_area to one place.
Thinker K.F. Li <thinker@codemud.net>
parents: 837
diff changeset
1505
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1506 coord_clear_flags(coord, COF_DIRTY);
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1507 coord_set_flags(coord, COF_JUST_CLEAN);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1508
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1509 return OK;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1510 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1511
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1512 /*! \brief Clean coord_t objects.
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1513 *
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1514 * It computes aggregation matrix and area for dirty coords.
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1515 *
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1516 * This function also responsible for computing area of parent cached
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1517 * coord, coord_canvas_info_t::pcache_cur_area, for its cached children.
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1518 */
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1519 static int clean_rdman_coords(redraw_man_t *rdman) {
769
7c73fbc8d700 Remove unused local variables
Thinker K.F. Li <thinker@codemud.net>
parents: 747
diff changeset
1520 coord_t *coord;
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1521 coord_t **dirty_coords;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1522 int n_dirty_coords;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1523 int i, r;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1524
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1525 n_dirty_coords = rdman->dirty_coords.num;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1526 if(n_dirty_coords > 0) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1527 dirty_coords = rdman->dirty_coords.ds;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1528 _insert_sort((void **)dirty_coords, n_dirty_coords,
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1529 OFFSET(coord_t, order)); /* ascend order */
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1530 for(i = 0; i < n_dirty_coords; i++) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1531 coord = dirty_coords[i];
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1532 if(!coord_get_flags(coord, COF_DIRTY | COF_JUST_CLEAN))
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1533 continue;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1534 r = clean_coord(rdman, coord);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1535 if(r != OK)
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1536 return ERR;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1537 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1538 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1539 return OK;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1540 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1541
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1542 static int clean_rdman_geos(redraw_man_t *rdman) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1543 int i;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1544 int n_dirty_geos;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1545 geo_t **dirty_geos;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1546 geo_t *visit_geo;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1547 coord_t *coord;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1548
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1549 n_dirty_geos = rdman->dirty_geos.num;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1550 if(n_dirty_geos > 0) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1551 dirty_geos = rdman->dirty_geos.ds;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1552 for(i = 0; i < n_dirty_geos; i++) {
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1553 visit_geo = dirty_geos[i];
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1554 if(!(visit_geo->flags & GEF_DIRTY))
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1555 continue;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1556
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1557 clean_shape(visit_geo->shape);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1558 coord = geo_get_coord(visit_geo);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1559 add_dirty_area(rdman, coord, visit_geo->cur_area);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1560 add_dirty_area(rdman, coord, visit_geo->last_area);
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1561 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1562 }
327
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1563
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1564 return OK;
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1565 }
85b8bb36fe71 Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents: 322
diff changeset
1566
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1567 /*! \brief Shift space of coord to align left-top of minimum covering.
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1568 *
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1569 * Align left-top of minimum rectangle covering occupied area of
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1570 * sub-graphic to origin of the space.
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1571 */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1572 static
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1573 void zeroing_coord(redraw_man_t *rdman, coord_t *coord) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1574 coord_t *cur;
769
7c73fbc8d700 Remove unused local variables
Thinker K.F. Li <thinker@codemud.net>
parents: 747
diff changeset
1575 area_t *area;
541
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
1576 geo_t *geo;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1577 co_aix min_x, min_y;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1578 co_aix max_x, max_y;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1579 co_aix x, y;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1580 int w, h;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1581 int c_w, c_h;
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
1582 mbe_t *canvas;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1583 co_aix *aggr;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1584
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1585 if(coord->parent == NULL) /*! \note Should not zeroing root coord */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1586 abort();
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1587 if(!(coord_is_zeroing(coord)))
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1588 abort();
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1589
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1590 coord_clear_zeroing(coord);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1591
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1592 /*
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1593 * Compute minimum overing area of sub-graphic
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1594 */
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1595 area = coord_get_area(coord);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1596 min_x = area->x;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1597 min_y = area->y;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1598 max_x = min_x + area->w;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1599 max_y = min_y + area->h;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1600
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
1601 for(cur = preorder_coord_subtree(coord, coord);
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
1602 cur != NULL;
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
1603 cur = preorder_coord_subtree(coord, cur)) {
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1604 if(coord_is_cached(cur)) {
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1605 preorder_coord_skip_subtree(cur);
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1606 /* This means pcache_area of descendants must be computed
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1607 * before zeroing ancestor cached one.
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1608 * (See add_rdman_zeroing_n_pcache_coords())
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1609 */
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1610 area = coord_get_pcache_area(cur);
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1611 } else
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1612 area = coord_get_area(cur);
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1613
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1614 if(area->w == 0 && area->h == 0)
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1615 continue;
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1616
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1617 if(min_x == max_x && min_y == max_y) {
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1618 min_x = area->x;
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1619 max_x = area->x + area->w;
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1620 min_y = area->y;
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1621 max_y = area->y + area->h;
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1622 continue;
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
1623 }
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1624
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1625 if(area->x < min_x)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1626 min_x = area->x;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1627 if(area->y < min_y)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1628 min_y = area->y;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1629
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1630 x = area->x + area->w;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1631 y = area->y + area->h;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1632
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1633 if(x > max_x)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1634 max_x = x;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1635 if(y > max_y)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1636 max_y = y;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1637 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1638
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1639 w = max_x - min_x;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1640 h = max_y - min_y;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1641
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1642 canvas = _coord_get_canvas(coord);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1643 if(canvas)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1644 canvas_get_size(canvas, &c_w, &c_h);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1645 else
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1646 c_w = c_h = 0;
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1647
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1648 /* Without COF_JUST_CLEAN means the coordination system and matrix
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1649 * of the coord have not changed since last time of zeroing. So,
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1650 * if canvas box cover all descendants, we don't need rezeroing,
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1651 * and avoid redraw all descendants.
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1652 *
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1653 * Width and height of actually drawing area should not be smaller
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1654 * than half of canvas's width and height.
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1655 */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1656 if(!coord_get_flags(coord, COF_JUST_CLEAN) &&
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1657 min_x >= 0 && min_y >= 0 && max_x <= c_w && max_y <= c_h &&
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1658 h >= (c_h >> 2) && w >= (c_w >> 2)) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1659 /* Canvas fully cover sub-graphic. */
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1660 coord_set_flags(coord, COF_SKIP_ZERO);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1661 return;
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1662 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1663
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1664 /*
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1665 * Adjust matrics of descendants to align left-top corner of
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1666 * minimum covering area with origin of space defined by
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1667 * zeroing coord.
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1668 */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1669 FOR_COORDS_PREORDER(coord, cur) {
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1670 if(coord_is_cached(cur) && coord != cur) {
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1671 /*
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1672 * Cached coords are zeroed from root to leaves, so
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1673 * changes of aggr_matrix would be propagated to next
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1674 * level of cached.
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1675 */
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1676 preorder_coord_skip_subtree(cur);
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1677 }
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1678 /* Shift space */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1679 aggr = coord_get_aggr_matrix(cur);
818
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
1680 aggr[2] -= min_x;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1681 aggr[5] -= min_y;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1682
541
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
1683 FOR_COORD_MEMBERS(coord, geo) {
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
1684 /* \see GEO_SWAP() */
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
1685 if(!geo_get_flags(geo, GEF_SWAP))
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
1686 SWAP(geo->cur_area, geo->last_area, area_t *);
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
1687 }
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1688 coord_clean_members_n_compute_area(cur);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1689 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1690
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1691 /*
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1692 * Setup canvas
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1693 *
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1694 * Canvas of a cached coord is not setted in
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1695 * coord_canvas_info_new(). It should be setted, here.
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1696 */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1697 if(canvas == NULL || w > c_w || h > c_w) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1698 if(canvas)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1699 canvas_free(canvas);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1700 canvas = canvas_new(w, h);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1701 _coord_set_canvas(coord, canvas);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1702 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1703
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
1704 coord_set_flags(coord, COF_JUST_ZERO);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1705 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1706
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1707 /*! \brief Add coords that need to perform zeroing or re-compute pcache_area.
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1708 *
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1709 * A coord that need to perform zeroing has one or more dirty members
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1710 * in its descendants.
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1711 *
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1712 * To zeroing a coord, pcache_area of first level cached descendants
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1713 * must be updated. To update the pcache_area of a cached coord, the
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1714 * cached coord also need to perform zeroing. So, zeroing and
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1715 * re-computing pcache_area are interleaved.
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1716 *
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1717 * The pcache_area of a cached coord must be re-computed if its
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1718 * parent/ancestors is dirty/just cleaned, or it must be zeroed. It
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1719 * means cached coord with jsut cleaned parent should also re-compute
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1720 * pcache_area. So, this function also check and add coords for this
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1721 * situation.
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1722 */
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1723 static int add_rdman_zeroing_n_pcache_coords(redraw_man_t *rdman) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1724 int i;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1725 int n_dirty_geos;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1726 geo_t **dirty_geos, *geo;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1727 int n_dirty_coords;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1728 coord_t **dirty_coords, *coord;
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1729 coord_t *parent_coord;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1730
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1731 /* Mark all cached ancestral coords of dirty geos */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1732 n_dirty_geos = rdman->dirty_geos.num;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1733 dirty_geos = rdman->dirty_geos.ds;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1734 for(i = 0; i < n_dirty_geos; i++) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1735 geo = dirty_geos[i];
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1736 coord = coord_get_cached(geo_get_coord(geo));
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1737 while(!coord_get_flags(coord, COF_MUST_ZEROING | COF_TEMP_MARK)) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1738 if(coord_is_root(coord))
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1739 break;
525
f9326e955417 Does not add root coord to zeroing list
Thinker K.F. Li <thinker@branda.to>
parents: 524
diff changeset
1740 coord_set_flags(coord, COF_TEMP_MARK);
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1741 coord = coord_get_cached(coord_get_parent(coord));
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1742 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1743 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1744
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1745 /* Mark all cached ancestral coords of dirty coords */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1746 n_dirty_coords = rdman->dirty_coords.num;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1747 dirty_coords = rdman->dirty_coords.ds;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1748 for(i = 0; i < n_dirty_coords; i++) {
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1749 coord = coord_get_cached(dirty_coords[i]);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1750 while(!coord_get_flags(coord, COF_MUST_ZEROING | COF_TEMP_MARK)) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1751 if(coord_is_root(coord))
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1752 break;
525
f9326e955417 Does not add root coord to zeroing list
Thinker K.F. Li <thinker@branda.to>
parents: 524
diff changeset
1753 coord_set_flags(coord, COF_TEMP_MARK);
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1754 coord = coord_get_cached(coord_get_parent(coord));
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1755 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1756 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1757
519
7a1b17ebb3b4 Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents: 512
diff changeset
1758 /* Add all marked coords into redraw_man_t::zeroing_coords list */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1759 FOR_COORDS_PREORDER(rdman->root_coord, coord) {
811
5aca6024b147 subtree of root coord can not be skept
Thinker K.F. Li <thinker@codemud.net>
parents: 771
diff changeset
1760 if(!coord_is_cached(coord) || coord_is_root(coord))
520
f106b57b8660 Skip coords that is not cached when add coords into zeroing_coords list.
Thinker K.F. Li <thinker@branda.to>
parents: 519
diff changeset
1761 continue; /* skip coords that is not cached */
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1762
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1763 if(!coord_get_flags(coord, COF_TEMP_MARK)) {
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1764 parent_coord = coord_get_parent(coord);
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1765 /* The pcache_area of a cached coord that is a child of a
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1766 * just cleaned one must be recomputed.
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1767 */
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1768 if(coord_get_flags(parent_coord, COF_JUST_CLEAN))
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1769 add_dirty_pcache_area_coord(rdman, coord);
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1770
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1771 preorder_coord_skip_subtree(coord);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1772 continue;
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
1773 }
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1774 add_zeroing_coord(rdman, coord);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1775
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1776 coord_clear_flags(coord, COF_TEMP_MARK);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1777 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1778
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1779 return OK;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1780 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1781
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1782 /*! \brief Zeroing coords in redraw_man_t::zeroing_coords.
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1783 *
538
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1784 * \note redraw_man_t::zeroing_coords must in descent partial order of
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1785 * tree. The size of a cached coord is effected by cached
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1786 * descendants.
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1787 */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1788 static int zeroing_rdman_coords(redraw_man_t *rdman) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1789 int i;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1790 coords_t *all_zeroing;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1791 coord_t *coord;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1792
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1793 all_zeroing = &rdman->zeroing_coords;
538
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1794 /*! Zeroing is performed from leaves to root.
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1795 *
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1796 * REASON: The size of canvas is also effected by cached
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1797 * descedants. A cached coord is only effected by parent
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1798 * cached coord when it-self is dirty. When a cached
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1799 * coord is dirty, it is clean (compute aggregated matrix)
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1800 * by recomputing a scale for x and y-axis from aggregated
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1801 * matrix of parent coord. And, cleaning coord is
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1802 * performed before zeroing. It means ancestors of a
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
1803 * cached coord would not effect it when zeroing.
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1804 */
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1805 for(i = all_zeroing->num - 1; i >= 0; i--) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1806 coord = all_zeroing->ds[i];
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1807 if(coord_is_zeroing(coord))
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1808 zeroing_coord(rdman, coord);
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1809 compute_cached_2_pdev_matrix(coord);
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1810 /* This is required by ancester cached ones to perform
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1811 * zeroing.
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1812 */
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1813 compute_pcache_area(coord);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1814 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1815
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1816 return OK;
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1817 }
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1818
851
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1819 /*! \brief Update aggregated cache_2_pdev matrix for cached coords.
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1820 *
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1821 * This is perfromed from root to leaves. Aggregated cache_2_pdev is
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1822 * named as aggr_2_pdev field of canvas_info_t. It is the matrix to
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1823 * transform a point from space of a cached coord to the space of root
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1824 * coord.
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1825 */
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1826 static int
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1827 update_aggr_pdev(redraw_man_t *rdman) {
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1828 int i;
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1829 coords_t *all_zeroing;
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1830 coord_t *coord, *parent_cached;
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1831
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1832 all_zeroing = &rdman->zeroing_coords;
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1833 for(i = 0; i < all_zeroing->num; i++) {
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1834 coord = all_zeroing->ds[i];
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1835 parent_cached = coord_get_cached(coord_get_parent(coord));
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1836 matrix_mul(coord_get_2pdev(parent_cached),
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1837 coord_get_2pdev(coord),
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1838 coord_get_aggr2pdev(coord));
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1839 matrix_mul(coord_get_2pdev_rev(coord),
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1840 coord_get_2pdev_rev(parent_cached),
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1841 coord_get_aggr2pdev_rev(coord));
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1842 }
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1843
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1844 return OK;
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1845 }
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
1846
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1847 /*! \brief Add aggregated dirty areas to ancestor.
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1848 *
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1849 * Dirty areas are aggregated into two areas. It assumes that even or odd
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1850 * ones are old areas or new areas repsective. So, all even ones are
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1851 * aggregated in an area, and odd ones are in another.
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1852 */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1853 static void add_aggr_dirty_areas_to_ancestor(redraw_man_t *rdman,
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1854 coord_t *coord) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1855 int i;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1856 int n_areas;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1857 co_aix poses0[2][2], poses1[2][2];
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1858 co_aix *canvas2pdev_matrix;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1859 area_t **areas, *area;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1860 area_t *area0, *area1;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1861 coord_t *parent, *pcached_coord;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1862
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1863 n_areas = _coord_get_dirty_areas(coord)->num;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1864 areas = _coord_get_dirty_areas(coord)->ds;
935
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1865 if(n_areas == 0) {
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1866 /* Go here for cached one that is descendant of another zeroed
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1867 * one, but itself is not zeroed. It is here for recomputing
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1868 * pcache areas.
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1869 */
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1870 if(coord_get_flags(coord, COF_JUST_CLEAN | COF_JUST_ZERO))
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1871 abort(); /* should not happen! */
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1872
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1873 parent = coord_get_parent(coord);
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1874 pcached_coord = coord_get_cached(parent);
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1875 area = coord_get_pcache_area(coord);
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1876 add_dirty_area(rdman, pcached_coord, area);
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1877 area = coord_get_pcache_last_area(coord);
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1878 add_dirty_area(rdman, pcached_coord, area);
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1879 return;
960e2395973d Fix the bug of crash by abort() when running testsvg.js.
Thinker K.F. Li <thinker@codemud.net>
parents: 887
diff changeset
1880 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1881
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1882 area0 = _coord_get_aggr_dirty_areas(coord);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1883 area1 = area0 + 1;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1884
532
5711059b9642 Add todo
Thinker K.F. Li <thinker@branda.to>
parents: 531
diff changeset
1885 /* TODO: Since both cur & last area of coords are added into dirty
5711059b9642 Add todo
Thinker K.F. Li <thinker@branda.to>
parents: 531
diff changeset
1886 * area list, position of both areas shoud be adjusted for
5711059b9642 Add todo
Thinker K.F. Li <thinker@branda.to>
parents: 531
diff changeset
1887 * all descendants when zeroing a cached coord.
5711059b9642 Add todo
Thinker K.F. Li <thinker@branda.to>
parents: 531
diff changeset
1888 */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1889 for(i = 0; i < n_areas; i++) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1890 area = areas[i];
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1891 if(area->w != 0 || area->h != 0)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1892 break;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1893 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1894
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1895 if(i >= n_areas)
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1896 return;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1897
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1898 area = areas[i++];
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1899 poses0[0][0] = area->x;
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1900 poses0[0][1] = area->y;
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1901 poses0[1][0] = area->x + area->w;
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1902 poses0[1][1] = area->y + area->h;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1903
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1904 if(i < n_areas) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1905 area = areas[i++];
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1906 poses1[0][0] = area->x;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1907 poses1[0][1] = area->y;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1908 poses1[1][0] = area->x + area->w;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1909 poses1[1][1] = area->y + area->h;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1910 } else {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1911 poses1[0][0] = 0;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1912 poses1[0][1] = 0;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1913 poses1[1][0] = 0;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1914 poses1[1][1] = 0;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1915 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1916
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1917 for(; i < n_areas - 1;) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1918 /* Even areas */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1919 area = areas[i++];
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1920 if(area->w != 0 || area->h != 0) {
375
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1921 poses0[0][0] = MB_MIN(poses0[0][0], area->x);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1922 poses0[0][1] = MB_MIN(poses0[0][1], area->y);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1923 poses0[1][0] = MB_MAX(poses0[1][0], area->x + area->w);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1924 poses0[1][1] = MB_MAX(poses0[1][1], area->y + area->h);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1925 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1926 /* Odd areas */
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1927 area = areas[i++];
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1928 if(area->w != 0 || area->h != 0) {
375
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1929 poses1[0][0] = MB_MIN(poses1[0][0], area->x);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1930 poses1[0][1] = MB_MIN(poses1[0][1], area->y);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1931 poses1[1][0] = MB_MAX(poses1[1][0], area->x + area->w);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1932 poses1[1][1] = MB_MAX(poses1[1][1], area->y + area->h);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1933 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1934 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1935
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1936 if(i < n_areas) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1937 area = areas[i];
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1938 if(area->w != 0 || area->h != 0) {
375
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1939 poses0[0][0] = MB_MIN(poses0[0][0], area->x);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1940 poses0[0][1] = MB_MIN(poses0[0][1], area->y);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1941 poses0[1][0] = MB_MAX(poses0[1][0], area->x + area->w);
44b8223f307c Rename MIN/MAX to MB_MIN/MB_MAX.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
1942 poses0[1][1] = MB_MAX(poses0[1][1], area->y + area->h);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1943 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1944 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1945
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1946 parent = coord_get_parent(coord);
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1947 pcached_coord = coord_get_cached(parent);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1948
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
1949 canvas2pdev_matrix = coord_get_2pdev(coord);
532
5711059b9642 Add todo
Thinker K.F. Li <thinker@branda.to>
parents: 531
diff changeset
1950
5711059b9642 Add todo
Thinker K.F. Li <thinker@branda.to>
parents: 531
diff changeset
1951 /* Add dirty areas to parent cached coord. */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1952 matrix_trans_pos(canvas2pdev_matrix, poses0[0], poses0[0] + 1);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1953 matrix_trans_pos(canvas2pdev_matrix, poses0[1], poses0[1] + 1);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1954 area_init(area0, 2, poses0);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1955 add_dirty_area(rdman, pcached_coord, area0);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
1956
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1957 matrix_trans_pos(canvas2pdev_matrix, poses1[0], poses1[0] + 1);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1958 matrix_trans_pos(canvas2pdev_matrix, poses1[1], poses1[1] + 1);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1959 area_init(area1, 2, poses1);
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
1960 add_dirty_area(rdman, pcached_coord, area1);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1961
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1962 if(coord_get_flags(coord, COF_JUST_CLEAN) &&
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1963 !coord_get_flags(pcached_coord, COF_JUST_CLEAN))
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1964 add_dirty_area(rdman, pcached_coord, coord->last_area);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1965 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1966
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1967 /*! \brief To test if redrawing all elements on the canvas of a cached coord.
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1968 */
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1969 #define IS_CACHE_REDRAW_ALL(co) \
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1970 (coord_get_flags((co), COF_JUST_CLEAN | COF_JUST_ZERO))
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1971
526
3f695a6177b2 Change typos in comment
Thinker K.F. Li <thinker@branda.to>
parents: 525
diff changeset
1972 /* Aggregate dirty areas and propagate them to ancestor cached coord.
521
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1973 *
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1974 * The aggregation is performed from leaves to root. But, this
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1975 * function do not aggregate dirty areas for root coord. The dirty
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1976 * areas of a cached coord are aggregated into two areas, one for old
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1977 * areas and one or new areas. Both aggregation areas are add into
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1978 * dirty_areas list of closet ancestral cached coord.
fa2ccf39ba53 imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents: 520
diff changeset
1979 */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1980 static int add_rdman_aggr_dirty_areas(redraw_man_t *rdman) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1981 int i;
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1982 coord_t *coord, *parent_coord, *pcached_coord;
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1983 int n_zeroing_coords; /* number of dirty pcache area coords */
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1984 coord_t **zeroing_coords; /* dirty pcache area coords */
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1985
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1986 n_zeroing_coords = rdman->zeroing_coords.num;
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1987 zeroing_coords = rdman->zeroing_coords.ds;
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1988 for(i = n_zeroing_coords - 1; i >= 0; i--) {
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1989 coord = zeroing_coords[i];
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1990 if(IS_CACHE_REDRAW_ALL(coord)) {
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1991 parent_coord = coord_get_parent(coord);
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1992 pcached_coord = coord_get_cached(parent_coord);
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
1993
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1994 add_dirty_area(rdman, pcached_coord,
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1995 coord_get_pcache_area(coord));
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1996 add_dirty_area(rdman, pcached_coord,
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1997 coord_get_pcache_last_area(coord));
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
1998 } else {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
1999 add_aggr_dirty_areas_to_ancestor(rdman, coord);
537
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
2000 }
3a7e3c1cd6e6 [mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents: 536
diff changeset
2001 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2002
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2003 return OK;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2004 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2005
541
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2006 /*! \brief Swap geo_t::cur_area and geo_t::last_area for a geo_t.
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2007 *
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2008 * It is call by rdman_clean_dirties() to swap areas for members of
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2009 * dirty coord in redraw_man_t::dirty_coords and dirty geos in
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2010 * redraw_man_t::dirty_geos.
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2011 *
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2012 * zeroing_coord() would also swap some areas for members of
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2013 * descendants of a cached coord. But, only members that was not
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2014 * swapped, without GEF_SWAP flag, in this round of redrawing.
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2015 * zeroing_coord() would not mark geos with GEF_SWAP since it not not
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2016 * referenced later. We don't mark geos in zeroing_coord() because we
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2017 * don't want to unmark it later. To unmark it, we should re-travel
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2018 * forest of cached coords in redraw_man_t::zeroing_coords. It is
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2019 * expansive.
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2020 */
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2021 #define GEO_SWAP(g) \
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2022 if(!geo_get_flags((g), GEF_SWAP)) { \
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2023 SWAP((g)->cur_area, (g)->last_area, area_t *); \
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2024 geo_set_flags((g), GEF_SWAP); \
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2025 }
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2026
534
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2027 /* \brief Clean dirty coords and shapes.
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2028 *
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2029 * The procedure of clean dirty coords and shapes include 3 major steps.
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2030 *
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2031 * - Add dirty coords and shapes to rdman.
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2032 * - All descendants of a dirty coord are also dirty, except
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2033 * descendants of cached descendants.
534
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2034 * - Recompute aggregated transformation matrix from root to leaves
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2035 * for dirty coords.
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2036 * - The aggregated transformation matrix for a cached coord is
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2037 * different from other coords.
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2038 * - Compute new area for every dirty coord.
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2039 * - Area of a dirty coord is an aggregation of areas of all members.
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2040 * - A cached coord has two type of areas, one is for members of the cached
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2041 * coord, another one is for the block that cached coord and descendants
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2042 * will be mapped in parent cached coord.
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2043 * - Areas, for parent cached coord (pcache_cur_area), of
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2044 * non-dirty cached coord would be recomputed when cleaning
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2045 * parent coord.
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2046 * - Areas, for parent cached coord (pcache_cur_area), of dirty
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2047 * cached coord would be recomputed when zeroing the cached
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2048 * coord. (because zeroing would change aggregated matrix, and
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2049 * zeroing was performed after cleaning)
534
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2050 * - Areas, for members, of dirty cached coord would only be
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2051 * recomputed when cleaning the coord.
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2052 * - Perform zeroing on some cached coords that
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2053 * - dirty, is,
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2054 * - dirty descendants, has.
534
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2055 * - Propagate dirty areas to dirty area list of parent cached coord
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2056 * for every cached coords, not only for dirty cached coords.
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2057 *
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2058 * The cur_area of a cached coord is where members of the coord will
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2059 * be draw in cache buffer, i.e. surface. The area of the cached
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2060 * coord and descendants is described by pcache_cur_area and
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2061 * pcache_last_area in coord_canvas_info_t.
534
9f2d07a60493 Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents: 532
diff changeset
2062 */
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2063 static int rdman_clean_dirties(redraw_man_t *rdman) {
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2064 int r;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2065 int i;
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2066 coord_t **coords, *coord;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2067 geo_t **geos;
541
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2068 geo_t *geo;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2069
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2070 /* coord_t::cur_area of coords are temporary pointed to
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2071 * coord_canvas_info_t::owner_mems_area for store area
526
3f695a6177b2 Change typos in comment
Thinker K.F. Li <thinker@branda.to>
parents: 525
diff changeset
2072 * by clean_coord().
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2073 */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2074 coords = rdman->dirty_coords.ds;
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2075 for(i = 0; i < rdman->dirty_coords.num; i++) {
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2076 coord = coords[i];
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2077 SWAP(coord->cur_area, coord->last_area, area_t *);
541
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2078 FOR_COORD_MEMBERS(coord, geo) {
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2079 GEO_SWAP(geo);
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2080 }
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2081 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2082
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2083 /* XXX: some geo may swap two times. Should avoid it.
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2084 */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2085 geos = rdman->dirty_geos.ds;
541
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2086 for(i = 0; i < rdman->dirty_geos.num; i++) {
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2087 geo = geos[i];
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2088 GEO_SWAP(geo);
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2089 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2090
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2091 r = clean_rdman_coords(rdman);
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2092 if(r != OK)
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2093 return ERR;
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2094
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2095 /* TODO: save area of cached coord and descendants in
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2096 * cached_dirty_area for parent cached coord space.
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2097 */
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2098
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2099 r = clean_rdman_geos(rdman);
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2100 if(r != OK)
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2101 return ERR;
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2102
531
1ad6c6192a80 Skip root coord when propagate dirty area to parent cached
Thinker K.F. Li <thinker@branda.to>
parents: 530
diff changeset
2103 /* Zeroing must be performed after clearing to get latest position
1ad6c6192a80 Skip root coord when propagate dirty area to parent cached
Thinker K.F. Li <thinker@branda.to>
parents: 530
diff changeset
2104 * of shapes for computing new bounding box
1ad6c6192a80 Skip root coord when propagate dirty area to parent cached
Thinker K.F. Li <thinker@branda.to>
parents: 530
diff changeset
2105 */
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
2106 r = add_rdman_zeroing_n_pcache_coords(rdman);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2107 if(r != OK)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2108 return ERR;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2109
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2110 r = zeroing_rdman_coords(rdman);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2111 if(r != OK)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2112 return ERR;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2113
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2114 r = add_rdman_aggr_dirty_areas(rdman);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2115 if(r != OK)
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2116 return ERR;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2117
851
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
2118 r = update_aggr_pdev(rdman);
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
2119 if(r != OK)
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
2120 return ERR;
85f22a771e4a Compute aggregated cache_2_pdev and reversed one
Thinker K.F. Li <thinker@codemud.net>
parents: 850
diff changeset
2121
538
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2122 /*
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2123 * Clear all flags setted by zeroing.
538
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2124 */
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2125 coords = rdman->dirty_coords.ds;
541
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2126 for(i = 0; i < rdman->dirty_coords.num; i++) {
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2127 coord = coords[i];
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2128 coord_clear_flags(coord, COF_JUST_CLEAN);
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2129 /* \see GEO_SWAP() */
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2130 FOR_COORD_MEMBERS(coord, geo) {
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2131 geo_clear_flags(geo, GEF_SWAP);
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2132 }
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2133 }
538
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2134 coords = rdman->zeroing_coords.ds;
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2135 for(i = 0; i < rdman->zeroing_coords.num; i++)
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2136 coord_clear_flags(coords[i],
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2137 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO);
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
2138
541
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2139 /* \see GEO_SWAP() */
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2140 for(i = 0; i < rdman->dirty_geos.num; i++) {
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2141 geo = geos[i];
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2142 geo_clear_flags(geo, GEF_SWAP);
f42419c08a65 Swap geo_t::cur_area and geo_t::last_area correctly.
Thinker K.F. Li <thinker@branda.to>
parents: 540
diff changeset
2143 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2144
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2145 return OK;
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2146 }
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2147
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2148
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2149 /* Drawing and Redrawing
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2150 * ============================================================
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2151 */
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
2152
26
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
2153 #ifndef UNITTEST
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2154 static void set_shape_stroke_param(shape_t *shape, mbe_t *cr) {
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2155 mbe_set_line_width(cr, shape->stroke_width);
26
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
2156 }
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2157
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2158 static void fill_path_preserve(redraw_man_t *rdman, mbe_t *cr) {
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2159 mbe_fill_preserve(cr);
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2160 }
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2161
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2162 static void fill_path(redraw_man_t *rdman, mbe_t *cr) {
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2163 mbe_fill(cr);
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2164 }
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2165
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2166 static void stroke_path(redraw_man_t *rdman, mbe_t *cr) {
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2167 mbe_stroke(cr);
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2168 }
26
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
2169 #else
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2170 static void set_shape_stroke_param(shape_t *shape, mbe_t *cr) {
26
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
2171 }
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2172
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2173 static void fill_path_preserve(redraw_man_t *rdman, mbe_t *cr) {
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2174 }
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2175
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2176 static void fill_path(redraw_man_t *rdman, mbe_t *cr) {
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2177 }
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2178
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2179 static void stroke_path(redraw_man_t *rdman, mbe_t *cr) {
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2180 }
26
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
2181 #endif
d50f33040de6 Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents: 25
diff changeset
2182
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2183 static void draw_shape(redraw_man_t *rdman, mbe_t *cr, shape_t *shape) {
22
8fcf2d878ecd shapes with stroke
Thinker K.F. Li <thinker@branda.to>
parents: 20
diff changeset
2184 paint_t *fill, *stroke;
18
0f3baa488a62 Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents: 17
diff changeset
2185
189
257af0ed5852 When a bullet hits a tank or wall, it shows a bang animation.
Thinker K.F. Li <thinker@branda.to>
parents: 186
diff changeset
2186 /*! \todo Move operator of shapes into singleton structures that define
257af0ed5852 When a bullet hits a tank or wall, it shows a bang animation.
Thinker K.F. Li <thinker@branda.to>
parents: 186
diff changeset
2187 * operators for them.
257af0ed5852 When a bullet hits a tank or wall, it shows a bang animation.
Thinker K.F. Li <thinker@branda.to>
parents: 186
diff changeset
2188 */
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2189 if(shape->fill || shape->stroke) {
196
c234ee745ceb Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents: 194
diff changeset
2190 switch(MBO_TYPE(shape)) {
c234ee745ceb Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents: 194
diff changeset
2191 case MBO_PATH:
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2192 sh_path_draw(shape, cr);
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2193 break;
435
2bdd4f5dd2ca Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents: 430
diff changeset
2194 #ifdef SH_TEXT
196
c234ee745ceb Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents: 194
diff changeset
2195 case MBO_TEXT:
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2196 sh_text_draw(shape, cr);
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 26
diff changeset
2197 break;
435
2bdd4f5dd2ca Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents: 430
diff changeset
2198 #endif
196
c234ee745ceb Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents: 194
diff changeset
2199 case MBO_RECT:
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2200 sh_rect_draw(shape, cr);
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
2201 break;
260
29acbd8a0dd0 Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents: 257
diff changeset
2202 case MBO_IMAGE:
29acbd8a0dd0 Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents: 257
diff changeset
2203 sh_image_draw(shape, cr);
29acbd8a0dd0 Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents: 257
diff changeset
2204 break;
435
2bdd4f5dd2ca Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents: 430
diff changeset
2205 #ifdef SH_STEXT
427
8f900da42eed Make sh_text_draw() passes first test case.
Thinker K.F. Li <thinker@branda.to>
parents: 424
diff changeset
2206 case MBO_STEXT:
8f900da42eed Make sh_text_draw() passes first test case.
Thinker K.F. Li <thinker@branda.to>
parents: 424
diff changeset
2207 sh_stext_draw(shape, cr);
8f900da42eed Make sh_text_draw() passes first test case.
Thinker K.F. Li <thinker@branda.to>
parents: 424
diff changeset
2208 break;
435
2bdd4f5dd2ca Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents: 430
diff changeset
2209 #endif
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2210 #ifdef UNITTEST
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2211 default:
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2212 sh_dummy_fill(shape, cr);
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2213 break;
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2214 #endif /* UNITTEST */
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2215 }
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2216
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2217 fill = shape->fill;
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2218 if(shape->fill) {
881
a17c4e231e54 Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 873
diff changeset
2219 fill->prepare(fill, cr, shape);
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2220 if(shape->stroke)
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2221 fill_path_preserve(rdman, cr);
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2222 else
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2223 fill_path(rdman, cr);
33
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2224 }
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2225
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2226 stroke = shape->stroke;
d82749f77108 Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents: 30
diff changeset
2227 if(stroke) {
881
a17c4e231e54 Transform positions of radient paints.
Thinker K.F. Li <thinker@codemud.net>
parents: 873
diff changeset
2228 stroke->prepare(stroke, cr, shape);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2229 set_shape_stroke_param(shape, cr);
841
ce6cd06adccf Fix error on area of cached coords and draw on right canvas.
Thinker K.F. Li <thinker@codemud.net>
parents: 840
diff changeset
2230 stroke_path(rdman, cr);
22
8fcf2d878ecd shapes with stroke
Thinker K.F. Li <thinker@branda.to>
parents: 20
diff changeset
2231 }
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2232 }
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2233 }
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2234
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2235 #ifndef UNITTEST
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2236 static void clear_canvas(canvas_t *canvas) {
469
4dc0be6c044a Add copy and clear graphic engine functions.
Thinker K.F. Li <thinker@branda.to>
parents: 467
diff changeset
2237 mbe_clear(canvas);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2238 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2239
1073
d09f603438d8 Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents: 1067
diff changeset
2240 #define make_scissoring(canvas, n_dirty_areas, dirty_areas) \
d09f603438d8 Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents: 1067
diff changeset
2241 mbe_scissoring(canvas, n_dirty_areas, dirty_areas)
15
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2242
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2243 static void reset_clip(canvas_t *cr) {
1073
d09f603438d8 Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents: 1067
diff changeset
2244 mbe_reset_scissoring(cr);
24
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2245 }
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2246
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2247 static void copy_cr_2_backend(redraw_man_t *rdman, int n_dirty_areas,
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2248 area_t **dirty_areas) {
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2249 if(n_dirty_areas)
1073
d09f603438d8 Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents: 1067
diff changeset
2250 make_scissoring(rdman->backend, n_dirty_areas, dirty_areas);
d09f603438d8 Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents: 1067
diff changeset
2251
512
d186d1e24458 Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents: 491
diff changeset
2252 mbe_copy_source(rdman->cr, rdman->backend);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2253 }
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2254 #else /* UNITTEST */
1073
d09f603438d8 Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents: 1067
diff changeset
2255 #define make_scissoring(canvas, n_dirty_areas, dirty_areas)
408
7f7855df2af0 Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents: 375
diff changeset
2256
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2257 static void clear_canvas(canvas_t *canvas) {
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2258 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2259
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2260 static void reset_clip(canvas_t *cr) {
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2261 }
24
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2262
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2263 static void copy_cr_2_backend(redraw_man_t *rdman, int n_dirty_areas,
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2264 area_t **dirty_areas) {
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2265 }
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2266 #endif /* UNITTEST */
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2267
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2268 static void
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2269 _update_cached_canvas_2_parent(redraw_man_t *rdman, co_aix reverse[6],
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2270 mbe_t *canvas, mbe_t *pcanvas,
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2271 co_aix opacity) {
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2272 mbe_surface_t *surface;
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2273 mbe_pattern_t *pattern;
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2274
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2275 surface = mbe_get_target(canvas);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2276 pattern = mbe_pattern_create_for_surface(surface);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2277 mbe_pattern_set_matrix(pattern, reverse);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2278 mbe_set_source(pcanvas, pattern);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2279 mbe_paint_with_alpha(pcanvas, opacity);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2280 }
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2281
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2282 static void update_cached_canvas_2_parent(redraw_man_t *rdman,
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2283 coord_t *coord) {
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2284 mbe_t *pcanvas, *canvas;
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
2285 co_aix *c2pdev_reverse;
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2286
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2287 if(coord_is_root(coord))
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2288 return;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2289
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
2290 c2pdev_reverse = coord_get_2pdev_rev(coord);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2291
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2292 canvas = _coord_get_canvas(coord);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2293 pcanvas = _coord_get_canvas(coord->parent);
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2294 #ifndef UNITTEST
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
2295 _update_cached_canvas_2_parent(rdman, c2pdev_reverse, canvas, pcanvas,
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2296 coord->opacity);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2297 #else
850
33fd5fdc8b48 Keep cache to parent device matrix in canvas_info.
Thinker K.F. Li <thinker@codemud.net>
parents: 841
diff changeset
2298 memcpy(((mock_mbe_t *)canvas)->parent_2_cache, c2pdev_reverse,
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2299 sizeof(co_aix) * 6);
824
93c54322d4d8 Do not copy canvas for unittest
Thinker K.F. Li <thinker@codemud.net>
parents: 823
diff changeset
2300 #endif
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2301 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2302
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2303 static int draw_coord_shapes_in_dirty_areas(redraw_man_t *rdman,
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2304 coord_t *coord) {
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2305 int dirty = 0;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2306 int r;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2307 area_t **areas;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2308 int n_areas;
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2309 mbe_t *canvas;
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2310 geo_t *member;
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2311 coord_t *child;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2312 int mem_idx;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2313
160
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
2314 if(coord->flags & COF_HIDDEN)
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
2315 return OK;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2316
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2317 areas = _coord_get_dirty_areas(coord)->ds;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2318 n_areas = _coord_get_dirty_areas(coord)->num;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2319 canvas = _coord_get_canvas(coord);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2320
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
2321 member = FIRST_MEMBER(coord);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2322 mem_idx = 0;
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
2323 child = FIRST_CHILD(coord);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2324 while(child != NULL || member != NULL) {
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2325 if(child && child->before_pmem == mem_idx) {
536
b6b3dbeaedf3 [mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents: 535
diff changeset
2326 if(coord_is_cached(child)) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2327 if(!(child->flags & COF_HIDDEN) &&
840
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
2328 is_area_in_areas(coord_get_pcache_area(child),
048cc704bef7 Merge dirty_pcache_area_coords and zeroing_coords.
Thinker K.F. Li <thinker@codemud.net>
parents: 839
diff changeset
2329 n_areas, areas)) {
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2330 update_cached_canvas_2_parent(rdman, child);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2331 dirty = 1;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2332 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2333 } else {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2334 r = draw_coord_shapes_in_dirty_areas(rdman, child);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2335 dirty |= r;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2336 }
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
2337 child = NEXT_CHILD(child);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2338 } else {
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2339 ASSERT(member != NULL);
747
d2f2ed27b84d Separate GEF_NOT_SHOWED and GEF_HIDDEN flags.
Thinker K.F. Li <thinker@codemud.net>
parents: 541
diff changeset
2340 if((!(member->flags & GEF_NOT_SHOWED)) &&
150
0824f4804ee0 Fix bug of broken coord_hide() and shape_hide().
Thinker K.F. Li <thinker@branda.to>
parents: 148
diff changeset
2341 is_geo_in_areas(member, n_areas, areas)) {
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2342 draw_shape(rdman, canvas, member->shape);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2343 dirty = 1;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2344 }
160
147c93163ef0 Fix bug of tank that bullet is not hidden when go out the map.
Thinker K.F. Li <thinker@branda.to>
parents: 159
diff changeset
2345
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
2346 member = NEXT_MEMBER(member);
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2347 mem_idx++;
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2348 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2349 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2350
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2351 return dirty;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2352 }
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2353
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2354 static int draw_dirty_cached_coord(redraw_man_t *rdman,
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2355 coord_t *coord) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2356 area_t **areas, *area;
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2357 area_t full_area;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2358 int n_areas;
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2359 mbe_t *canvas;
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2360 mbe_surface_t *surface;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2361 int i;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2362 int r;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2363
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2364 canvas = _coord_get_canvas(coord);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2365
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2366 if(IS_CACHE_REDRAW_ALL(coord)) {
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2367 /*
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2368 * full_area covers all dirty areas of the cached coord.
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2369 */
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2370 DARRAY_CLEAN(_coord_get_dirty_areas(coord));
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2371 surface = mbe_get_target(canvas);
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2372 full_area.x = 0;
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2373 full_area.y = 0;
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2374 full_area.w = mbe_image_surface_get_width(surface);
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2375 full_area.h = mbe_image_surface_get_height(surface);
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2376 add_dirty_area(rdman, coord, &full_area);
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2377 }
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2378
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2379 areas = _coord_get_dirty_areas(coord)->ds;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2380 n_areas = _coord_get_dirty_areas(coord)->num;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2381
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2382 for(i = 0; i < n_areas; i++) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2383 area = areas[i];
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2384 area->x = floorf(area->x);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2385 area->y = floorf(area->y);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2386 area->w = ceilf(area->w);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2387 area->h = ceilf(area->h);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2388 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2389
1073
d09f603438d8 Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents: 1067
diff changeset
2390 make_scissoring(canvas, n_areas, areas);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2391 clear_canvas(canvas);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2392
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2393 r = draw_coord_shapes_in_dirty_areas(rdman, coord);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2394
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2395 reset_clip(canvas);
441
94477e7d981e Fix compile error: no return statement
john.cylee@gmail.com
parents: 435
diff changeset
2396
94477e7d981e Fix compile error: no return statement
john.cylee@gmail.com
parents: 435
diff changeset
2397 return OK;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2398 }
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2399
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2400 static void draw_shapes_in_dirty_areas(redraw_man_t *rdman) {
538
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2401 int num;
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2402 coord_t **zeroings;
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2403 coord_t *coord;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2404 int i;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2405
538
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2406 zeroings = rdman->zeroing_coords.ds;
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2407 num = rdman->zeroing_coords.num;
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2408 /* Draw cached ones from leaves to root.
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2409 * Since content of cached ones depend on descendants.
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2410 */
538
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2411 for(i = num - 1; i >= 0; i--) {
a1d49b6355c3 Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents: 537
diff changeset
2412 coord = zeroings[i];
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2413 if(coord_get_flags(coord, COF_TEMP_MARK))
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2414 continue;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2415 draw_dirty_cached_coord(rdman, coord);
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2416 coord_set_flags(coord, COF_TEMP_MARK);
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2417 }
887
8a2d676d9fa3 Fix bug of clearing COF_TEMP_MARK.
Thinker K.F. Li <thinker@codemud.net>
parents: 881
diff changeset
2418 for(i = 0; i < num; i++) {
8a2d676d9fa3 Fix bug of clearing COF_TEMP_MARK.
Thinker K.F. Li <thinker@codemud.net>
parents: 881
diff changeset
2419 coord = zeroings[i];
539
ce11e889ea4e Simplify dirty area for coords that should be totally redraw
Thinker K.F. Li <thinker@branda.to>
parents: 538
diff changeset
2420 coord_clear_flags(coord, COF_TEMP_MARK);
887
8a2d676d9fa3 Fix bug of clearing COF_TEMP_MARK.
Thinker K.F. Li <thinker@codemud.net>
parents: 881
diff changeset
2421 }
528
d687d3395264 Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents: 527
diff changeset
2422
d687d3395264 Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents: 527
diff changeset
2423 draw_dirty_cached_coord(rdman, rdman->root_coord);
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2424 }
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2425
24
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2426
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2427 /*! \brief Re-draw all changed shapes or shapes affected by changed coords.
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2428 *
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2429 * A coord object has a geo to keep track the range that it's members will
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2430 * draw on. Geo of a coord should be recomputed when the coord is changed.
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2431 * Geo of a coord used to accelerate finding overlay shape objects of
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2432 * a specified geo. A coord object also must be recomputed when one of
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2433 * it's members is changed.
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2434 *
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2435 * New and old geo values of a coord object that is recomputed for
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2436 * changing of it-self must be used to find overlay shape objects.
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2437 * New and old geo values of a shape should also be used to find
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2438 * overlay shape objects, too. If a shape's coord is changed, shape's
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2439 * geo object is not used to find overlay shape objects any more.
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2440 *
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2441 * steps:
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2442 * - update chagned coord objects
14
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2443 * - recompute area for changed coord objects
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2444 * - recompute geo for members shape objects
14
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2445 * - clear dirty of geo for members to prevent from
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2446 * recomputing for change of shape objects.
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2447 * - add old and new area value to list of dirty areas.
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2448 * - recompute geo for changed shape objects
14
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2449 * - only if a shape object is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2450 * - put new and old value of area of geo to list of dirty areas.
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2451 * - Scan all shapes and redraw shapes overlaid with dirty areas.
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2452 *
14
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2453 * dirty flag of coord objects is cleared after update.
15
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2454 * dirty flag of geo objects is also cleared after recomputing.
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2455 * Clean dirty flag can prevent redundant computing for geo and
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2456 * corod objects.
14
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
2457 *
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2458 */
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2459 int rdman_redraw_changed(redraw_man_t *rdman) {
28
604bc90d509d Refactory
Thinker K.F. Li <thinker@branda.to>
parents: 27
diff changeset
2460 int r;
154
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
2461 event_t event;
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
2462 subject_t *redraw;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2463 int i;
769
7c73fbc8d700 Remove unused local variables
Thinker K.F. Li <thinker@codemud.net>
parents: 747
diff changeset
2464 coord_t *coord;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2465 int n_areas;
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2466 area_t **areas;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2467
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2468 r = rdman_clean_dirties(rdman);
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
2469 if(r != OK)
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
2470 return ERR;
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2471
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2472 if(rdman->n_dirty_areas > 0) {
135
Thinker K.F. Li <thinker@branda.to>
parents: 133
diff changeset
2473 /*! \brief Draw shapes in preorder of coord tree and support opacity
Thinker K.F. Li <thinker@branda.to>
parents: 133
diff changeset
2474 * rules.
Thinker K.F. Li <thinker@branda.to>
parents: 133
diff changeset
2475 */
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2476 draw_shapes_in_dirty_areas(rdman);
1114
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2477 if(rdman->backend) {
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2478 n_areas = _coord_get_dirty_areas(rdman->root_coord)->num;
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2479 areas = _coord_get_dirty_areas(rdman->root_coord)->ds;
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2480 copy_cr_2_backend(rdman, n_areas, areas);
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2481 reset_clip(rdman->backend);
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2482 } else {
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2483 mbe_flush(rdman->cr);
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2484 }
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2485 for(i = 0; i < rdman->zeroing_coords.num; i++) {
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2486 coord = rdman->zeroing_coords.ds[i];
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2487 DARRAY_CLEAN(_coord_get_dirty_areas(coord));
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2488 }
528
d687d3395264 Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents: 527
diff changeset
2489 DARRAY_CLEAN(_coord_get_dirty_areas(rdman->root_coord));
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2490 rdman->n_dirty_areas = 0;
15
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2491 }
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
2492
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2493 DARRAY_CLEAN(&rdman->dirty_coords);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2494 DARRAY_CLEAN(&rdman->dirty_geos);
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2495 DARRAY_CLEAN(&rdman->zeroing_coords);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2496
158
c1cdd3fcd28f Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents: 154
diff changeset
2497 /* Free postponsed removing */
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2498 free_free_objs(rdman);
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
2499
154
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
2500 redraw = rdman_get_redraw_subject(rdman);
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
2501 event.type = EVT_RDMAN_REDRAW;
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
2502 event.tgt = event.cur_tgt = redraw;
192
54fdc2a65242 Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents: 189
diff changeset
2503 subject_notify(redraw, &event);
154
6ce68c1f7405 Tank can fire bullet.
Thinker K.F. Li <thinker@branda.to>
parents: 152
diff changeset
2504
15
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2505 return OK;
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2506 }
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2507
38
Thinker K.F. Li <thinker@branda.to>
parents: 37
diff changeset
2508 /* NOTE: Before redrawing, the canvas/surface must be cleaned.
Thinker K.F. Li <thinker@branda.to>
parents: 37
diff changeset
2509 * NOTE: After redrawing, the content must be copied to the backend surface.
Thinker K.F. Li <thinker@branda.to>
parents: 37
diff changeset
2510 */
Thinker K.F. Li <thinker@branda.to>
parents: 37
diff changeset
2511
15
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2512 int rdman_redraw_all(redraw_man_t *rdman) {
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2513 area_t area;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2514 #ifndef UNITTEST
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2515 mbe_surface_t *surface;
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2516 #endif
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2517 int r;
15
c2ce186a5c37 X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents: 14
diff changeset
2518
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2519 area.x = area.y = 0;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2520 #ifndef UNITTEST
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2521 surface = mbe_get_target(rdman->cr);
1114
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2522 area.w = rdman->w;
7451af5d63ec Make tank and calculator works for console backend
Thinker K.F. Li <thinker@codemud.net>
parents: 1073
diff changeset
2523 area.h = rdman->h;
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2524 #else
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2525 area.w = 1024;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2526 area.h = 1024;
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2527 #endif
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2528 add_dirty_area(rdman, rdman->root_coord, &area);
138
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2529
9f4fc9ecfd1f Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents: 135
diff changeset
2530 r = rdman_redraw_changed(rdman);
29
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2531 if(r != OK)
Thinker K.F. Li <thinker@branda.to>
parents: 28
diff changeset
2532 return ERR;
16
e17e12b112c4 A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 15
diff changeset
2533
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
2534 return OK;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2535 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2536
37
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2537 int rdman_redraw_area(redraw_man_t *rdman, co_aix x, co_aix y,
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2538 co_aix w, co_aix h) {
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2539 area_t area;
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2540 int r;
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2541
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2542 area.x = x;
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2543 area.y = y;
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2544 area.w = w;
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2545 area.h = h;
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2546 add_dirty_area(rdman, rdman->root_coord, &area);
37
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2547
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2548 r = rdman_redraw_changed(rdman);
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2549
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2550 return r;
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2551 }
943acee7f346 update exposed area
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
2552
314
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2553 /*! \brief Helping function to travel descendant shapes of a coord.
6c350fc92ae3 Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents: 289
diff changeset
2554 */
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2555 geo_t *rdman_geos(redraw_man_t *rdman, geo_t *last) {
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2556 geo_t *next;
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2557 coord_t *coord;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2558
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2559 if(last == NULL) {
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2560 coord = rdman->root_coord;
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
2561 while(coord != NULL && FIRST_MEMBER(coord) == NULL)
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2562 coord = preorder_coord_subtree(rdman->root_coord, coord);
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2563 if(coord == NULL)
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2564 return NULL;
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
2565 return FIRST_MEMBER(coord);
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2566 }
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2567
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2568 coord = last->shape->coord;
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
2569 next = NEXT_MEMBER(last);
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2570 while(next == NULL) {
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2571 coord = preorder_coord_subtree(rdman->root_coord, coord);
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2572 if(coord == NULL)
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2573 return NULL;
140
0de8fd11271e Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents: 139
diff changeset
2574 next = FIRST_MEMBER(coord);
139
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2575 }
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2576 return next;
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2577 }
1695a4b02b14 Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents: 138
diff changeset
2578
30
e06a4a667ce2 Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents: 29
diff changeset
2579 int rdman_force_clean(redraw_man_t *rdman) {
e06a4a667ce2 Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents: 29
diff changeset
2580 int r;
e06a4a667ce2 Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents: 29
diff changeset
2581
535
a545f126d2bf pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents: 534
diff changeset
2582 r = rdman_clean_dirties(rdman);
30
e06a4a667ce2 Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents: 29
diff changeset
2583
e06a4a667ce2 Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents: 29
diff changeset
2584 return r;
e06a4a667ce2 Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents: 29
diff changeset
2585 }
e06a4a667ce2 Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents: 29
diff changeset
2586
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2587 /*! \page man_obj Manage Objects.
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2588 *
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2589 * Shapes and paints should also be managed by redraw manager. Redraw
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2590 * manager must know life-cycle of shapes and paints to avoid to use them
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2591 * after being free. If a shape is released when it is dirty, redraw
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2592 * manager will try to access them, after released, for redrawing.
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2593 * We can make a copy information need by redraw manager to redraw them,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2594 * but it is more complicate, and induce runtime overhead.
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2595 *
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2596 * So, redraw manage had better also manage life-cycle of shapes and paints.
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2597 * Shapes and paints should be created and freed through interfaces
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2598 * provided by redraw manager. To reduce overhead of interfaces, they can
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2599 * be implemented as C macros.
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2600 *
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2601 * To refactory redraw manage to manage life-cycle of shapes and paints,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2602 * following functions/macros are introduced.
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2603 * - rdman_paint_*_new()
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2604 * - rdman_paint_free()
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2605 * - rdman_shape_*_new()
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2606 * - rdman_shape_free()
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2607 */
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2608
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2609 /* \defgroup rdman_observer Observer memory management
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2610 *
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2611 * Implment factory and strategy functions for observers and subjects.
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2612 * @{
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2613 */
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2614 static subject_t *observer_subject_alloc(observer_factory_t *factory) {
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2615 redraw_man_t *rdman;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2616 subject_t *subject;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2617
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2618 rdman = MEM2OBJ(factory, redraw_man_t, observer_factory);
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2619 subject = elmpool_elm_alloc(rdman->subject_pool);
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2620
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2621 return subject;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2622 }
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2623
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2624 static void
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2625 observer_subject_free(observer_factory_t *factory, subject_t *subject) {
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2626 redraw_man_t *rdman;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2627
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2628 rdman = MEM2OBJ(factory, redraw_man_t, observer_factory);
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2629 elmpool_elm_free(rdman->subject_pool, subject);
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2630 }
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2631
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2632 static observer_t *observer_observer_alloc(observer_factory_t *factory) {
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2633 redraw_man_t *rdman;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2634 observer_t *observer;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2635
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2636 rdman = MEM2OBJ(factory, redraw_man_t, observer_factory);
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2637 observer = elmpool_elm_alloc(rdman->observer_pool);
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2638
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2639 return observer;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2640 }
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2641
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2642 static void
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2643 observer_observer_free(observer_factory_t *factory, observer_t *observer) {
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2644 redraw_man_t *rdman;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2645
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2646 rdman = MEM2OBJ(factory, redraw_man_t, observer_factory);
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2647 elmpool_elm_free(rdman->observer_pool, observer);
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2648 }
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2649
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2650 static subject_t *
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2651 observer_get_parent_subject(observer_factory_t *factory,
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2652 subject_t *cur_subject) {
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2653 redraw_man_t *rdman;
79
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2654 coord_t *coord, *parent_coord;
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2655 geo_t *geo;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2656 subject_t *parent;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2657
1060
e415c55b4a0d Stop using ob as acronym observer
Thinker K.F. Li <thinker@codemud.net>
parents: 1059
diff changeset
2658 rdman = MEM2OBJ(factory, redraw_man_t, observer_factory);
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2659 switch(cur_subject->obj_type) {
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2660 case OBJT_GEO:
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2661 geo = (geo_t *)cur_subject->obj;
79
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2662 parent_coord = geo->shape->coord;
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2663 parent = parent_coord->mouse_event;
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2664 break;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2665 case OBJT_COORD:
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2666 coord = (coord_t *)cur_subject->obj;
79
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2667 parent_coord = coord->parent;
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2668 if(parent_coord == NULL) {
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2669 parent = NULL;
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2670 break;
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2671 }
5bcb329a5157 Fix bug of core dump caused by forget to check if parent is NULL, root.
Thinker K.F. Li <thinker@branda.to>
parents: 75
diff changeset
2672 parent = parent_coord->mouse_event;
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2673 break;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2674 default:
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2675 parent = NULL;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2676 break;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2677 }
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2678
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2679 return parent;
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2680 }
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2681
322
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2682 /* @} */
c1afd14caa85 Remove out-of-date comments and refactor code and fix a small bug.
Thinker K.F. Li <thinker@branda.to>
parents: 317
diff changeset
2683
356
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2684 /*! \brief Load an image as a paint_image_t.
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2685 */
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2686 paint_t *rdman_img_ldr_load_paint(redraw_man_t *rdman, const char *img_id) {
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2687 mb_img_data_t *img_data;
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2688 paint_t *paint;
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2689 mb_img_ldr_t *ldr = rdman_img_ldr(rdman);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2690
356
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2691 img_data = MB_IMG_LDR_LOAD(ldr, img_id);
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2692 if(img_data == NULL)
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2693 return NULL;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2694
356
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2695 paint = rdman_paint_image_new(rdman, img_data);
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2696 if(paint == NULL)
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2697 MB_IMG_DATA_FREE(img_data);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2698
356
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2699 return paint;
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2700 }
3e84458968ec Move mb_img_data_t out from argument list of rdman_shape_image_new().
Thinker K.F. Li <thinker@branda.to>
parents: 327
diff changeset
2701
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2702 #ifdef UNITTEST
73
9ab15ebc9061 Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents: 58
diff changeset
2703 /* Test cases */
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2704
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2705 #include <CUnit/Basic.h>
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2706
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2707 struct _sh_dummy {
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2708 shape_t shape;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2709 co_aix x, y;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2710 co_aix w, h;
119
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2711 int trans_cnt;
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2712 int draw_cnt;
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2713 mbe_t *last_draw;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2714 };
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2715
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2716 void sh_dummy_free(shape_t *sh) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2717 free(sh);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2718 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2719
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2720 shape_t *sh_dummy_new(redraw_man_t *rdman,
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2721 co_aix x, co_aix y, co_aix w, co_aix h) {
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2722 sh_dummy_t *dummy;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2723
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2724 dummy = (sh_dummy_t *)malloc(sizeof(sh_dummy_t));
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2725 if(dummy == NULL)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2726 return NULL;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2727
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2728 memset(dummy, 0, sizeof(sh_dummy_t));
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2729
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2730 dummy->x = x;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2731 dummy->y = y;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2732 dummy->w = w;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2733 dummy->h = h;
119
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2734 dummy->trans_cnt = 0;
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2735 dummy->draw_cnt = 0;
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2736 dummy->shape.free = sh_dummy_free;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2737
1062
a8d20bc8ce40 Rename rdman_shape_man() to rdman_man_shape() to mean managing a shape
Thinker K.F. Li <thinker@codemud.net>
parents: 1060
diff changeset
2738 rdman_man_shape(rdman, (shape_t *)dummy);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2739
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2740 return (shape_t *)dummy;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2741 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2742
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2743 void sh_dummy_transform(shape_t *shape) {
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2744 sh_dummy_t *dummy = (sh_dummy_t *)shape;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2745 co_aix poses[2][2];
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2746 co_aix x1, y1, x2, y2;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2747
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2748 if(shape->geo && shape->coord) {
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2749 x1 = dummy->x;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2750 y1 = dummy->y;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2751 x2 = x1 + dummy->w;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2752 y2 = y1 + dummy->h;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2753
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2754 coord_trans_pos(shape->coord, &x1, &y1);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2755 coord_trans_pos(shape->coord, &x2, &y2);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2756 poses[0][0] = x1;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2757 poses[0][1] = y1;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2758 poses[1][0] = x2;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2759 poses[1][1] = y2;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2760
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2761 if(shape->geo)
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2762 geo_from_positions(shape->geo, 2, poses);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2763 }
119
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2764 dummy->trans_cnt++;
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2765 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2766
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2767 void sh_dummy_fill(shape_t *shape, mbe_t *cr) {
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2768 sh_dummy_t *dummy;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2769
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2770 dummy = (sh_dummy_t *)shape;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2771 dummy->draw_cnt++;
825
e83956ba22d7 Make sure drawing on right cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 824
diff changeset
2772 dummy->last_draw = cr;
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2773 }
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2774
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 441
diff changeset
2775 static void dummy_paint_prepare(paint_t *paint, mbe_t *cr) {
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2776 }
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2777
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2778 static void dummy_paint_free(redraw_man_t *rdman, paint_t *paint) {
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2779 if(paint)
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2780 free(paint);
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2781 }
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2782
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2783 paint_t *dummy_paint_new(redraw_man_t *rdman) {
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2784 paint_t *paint;
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2785
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2786 paint = (paint_t *)malloc(sizeof(paint_t));
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2787 if(paint == NULL)
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2788 return NULL;
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2789
408
7f7855df2af0 Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents: 375
diff changeset
2790 paint_init(paint, MBP_DUMMY, dummy_paint_prepare, dummy_paint_free);
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2791
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2792 return paint;
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2793 }
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2794
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2795 static void test_rdman_redraw_changed(void) {
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2796 coord_t *coords[3];
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2797 shape_t *shapes[3];
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2798 sh_dummy_t **dummys;
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2799 paint_t *paint;
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2800 redraw_man_t *rdman;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2801 redraw_man_t _rdman;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2802 int i;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2803
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2804 dummys = (sh_dummy_t **)shapes;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2805
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2806 rdman = &_rdman;
24
e598bc809c0f No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents: 23
diff changeset
2807 redraw_man_init(rdman, NULL, NULL);
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2808 paint = dummy_paint_new(rdman);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2809 for(i = 0; i < 3; i++) {
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2810 shapes[i] = sh_dummy_new(rdman, 0, 0, 50, 50);
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2811 rdman_paint_fill(rdman, paint, shapes[i]);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2812 coords[i] = rdman_coord_new(rdman, rdman->root_coord);
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2813 coords[i]->matrix[2] = 10 + i * 100;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2814 coords[i]->matrix[5] = 10 + i * 100;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2815 rdman_coord_changed(rdman, coords[i]);
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2816 rdman_add_shape(rdman, shapes[i], coords[i]);
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2817 }
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2818 rdman_redraw_all(rdman);
119
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2819 CU_ASSERT(dummys[0]->trans_cnt == 1);
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2820 CU_ASSERT(dummys[1]->trans_cnt == 1);
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2821 CU_ASSERT(dummys[2]->trans_cnt == 1);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2822 CU_ASSERT(dummys[0]->draw_cnt == 1);
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2823 CU_ASSERT(dummys[1]->draw_cnt == 1);
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2824 CU_ASSERT(dummys[2]->draw_cnt == 1);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2825
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2826 coords[2]->matrix[2] = 100;
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2827 coords[2]->matrix[5] = 100;
119
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2828 rdman_coord_changed(rdman, coords[0]);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2829 rdman_coord_changed(rdman, coords[2]);
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2830 rdman_redraw_changed(rdman);
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2831
119
257a1d314bcd Bug of insert sort
Thinker K.F. Li <thinker@branda.to>
parents: 115
diff changeset
2832 CU_ASSERT(dummys[0]->draw_cnt == 2);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2833 CU_ASSERT(dummys[1]->draw_cnt == 2);
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2834 CU_ASSERT(dummys[2]->draw_cnt == 2);
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2835
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2836 rdman_paint_free(rdman, paint);
19
cf6d65398619 More animation demo
Thinker K.F. Li <thinker@branda.to>
parents: 18
diff changeset
2837 redraw_man_destroy(rdman);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2838 }
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
2839
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2840 static int test_free_pass = 0;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2841
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2842 static void test_free(redraw_man_t *rdman, void *obj) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2843 test_free_pass++;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2844 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2845
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2846 static void test_rdman_free_objs(void) {
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2847 redraw_man_t *rdman;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2848 redraw_man_t _rdman;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2849 int i;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2850
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2851 redraw_man_init(&_rdman, NULL, NULL);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2852 rdman = &_rdman;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2853
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2854 test_free_pass = 0;
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2855
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2856 for(i = 0; i < 4; i++)
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2857 add_free_obj(rdman, NULL, test_free);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2858
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2859 redraw_man_destroy(rdman);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2860 CU_ASSERT(test_free_pass == 4);
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2861 }
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
2862
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2863 static void
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2864 test_setup_canvas_info(void) {
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2865 redraw_man_t *rdman;
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2866 redraw_man_t _rdman;
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2867 coord_t *coord;
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2868
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2869 redraw_man_init(&_rdman, NULL, NULL);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2870 rdman = &_rdman;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2871
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2872 coord = rdman_coord_new(rdman, rdman->root_coord);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2873 CU_ASSERT(coord->parent == rdman->root_coord);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2874
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2875 coord_set_opacity(coord, 0.9);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2876 setup_canvas_info(rdman, coord);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2877
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2878 CU_ASSERT(coord->canvas_info != rdman->root_coord->canvas_info);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2879
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2880 coord_set_opacity(coord, 1);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2881 setup_canvas_info(rdman, coord);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2882
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2883 CU_ASSERT(coord->canvas_info == rdman->root_coord->canvas_info);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2884 }
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2885
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2886 static void
818
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2887 test_own_canvas_area(void) {
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2888 redraw_man_t *rdman;
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2889 redraw_man_t _rdman;
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2890 coord_t *coord1, *coord2;
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2891 sh_dummy_t *sh;
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2892
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2893 redraw_man_init(&_rdman, NULL, NULL);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2894 rdman = &_rdman;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2895
818
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2896 coord1 = rdman_coord_new(rdman, rdman->root_coord);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2897 CU_ASSERT(coord1->parent == rdman->root_coord);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2898
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2899 coord2 = rdman_coord_new(rdman, coord1);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2900 CU_ASSERT(coord2->parent == coord1);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2901
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2902 coord_set_opacity(coord2, 0.9);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2903 rdman_coord_changed(rdman, coord2);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2904
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2905 sh = (sh_dummy_t *)sh_dummy_new(rdman, 100, 100, 20, 20);
818
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2906 rdman_add_shape(rdman, (shape_t *)sh, coord2);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2907 rdman_shape_changed(rdman, (shape_t *)sh);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2908
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2909 clean_coord(rdman, coord2);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2910
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2911 /* Parent cached coord must be updated */
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2912 CU_ASSERT(geo_get_area(coord2)->x == 100);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2913 CU_ASSERT(geo_get_area(coord2)->y == 100);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2914 CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2915 CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19);
823
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2916
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2917 redraw_man_destroy(rdman);
818
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2918 }
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2919
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2920 static void
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2921 test_own_canvas(void) {
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2922 redraw_man_t *rdman;
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2923 redraw_man_t _rdman;
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2924 coord_t *coord1, *coord2;
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2925 sh_dummy_t *sh;
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2926
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2927 redraw_man_init(&_rdman, NULL, NULL);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2928 rdman = &_rdman;
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 818
diff changeset
2929
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2930 coord1 = rdman_coord_new(rdman, rdman->root_coord);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2931 CU_ASSERT(coord1->parent == rdman->root_coord);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2932
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2933 coord2 = rdman_coord_new(rdman, coord1);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2934 CU_ASSERT(coord2->parent == coord1);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2935
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2936 coord_set_opacity(coord2, 0.9);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2937 rdman_coord_changed(rdman, coord2);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2938
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2939 sh = (sh_dummy_t *)sh_dummy_new(rdman, 100, 100, 20, 20);
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2940 rdman_add_shape(rdman, (shape_t *)sh, coord2);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2941 rdman_shape_changed(rdman, (shape_t *)sh);
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2942
817
387d1c597632 Change order of statements to fix bug of wild pointers.
Thinker K.F. Li <thinker@codemud.net>
parents: 816
diff changeset
2943 rdman_clean_dirties(rdman);
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2944
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
2945 /* Parent cached coord must be updated */
818
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2946 CU_ASSERT(_coord_get_dirty_areas(rdman->root_coord)->num == 1);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2947
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2948 CU_ASSERT(geo_get_area(coord2)->x == 0);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2949 CU_ASSERT(geo_get_area(coord2)->y == 0);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2950 CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2951 CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19);
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
2952
823
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2953 redraw_man_destroy(rdman);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2954 }
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2955
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2956 static void
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2957 test_own_canvas_redraw(void) {
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2958 redraw_man_t *rdman;
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2959 redraw_man_t _rdman;
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2960 coord_t *coord1, *coord2;
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2961 sh_dummy_t *sh;
824
93c54322d4d8 Do not copy canvas for unittest
Thinker K.F. Li <thinker@codemud.net>
parents: 823
diff changeset
2962 paint_t *paint;
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2963 co_aix *parent_2_cache;
823
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2964
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2965 redraw_man_init(&_rdman, NULL, NULL);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2966 rdman = &_rdman;
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2967
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2968 coord1 = rdman_coord_new(rdman, rdman->root_coord);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2969 CU_ASSERT(coord1->parent == rdman->root_coord);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2970
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2971 coord2 = rdman_coord_new(rdman, coord1);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2972 CU_ASSERT(coord2->parent == coord1);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2973
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2974 coord_set_opacity(coord2, 0.9);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2975 rdman_coord_changed(rdman, coord2);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2976
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2977 sh = (sh_dummy_t *)sh_dummy_new(rdman, 100, 100, 20, 20);
823
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2978 rdman_add_shape(rdman, (shape_t *)sh, coord2);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2979 rdman_shape_changed(rdman, (shape_t *)sh);
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2980
824
93c54322d4d8 Do not copy canvas for unittest
Thinker K.F. Li <thinker@codemud.net>
parents: 823
diff changeset
2981 paint = dummy_paint_new(rdman);
93c54322d4d8 Do not copy canvas for unittest
Thinker K.F. Li <thinker@codemud.net>
parents: 823
diff changeset
2982 rdman_paint_fill(rdman, paint, (shape_t *)sh);
93c54322d4d8 Do not copy canvas for unittest
Thinker K.F. Li <thinker@codemud.net>
parents: 823
diff changeset
2983
93c54322d4d8 Do not copy canvas for unittest
Thinker K.F. Li <thinker@codemud.net>
parents: 823
diff changeset
2984 rdman_redraw_all(rdman);
823
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2985
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2986 CU_ASSERT(sh->draw_cnt == 1);
825
e83956ba22d7 Make sure drawing on right cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 824
diff changeset
2987 CU_ASSERT(sh->last_draw == _coord_get_canvas(coord2));
823
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
2988
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2989 parent_2_cache = ((mock_mbe_t *)_coord_get_canvas(coord2))->parent_2_cache;
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2990 CU_ASSERT(parent_2_cache[0] == 1);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2991 CU_ASSERT(parent_2_cache[1] == 0);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2992 CU_ASSERT(parent_2_cache[2] == -100);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2993 CU_ASSERT(parent_2_cache[3] == 0);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2994 CU_ASSERT(parent_2_cache[4] == 1);
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
2995 CU_ASSERT(parent_2_cache[5] == -100);
833
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
2996
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
2997 coord2->matrix[2] = 20;
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
2998 coord2->matrix[5] = 30;
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
2999 rdman_coord_changed(rdman, coord2);
834
9f305d895e8f Keep width and height of a canvas for mock of canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 833
diff changeset
3000 rdman_redraw_changed(rdman);
833
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3001
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3002 /* To test if transform matrix of cached coord working */
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3003 parent_2_cache = ((mock_mbe_t *)_coord_get_canvas(coord2))->parent_2_cache;
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3004 CU_ASSERT(parent_2_cache[0] == 1);
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3005 CU_ASSERT(parent_2_cache[1] == 0);
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3006 CU_ASSERT(parent_2_cache[2] == -120);
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3007 CU_ASSERT(parent_2_cache[3] == 0);
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3008 CU_ASSERT(parent_2_cache[4] == 1);
419c7de41bfa Make sure transform matrix of a cached coord working
Thinker K.F. Li <thinker@codemud.net>
parents: 832
diff changeset
3009 CU_ASSERT(parent_2_cache[5] == -130);
832
8ae1fb7b3104 Check transform from parent cached coord to descendant cached coord
Thinker K.F. Li <thinker@codemud.net>
parents: 826
diff changeset
3010
824
93c54322d4d8 Do not copy canvas for unittest
Thinker K.F. Li <thinker@codemud.net>
parents: 823
diff changeset
3011 rdman_paint_free(rdman, paint);
823
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
3012 redraw_man_destroy(rdman);
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
3013 }
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
3014
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3015 CU_pSuite get_redraw_man_suite(void) {
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3016 CU_pSuite suite;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3017
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3018 suite = CU_add_suite("Suite_redraw_man", NULL, NULL);
17
41f0907b27ac Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents: 16
diff changeset
3019 CU_ADD_TEST(suite, test_rdman_redraw_changed);
159
b90abd31a281 Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents: 158
diff changeset
3020 CU_ADD_TEST(suite, test_rdman_free_objs);
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
3021 CU_ADD_TEST(suite, test_setup_canvas_info);
818
86f2c59cef09 Fix typo on index of matrix
Thinker K.F. Li <thinker@codemud.net>
parents: 817
diff changeset
3022 CU_ADD_TEST(suite, test_own_canvas_area);
816
0e56a1ca19b2 Testcases for caching coords
Thinker K.F. Li <thinker@codemud.net>
parents: 815
diff changeset
3023 CU_ADD_TEST(suite, test_own_canvas);
823
ea544a68f55d Testcase for redrawing cached canvas
Thinker K.F. Li <thinker@codemud.net>
parents: 818
diff changeset
3024 CU_ADD_TEST(suite, test_own_canvas_redraw);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3025
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3026 return suite;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3027 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3028
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3029 #endif /* UNITTEST */