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