12
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4 #include "mb_types.h"
|
|
5 #include "shapes.h"
|
|
6 #include "tools.h"
|
|
7 #include "redraw_man.h"
|
|
8
|
|
9 #define OK 0
|
|
10 #define ERR -1
|
|
11
|
13
|
12 #define OFFSET(type, field) ((void *)&((type *)NULL)->field - (void *)NULL)
|
|
13 #define SWAP(a, b, t) do { t c; c = a; a = b; b = c; } while(0)
|
|
14
|
12
|
15 int redraw_man_init(redraw_man_t *rdman) {
|
|
16 extern void redraw_man_destroy(redraw_man_t *rdman);
|
|
17
|
|
18 memset(rdman, 0, sizeof(redraw_man_t));
|
|
19
|
|
20 rdman->geo_pool = elmpool_new(sizeof(geo_t), 128);
|
|
21 if(rdman->geo_pool == NULL)
|
|
22 return ERR;
|
|
23
|
|
24 rdman->coord_pool = elmpool_new(sizeof(coord_t), 16);
|
|
25 if(rdman->coord_pool == NULL) {
|
|
26 elmpool_free(rdman->geo_pool);
|
|
27 return ERR;
|
|
28 }
|
|
29
|
|
30 rdman->root_coord = elmpool_elm_alloc(rdman->coord_pool);
|
|
31 if(rdman->root_coord == NULL)
|
|
32 redraw_man_destroy(rdman);
|
13
|
33 rdman->n_coords = 1;
|
12
|
34 coord_init(rdman->root_coord, NULL);
|
|
35
|
|
36 return OK;
|
|
37 }
|
|
38
|
|
39 void redraw_man_destroy(redraw_man_t *rdman) {
|
|
40 elmpool_free(rdman->coord_pool);
|
|
41 elmpool_free(rdman->geo_pool);
|
13
|
42 if(rdman->dirty_coords)
|
|
43 free(rdman->dirty_coords);
|
14
|
44 if(rdman->dirty_geos)
|
|
45 free(rdman->dirty_geos);
|
12
|
46 }
|
|
47
|
|
48
|
|
49 #define ASSERT(x)
|
|
50 /*
|
|
51 * Change transformation matrix
|
|
52 * - update aggregated transformation matrix
|
|
53 * - of coord_t object been changed.
|
|
54 * - of children coord_t objects.
|
|
55 * - redraw members of coord_t objects.
|
|
56 * - redraw shape objects they are overlaid with members.
|
|
57 * - find out overlaid shape objects.
|
|
58 * - geo_t of a coord_t object
|
|
59 * - can make finding more efficiency.
|
|
60 * - fill overlay geo_t objects of members.
|
|
61 *
|
|
62 * Change a shape object
|
|
63 * - redraw changed object.
|
|
64 * - redraw shape objects they are overlaid with changed object.
|
|
65 * - find out overlaid shape objects.
|
|
66 *
|
|
67 * That coord and geo of shape objects are setted by user code
|
|
68 * give user code a chance to collect coord and geo objects together
|
|
69 * and gain interest of higher cache hit rate.
|
|
70 */
|
|
71
|
|
72 /*! \brief Find out all affected shape objects.
|
|
73 *
|
|
74 * Find out all shape objects that are overalid with geo_t of
|
|
75 * a geometry changed object.
|
|
76 *
|
|
77 * Linear scan geo_t objects of all shape objects in all_shapes
|
|
78 * list of a redraw_man_t object.
|
|
79 */
|
|
80 int rdman_find_overlaid_shapes(redraw_man_t *rdman, geo_t *geo,
|
|
81 geo_t ***overlays) {
|
|
82 int n_geos;
|
|
83 geo_t **geos;
|
|
84 geo_t *geo_cur;
|
|
85 int n_overlays;
|
|
86 geo_t **_overlays;
|
|
87 int i;
|
|
88
|
|
89 n_geos = rdman->n_geos;
|
|
90
|
|
91 geos = (geo_t **)malloc(sizeof(geo_t *) * n_geos);
|
|
92 if(geos == NULL)
|
|
93 return -1;
|
|
94
|
|
95 _overlays = (geo_t **)malloc(sizeof(geo_t *) * n_geos);
|
|
96 if(geos == NULL) {
|
|
97 free(geos);
|
|
98 return -1;
|
|
99 }
|
|
100
|
|
101 geo_cur = STAILQ_HEAD(rdman->all_geos);
|
|
102 for(i = 0; i < n_geos; i++) {
|
|
103 geos[i] = geo_cur;
|
|
104 geo_cur = STAILQ_NEXT(geo_t, next, geo_cur);
|
|
105 }
|
|
106 geo_mark_overlay(geo, n_geos, geos, &n_overlays, _overlays);
|
|
107
|
|
108 free(geos);
|
|
109 *overlays = _overlays;
|
|
110
|
|
111 return n_overlays;
|
|
112 }
|
|
113
|
|
114 int rdman_add_shape(redraw_man_t *rdman, shape_t *shape, coord_t *coord) {
|
|
115 geo_t *geo;
|
13
|
116 geo_t *visit;
|
|
117 unsigned int next_order;
|
12
|
118
|
|
119 geo = elmpool_elm_alloc(rdman->geo_pool);
|
|
120 if(geo == NULL)
|
|
121 return ERR;
|
|
122 sh_attach_geo(shape, geo);
|
|
123 STAILQ_INS_TAIL(rdman->all_geos, geo_t, next, geo);
|
|
124 rdman->n_geos++;
|
13
|
125
|
|
126 geo->order = ++rdman->next_geo_order;
|
|
127 if(geo->order == 0) {
|
|
128 next_order = 0;
|
|
129 for(visit = STAILQ_HEAD(rdman->all_geos);
|
|
130 visit != NULL;
|
|
131 visit = STAILQ_NEXT(geo_t, next, visit))
|
|
132 visit->order = ++next_order;
|
|
133 rdman->next_geo_order = next_order;
|
|
134 }
|
|
135
|
12
|
136 sh_attach_coord(shape, coord);
|
|
137
|
|
138 return OK;
|
|
139 }
|
|
140
|
|
141 int rdman_remove_shape(redraw_man_t *rdman, shape_t *shape) {
|
|
142 STAILQ_REMOVE(rdman->all_geos, geo_t, next, shape->geo);
|
|
143 elmpool_elm_free(rdman->geo_pool, shape->geo);
|
|
144 sh_detach_geo(shape);
|
|
145 rdman->n_geos--;
|
|
146 sh_detach_coord(shape);
|
|
147 return OK;
|
|
148 }
|
|
149
|
|
150 coord_t *rdman_coord_new(redraw_man_t *rdman, coord_t *parent) {
|
13
|
151 coord_t *coord, *root_coord;
|
|
152 coord_t *visit;
|
12
|
153
|
|
154 coord = elmpool_elm_alloc(rdman->coord_pool);
|
|
155 if(coord == NULL)
|
|
156 return NULL;
|
|
157
|
|
158 coord_init(coord, parent);
|
13
|
159 rdman->n_coords++;
|
|
160
|
|
161 coord->order = ++rdman->next_coord_order;
|
|
162 if(coord->order == 0) {
|
|
163 rdman->next_coord_order = 0;
|
|
164 root_coord = visit = rdman->root_coord;
|
|
165 /* skip root coord. */
|
|
166 visit = preorder_coord_subtree(root_coord, visit);
|
|
167 while(visit) {
|
|
168 visit->order = ++rdman->next_coord_order;
|
|
169 visit = preorder_coord_subtree(root_coord, visit);
|
|
170 }
|
|
171 }
|
12
|
172
|
|
173 return coord;
|
|
174 }
|
|
175
|
|
176 /*! \brief Free a coord of a redraw_man_t object.
|
|
177 *
|
|
178 * \param coord is a coord_t without children and members.
|
|
179 * \return 0 for successful, -1 for error.
|
|
180 */
|
|
181 int rdman_coord_free(redraw_man_t *rdman, coord_t *coord) {
|
|
182 coord_t *parent;
|
|
183
|
|
184 parent = coord->parent;
|
|
185 if(parent == NULL)
|
|
186 return ERR;
|
|
187
|
|
188 if(STAILQ_HEAD(coord->members) != NULL)
|
|
189 return ERR;
|
|
190
|
|
191 if(STAILQ_HEAD(coord->children) != NULL)
|
|
192 return ERR;
|
|
193
|
|
194 STAILQ_REMOVE(parent->children, coord_t, sibling, coord);
|
|
195 elmpool_elm_free(rdman->coord_pool, coord);
|
13
|
196 rdman->n_coords--;
|
|
197
|
|
198 return OK;
|
|
199 }
|
|
200
|
|
201 static int extend_memblk(void **buf, int o_size, int n_size) {
|
|
202 void *new_buf;
|
|
203
|
|
204 new_buf = realloc(*buf, n_size);
|
|
205 if(new_buf == NULL)
|
|
206 return ERR;
|
|
207
|
|
208 if(new_buf != *buf) {
|
|
209 memcpy(new_buf, *buf, o_size);
|
|
210 free(*buf);
|
|
211 *buf = new_buf;
|
|
212 }
|
|
213
|
|
214 return OK;
|
|
215 }
|
|
216
|
|
217 static int add_dirty_geo(redraw_man_t *rdman, geo_t *geo) {
|
14
|
218 int max_dirty_geos;
|
13
|
219 int r;
|
|
220
|
14
|
221 if(rdman->n_dirty_geos >= rdman->max_dirty_geos) {
|
|
222 max_dirty_geos = rdman->n_geos;
|
|
223 r = extend_memblk((void **)&rdman->dirty_geos,
|
|
224 sizeof(geo_t *) * rdman->n_dirty_geos,
|
|
225 sizeof(geo_t *) * max_dirty_geos);
|
13
|
226 if(r != OK)
|
|
227 return ERR;
|
14
|
228 rdman->max_dirty_geos = max_dirty_geos;
|
13
|
229 }
|
|
230
|
14
|
231 rdman->dirty_geos[rdman->n_dirty_geos++] = geo;
|
13
|
232 return OK;
|
|
233 }
|
|
234
|
|
235 static int add_dirty_area(redraw_man_t *rdman, area_t *area) {
|
|
236 int max_dirty_areas;
|
|
237 int r;
|
|
238
|
|
239 if(rdman->n_dirty_areas >= rdman->max_dirty_areas) {
|
|
240 max_dirty_areas = (rdman->n_geos + rdman->n_coords) * 2;
|
|
241 r = extend_memblk((void **)&rdman->dirty_areas,
|
|
242 sizeof(area_t *) * rdman->n_dirty_areas,
|
|
243 sizeof(area_t *) * max_dirty_areas);
|
|
244 if(r != OK)
|
|
245 return ERR;
|
|
246 rdman->max_dirty_areas = max_dirty_areas;
|
|
247 }
|
|
248
|
|
249 rdman->dirty_areas[++rdman->n_dirty_areas] = area;
|
|
250 return OK;
|
|
251 }
|
|
252
|
|
253 /*! \brief Mark a coord is changed.
|
|
254 *
|
|
255 * A changed coord_t object is marked as dirty and put
|
|
256 * into dirty_coords list.
|
|
257 */
|
|
258 int rdman_coord_changed(redraw_man_t *rdman, coord_t *coord) {
|
|
259 int max_dirty_coords;
|
|
260 int r;
|
|
261
|
|
262 if(coord->flags & COF_DIRTY)
|
|
263 return OK;
|
|
264
|
|
265 if(rdman->n_dirty_coords >= rdman->max_dirty_coords) {
|
|
266 /* Max of dirty_coords is not big enough. */
|
|
267 max_dirty_coords = rdman->max_dirty_coords + 16;
|
|
268
|
|
269 r = extend_memblk((void **)&rdman->dirty_coords,
|
|
270 sizeof(coord_t *) * rdman->n_dirty_coords,
|
|
271 sizeof(coord_t *) * max_dirty_coords);
|
|
272 rdman->max_dirty_coords = max_dirty_coords;
|
|
273 }
|
|
274
|
|
275 rdman->dirty_coords[rdman->n_dirty_coords++] = coord;
|
|
276 coord->flags |= COF_DIRTY;
|
|
277
|
|
278 return OK;
|
|
279 }
|
|
280
|
|
281 /*! \brief Mark a shape is changed.
|
|
282 *
|
|
283 * The geo_t object of a changed shape is mark as dirty and
|
14
|
284 * put into dirty_geos list.
|
13
|
285 */
|
|
286 int rdman_shape_changed(redraw_man_t *rdman, shape_t *shape) {
|
|
287 geo_t *geo;
|
|
288 int r;
|
|
289
|
|
290 geo = shape->geo;
|
|
291
|
|
292 if(geo->flags & GEF_DIRTY)
|
|
293 return OK;
|
|
294
|
|
295 r = add_dirty_geo(rdman, geo);
|
|
296 if(r == ERR)
|
|
297 return ERR;
|
|
298 geo->flags |= GEF_DIRTY;
|
12
|
299
|
|
300 return OK;
|
|
301 }
|
|
302
|
13
|
303 /*! \brief Sort a list of element by a unsigned integer.
|
|
304 *
|
|
305 * The result is in ascend order. The unsigned integers is
|
|
306 * at offset specified by 'off' from start address of elemnts.
|
|
307 */
|
|
308 static void _insert_sort(void **elms, int num, int off) {
|
|
309 int i, j;
|
|
310 unsigned int val;
|
|
311
|
|
312 for(i = 1; i < num; i++) {
|
|
313 val = *(unsigned int *)(elms[i] + off);
|
|
314 for(j = i; j > 0; j--) {
|
|
315 if(*(unsigned int *)(elms[j - 1] + off) <= val)
|
|
316 break;
|
|
317 elms[j] = elms[j - 1];
|
|
318 }
|
|
319 elms[j] = elms[i];
|
|
320 }
|
|
321 }
|
|
322
|
|
323 static void make_redrawing_members(redraw_man_t *rdman, coord_t *coord) {
|
|
324 shape_t *shape;
|
|
325
|
|
326 for(shape = STAILQ_HEAD(coord->members);
|
|
327 shape != NULL;
|
|
328 shape = STAILQ_NEXT(shape_t, coord_mem_next, shape)) {
|
|
329 shape->geo->flags &= ~GEF_DIRTY;
|
|
330 add_dirty_geo(rdman, shape->geo);
|
|
331 }
|
|
332 }
|
|
333
|
14
|
334 static void compute_coord_area(coord_t *coord) {
|
|
335 }
|
|
336
|
|
337 static void update_shape_geo(shape_t *shape) {
|
13
|
338 }
|
|
339
|
14
|
340 static void draw_shape(redraw_man_t *rdman, shape_t *shape) {
|
13
|
341 }
|
|
342
|
14
|
343 static void clip_and_show(redraw_man_t *rdman, int n_dirty_areas,
|
|
344 area_t **dirty_areas) {
|
13
|
345 }
|
|
346
|
|
347 /*! \brief Re-draw all changed shapes or shapes affected by changed coords.
|
|
348 *
|
|
349 * A coord object has a geo to keep track the range that it's members will
|
|
350 * draw on. Geo of a coord should be recomputed when the coord is changed.
|
|
351 * Geo of a coord used to accelerate finding overlay shape objects of
|
|
352 * a specified geo. A coord object also must be recomputed when one of
|
|
353 * it's members is changed.
|
|
354 *
|
|
355 * New and old geo values of a coord object that is recomputed for
|
|
356 * changing of it-self must be used to find overlay shape objects.
|
|
357 * New and old geo values of a shape should also be used to find
|
|
358 * overlay shape objects, too. If a shape's coord is changed, shape's
|
|
359 * geo object is not used to find overlay shape objects any more.
|
|
360 *
|
|
361 * steps:
|
|
362 * - update chagned coord objects
|
14
|
363 * - recompute area for changed coord objects
|
13
|
364 * - recompute geo for members shape objects
|
14
|
365 * - clear dirty of geo for members to prevent from
|
|
366 * recomputing for change of shape objects.
|
|
367 * - add old and new area value to list of dirty areas.
|
13
|
368 * - recompute geo for changed shape objects
|
14
|
369 * - only if a shape object is dirty.
|
|
370 * - put new and old value of area of geo to list of dirty areas.
|
|
371 * - Scan all shapes and redraw shapes overlaid with dirty areas.
|
13
|
372 *
|
14
|
373 * dirty flag of coord objects is cleared after update.
|
|
374 *
|
|
375 * assert(n_dirty_geos <= (num_of(shape) + num_of(coord)))
|
13
|
376 * Because
|
|
377 * - num_of(geo from coord) < num_of(coord)
|
|
378 * - num_of(geo from shape) < num_of(shape)
|
|
379 */
|
|
380 int rdman_redraw_changed(redraw_man_t *rdman) {
|
14
|
381 int i;
|
13
|
382 int n_dirty_coords;
|
|
383 coord_t **dirty_coords;
|
|
384 coord_t *visit_coord;
|
14
|
385 geo_t *visit_geo, **dirty_geos;
|
|
386 int n_dirty_geos;
|
13
|
387 int n_dirty_areas;
|
14
|
388 area_t **dirty_areas;
|
13
|
389
|
|
390 if(rdman->n_dirty_coords > 0) {
|
|
391 _insert_sort((void **)rdman->dirty_coords,
|
|
392 rdman->n_dirty_coords,
|
|
393 OFFSET(coord_t, order));
|
|
394 n_dirty_coords = rdman->n_dirty_coords;
|
|
395 dirty_coords = rdman->dirty_coords;
|
|
396 for(i = 0; i < n_dirty_coords; i++) {
|
|
397 if(!(dirty_coords[i]->flags & COF_DIRTY))
|
|
398 continue;
|
|
399
|
|
400 update_aggr_matrix(dirty_coords[i]);
|
|
401 for(visit_coord = dirty_coords[i];
|
|
402 visit_coord != NULL;
|
|
403 visit_coord = preorder_coord_subtree(dirty_coords[i],
|
|
404 visit_coord)) {
|
|
405 /* Dirty member, here, and members of this coord
|
|
406 * will not be visited anymore. */
|
|
407 visit_coord->flags &= ~COF_DIRTY;
|
|
408
|
|
409 SWAP(visit_coord->cur_area, visit_coord->last_area, area_t *);
|
14
|
410 compute_coord_area(visit_coord);
|
13
|
411 add_dirty_area(rdman, visit_coord->cur_area);
|
|
412 add_dirty_area(rdman, visit_coord->last_area);
|
|
413 make_redrawing_members(rdman, visit_coord);
|
|
414 }
|
|
415 }
|
|
416 rdman->n_dirty_coords = 0;
|
|
417 }
|
|
418
|
14
|
419 n_dirty_geos = rdman->n_dirty_geos;
|
|
420 if(n_dirty_geos > 0) {
|
|
421 dirty_geos = rdman->dirty_geos;
|
|
422 for(i = 0; i < n_dirty_geos; i++) {
|
|
423 visit_geo = dirty_geos[i];
|
13
|
424 if(!(visit_geo->flags & GEF_DIRTY))
|
|
425 continue;
|
|
426
|
14
|
427 visit_geo->flags &= ~GEF_DIRTY;
|
13
|
428 SWAP(visit_geo->cur_area, visit_geo->last_area, area_t *);
|
14
|
429 update_shape_geo(visit_geo->shape);
|
13
|
430 add_dirty_area(rdman, visit_geo->cur_area);
|
|
431 add_dirty_area(rdman, visit_geo->last_area);
|
|
432 }
|
|
433
|
|
434 n_dirty_areas = rdman->n_dirty_areas;
|
14
|
435 dirty_areas = rdman->dirty_areas;
|
13
|
436 for(visit_geo = STAILQ_HEAD(rdman->all_geos);
|
|
437 visit_geo != NULL;
|
|
438 visit_geo = STAILQ_NEXT(geo_t, next, visit_geo)) {
|
14
|
439 for(i = 0; i < n_dirty_areas; i++) {
|
|
440 if(is_overlay(visit_geo->cur_area,
|
|
441 dirty_areas[i])) {
|
|
442 draw_shape(rdman, visit_geo->shape);
|
|
443 break;
|
|
444 }
|
|
445 }
|
13
|
446 }
|
14
|
447 clip_and_show(rdman, n_dirty_areas, dirty_areas);
|
13
|
448 }
|
|
449
|
|
450 return OK;
|
12
|
451 }
|
|
452
|
|
453 /*
|
|
454 * When redraw an area, the affected elements may also extend to
|
|
455 * outside of the area. Since the order of drawing will change
|
|
456 * the result, it will infect more and more elements to keep
|
|
457 * drawing order althrough they are overlaid directly with
|
|
458 * specified area.
|
|
459 *
|
|
460 * To fix the problem, we don't extend the set of redrawing to
|
|
461 * elements they are not overliad directly. The redrawing is
|
|
462 * performed on a temporary surface, clipped to fit the area, and
|
|
463 * update only specified area on the destinate surface.
|
|
464 */
|
|
465
|
|
466 /*
|
|
467 * To accelerate speed of transformation, when a matrix changed,
|
|
468 * transformation should be aggregated and computed in a loop.
|
|
469 * It can get intereset of higher hit rate of cache.
|
|
470 * - shapes prvoide list of positions needed to be transformed.
|
|
471 * - redraw_man transforms positions from shapes.
|
|
472 * - shapes drawing with result of transforms.
|
|
473 * - shapes should be called to give them a chance to update geometries.
|
|
474 */
|
|
475
|
13
|
476 /*
|
|
477 * functions:
|
|
478 * - redraw all
|
|
479 * - redraw changed
|
|
480 */
|
|
481
|
12
|
482 #ifdef UNITTEST
|
|
483
|
|
484 #include <CUnit/Basic.h>
|
|
485
|
|
486 struct _sh_dummy {
|
|
487 shape_t shape;
|
|
488 co_aix x, y;
|
|
489 co_aix w, h;
|
|
490 };
|
|
491 typedef struct _sh_dummy sh_dummy_t;
|
|
492
|
|
493 shape_t *sh_dummy_new(co_aix x, co_aix y, co_aix w, co_aix h) {
|
|
494 sh_dummy_t *dummy;
|
|
495
|
|
496 dummy = (sh_dummy_t *)malloc(sizeof(sh_dummy_t));
|
|
497 if(dummy == NULL)
|
|
498 return NULL;
|
|
499
|
|
500 dummy->x = x;
|
|
501 dummy->y = y;
|
|
502 dummy->w = w;
|
|
503 dummy->h = h;
|
|
504
|
|
505 return (shape_t *)dummy;
|
|
506 }
|
|
507
|
|
508 void sh_dummy_free(shape_t *sh) {
|
|
509 free(sh);
|
|
510 }
|
|
511
|
|
512 void sh_dummy_transform(shape_t *shape) {
|
|
513 sh_dummy_t *dummy = (sh_dummy_t *)shape;
|
|
514 co_aix poses[2][2];
|
|
515 co_aix x1, y1, x2, y2;
|
|
516
|
|
517 if(shape->geo && shape->coord) {
|
|
518 x1 = dummy->x;
|
|
519 y1 = dummy->y;
|
|
520 x2 = x1 + dummy->w;
|
|
521 y2 = y1 + dummy->h;
|
|
522
|
|
523 coord_trans_pos(shape->coord, &x1, &y1);
|
|
524 coord_trans_pos(shape->coord, &x2, &y2);
|
|
525 poses[0][0] = x1;
|
|
526 poses[0][1] = y1;
|
|
527 poses[1][0] = x2;
|
|
528 poses[1][1] = y2;
|
|
529
|
|
530 geo_init(shape->geo, 2, poses);
|
|
531 }
|
|
532 }
|
|
533
|
|
534 void test_rdman_find_overlaid_shapes(void) {
|
|
535 redraw_man_t rdman;
|
|
536 geo_t geo;
|
|
537 coord_t *coords[3];
|
|
538 shape_t *shapes[5];
|
|
539 geo_t **overlays;
|
13
|
540 co_aix pos[2][2];
|
12
|
541 int n;
|
|
542 int i;
|
|
543
|
|
544 redraw_man_init(&rdman);
|
|
545 coords[0] = rdman.root_coord;
|
|
546 for(i = 1; i < 3; i++) {
|
|
547 coords[i] = rdman_coord_new(&rdman, rdman.root_coord);
|
|
548 }
|
|
549 for(i = 0; i < 5; i++) {
|
|
550 shapes[i] = sh_dummy_new(10 + i * 30, 10 + i * 20, 25, 15);
|
|
551 CU_ASSERT(shapes[i] != NULL);
|
|
552 }
|
|
553 for(i = 0; i < 3; i++)
|
|
554 rdman_add_shape(&rdman, shapes[i], coords[1]);
|
|
555 for(i = 3; i < 5; i++)
|
|
556 rdman_add_shape(&rdman, shapes[i], coords[2]);
|
|
557
|
|
558 coords[1]->matrix[0] = 2;
|
|
559 coords[0]->matrix[4] = 2;
|
|
560
|
|
561 update_aggr_matrix(coords[0]);
|
|
562 for(i = 0; i < 5; i++)
|
|
563 sh_dummy_transform(shapes[i]);
|
|
564
|
13
|
565 pos[0][0] = 100;
|
|
566 pos[0][1] = 120;
|
|
567 pos[1][0] = 100 + 140;
|
|
568 pos[1][1] = 120 + 40;
|
|
569 geo_init(&geo, 2, pos);
|
12
|
570
|
|
571 n = rdman_find_overlaid_shapes(&rdman, &geo, &overlays);
|
|
572 CU_ASSERT(n == 2);
|
|
573 CU_ASSERT(overlays != NULL);
|
|
574 CU_ASSERT(overlays[0] == shapes[2]->geo);
|
|
575 CU_ASSERT(overlays[1] == shapes[3]->geo);
|
|
576
|
|
577 free(overlays);
|
|
578 for(i = 0; i < 5; i++)
|
|
579 sh_dummy_free(shapes[i]);
|
|
580
|
|
581 redraw_man_destroy(&rdman);
|
|
582 }
|
|
583
|
|
584 CU_pSuite get_redraw_man_suite(void) {
|
|
585 CU_pSuite suite;
|
|
586
|
|
587 suite = CU_add_suite("Suite_redraw_man", NULL, NULL);
|
|
588 CU_ADD_TEST(suite, test_rdman_find_overlaid_shapes);
|
|
589
|
|
590 return suite;
|
|
591 }
|
|
592
|
|
593 #endif /* UNITTEST */
|