Mercurial > MadButterfly
annotate src/redraw_man.c @ 538:a1d49b6355c3 Android_Skia
Clear flags for clearing procedure and draw dirty cached ones
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 24 May 2010 11:59:27 +0800 |
parents | 3a7e3c1cd6e6 |
children | ce11e889ea4e |
rev | line source |
---|---|
12 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
4 #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
|
5 #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
|
6 #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
|
7 #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
|
8 #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
|
9 #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
|
10 #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
|
11 #include "mb_prop.h" |
467
6e18550c8fa8
Header file to config graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
466
diff
changeset
|
12 #include "config.h" |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
13 |
408
7f7855df2af0
Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents:
375
diff
changeset
|
14 /* 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
|
15 #include "mb_paint.h" |
7f7855df2af0
Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents:
375
diff
changeset
|
16 |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
17 /*! \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
|
18 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
19 * \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
|
20 * 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
|
21 * 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
|
22 * 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
|
23 * 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
|
24 * 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
|
25 * repective shapes. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
26 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
27 * \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
|
28 * 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
|
29 * 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
|
30 * 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
|
31 * 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
|
32 * 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
|
33 * 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
|
34 * 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
|
35 * 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
|
36 * 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
|
37 * 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
|
38 * 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
|
39 * 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
|
40 * 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
|
41 * |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
42 * 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
|
43 * 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
|
44 * 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
|
45 * 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
|
46 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
47 * 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
|
48 * 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
|
49 * 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
|
50 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
51 * 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
|
52 * coords will also clean member geos. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
53 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
54 * \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
|
55 * 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
|
56 * 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
|
57 * 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
|
58 * 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
|
59 * 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
|
60 * 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
|
61 * 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
|
62 * shapes. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
63 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
64 * 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
|
65 * 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
|
66 * 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
|
67 * be redrawed. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
68 */ |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
69 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
70 /*! \page redraw How to Redraw Shapes? |
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 * 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
|
73 * 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
|
74 * 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
|
75 * canvas of parent of the group. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
76 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
77 * 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
|
78 * 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
|
79 * 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
|
80 * 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
|
81 * 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
|
82 * 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
|
83 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
84 * \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
|
85 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
86 * \sa |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
87 * - rdman_redraw_all() |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
88 * - rdman_redraw_changed() |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
89 * - draw_shapes_in_areas() |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
90 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
91 * \section img_cache Image Cache |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
92 * 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
|
93 * 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
|
94 * 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
|
95 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
96 * \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
|
97 * coord that it's |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
98 * 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
|
99 * 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
|
100 * 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
|
101 * 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
|
102 * size, in width or height. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
103 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
104 * 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
|
105 * 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
|
106 * transformed as |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
107 * \code |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
108 * 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
|
109 * 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
|
110 * 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
|
111 * cache_p_matrix[1] = 0; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
112 * 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
|
113 * cache_p_matrix[3] = 0; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
114 * 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
|
115 * 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
|
116 * \endcode |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
117 * 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
|
118 * 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
|
119 * \code |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
120 * aggr_matrix = cache_p_matrix * matrix |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
121 * \endcode |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
122 * 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
|
123 * 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
|
124 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
125 * 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
|
126 * (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
|
127 * 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
|
128 * 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
|
129 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
130 * 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
|
131 * 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
|
132 * by parent with following matrix. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
133 * \code |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
134 * 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
|
135 * \endcode |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
136 * 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
|
137 * 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
|
138 * 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
|
139 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
140 * 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
|
141 * following condition is true. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
142 * \code |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
143 * 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
|
144 * 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
|
145 * \endcode |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
146 * 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
|
147 * 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
|
148 * before changing transformation of ancestors. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
149 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
150 * 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
|
151 * \code |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
152 * 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
|
153 * 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
|
154 * \endcode |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
155 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
156 * \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
|
157 * - *_transform of shapes works as normal |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
158 * - 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
|
159 * by aggr_matrix of cached coord. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
160 * - descendants are marked with \ref COF_ANCESTOR_CACHE |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
161 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
162 * 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
|
163 * 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
|
164 * \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
|
165 * 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
|
166 * \code |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
167 * 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
|
168 * \endcode |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
169 * 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
|
170 * 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
|
171 * 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
|
172 * coord. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
173 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
174 * 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
|
175 * 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
|
176 * 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
|
177 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
178 * \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
|
179 * 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
|
180 * 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
|
181 * cached-bounding. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
182 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
183 * 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
|
184 * 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
|
185 * 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
|
186 * 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
|
187 * 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
|
188 * 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
|
189 * following statements. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
190 * \code |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
191 * aggr_matrix[2] += range_shift_x; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
192 * aggr_matrix[5] += range_shift_y; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
193 * \endcode |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
194 * 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
|
195 * aligned to origin of coordinate system. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
196 * 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
|
197 * 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
|
198 * box. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
199 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
200 * \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
|
201 * 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
|
202 * 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
|
203 * 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
|
204 * 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
|
205 * 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
|
206 * area. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
207 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
208 * 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
|
209 * 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
|
210 * resize factor to get better output. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
211 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
212 * 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
|
213 * 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
|
214 * 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
|
215 * 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
|
216 * 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
|
217 * 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
|
218 * range_shift_*. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
219 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
220 * 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
|
221 * 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
|
222 * 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
|
223 * 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
|
224 * 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
|
225 * 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
|
226 * 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
|
227 * 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
|
228 * descendants. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
229 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
230 * \section cache_imp Implementation of Cache |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
231 * 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
|
232 * 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
|
233 * 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
|
234 * 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
|
235 * 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
|
236 * 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
|
237 * 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
|
238 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
239 * Following is rules. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
240 * - zeroing on a cached coord is performed by adjust coord_t::aggr_matrix |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
241 * of the cached coord and descendnats. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
242 * - 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
|
243 * - in preorder |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
244 * - never perform zeroing on root_coord. |
519
7a1b17ebb3b4
Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
245 * - 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
|
246 * - 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
|
247 * 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
|
248 * - zeroing is performed immediately after clean coords. |
519
7a1b17ebb3b4
Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
249 * - 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
|
250 * - 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
|
251 * - 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
|
252 * must be ajdusted. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
253 * - 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
|
254 * - 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
|
255 * cached coord. |
519
7a1b17ebb3b4
Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
256 * - 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
|
257 * descendants. |
7a1b17ebb3b4
Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
258 * - 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
|
259 * be draw. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
260 * - 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
|
261 * - 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
|
262 * parent cached coord. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
263 * - aggregates areas before adding to parent. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
264 * - 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
|
265 * - descendants are dirty, or |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
266 * - it-self is dirty. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
267 * - 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
|
268 * - 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
|
269 * - 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
|
270 * - 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
|
271 * 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
|
272 * - 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
|
273 * - 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
|
274 * - 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
|
275 * - 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
|
276 * |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
277 * Steps: |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
278 * - 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
|
279 * - 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
|
280 * - clean coords |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
281 * - 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
|
282 * - see \ref img_cache |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
283 * - clean geos |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
284 * - 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
|
285 * - 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
|
286 * - 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
|
287 * - 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
|
288 * - zeroing |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
289 * - 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
|
290 * - From leaves to root. |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
291 * - 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
|
292 * - 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
|
293 * - 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
|
294 * 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
|
295 * - 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
|
296 * - draw dirty areas |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
297 * - 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
|
298 * - from leaves to root. |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
299 */ |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
300 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
301 #ifndef ASSERT |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
302 #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
|
303 #endif |
12 | 304 |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
25
diff
changeset
|
305 /* 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
|
306 */ |
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
25
diff
changeset
|
307 |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
308 #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
|
309 do { \ |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
310 (sh)->geo = g; \ |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
311 (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
|
312 } while(0) |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
313 #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
|
314 do { \ |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
315 (sh)->geo->shape = NULL; \ |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
316 (sh)->geo = NULL; \ |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
317 } while(0) |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
318 #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
|
319 #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
|
320 #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
|
321 #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
|
322 ((rdman)->dirty_coords.num != 0 || \ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
323 (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
|
324 |
12 | 325 #define OK 0 |
326 #define ERR -1 | |
327 | |
139
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
328 #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
|
329 |
13 | 330 #define SWAP(a, b, t) do { t c; c = a; a = b; b = c; } while(0) |
331 | |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
332 #ifdef UNITTEST |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
333 typedef struct _sh_dummy sh_dummy_t; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
334 |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
335 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
|
336 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
|
337 #endif /* UNITTEST */ |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
338 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
339 static subject_t *ob_subject_alloc(ob_factory_t *factory); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
340 static void ob_subject_free(ob_factory_t *factory, subject_t *subject); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
341 static observer_t *ob_observer_alloc(ob_factory_t *factory); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
342 static void ob_observer_free(ob_factory_t *factory, observer_t *observer); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
343 static subject_t *ob_get_parent_subject(ob_factory_t *factory, |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
344 subject_t *cur_subject); |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
345 /* Functions for children. */ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
346 #define FORCHILDREN(coord, child) \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
347 for((child) = STAILQ_HEAD((coord)->children); \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
348 (child) != NULL; \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
349 (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
|
350 #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
|
351 #define ADD_CHILD(parent, child) \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
352 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
|
353 #define RM_CHILD(parent, child) \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
354 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
|
355 #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
|
356 |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
357 /* Functions for members. */ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
358 #define FORMEMBERS(coord, member) \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
359 for((member) = STAILQ_HEAD((coord)->members); \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
360 (member) != NULL; \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
361 (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
|
362 #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
|
363 #define ADD_MEMBER(coord, member) \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
364 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
|
365 #define RM_MEMBER(coord, member) \ |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
366 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
|
367 #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
|
368 |
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
|
369 /* 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
|
370 #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
|
371 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
|
372 (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
|
373 (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
|
374 #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
|
375 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
|
376 |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
377 /*! \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
|
378 * |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
379 * 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
|
380 * 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
|
381 */ |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
382 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
|
383 int i, j; |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
384 unsigned int val; |
121
76ba6fd61c7d
More bug of insert sort.
Thinker K.F. Li <thinker@branda.to>
parents:
119
diff
changeset
|
385 void *elm_i; |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
386 |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
387 for(i = 1; i < num; i++) { |
121
76ba6fd61c7d
More bug of insert sort.
Thinker K.F. Li <thinker@branda.to>
parents:
119
diff
changeset
|
388 elm_i = elms[i]; |
76ba6fd61c7d
More bug of insert sort.
Thinker K.F. Li <thinker@branda.to>
parents:
119
diff
changeset
|
389 val = *(unsigned int *)(elm_i + off); |
119 | 390 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
|
391 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
|
392 break; |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
393 elms[j] = elms[j - 1]; |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
394 } |
121
76ba6fd61c7d
More bug of insert sort.
Thinker K.F. Li <thinker@branda.to>
parents:
119
diff
changeset
|
395 elms[j] = elm_i; |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
396 } |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
397 } |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
398 |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
399 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
|
400 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
|
401 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
|
402 |
235 | 403 int rdman_add_gen_geos(redraw_man_t *rdman, geo_t *geo) { |
404 int r; | |
405 | |
406 r = geos_add(rdman_get_gen_geos(rdman), geo); | |
407 return r; | |
408 } | |
409 | |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
410 /*! 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
|
411 */ |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
412 #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
|
413 int r; \ |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
414 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
|
415 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
|
416 |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
417 |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
418 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
|
419 int n_areas, |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
420 area_t **areas) { |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
421 int i; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
422 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
423 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
|
424 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
|
425 return 1; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
426 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
427 return 0; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
428 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
429 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
430 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
|
431 int n_areas, |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
432 area_t **areas) { |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
433 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
|
434 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
435 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
436 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
|
437 poses[0][0] = area->x; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
438 poses[0][1] = area->y; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
439 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
|
440 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
|
441 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
442 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
443 /* Maintain Lists */ |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
444 |
152
2b316b5d65f9
Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
151
diff
changeset
|
445 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
|
446 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
|
447 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
|
448 return OK; |
152
2b316b5d65f9
Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
151
diff
changeset
|
449 } |
2b316b5d65f9
Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
151
diff
changeset
|
450 |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
451 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
|
452 geo->flags |= GEF_DIRTY; |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
453 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
|
454 return OK; |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
455 } |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
456 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
457 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
|
458 int r; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
459 |
530
cd41d9033567
Ignore small dirty area.
Thinker K.F. Li <thinker@branda.to>
parents:
528
diff
changeset
|
460 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
|
461 return OK; |
cd41d9033567
Ignore small dirty area.
Thinker K.F. Li <thinker@branda.to>
parents:
528
diff
changeset
|
462 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
463 rdman->n_dirty_areas++; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
464 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
|
465 return r == 0? OK: ERR; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
466 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
467 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
468 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
|
469 coord_set_zeroing(coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
470 ADD_DATA(coords, zeroing_coords, coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
471 return OK; |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
472 } |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
473 |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
474 static int add_dirty_pcache_area_coord(redraw_man_t *rdman, coord_t *coord) { |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
475 coord_set_flags(coord, COF_DIRTY_PCACHE_AREA); |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
476 ADD_DATA(coords, dirty_pcache_area_coords, coord); |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
477 return OK; |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
478 } |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
479 |
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
|
480 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
|
481 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
|
482 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
|
483 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
|
484 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
485 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
|
486 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
|
487 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
|
488 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
|
489 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
|
490 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
|
491 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
|
492 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
|
493 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
494 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
495 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
|
496 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
|
497 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
|
498 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
499 return OK; |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
500 } |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
501 |
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
|
502 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
|
503 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
|
504 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
|
505 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
506 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
|
507 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
|
508 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
|
509 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
510 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
|
511 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
512 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
513 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
|
514 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
|
515 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
|
516 } |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
517 |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
518 |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
519 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
520 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
|
521 #ifndef UNITTEST |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
522 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
|
523 mbe_t *cr; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
524 |
450
a417fd980228
Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
525 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
|
526 w, h); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
527 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
|
528 |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
529 return cr; |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
530 #else |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
531 return NULL; |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
532 #endif |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
533 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
534 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
535 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
|
536 #ifndef UNITTEST |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
537 mbe_destroy(canvas); |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
538 #endif |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
539 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
540 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
541 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
|
542 #ifndef UNITTEST |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
543 mbe_surface_t *surface; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
544 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
545 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
|
546 *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
|
547 *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
|
548 #else |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
549 *w = 0; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
550 *h = 0; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
551 #endif |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
552 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
553 |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
554 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
|
555 int off = 0; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
556 geo_t *vgeo; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
557 |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
558 FORMEMBERS(coord, vgeo) { |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
559 if(vgeo == geo) |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
560 return off; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
561 off++; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
562 } |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
563 return -1; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
564 } |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
565 |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
566 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
|
567 ADD_MEMBER(coord, geo); |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
568 coord->num_members++; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
569 } |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
570 |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
571 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
|
572 int off; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
573 coord_t *child; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
574 |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
575 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
|
576 if(off < 0) |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
577 return; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
578 FORCHILDREN(coord, child) { |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
579 if(child->before_pmem >= off) |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
580 child->before_pmem--; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
581 } |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
582 |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
583 RM_MEMBER(coord, geo); |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
584 coord->num_members--; |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
585 } |
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
586 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
587 static coord_canvas_info_t *coord_canvas_info_new(redraw_man_t *rdman, |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
588 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
|
589 mbe_t *canvas) { |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
590 coord_canvas_info_t *info; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
591 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
592 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
|
593 if(info == NULL) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
594 return info; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
595 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
596 info->owner = coord; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
597 info->canvas = canvas; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
598 DARRAY_INIT(&info->dirty_areas); |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
599 |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
600 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
|
601 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
|
602 info->pcache_last_area = &info->pcache_areas[1]; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
603 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
604 return info; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
605 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
606 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
607 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
|
608 coord_canvas_info_t *info) { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
609 DARRAY_DESTROY(&info->dirty_areas); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
610 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
|
611 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
612 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
613 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
|
614 } |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
615 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
616 int redraw_man_init(redraw_man_t *rdman, mbe_t *cr, mbe_t *backend) { |
12 | 617 extern void redraw_man_destroy(redraw_man_t *rdman); |
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
|
618 extern int _paint_color_size; |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
619 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
|
620 extern void addrm_monitor_hdlr(event_t *evt, void *arg); |
12 | 621 |
622 memset(rdman, 0, sizeof(redraw_man_t)); | |
623 | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
624 DARRAY_INIT(&rdman->dirty_coords); |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
625 DARRAY_INIT(&rdman->dirty_pcache_area_coords); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
626 DARRAY_INIT(&rdman->dirty_geos); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
627 DARRAY_INIT(&rdman->gen_geos); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
628 DARRAY_INIT(&rdman->zeroing_coords); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
629 |
12 | 630 rdman->geo_pool = elmpool_new(sizeof(geo_t), 128); |
631 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
|
632 rdman->shnode_pool = elmpool_new(sizeof(shnode_t), 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
|
633 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
|
634 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
|
635 rdman->paint_color_pool = elmpool_new(_paint_color_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
|
636 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
|
637 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
|
638 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
|
639 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
|
640 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
|
641 goto err; |
146
e96a584487af
Use elmpool to manage paint_color_t objects.
Thinker K.F. Li <thinker@branda.to>
parents:
141
diff
changeset
|
642 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
643 rdman->ob_factory.subject_alloc = ob_subject_alloc; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
644 rdman->ob_factory.subject_free = ob_subject_free; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
645 rdman->ob_factory.observer_alloc = ob_observer_alloc; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
646 rdman->ob_factory.observer_free = ob_observer_free; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
647 rdman->ob_factory.get_parent_subject = ob_get_parent_subject; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
648 |
154 | 649 rdman->redraw = |
650 subject_new(&rdman->ob_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
|
651 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
|
652 subject_new(&rdman->ob_factory, rdman, OBJT_RDMAN); |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
653 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
|
654 goto err; |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
655 |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
656 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
|
657 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
|
658 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
|
659 goto err; |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
660 |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
661 rdman->last_mouse_over = NULL; |
154 | 662 |
12 | 663 rdman->root_coord = elmpool_elm_alloc(rdman->coord_pool); |
664 if(rdman->root_coord == NULL) | |
665 redraw_man_destroy(rdman); | |
13 | 666 rdman->n_coords = 1; |
12 | 667 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
|
668 mb_prop_store_init(&rdman->root_coord->obj.props, rdman->pent_pool); |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
669 rdman->root_coord->mouse_event = subject_new(&rdman->ob_factory, |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
670 rdman->root_coord, |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
671 OBJT_COORD); |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
672 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
|
673 rdman->root_coord->canvas_info = |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
674 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
|
675 rdman->root_coord->opacity = 1; |
12 | 676 |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
677 rdman->cr = cr; |
24
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
678 rdman->backend = backend; |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
679 |
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
|
680 STAILQ_INIT(rdman->shapes); |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
681 |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
682 /* \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
|
683 * 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
|
684 */ |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
685 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
|
686 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
|
687 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
|
688 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
|
689 |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
251
diff
changeset
|
690 mb_prop_store_init(&rdman->props, rdman->pent_pool); |
12 | 691 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
|
692 |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
693 err: |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
694 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
|
695 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
|
696 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
|
697 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
|
698 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
|
699 elmpool_free(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
|
700 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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 elmpool_free(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
|
706 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
|
707 elmpool_free(rdman->pent_pool); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
708 if(rdman->coord_canvas_pool) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
709 elmpool_free(rdman->coord_canvas_pool); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
710 DARRAY_DESTROY(&rdman->dirty_coords); |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
711 DARRAY_DESTROY(&rdman->dirty_pcache_area_coords); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
712 DARRAY_DESTROY(&rdman->dirty_geos); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
713 DARRAY_DESTROY(&rdman->gen_geos); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
714 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
|
715 return ERR; |
12 | 716 } |
717 | |
718 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
|
719 coord_t *coord, *saved_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
|
720 shape_t *shape, *saved_shape; |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
721 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
|
722 |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
251
diff
changeset
|
723 mb_prop_store_destroy(&rdman->props); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
251
diff
changeset
|
724 |
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
|
725 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
|
726 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
|
727 |
489
23c7667b3ec0
Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
728 /* 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
|
729 * successfully. |
23c7667b3ec0
Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
730 */ |
23c7667b3ec0
Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
731 DARRAY_CLEAN(&rdman->dirty_coords); |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
732 DARRAY_CLEAN(&rdman->dirty_pcache_area_coords); |
489
23c7667b3ec0
Fix a potential bug when destroy a rdman.
Thinker K.F. Li <thinker@branda.to>
parents:
473
diff
changeset
|
733 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
|
734 |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
735 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
|
736 while(coord) { |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
737 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
|
738 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
|
739 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
|
740 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
|
741 } |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
742 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
|
743 } |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
744 /* 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
|
745 * caller; for canvas |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
746 */ |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
747 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
748 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
|
749 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
|
750 } |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
751 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
752 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
|
753 |
5d0b2761f89c
Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents:
489
diff
changeset
|
754 /* 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
|
755 * 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
|
756 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
757 |
12 | 758 elmpool_free(rdman->coord_pool); |
759 elmpool_free(rdman->geo_pool); | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
760 elmpool_free(rdman->shnode_pool); |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
761 elmpool_free(rdman->observer_pool); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
762 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
|
763 elmpool_free(rdman->paint_color_pool); |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
764 elmpool_free(rdman->pent_pool); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
765 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
|
766 |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
767 DARRAY_DESTROY(&rdman->dirty_coords); |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
768 DARRAY_DESTROY(&rdman->dirty_pcache_area_coords); |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
769 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
|
770 DARRAY_DESTROY(&rdman->gen_geos); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
771 DARRAY_DESTROY(&rdman->zeroing_coords); |
12 | 772 } |
773 | |
774 | |
775 #define ASSERT(x) | |
776 /* | |
777 * Change transformation matrix | |
778 * - update aggregated transformation matrix | |
779 * - of coord_t object been changed. | |
780 * - of children coord_t objects. | |
781 * - redraw members of coord_t objects. | |
782 * - redraw shape objects they are overlaid with members. | |
783 * - find out overlaid shape objects. | |
784 * - geo_t of a coord_t object | |
785 * - can make finding more efficiency. | |
786 * - fill overlay geo_t objects of members. | |
787 * | |
788 * Change a shape object | |
789 * - redraw changed object. | |
790 * - redraw shape objects they are overlaid with changed object. | |
791 * - find out overlaid shape objects. | |
792 * | |
793 * That coord and geo of shape objects are setted by user code | |
794 * give user code a chance to collect coord and geo objects together | |
795 * and gain interest of higher cache hit rate. | |
796 */ | |
797 | |
798 int rdman_add_shape(redraw_man_t *rdman, shape_t *shape, coord_t *coord) { | |
799 geo_t *geo; | |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
800 int r; |
12 | 801 |
802 geo = elmpool_elm_alloc(rdman->geo_pool); | |
803 if(geo == NULL) | |
804 return ERR; | |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
805 |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
806 geo_init(geo); |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
807 geo->mouse_event = subject_new(&rdman->ob_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
|
808 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
|
809 |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
810 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
|
811 |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
812 /* 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
|
813 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
|
814 if(r != OK) |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
815 return ERR; |
13 | 816 |
12 | 817 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
|
818 sh_attach_geo(shape, geo); |
12 | 819 |
820 return OK; | |
821 } | |
822 | |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
823 /*! \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
|
824 * |
154 | 825 * \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
|
826 * \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
|
827 * is postponsed. |
58 | 828 * \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
|
829 */ |
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 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
|
831 geo_t *geo; |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
832 int r; |
139
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
833 |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
834 geo = shape->geo; |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
835 |
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
|
836 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
|
837 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
|
838 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
|
839 |
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
|
840 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
|
841 sh_hide(shape); |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
842 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
|
843 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
|
844 if(r != OK) |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
845 return ERR; |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
846 } |
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
|
847 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
|
848 if(r != OK) |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
849 return ERR; |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
850 return OK; |
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 |
490
5d0b2761f89c
Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents:
489
diff
changeset
|
853 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
|
854 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
|
855 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
|
856 rdman_paint_fill(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
|
857 |
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
|
858 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
|
859 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
|
860 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
|
861 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
|
862 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
|
863 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
|
864 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
865 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
|
866 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
|
867 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
|
868 |
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
869 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
|
870 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
|
871 |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
872 |
12 | 873 return OK; |
874 } | |
875 | |
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
|
876 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
|
877 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
|
878 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
879 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
|
880 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
|
881 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
|
882 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
|
883 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
884 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
|
885 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
886 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
887 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
|
888 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
|
889 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
|
890 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
891 if(rdman_is_dirty(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
|
892 if(!(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
|
893 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
|
894 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
|
895 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
|
896 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
|
897 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
898 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
899 /* 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
|
900 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
|
901 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
|
902 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
|
903 RM_PAINTMEMBER(paint, 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
|
904 |
5d0b2761f89c
Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents:
489
diff
changeset
|
905 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
|
906 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
|
907 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
|
908 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
|
909 rdman_paint_fill(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
|
910 |
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
|
911 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
|
912 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
913 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
|
914 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
915 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
|
916 RM_PAINTMEMBER(paint, 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
|
917 |
5d0b2761f89c
Reset stroke and fill for shapes when a paint is freed.
Thinker K.F. Li <thinker@branda.to>
parents:
489
diff
changeset
|
918 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
|
919 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
|
920 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
|
921 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
|
922 rdman_paint_fill(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
|
923 |
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
|
924 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
|
925 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
926 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
927 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
|
928 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
|
929 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
930 |
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 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
|
932 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
|
933 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
|
934 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
|
935 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
936 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
|
937 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
|
938 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
|
939 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
|
940 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
|
941 } |
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 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
943 } |
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 |
12 | 945 coord_t *rdman_coord_new(redraw_man_t *rdman, coord_t *parent) { |
13 | 946 coord_t *coord, *root_coord; |
947 coord_t *visit; | |
12 | 948 |
949 coord = elmpool_elm_alloc(rdman->coord_pool); | |
950 if(coord == NULL) | |
951 return NULL; | |
952 | |
953 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
|
954 mb_prop_store_init(&coord->obj.props, rdman->pent_pool); |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
955 coord->mouse_event = subject_new(&rdman->ob_factory, |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
956 coord, |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
957 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
|
958 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
|
959 /*! \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
|
960 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
|
961 if(parent) |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
962 coord->canvas_info = parent->canvas_info; |
13 | 963 rdman->n_coords++; |
964 | |
965 coord->order = ++rdman->next_coord_order; | |
966 if(coord->order == 0) { | |
967 rdman->next_coord_order = 0; | |
968 root_coord = visit = rdman->root_coord; | |
969 /* skip root coord. */ | |
970 visit = preorder_coord_subtree(root_coord, visit); | |
971 while(visit) { | |
972 visit->order = ++rdman->next_coord_order; | |
973 visit = preorder_coord_subtree(root_coord, visit); | |
974 } | |
975 } | |
12 | 976 |
139
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
977 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
|
978 |
151
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
150
diff
changeset
|
979 /* 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
|
980 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
|
981 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
|
982 |
12 | 983 return coord; |
984 } | |
985 | |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
986 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
|
987 int r; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
988 |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
989 if(coord->flags & COF_FREE) |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
990 return ERR; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
991 |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
992 coord->flags |= COF_FREE; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
993 coord_hide(coord); |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
994 if(!(coord->flags & COF_DIRTY)) { |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
995 r = add_dirty_coord(rdman, coord); |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
996 if(r != OK) |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
997 return ERR; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
998 } |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
999 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
|
1000 if(r != OK) |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1001 return ERR; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1002 return OK; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1003 } |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1004 |
12 | 1005 /*! \brief Free a coord of a redraw_man_t object. |
1006 * | |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1007 * 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
|
1008 * |
12 | 1009 * \param coord is a coord_t without children and members. |
1010 * \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
|
1011 * |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1012 * \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
|
1013 * or members postponsed for free. |
12 | 1014 */ |
1015 int rdman_coord_free(redraw_man_t *rdman, coord_t *coord) { | |
1016 coord_t *parent; | |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
1017 coord_t *child; |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
1018 geo_t *member; |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1019 int cm_cnt; /* children & members counter */ |
12 | 1020 |
1021 parent = coord->parent; | |
1022 if(parent == NULL) | |
1023 return ERR; | |
1024 | |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1025 cm_cnt = 0; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1026 FORCHILDREN(coord, child) { |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1027 cm_cnt++; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1028 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
|
1029 return ERR; |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1030 } |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1031 FORMEMBERS(coord, member) { |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1032 cm_cnt++; |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1033 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
|
1034 return ERR; |
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
1035 } |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1036 |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1037 if(cm_cnt || rdman_is_dirty(rdman)) |
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1038 return rdman_coord_free_postponse(rdman, coord); |
12 | 1039 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1040 /* Free canvas and canvas_info (\ref redraw) */ |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1041 if(coord_is_cached(coord)) { |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1042 canvas_free(_coord_get_canvas(coord)); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1043 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
|
1044 } |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
1045 |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
1046 RM_CHILD(parent, coord); |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
1047 subject_free(coord->mouse_event); |
251
f08b3ba9c1d8
Remove potential memory address error.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
1048 mb_prop_store_destroy(&coord->obj.props); |
12 | 1049 elmpool_elm_free(rdman->coord_pool, coord); |
13 | 1050 rdman->n_coords--; |
1051 | |
1052 return OK; | |
1053 } | |
1054 | |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
1055 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
|
1056 geo_t *member; |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1057 shape_t *shape; |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1058 int r; |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1059 |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1060 FORMEMBERS(coord, member) { |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1061 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
|
1062 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
|
1063 if(r != OK) |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1064 return ERR; |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1065 } |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1066 return OK; |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1067 } |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1068 |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1069 /*! \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
|
1070 * |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1071 * 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
|
1072 */ |
154 | 1073 int rdman_coord_subtree_free(redraw_man_t *rdman, coord_t *subtree) { |
1074 coord_t *coord, *prev_coord; | |
1075 int r; | |
1076 | |
1077 if(subtree == NULL) | |
1078 return OK; | |
1079 | |
1080 prev_coord = postorder_coord_subtree(subtree, NULL); | |
1081 for(coord = postorder_coord_subtree(subtree, prev_coord); | |
1082 coord != NULL; | |
1083 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
|
1084 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
|
1085 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
|
1086 if(r != OK) |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1087 return ERR; |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1088 |
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
|
1089 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
|
1090 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
|
1091 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
|
1092 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
1093 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
|
1094 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
1095 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
|
1096 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
|
1097 if(r != OK) |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1098 return ERR; |
45d9a1e2764d
Add mb_subtree_free animate action and fix bugs.
Thinker K.F. Li <thinker@branda.to>
parents:
192
diff
changeset
|
1099 |
154 | 1100 r = rdman_coord_free(rdman, prev_coord); |
1101 if(r != OK) | |
1102 return ERR; | |
1103 } | |
1104 | |
1105 return OK; | |
1106 } | |
1107 | |
13 | 1108 /*! \brief Mark a coord is changed. |
1109 * | |
1110 * 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
|
1111 * 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
|
1112 * 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
|
1113 * redraw shapes grouped by it. |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1114 * |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1115 * 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
|
1116 * dirty. |
13 | 1117 */ |
1118 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
|
1119 coord_t *child; |
13 | 1120 |
1121 if(coord->flags & COF_DIRTY) | |
1122 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
|
1123 |
152
2b316b5d65f9
Refactory code snippets for making coords dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
151
diff
changeset
|
1124 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
|
1125 |
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
|
1126 #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
|
1127 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
|
1128 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
|
1129 #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
|
1130 |
151
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
150
diff
changeset
|
1131 /* 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
|
1132 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
|
1133 child != NULL; |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
1134 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
|
1135 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
|
1136 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
|
1137 continue; |
151
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
150
diff
changeset
|
1138 } |
d11aa8fc06c7
Fix bug of tanks do not show at right places.
Thinker K.F. Li <thinker@branda.to>
parents:
150
diff
changeset
|
1139 |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1140 if(coord_is_cached(child)) { |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1141 preorder_coord_skip_subtree(child); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1142 continue; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1143 } |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1144 |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1145 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
|
1146 } |
13 | 1147 |
1148 return OK; | |
1149 } | |
1150 | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
1151 static int _rdman_shape_changed(redraw_man_t *rdman, shape_t *shape) { |
13 | 1152 geo_t *geo; |
1153 int r; | |
1154 | |
1155 geo = shape->geo; | |
1156 | |
1157 if(geo->flags & GEF_DIRTY) | |
1158 return OK; | |
1159 | |
1160 r = add_dirty_geo(rdman, geo); | |
1161 if(r == ERR) | |
1162 return ERR; | |
12 | 1163 |
1164 return OK; | |
1165 } | |
1166 | |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
1167 /*! \brief Mark a shape is changed. |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
1168 * |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
1169 * 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
|
1170 * put into dirty_geos list. |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
1171 */ |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
1172 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
|
1173 return _rdman_shape_changed(rdman, shape); |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
1174 } |
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
1175 |
29 | 1176 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
|
1177 shnode_t *shnode; |
29 | 1178 int r; |
1179 | |
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
|
1180 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
|
1181 r = _rdman_shape_changed(rdman, shnode->shape); |
29 | 1182 if(r != OK) |
1183 return ERR; | |
1184 } | |
1185 return OK; | |
1186 } | |
1187 | |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1188 |
28 | 1189 /* Clean dirties */ |
1190 | |
57
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1191 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
|
1192 while(coord) { |
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1193 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
|
1194 return 1; |
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1195 coord = coord->parent; |
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1196 } |
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1197 return 0; |
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1198 } |
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1199 |
28 | 1200 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
|
1201 switch(MBO_TYPE(shape)) { |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
194
diff
changeset
|
1202 case MBO_PATH: |
28 | 1203 sh_path_transform(shape); |
1204 break; | |
435
2bdd4f5dd2ca
Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents:
430
diff
changeset
|
1205 #ifdef SH_TEXT |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
194
diff
changeset
|
1206 case MBO_TEXT: |
28 | 1207 sh_text_transform(shape); |
1208 break; | |
435
2bdd4f5dd2ca
Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents:
430
diff
changeset
|
1209 #endif |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
194
diff
changeset
|
1210 case MBO_RECT: |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
1211 sh_rect_transform(shape); |
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
1212 break; |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
1213 case MBO_IMAGE: |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
1214 sh_image_transform(shape); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
1215 break; |
435
2bdd4f5dd2ca
Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents:
430
diff
changeset
|
1216 #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
|
1217 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
|
1218 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
|
1219 break; |
435
2bdd4f5dd2ca
Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents:
430
diff
changeset
|
1220 #endif |
28 | 1221 #ifdef UNITTEST |
1222 default: | |
1223 sh_dummy_transform(shape); | |
1224 break; | |
1225 #endif /* UNITTEST */ | |
1226 } | |
1227 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
|
1228 |
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1229 if(is_coord_subtree_hidden(shape->coord)) |
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
|
1230 sh_hide(shape); |
57
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
38
diff
changeset
|
1231 else |
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
|
1232 sh_show(shape); |
28 | 1233 } |
1234 | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1235 /*! \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
|
1236 * |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
1237 * 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
|
1238 * \sa |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
1239 * - \ref redraw |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
1240 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1241 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
|
1242 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
|
1243 return; |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
1244 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1245 if(coord->opacity != 1 || coord_is_cached(coord)) { |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1246 if(!coord_is_cached(coord)) { |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1247 /* 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
|
1248 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
|
1249 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
|
1250 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
1251 } else { |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1252 if(coord_is_cached(coord)) { |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1253 canvas_free(_coord_get_canvas(coord)); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1254 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
|
1255 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
|
1256 } |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1257 /* 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
|
1258 * 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
|
1259 * 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
|
1260 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1261 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
|
1262 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
1263 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
1264 |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1265 /* \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
|
1266 */ |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1267 static void compute_cached_2_pdev_matrix(coord_t *coord, |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1268 co_aix canvas2pdev_matrix[6]) { |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1269 coord_t *parent; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1270 co_aix *aggr; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1271 co_aix *matrix, *paggr; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1272 co_aix scale_x, scale_y; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1273 co_aix shift_x, shift_y; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1274 co_aix canvas2p[6]; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1275 |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1276 aggr = coord_get_aggr_matrix(coord); |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1277 matrix = coord->matrix; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1278 parent = coord->parent; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1279 paggr = coord_get_aggr_matrix(parent); |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1280 |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1281 scale_x = matrix[0] / aggr[0]; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1282 scale_y = matrix[3] / aggr[3]; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1283 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
|
1284 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
|
1285 |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1286 canvas2p[0] = scale_x; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1287 canvas2p[1] = 0; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1288 canvas2p[2] = shift_x; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1289 canvas2p[3] = 0; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1290 canvas2p[4] = scale_y; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1291 canvas2p[5] = shift_y; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1292 |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1293 matrix_mul(paggr, canvas2p, canvas2pdev_matrix); |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1294 } |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1295 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1296 /*! \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
|
1297 * |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1298 * 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
|
1299 * 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
|
1300 * 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
|
1301 * |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1302 * 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
|
1303 * 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
|
1304 * 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
|
1305 * ancestral cached coord. |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1306 */ |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1307 static void compute_pcache_area(coord_t *coord) { |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1308 co_aix cached2pdev[6]; |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1309 int c_w, c_h; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1310 canvas_t *canvas; |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1311 coord_canvas_info_t *canvas_info; |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1312 co_aix poses[4][2]; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1313 |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1314 canvas_info = coord->canvas_info; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1315 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
|
1316 area_t *); |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1317 compute_cached_2_pdev_matrix(coord, cached2pdev); |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1318 |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1319 canvas = _coord_get_canvas(coord); |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1320 canvas_get_size(canvas, &c_w, &c_h); |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1321 |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1322 poses[0][0] = 0; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1323 poses[0][1] = 0; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1324 poses[1][0] = c_w; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1325 poses[1][1] = c_h; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1326 poses[2][0] = 0; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1327 poses[2][1] = c_h; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1328 poses[3][0] = c_w; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1329 poses[3][1] = 0; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1330 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
|
1331 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
|
1332 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
|
1333 matrix_trans_pos(cached2pdev, &poses[3][0], &poses[3][1]); |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1334 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1335 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
|
1336 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1337 coord_set_flags(coord, COF_DIRTY_PCACHE_AREA); |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1338 } |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1339 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1340 /*! \brief Compute area of a coord. |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1341 */ |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1342 static int |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1343 compute_area(coord_t *coord) { |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1344 static co_aix (*poses)[2]; |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1345 static int max_poses = 0; |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1346 geo_t *geo; |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1347 int cnt, pos_cnt; |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1348 |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1349 cnt = 0; |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1350 FORMEMBERS(coord, geo) { |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1351 cnt++; |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1352 } |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1353 |
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
|
1354 if(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
|
1355 free(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
|
1356 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
|
1357 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
|
1358 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
|
1359 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
|
1360 } |
28 | 1361 |
1362 pos_cnt = 0; | |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
1363 FORMEMBERS(coord, geo) { |
28 | 1364 area_to_positions(geo->cur_area, poses + pos_cnt); |
1365 pos_cnt += 2; | |
1366 } | |
1367 | |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1368 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
|
1369 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1370 return OK; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1371 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1372 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1373 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
|
1374 geo_t *geo; |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1375 int r; |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1376 /*! \note poses is shared by invokings, it is not support reentrying. */ |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1377 |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1378 /* Clean member shapes. */ |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1379 FORMEMBERS(coord, geo) { |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1380 clean_shape(geo->shape); |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1381 } |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1382 |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1383 r = compute_area(coord); |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1384 if(r != OK) |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1385 return ERR; |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1386 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1387 return OK; |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1388 } |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1389 |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1390 /*! \brief Clean dirty coords. |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1391 * |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1392 * 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
|
1393 * 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
|
1394 * 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
|
1395 * |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1396 * \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
|
1397 */ |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1398 static int clean_coord(redraw_man_t *rdman, coord_t *coord) { |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1399 coord_t *child; |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1400 int r; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1401 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1402 setup_canvas_info(rdman, coord); |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1403 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1404 compute_aggr(coord); |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1405 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1406 /* 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
|
1407 * 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
|
1408 * 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
|
1409 * 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
|
1410 */ |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1411 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
|
1412 if(r != OK) |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1413 return ERR; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1414 |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1415 add_dirty_area(rdman, coord, coord->cur_area); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1416 add_dirty_area(rdman, coord, coord->last_area); |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1417 |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1418 coord_clear_flags(coord, COF_DIRTY); |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1419 coord_set_flags(coord, COF_JUST_CLEAN); |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1420 |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1421 FORCHILDREN(coord, child) { |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1422 if(coord_is_cached(child)) |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1423 add_dirty_pcache_area_coord(rdman, child); |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1424 } |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1425 |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1426 return OK; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1427 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1428 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1429 /*! \brief Clean coord_t objects. |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1430 * |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1431 * 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
|
1432 * |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1433 * 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
|
1434 * 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
|
1435 */ |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1436 static int clean_rdman_coords(redraw_man_t *rdman) { |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1437 coord_t *coord, *child; |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1438 coord_t **dirty_coords; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1439 int n_dirty_coords; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1440 int i, r; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1441 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1442 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
|
1443 if(n_dirty_coords > 0) { |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1444 dirty_coords = rdman->dirty_coords.ds; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1445 _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
|
1446 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
|
1447 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
|
1448 coord = dirty_coords[i]; |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1449 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
|
1450 continue; |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1451 SWAP(coord->cur_area, coord->last_area, area_t *); |
327
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1452 r = clean_coord(rdman, coord); |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1453 if(r != OK) |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1454 return ERR; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1455 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1456 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1457 return OK; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1458 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1459 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1460 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
|
1461 int i; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1462 int n_dirty_geos; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1463 geo_t **dirty_geos; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1464 geo_t *visit_geo; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1465 coord_t *coord; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1466 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1467 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
|
1468 if(n_dirty_geos > 0) { |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1469 dirty_geos = rdman->dirty_geos.ds; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1470 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
|
1471 visit_geo = dirty_geos[i]; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1472 if(!(visit_geo->flags & GEF_DIRTY)) |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1473 continue; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1474 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1475 clean_shape(visit_geo->shape); |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1476 coord = geo_get_coord(visit_geo); |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1477 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
|
1478 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
|
1479 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1480 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1481 |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1482 return OK; |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1483 } |
85b8bb36fe71
Move and update in source documents
Thinker K.F. Li <thinker@branda.to>
parents:
322
diff
changeset
|
1484 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1485 /*! \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
|
1486 * |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1487 * 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
|
1488 * 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
|
1489 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1490 static |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1491 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
|
1492 coord_t *cur; |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1493 area_t *area, *saved_area; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1494 co_aix min_x, min_y; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1495 co_aix max_x, max_y; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1496 co_aix x, y; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1497 int w, h; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1498 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
|
1499 mbe_t *canvas; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1500 co_aix *aggr; |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1501 co_aix poses[4][2]; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1502 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1503 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
|
1504 abort(); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1505 if(!(coord_is_zeroing(coord))) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1506 abort(); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1507 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1508 coord_clear_zeroing(coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1509 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1510 /* |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1511 * 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
|
1512 */ |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1513 area = coord_get_area(coord); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1514 min_x = area->x; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1515 min_y = area->y; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1516 max_x = min_x + area->w; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1517 max_y = min_y + area->h; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1518 |
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
|
1519 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
|
1520 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
|
1521 cur = preorder_coord_subtree(coord, cur)) { |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1522 area = coord_get_area(cur); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1523 if(area->x < min_x) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1524 min_x = area->x; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1525 if(area->y < min_y) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1526 min_y = area->y; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1527 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1528 x = area->x + area->w; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1529 y = area->y + area->h; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1530 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1531 if(x > max_x) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1532 max_x = x; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1533 if(y > max_y) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1534 max_y = y; |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1535 if(coord_is_cached(cur)) |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1536 preorder_coord_skip_subtree(cur); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1537 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1538 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1539 w = max_x - min_x; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1540 h = max_y - min_y; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1541 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1542 canvas = _coord_get_canvas(coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1543 if(canvas) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1544 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
|
1545 else |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1546 c_w = c_h = 0; |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1547 |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1548 /* 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
|
1549 * 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
|
1550 * 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
|
1551 * and avoid redraw all descendants. |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1552 * |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1553 * 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
|
1554 * 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
|
1555 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1556 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
|
1557 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
|
1558 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
|
1559 /* Canvas fully cover sub-graphic. */ |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1560 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
|
1561 return; |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1562 } |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1563 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1564 /* |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1565 * 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
|
1566 * 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
|
1567 * zeroing coord. |
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 FOR_COORDS_PREORDER(coord, cur) { |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1570 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
|
1571 /* |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1572 * 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
|
1573 * 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
|
1574 * level of cached. |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1575 */ |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1576 preorder_coord_skip_subtree(cur); |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1577 } |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1578 /* Shift space */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1579 aggr = coord_get_aggr_matrix(cur); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1580 aggr[3] -= min_x; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1581 aggr[5] -= min_y; |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1582 |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1583 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
|
1584 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1585 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1586 /* |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1587 * Setup canvas |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1588 * |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1589 * 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
|
1590 * 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
|
1591 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1592 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
|
1593 if(canvas) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1594 canvas_free(canvas); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1595 canvas = canvas_new(w, h); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1596 _coord_set_canvas(coord, canvas); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1597 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1598 |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1599 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
|
1600 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1601 |
519
7a1b17ebb3b4
Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
1602 /*! \brief Add canvas owner of dirty geos to redraw_man_t::zeroing_coords. |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1603 * |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1604 * All possible coords that need a zeroing have at least one dirty geo. |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1605 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1606 static int add_rdman_zeroing_coords(redraw_man_t *rdman) { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1607 int i; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1608 int n_dirty_geos; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1609 geo_t **dirty_geos, *geo; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1610 int n_dirty_coords; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1611 coord_t **dirty_coords, *coord; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1612 |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1613 /* 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
|
1614 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
|
1615 dirty_geos = rdman->dirty_geos.ds; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1616 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
|
1617 geo = dirty_geos[i]; |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1618 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
|
1619 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
|
1620 if(coord_is_root(coord)) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1621 break; |
525
f9326e955417
Does not add root coord to zeroing list
Thinker K.F. Li <thinker@branda.to>
parents:
524
diff
changeset
|
1622 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
|
1623 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
|
1624 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1625 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1626 |
521
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1627 /* 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
|
1628 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
|
1629 dirty_coords = rdman->dirty_coords.ds; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1630 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
|
1631 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
|
1632 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
|
1633 if(coord_is_root(coord)) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1634 break; |
525
f9326e955417
Does not add root coord to zeroing list
Thinker K.F. Li <thinker@branda.to>
parents:
524
diff
changeset
|
1635 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
|
1636 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
|
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 |
519
7a1b17ebb3b4
Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
1640 /* 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
|
1641 FOR_COORDS_PREORDER(rdman->root_coord, coord) { |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1642 if(!coord_is_cached(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
|
1643 continue; /* skip coords that is not cached */ |
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
|
1644 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1645 if(!coord_get_flags(coord, COF_TEMP_MARK)) { |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1646 if(coord_get_flags(coord, COF_DIRTY_PCACHE_AREA)) |
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
1647 add_dirty_pcache_area_coord(rdman, coord); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1648 preorder_coord_skip_subtree(coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1649 continue; |
28 | 1650 } |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1651 add_zeroing_coord(rdman, coord); |
519
7a1b17ebb3b4
Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
1652 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1653 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
|
1654 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1655 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1656 return OK; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1657 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1658 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1659 /*! \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
|
1660 * |
538
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1661 * \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
|
1662 * 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
|
1663 * descendants. |
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 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
|
1666 int i; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1667 coords_t *all_zeroing; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1668 coord_t *coord; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1669 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1670 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
|
1671 /*! 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
|
1672 * |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1673 * 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
|
1674 * 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
|
1675 * 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
|
1676 * 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
|
1677 * 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
|
1678 * 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
|
1679 * 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
|
1680 * 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
|
1681 */ |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1682 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
|
1683 coord = all_zeroing->ds[i]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1684 zeroing_coord(rdman, coord); |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1685 compute_pcache_area(coord); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1686 } |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1687 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1688 return OK; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1689 } |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1690 |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1691 /*! \brief Compute pcache_area for coords whoes pcache_area is dirty. |
538
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1692 * |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1693 * coord_t::dirty_pcache_area_coords also includes part of coords in |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1694 * coord_t::zeroing_coords. The pcache_area of coords that is in |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1695 * coord_t::dirty_pcache_area_coords, but is not in |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1696 * coord_t::zeroing_coords should be computed here. |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1697 * zeroing_rdman_coords() is responsible for computing pcache_area for |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1698 * zeroing ones. |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1699 */ |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1700 static int |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1701 compute_rdman_coords_pcache_area(redraw_man_t *rdman) { |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1702 coords_t *all_coords; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1703 coord_t *coord; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1704 int i; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1705 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1706 all_coords = &rdman->dirty_pcache_area_coords; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1707 for(i = 0; i < all_coords->num; i++) { |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1708 coord = all_coords->ds[i]; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1709 if(coord_get_flags(coord, COF_DIRTY_PCACHE_AREA)) |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1710 compute_pcache_area(coord); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1711 } |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1712 return OK; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1713 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1714 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1715 /*! \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
|
1716 * |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1717 * 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
|
1718 * 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
|
1719 * 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
|
1720 */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1721 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
|
1722 coord_t *coord) { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1723 int i; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1724 int n_areas; |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1725 int enable_poses1 = 0; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1726 co_aix poses0[2][2], poses1[2][2]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1727 co_aix reverse[6]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1728 co_aix canvas2pdev_matrix[6]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1729 area_t **areas, *area; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1730 area_t *area0, *area1; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1731 coord_t *parent, *pcached_coord; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1732 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1733 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
|
1734 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
|
1735 if(n_areas == 0) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1736 abort(); /* should not happen! */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1737 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1738 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
|
1739 area1 = area0 + 1; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1740 |
532 | 1741 /* TODO: Since both cur & last area of coords are added into dirty |
1742 * area list, position of both areas shoud be adjusted for | |
1743 * all descendants when zeroing a cached coord. | |
1744 */ | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1745 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
|
1746 area = areas[i]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1747 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
|
1748 break; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1749 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1750 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1751 if(i >= n_areas) |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1752 return; |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1753 |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1754 area = areas[i++]; |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1755 poses0[0][0] = area->x; |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1756 poses0[0][1] = area->y; |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1757 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
|
1758 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
|
1759 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1760 if(i < n_areas) { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1761 area = areas[i++]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1762 poses1[0][0] = area->x; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1763 poses1[0][1] = area->y; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1764 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
|
1765 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
|
1766 } else { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1767 poses1[0][0] = 0; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1768 poses1[0][1] = 0; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1769 poses1[1][0] = 0; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1770 poses1[1][1] = 0; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1771 } |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1772 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1773 for(; i < n_areas - 1;) { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1774 /* Even areas */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1775 area = areas[i++]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1776 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
|
1777 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
|
1778 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
|
1779 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
|
1780 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
|
1781 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1782 /* Odd areas */ |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1783 area = areas[i++]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1784 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
|
1785 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
|
1786 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
|
1787 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
|
1788 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
|
1789 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1790 } |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1791 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1792 if(i < n_areas) { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1793 area = areas[i]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1794 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
|
1795 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
|
1796 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
|
1797 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
|
1798 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
|
1799 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1800 } |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1801 |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1802 parent = coord_get_parent(coord); |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1803 pcached_coord = coord_get_cached(parent); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1804 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1805 compute_cached_2_pdev_matrix(coord, canvas2pdev_matrix); |
532 | 1806 |
1807 /* 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
|
1808 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
|
1809 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
|
1810 area_init(area0, 2, poses0); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1811 add_dirty_area(rdman, pcached_coord, area0); |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1812 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1813 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
|
1814 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
|
1815 area_init(area1, 2, poses1); |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1816 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
|
1817 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1818 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
|
1819 !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
|
1820 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
|
1821 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1822 |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1823 /*! \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
|
1824 */ |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1825 #define IS_CACHE_REDRAW_ALL(co) \ |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1826 (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
|
1827 |
526
3f695a6177b2
Change typos in comment
Thinker K.F. Li <thinker@branda.to>
parents:
525
diff
changeset
|
1828 /* 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
|
1829 * |
fa2ccf39ba53
imported patch more_comment.diff
Thinker K.F. Li <thinker@branda.to>
parents:
520
diff
changeset
|
1830 * 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
|
1831 * 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
|
1832 * 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
|
1833 * 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
|
1834 * 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
|
1835 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1836 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
|
1837 int i; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1838 int n_zeroing; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1839 coord_t **zeroings; |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1840 coord_t *coord, *pcached_coord; |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1841 int n_dpca_coords; /* number of dirty pcache area coords */ |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1842 coord_t **dpca_coords; /* dirty pcache area coords */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1843 |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1844 /* Add aggregated areas to parent cached one for coords in zeroing |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1845 * list |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1846 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1847 n_zeroing = rdman->zeroing_coords.num; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1848 zeroings = rdman->zeroing_coords.ds; |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1849 for(i = 0; i < n_zeroing; i++) { |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1850 if(coord_get_flags(coord, COF_TEMP_MARK)) |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1851 continue; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1852 coord_set_flags(coord, COF_TEMP_MARK); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1853 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1854 coord = zeroings[i]; |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1855 pcached_coord = coord_get_cached(coord_get_parent(coord)); |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1856 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1857 if(coord_is_root(coord) || IS_CACHE_REDRAW_ALL(pcached_coord)) |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1858 continue; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1859 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1860 if(IS_CACHE_REDRAW_ALL(coord)) { |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1861 add_dirty_area(rdman, pcached_coord, |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1862 coord_get_pcache_area(coord)); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1863 add_dirty_area(rdman, pcached_coord, |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1864 coord_get_pcache_last_area(coord)); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1865 } else { |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1866 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
|
1867 } |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1868 } |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1869 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1870 /* Add pcache_areas to parent cached one for coord that is |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1871 * non-zeroing and its parent is changed. |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1872 */ |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1873 n_dpca_coords = rdman->dirty_pcache_area_coords.num; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1874 dpca_coords = rdman->dirty_pcache_area_coords.ds; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1875 for(i = 0; i < n_dpca_coords; i++) { |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1876 if(coord_get_flags(coord, COF_TEMP_MARK)) |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1877 continue; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1878 coord_set_flags(coord, COF_TEMP_MARK); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1879 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1880 coord = dpca_coords[i]; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1881 pcached_coord = coord_get_cached(coord_get_parent(coord)); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1882 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1883 if(coord_is_root(coord) || IS_CACHE_REDRAW_ALL(pcached_coord)) |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1884 continue; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1885 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1886 add_dirty_area(rdman, pcached_coord, |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1887 coord_get_pcache_area(coord)); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1888 add_dirty_area(rdman, pcached_coord, |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1889 coord_get_pcache_last_area(coord)); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1890 } |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1891 |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1892 /* Remove temporary mark */ |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1893 for(i = 0; i < n_zeroing; i++) { |
538
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1894 coord_clear_flags(zeroings[i], COF_TEMP_MARK); |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1895 } |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1896 for(i = 0; i < n_dpca_coords; i++) { |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1897 coord_clear_flags(dpca_coords[i], COF_TEMP_MARK); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1898 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1899 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1900 return OK; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1901 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1902 |
534
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1903 /* \brief Clean dirty coords and shapes. |
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1904 * |
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1905 * 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
|
1906 * |
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1907 * - Add dirty coords and shapes to rdman. |
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1908 * - 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
|
1909 * descendants of cached descendants. |
534
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1910 * - 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
|
1911 * for dirty coords. |
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1912 * - 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
|
1913 * different from other coords. |
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1914 * - Compute new area for every dirty coord. |
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1915 * - 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
|
1916 * - 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
|
1917 * 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
|
1918 * 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
|
1919 * - 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
|
1920 * 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
|
1921 * parent coord. |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1922 * - 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
|
1923 * 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
|
1924 * 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
|
1925 * zeroing was performed after cleaning) |
534
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1926 * - 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
|
1927 * recomputed when cleaning the coord. |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1928 * - 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
|
1929 * - dirty, is, |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1930 * - dirty descendants, has. |
534
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1931 * - 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
|
1932 * 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
|
1933 * |
9f2d07a60493
Document on clean_rdman_dirties()
Thinker K.F. Li <thinker@branda.to>
parents:
532
diff
changeset
|
1934 * 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
|
1935 * 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
|
1936 * 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
|
1937 * 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
|
1938 */ |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1939 static int rdman_clean_dirties(redraw_man_t *rdman) { |
29 | 1940 int r; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1941 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
|
1942 coord_t **coords, *coord; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1943 geo_t **geos; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1944 |
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
|
1945 /* 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
|
1946 * 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
|
1947 * 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
|
1948 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1949 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
|
1950 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
|
1951 coord = coords[i]; |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1952 SWAP(coord->cur_area, coord->last_area, area_t *); |
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
|
1953 } |
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
|
1954 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1955 geos = rdman->dirty_geos.ds; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1956 for(i = 0; i < rdman->dirty_geos.num; i++) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1957 if(geos[i]->flags & GEF_DIRTY) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1958 SWAP(geos[i]->cur_area, geos[i]->last_area, area_t *); |
29 | 1959 |
1960 r = clean_rdman_coords(rdman); | |
1961 if(r != OK) | |
1962 return ERR; | |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1963 |
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
1964 /* 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
|
1965 * 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
|
1966 */ |
29 | 1967 |
1968 r = clean_rdman_geos(rdman); | |
1969 if(r != OK) | |
1970 return ERR; | |
1971 | |
531
1ad6c6192a80
Skip root coord when propagate dirty area to parent cached
Thinker K.F. Li <thinker@branda.to>
parents:
530
diff
changeset
|
1972 /* 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
|
1973 * 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
|
1974 */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1975 r = add_rdman_zeroing_coords(rdman); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1976 if(r != OK) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1977 return ERR; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1978 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1979 r = zeroing_rdman_coords(rdman); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1980 if(r != OK) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1981 return ERR; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1982 |
537
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1983 r = compute_rdman_coords_pcache_area(rdman); |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1984 if(r != OK) |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1985 return ERR; |
3a7e3c1cd6e6
[mq]: propagate_areas.diff
Thinker K.F. Li <thinker@branda.to>
parents:
536
diff
changeset
|
1986 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1987 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
|
1988 if(r != OK) |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1989 return ERR; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1990 |
538
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1991 /* |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1992 * Clear all flags setted by this function |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1993 */ |
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
|
1994 coords = rdman->dirty_coords.ds; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
1995 for(i = 0; i < rdman->dirty_coords.num; 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
|
1996 coord_clear_flags(coords[i], COF_JUST_CLEAN); |
538
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
1997 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
|
1998 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
|
1999 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
|
2000 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO); |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
2001 coords = rdman->dirty_pcache_area_coords.ds; |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
2002 for(i = 0; i < rdman->dirty_pcache_area_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
|
2003 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
|
2004 COF_JUST_CLEAN | COF_JUST_ZERO | COF_SKIP_ZERO); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2005 |
29 | 2006 return OK; |
2007 } | |
2008 | |
2009 | |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2010 /* Drawing and Redrawing |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2011 * ============================================================ |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2012 */ |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
2013 |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
25
diff
changeset
|
2014 #ifndef UNITTEST |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2015 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
|
2016 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
|
2017 } |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2018 |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2019 static void fill_path_preserve(redraw_man_t *rdman) { |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2020 mbe_fill_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
|
2021 } |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2022 |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2023 static void fill_path(redraw_man_t *rdman) { |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2024 mbe_fill(rdman->cr); |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2025 } |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2026 |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2027 static void stroke_path(redraw_man_t *rdman) { |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2028 mbe_stroke(rdman->cr); |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2029 } |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
25
diff
changeset
|
2030 #else |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2031 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
|
2032 } |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2033 |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2034 static void fill_path_preserve(redraw_man_t *rdman) { |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2035 } |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2036 |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2037 static void fill_path(redraw_man_t *rdman) { |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2038 } |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2039 |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2040 static void stroke_path(redraw_man_t *rdman) { |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2041 } |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
25
diff
changeset
|
2042 #endif |
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
25
diff
changeset
|
2043 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2044 static void draw_shape(redraw_man_t *rdman, mbe_t *cr, shape_t *shape) { |
22 | 2045 paint_t *fill, *stroke; |
18
0f3baa488a62
Support solid color paint for fill.
Thinker K.F. Li <thinker@branda.to>
parents:
17
diff
changeset
|
2046 |
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
|
2047 /*! \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
|
2048 * 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
|
2049 */ |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2050 if(shape->fill || shape->stroke) { |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
194
diff
changeset
|
2051 switch(MBO_TYPE(shape)) { |
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
194
diff
changeset
|
2052 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
|
2053 sh_path_draw(shape, cr); |
19 | 2054 break; |
435
2bdd4f5dd2ca
Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents:
430
diff
changeset
|
2055 #ifdef SH_TEXT |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
194
diff
changeset
|
2056 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
|
2057 sh_text_draw(shape, cr); |
27 | 2058 break; |
435
2bdd4f5dd2ca
Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents:
430
diff
changeset
|
2059 #endif |
196
c234ee745ceb
Start moving to mb_obj_t
Thinker K.F. Li <thinker@branda.to>
parents:
194
diff
changeset
|
2060 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
|
2061 sh_rect_draw(shape, cr); |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
2062 break; |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
2063 case MBO_IMAGE: |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
2064 sh_image_draw(shape, cr); |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
2065 break; |
435
2bdd4f5dd2ca
Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents:
430
diff
changeset
|
2066 #ifdef SH_STEXT |
427
8f900da42eed
Make sh_text_draw() passes first test case.
Thinker K.F. Li <thinker@branda.to>
parents:
424
diff
changeset
|
2067 case MBO_STEXT: |
8f900da42eed
Make sh_text_draw() passes first test case.
Thinker K.F. Li <thinker@branda.to>
parents:
424
diff
changeset
|
2068 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
|
2069 break; |
435
2bdd4f5dd2ca
Make sh_text and sh_stext optional.
Thinker K.F. Li <thinker@branda.to>
parents:
430
diff
changeset
|
2070 #endif |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2071 #ifdef UNITTEST |
19 | 2072 default: |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2073 sh_dummy_fill(shape, cr); |
19 | 2074 break; |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2075 #endif /* UNITTEST */ |
19 | 2076 } |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2077 |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2078 fill = shape->fill; |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2079 if(shape->fill) { |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2080 fill->prepare(fill, cr); |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2081 if(shape->stroke) |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2082 fill_path_preserve(rdman); |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2083 else |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2084 fill_path(rdman); |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2085 } |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2086 |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2087 stroke = shape->stroke; |
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2088 if(stroke) { |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2089 stroke->prepare(stroke, cr); |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2090 set_shape_stroke_param(shape, cr); |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
30
diff
changeset
|
2091 stroke_path(rdman); |
22 | 2092 } |
285
248a40d51473
Check in test program for sh_text_set_text for debugging. It is not working yet.
wycc
parents:
270
diff
changeset
|
2093 } |
13 | 2094 } |
2095 | |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2096 #ifndef UNITTEST |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2097 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
|
2098 mbe_clear(canvas); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2099 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2100 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2101 static void make_clip(mbe_t *cr, int n_dirty_areas, |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2102 area_t **dirty_areas) { |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2103 int i; |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2104 area_t *area; |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2105 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2106 mbe_new_path(cr); |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2107 for(i = 0; i < n_dirty_areas; i++) { |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2108 area = dirty_areas[i]; |
524
dcf4673896f4
Skip very small dirty areas.
Thinker K.F. Li <thinker@branda.to>
parents:
523
diff
changeset
|
2109 if(area->w < 0.1 || area->h < 0.1) |
dcf4673896f4
Skip very small dirty areas.
Thinker K.F. Li <thinker@branda.to>
parents:
523
diff
changeset
|
2110 continue; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2111 mbe_rectangle(cr, area->x, area->y, area->w, area->h); |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2112 } |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2113 mbe_clip(cr); |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2114 } |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2115 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2116 static void reset_clip(canvas_t *cr) { |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2117 mbe_reset_clip(cr); |
24
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2118 } |
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2119 |
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2120 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
|
2121 area_t **dirty_areas) { |
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2122 if(n_dirty_areas) |
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2123 make_clip(rdman->backend, n_dirty_areas, dirty_areas); |
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2124 |
512
d186d1e24458
Change prototype of mbe_copy_source().
Thinker K.F. Li <thinker@branda.to>
parents:
491
diff
changeset
|
2125 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
|
2126 } |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2127 #else /* UNITTEST */ |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2128 static void make_clip(mbe_t *cr, int n_dirty_areas, |
408
7f7855df2af0
Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents:
375
diff
changeset
|
2129 area_t **dirty_areas) { |
7f7855df2af0
Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents:
375
diff
changeset
|
2130 } |
7f7855df2af0
Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents:
375
diff
changeset
|
2131 |
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
|
2132 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
|
2133 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2134 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2135 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
|
2136 } |
24
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2137 |
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2138 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
|
2139 area_t **dirty_areas) { |
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2140 } |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2141 #endif /* UNITTEST */ |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2142 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2143 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
|
2144 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
|
2145 mbe_t *pcanvas, *canvas; |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2146 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
|
2147 mbe_pattern_t *pattern; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2148 co_aix reverse[6]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2149 co_aix canvas2pdev_matrix[6]; |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2150 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2151 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
|
2152 return; |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2153 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2154 compute_cached_2_pdev_matrix(coord, canvas2pdev_matrix); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2155 compute_reverse(canvas2pdev_matrix, reverse); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2156 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2157 canvas = _coord_get_canvas(coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2158 pcanvas = _coord_get_canvas(coord->parent); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2159 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
|
2160 pattern = mbe_pattern_create_for_surface(surface); |
473
ba64f928542b
Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents:
469
diff
changeset
|
2161 mbe_pattern_set_matrix(pattern, reverse); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2162 mbe_set_source(pcanvas, pattern); |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2163 mbe_paint_with_alpha(pcanvas, coord->opacity); |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2164 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2165 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2166 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
|
2167 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
|
2168 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
|
2169 int r; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2170 area_t **areas; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2171 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
|
2172 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
|
2173 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
|
2174 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
|
2175 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
|
2176 |
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
|
2177 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
|
2178 return OK; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2179 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2180 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
|
2181 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
|
2182 canvas = _coord_get_canvas(coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2183 |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
2184 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
|
2185 mem_idx = 0; |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
2186 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
|
2187 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
|
2188 if(child && child->before_pmem == mem_idx) { |
536
b6b3dbeaedf3
[mq]: pcached_area1.diff
Thinker K.F. Li <thinker@branda.to>
parents:
535
diff
changeset
|
2189 if(coord_is_cached(child)) { |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2190 if(!(child->flags & COF_HIDDEN) && |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2191 is_area_in_areas(coord_get_area(child), n_areas, areas)) { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2192 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
|
2193 dirty = 1; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2194 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2195 } else { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2196 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
|
2197 dirty |= r; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2198 } |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
2199 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
|
2200 } else { |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2201 ASSERT(member != NULL); |
150
0824f4804ee0
Fix bug of broken coord_hide() and shape_hide().
Thinker K.F. Li <thinker@branda.to>
parents:
148
diff
changeset
|
2202 if((!(member->flags & GEF_HIDDEN)) && |
0824f4804ee0
Fix bug of broken coord_hide() and shape_hide().
Thinker K.F. Li <thinker@branda.to>
parents:
148
diff
changeset
|
2203 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
|
2204 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
|
2205 dirty = 1; |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2206 } |
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
|
2207 |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
2208 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
|
2209 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
|
2210 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2211 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2212 |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2213 return dirty; |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2214 } |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2215 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2216 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
|
2217 coord_t *coord) { |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2218 area_t **areas, *area; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2219 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
|
2220 mbe_t *canvas; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2221 int i; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2222 int r; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2223 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2224 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
|
2225 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
|
2226 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2227 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
|
2228 area = areas[i]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2229 area->x = floorf(area->x); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2230 area->y = floorf(area->y); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2231 area->w = ceilf(area->w); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2232 area->h = ceilf(area->h); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2233 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2234 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2235 canvas = _coord_get_canvas(coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2236 make_clip(canvas, n_areas, areas); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2237 clear_canvas(canvas); |
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 r = draw_coord_shapes_in_dirty_areas(rdman, coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2240 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2241 reset_clip(canvas); |
441
94477e7d981e
Fix compile error: no return statement
john.cylee@gmail.com
parents:
435
diff
changeset
|
2242 |
94477e7d981e
Fix compile error: no return statement
john.cylee@gmail.com
parents:
435
diff
changeset
|
2243 return OK; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2244 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2245 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2246 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
|
2247 int num; |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
2248 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
|
2249 coord_t *coord; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2250 int i; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2251 |
538
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
2252 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
|
2253 num = rdman->zeroing_coords.num; |
a1d49b6355c3
Clear flags for clearing procedure and draw dirty cached ones
Thinker K.F. Li <thinker@branda.to>
parents:
537
diff
changeset
|
2254 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
|
2255 coord = zeroings[i]; |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2256 draw_dirty_cached_coord(rdman, coord); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2257 } |
528
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
527
diff
changeset
|
2258 |
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
527
diff
changeset
|
2259 draw_dirty_cached_coord(rdman, rdman->root_coord); |
13 | 2260 } |
2261 | |
24
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2262 |
13 | 2263 /*! \brief Re-draw all changed shapes or shapes affected by changed coords. |
2264 * | |
2265 * A coord object has a geo to keep track the range that it's members will | |
2266 * draw on. Geo of a coord should be recomputed when the coord is changed. | |
2267 * Geo of a coord used to accelerate finding overlay shape objects of | |
2268 * a specified geo. A coord object also must be recomputed when one of | |
2269 * it's members is changed. | |
2270 * | |
2271 * New and old geo values of a coord object that is recomputed for | |
2272 * changing of it-self must be used to find overlay shape objects. | |
2273 * New and old geo values of a shape should also be used to find | |
2274 * overlay shape objects, too. If a shape's coord is changed, shape's | |
2275 * geo object is not used to find overlay shape objects any more. | |
2276 * | |
2277 * steps: | |
2278 * - update chagned coord objects | |
14 | 2279 * - recompute area for changed coord objects |
13 | 2280 * - recompute geo for members shape objects |
14 | 2281 * - clear dirty of geo for members to prevent from |
2282 * recomputing for change of shape objects. | |
2283 * - add old and new area value to list of dirty areas. | |
13 | 2284 * - recompute geo for changed shape objects |
14 | 2285 * - only if a shape object is dirty. |
2286 * - put new and old value of area of geo to list of dirty areas. | |
2287 * - Scan all shapes and redraw shapes overlaid with dirty areas. | |
13 | 2288 * |
14 | 2289 * 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
|
2290 * 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
|
2291 * 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
|
2292 * corod objects. |
14 | 2293 * |
13 | 2294 */ |
2295 int rdman_redraw_changed(redraw_man_t *rdman) { | |
28 | 2296 int r; |
154 | 2297 event_t event; |
2298 subject_t *redraw; | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2299 int i; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2300 coord_t *coord, **coords; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2301 int n_areas; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2302 area_t **areas; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2303 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
2304 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
|
2305 if(r != OK) |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
2306 return ERR; |
13 | 2307 |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2308 if(rdman->n_dirty_areas > 0) { |
135 | 2309 /*! \brief Draw shapes in preorder of coord tree and support opacity |
2310 * rules. | |
2311 */ | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2312 draw_shapes_in_dirty_areas(rdman); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2313 n_areas = _coord_get_dirty_areas(rdman->root_coord)->num; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2314 areas = _coord_get_dirty_areas(rdman->root_coord)->ds; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2315 copy_cr_2_backend(rdman, n_areas, areas); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2316 reset_clip(rdman->backend); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2317 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
|
2318 coord = rdman->zeroing_coords.ds[i]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2319 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
|
2320 } |
528
d687d3395264
Clear variables and draw root coord.
Thinker K.F. Li <thinker@branda.to>
parents:
527
diff
changeset
|
2321 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
|
2322 rdman->n_dirty_areas = 0; |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2323 } |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
2324 |
519
7a1b17ebb3b4
Change documentation for zeroing
Thinker K.F. Li <thinker@branda.to>
parents:
512
diff
changeset
|
2325 /* clear COF_MUST_ZEROING flag for coords */ |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2326 coords = rdman->zeroing_coords.ds; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2327 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
|
2328 coord = coords[i]; |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2329 coord_clear_flags(coord, COF_MUST_ZEROING); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2330 } |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2331 |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2332 DARRAY_CLEAN(&rdman->dirty_coords); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2333 DARRAY_CLEAN(&rdman->dirty_geos); |
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2334 DARRAY_CLEAN(&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
|
2335 DARRAY_CLEAN(&rdman->dirty_pcache_area_coords); |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2336 |
158
c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
Thinker K.F. Li <thinker@branda.to>
parents:
154
diff
changeset
|
2337 /* 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
|
2338 free_free_objs(rdman); |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
2339 |
154 | 2340 redraw = rdman_get_redraw_subject(rdman); |
2341 event.type = EVT_RDMAN_REDRAW; | |
2342 event.tgt = event.cur_tgt = redraw; | |
192
54fdc2a65242
Remove factory from observer APIs.
Thinker K.F. Li <thinker@branda.to>
parents:
189
diff
changeset
|
2343 subject_notify(redraw, &event); |
154 | 2344 |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2345 return OK; |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2346 } |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2347 |
38 | 2348 /* NOTE: Before redrawing, the canvas/surface must be cleaned. |
2349 * NOTE: After redrawing, the content must be copied to the backend surface. | |
2350 */ | |
2351 | |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2352 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
|
2353 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
|
2354 #ifndef UNITTEST |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2355 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
|
2356 #endif |
29 | 2357 int r; |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
14
diff
changeset
|
2358 |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2359 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
|
2360 #ifndef UNITTEST |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2361 surface = mbe_get_target(rdman->cr); |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2362 area.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
|
2363 area.h = mbe_image_surface_get_height(surface); |
138
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2364 #else |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2365 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
|
2366 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
|
2367 #endif |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2368 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
|
2369 |
9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
Thinker K.F. Li <thinker@branda.to>
parents:
135
diff
changeset
|
2370 r = rdman_redraw_changed(rdman); |
29 | 2371 if(r != OK) |
2372 return ERR; | |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
2373 |
13 | 2374 return OK; |
12 | 2375 } |
2376 | |
37 | 2377 int rdman_redraw_area(redraw_man_t *rdman, co_aix x, co_aix y, |
2378 co_aix w, co_aix h) { | |
2379 area_t area; | |
2380 int r; | |
2381 | |
2382 area.x = x; | |
2383 area.y = y; | |
2384 area.w = w; | |
2385 area.h = h; | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2386 add_dirty_area(rdman, rdman->root_coord, &area); |
37 | 2387 |
2388 r = rdman_redraw_changed(rdman); | |
2389 | |
2390 return r; | |
2391 } | |
2392 | |
314
6c350fc92ae3
Cache rednering result is now workable.
Thinker K.F. Li <thinker@branda.to>
parents:
289
diff
changeset
|
2393 /*! \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
|
2394 */ |
139
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2395 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
|
2396 geo_t *next; |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2397 coord_t *coord; |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2398 |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2399 if(last == NULL) { |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2400 coord = rdman->root_coord; |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
2401 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
|
2402 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
|
2403 if(coord == NULL) |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2404 return NULL; |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
2405 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
|
2406 } |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2407 |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2408 coord = last->shape->coord; |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
2409 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
|
2410 while(next == NULL) { |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2411 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
|
2412 if(coord == NULL) |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2413 return NULL; |
140
0de8fd11271e
Use macro to simplify the code.
Thinker K.F. Li <thinker@branda.to>
parents:
139
diff
changeset
|
2414 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
|
2415 } |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2416 return next; |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2417 } |
1695a4b02b14
Members of coords are geos instead of shapes, now.
Thinker K.F. Li <thinker@branda.to>
parents:
138
diff
changeset
|
2418 |
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
|
2419 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
|
2420 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
|
2421 |
535
a545f126d2bf
pcached_area replaces owner_mems_area
Thinker K.F. Li <thinker@branda.to>
parents:
534
diff
changeset
|
2422 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
|
2423 |
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
|
2424 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
|
2425 } |
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
|
2426 |
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
|
2427 /*! \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
|
2428 * |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2429 * 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
|
2430 * 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
|
2431 * 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
|
2432 * 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
|
2433 * 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
|
2434 * 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
|
2435 * |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2436 * 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
|
2437 * 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
|
2438 * 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
|
2439 * 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
|
2440 * |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2441 * 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
|
2442 * 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
|
2443 * - 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
|
2444 * - 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
|
2445 * - 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
|
2446 * - 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
|
2447 */ |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2448 |
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
|
2449 /* \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
|
2450 * |
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
|
2451 * 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
|
2452 * @{ |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2453 */ |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2454 static subject_t *ob_subject_alloc(ob_factory_t *factory) { |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2455 redraw_man_t *rdman; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2456 subject_t *subject; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2457 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2458 rdman = MEM2OBJ(factory, redraw_man_t, ob_factory); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2459 subject = elmpool_elm_alloc(rdman->subject_pool); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2460 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2461 return subject; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2462 } |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2463 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2464 static void ob_subject_free(ob_factory_t *factory, subject_t *subject) { |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2465 redraw_man_t *rdman; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2466 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2467 rdman = MEM2OBJ(factory, redraw_man_t, ob_factory); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2468 elmpool_elm_free(rdman->subject_pool, subject); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2469 } |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2470 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2471 static observer_t *ob_observer_alloc(ob_factory_t *factory) { |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2472 redraw_man_t *rdman; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2473 observer_t *observer; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2474 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2475 rdman = MEM2OBJ(factory, redraw_man_t, ob_factory); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2476 observer = elmpool_elm_alloc(rdman->observer_pool); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2477 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2478 return observer; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2479 } |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2480 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2481 static void ob_observer_free(ob_factory_t *factory, observer_t *observer) { |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2482 redraw_man_t *rdman; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2483 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2484 rdman = MEM2OBJ(factory, redraw_man_t, ob_factory); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2485 elmpool_elm_free(rdman->observer_pool, observer); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2486 } |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2487 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2488 static subject_t *ob_get_parent_subject(ob_factory_t *factory, |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2489 subject_t *cur_subject) { |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2490 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
|
2491 coord_t *coord, *parent_coord; |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2492 geo_t *geo; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2493 subject_t *parent; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2494 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2495 rdman = MEM2OBJ(factory, redraw_man_t, ob_factory); |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2496 switch(cur_subject->obj_type) { |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2497 case OBJT_GEO: |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2498 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
|
2499 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
|
2500 parent = parent_coord->mouse_event; |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2501 break; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2502 case OBJT_COORD: |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2503 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
|
2504 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
|
2505 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
|
2506 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
|
2507 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
|
2508 } |
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
|
2509 parent = parent_coord->mouse_event; |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2510 break; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2511 default: |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2512 parent = NULL; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2513 break; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2514 } |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2515 |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2516 return parent; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2517 } |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2518 |
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
|
2519 /* @} */ |
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
|
2520 |
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
|
2521 /*! \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
|
2522 */ |
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
|
2523 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
|
2524 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
|
2525 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
|
2526 mb_img_ldr_t *ldr = rdman_img_ldr(rdman); |
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
|
2527 |
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
|
2528 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
|
2529 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
|
2530 return 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
|
2531 |
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
|
2532 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
|
2533 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
|
2534 MB_IMG_DATA_FREE(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
|
2535 |
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
|
2536 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
|
2537 } |
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
|
2538 |
12 | 2539 #ifdef UNITTEST |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
2540 /* Test cases */ |
12 | 2541 |
2542 #include <CUnit/Basic.h> | |
2543 | |
2544 struct _sh_dummy { | |
2545 shape_t shape; | |
2546 co_aix x, y; | |
2547 co_aix w, h; | |
119 | 2548 int trans_cnt; |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2549 int draw_cnt; |
12 | 2550 }; |
2551 | |
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
|
2552 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
|
2553 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
|
2554 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2555 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2556 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
|
2557 co_aix x, co_aix y, co_aix w, co_aix h) { |
12 | 2558 sh_dummy_t *dummy; |
2559 | |
2560 dummy = (sh_dummy_t *)malloc(sizeof(sh_dummy_t)); | |
2561 if(dummy == NULL) | |
2562 return NULL; | |
2563 | |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2564 memset(dummy, 0, sizeof(sh_dummy_t)); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2565 |
12 | 2566 dummy->x = x; |
2567 dummy->y = y; | |
2568 dummy->w = w; | |
2569 dummy->h = h; | |
119 | 2570 dummy->trans_cnt = 0; |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2571 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
|
2572 dummy->shape.free = sh_dummy_free; |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
196
diff
changeset
|
2573 |
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
|
2574 rdman_shape_man(rdman, (shape_t *)dummy); |
12 | 2575 |
2576 return (shape_t *)dummy; | |
2577 } | |
2578 | |
2579 void sh_dummy_transform(shape_t *shape) { | |
2580 sh_dummy_t *dummy = (sh_dummy_t *)shape; | |
2581 co_aix poses[2][2]; | |
2582 co_aix x1, y1, x2, y2; | |
2583 | |
2584 if(shape->geo && shape->coord) { | |
2585 x1 = dummy->x; | |
2586 y1 = dummy->y; | |
2587 x2 = x1 + dummy->w; | |
2588 y2 = y1 + dummy->h; | |
2589 | |
2590 coord_trans_pos(shape->coord, &x1, &y1); | |
2591 coord_trans_pos(shape->coord, &x2, &y2); | |
2592 poses[0][0] = x1; | |
2593 poses[0][1] = y1; | |
2594 poses[1][0] = x2; | |
2595 poses[1][1] = y2; | |
2596 | |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2597 if(shape->geo) |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2598 geo_from_positions(shape->geo, 2, poses); |
12 | 2599 } |
119 | 2600 dummy->trans_cnt++; |
12 | 2601 } |
2602 | |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2603 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
|
2604 sh_dummy_t *dummy; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2605 |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2606 dummy = (sh_dummy_t *)shape; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2607 dummy->draw_cnt++; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2608 } |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2609 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
441
diff
changeset
|
2610 static void dummy_paint_prepare(paint_t *paint, mbe_t *cr) { |
19 | 2611 } |
2612 | |
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
|
2613 static void dummy_paint_free(redraw_man_t *rdman, paint_t *paint) { |
19 | 2614 if(paint) |
2615 free(paint); | |
2616 } | |
2617 | |
2618 paint_t *dummy_paint_new(redraw_man_t *rdman) { | |
2619 paint_t *paint; | |
2620 | |
2621 paint = (paint_t *)malloc(sizeof(paint_t)); | |
2622 if(paint == NULL) | |
2623 return NULL; | |
2624 | |
408
7f7855df2af0
Make unittest built by automake and autoconf.
Thinker K.F. Li <thinker@branda.to>
parents:
375
diff
changeset
|
2625 paint_init(paint, MBP_DUMMY, dummy_paint_prepare, dummy_paint_free); |
19 | 2626 |
2627 return paint; | |
2628 } | |
2629 | |
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
|
2630 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
|
2631 coord_t *coords[3]; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2632 shape_t *shapes[3]; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2633 sh_dummy_t **dummys; |
19 | 2634 paint_t *paint; |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2635 redraw_man_t *rdman; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2636 redraw_man_t _rdman; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2637 int i; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2638 |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2639 dummys = (sh_dummy_t **)shapes; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2640 |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2641 rdman = &_rdman; |
24
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
2642 redraw_man_init(rdman, NULL, NULL); |
19 | 2643 paint = dummy_paint_new(rdman); |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2644 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
|
2645 shapes[i] = sh_dummy_new(rdman, 0, 0, 50, 50); |
19 | 2646 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
|
2647 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
|
2648 coords[i]->matrix[2] = 10 + i * 100; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2649 coords[i]->matrix[5] = 10 + i * 100; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2650 rdman_coord_changed(rdman, coords[i]); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2651 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
|
2652 } |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2653 rdman_redraw_all(rdman); |
119 | 2654 CU_ASSERT(dummys[0]->trans_cnt == 1); |
2655 CU_ASSERT(dummys[1]->trans_cnt == 1); | |
2656 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
|
2657 CU_ASSERT(dummys[0]->draw_cnt == 1); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2658 CU_ASSERT(dummys[1]->draw_cnt == 1); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2659 CU_ASSERT(dummys[2]->draw_cnt == 1); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2660 |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2661 coords[2]->matrix[2] = 100; |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2662 coords[2]->matrix[5] = 100; |
119 | 2663 rdman_coord_changed(rdman, coords[0]); |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2664 rdman_coord_changed(rdman, coords[2]); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2665 rdman_redraw_changed(rdman); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2666 |
119 | 2667 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
|
2668 CU_ASSERT(dummys[1]->draw_cnt == 2); |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2669 CU_ASSERT(dummys[2]->draw_cnt == 2); |
19 | 2670 |
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
|
2671 rdman_paint_free(rdman, paint); |
19 | 2672 redraw_man_destroy(rdman); |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2673 } |
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
16
diff
changeset
|
2674 |
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
|
2675 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
|
2676 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2677 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
|
2678 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
|
2679 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2680 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2681 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
|
2682 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
|
2683 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
|
2684 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
|
2685 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2686 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
|
2687 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
|
2688 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2689 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
|
2690 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2691 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
|
2692 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
|
2693 |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2694 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
|
2695 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
|
2696 } |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
158
diff
changeset
|
2697 |
12 | 2698 CU_pSuite get_redraw_man_suite(void) { |
2699 CU_pSuite suite; | |
2700 | |
2701 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
|
2702 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
|
2703 CU_ADD_TEST(suite, test_rdman_free_objs); |
12 | 2704 |
2705 return suite; | |
2706 } | |
2707 | |
2708 #endif /* UNITTEST */ |