Mercurial > MadButterfly
comparison src/redraw_man.c @ 841:ce6cd06adccf
Fix error on area of cached coords and draw on right canvas.
When zerioing, zeroing_coord() does not compute area of a cached coord
and its descendant coords. It is fixed by eliminate empty areas of
descendants and with special case of first non-empty area.
In previous version, it always draw on canvas of root coord. It is fixed.
Known issues:
- It can not translate position of a pointer to a cached coord and
descendants correctly.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 17 Sep 2010 16:26:14 +0800 |
parents | 048cc704bef7 |
children | 33fd5fdc8b48 6eaeec6806f2 |
comparison
equal
deleted
inserted
replaced
840:048cc704bef7 | 841:ce6cd06adccf |
---|---|
1542 * (See add_rdman_zeroing_n_pcache_coords()) | 1542 * (See add_rdman_zeroing_n_pcache_coords()) |
1543 */ | 1543 */ |
1544 area = coord_get_pcache_area(cur); | 1544 area = coord_get_pcache_area(cur); |
1545 } else | 1545 } else |
1546 area = coord_get_area(cur); | 1546 area = coord_get_area(cur); |
1547 | |
1548 if(area->w == 0 && area->h == 0) | |
1549 continue; | |
1550 | |
1551 if(min_x == max_x && min_y == max_y) { | |
1552 min_x = area->x; | |
1553 max_x = area->x + area->w; | |
1554 min_y = area->y; | |
1555 max_y = area->y + area->h; | |
1556 continue; | |
1557 } | |
1547 | 1558 |
1548 if(area->x < min_x) | 1559 if(area->x < min_x) |
1549 min_x = area->x; | 1560 min_x = area->x; |
1550 if(area->y < min_y) | 1561 if(area->y < min_y) |
1551 min_y = area->y; | 1562 min_y = area->y; |
2029 #ifndef UNITTEST | 2040 #ifndef UNITTEST |
2030 static void set_shape_stroke_param(shape_t *shape, mbe_t *cr) { | 2041 static void set_shape_stroke_param(shape_t *shape, mbe_t *cr) { |
2031 mbe_set_line_width(cr, shape->stroke_width); | 2042 mbe_set_line_width(cr, shape->stroke_width); |
2032 } | 2043 } |
2033 | 2044 |
2034 static void fill_path_preserve(redraw_man_t *rdman) { | 2045 static void fill_path_preserve(redraw_man_t *rdman, mbe_t *cr) { |
2035 mbe_fill_preserve(rdman->cr); | 2046 mbe_fill_preserve(cr); |
2036 } | 2047 } |
2037 | 2048 |
2038 static void fill_path(redraw_man_t *rdman) { | 2049 static void fill_path(redraw_man_t *rdman, mbe_t *cr) { |
2039 mbe_fill(rdman->cr); | 2050 mbe_fill(cr); |
2040 } | 2051 } |
2041 | 2052 |
2042 static void stroke_path(redraw_man_t *rdman) { | 2053 static void stroke_path(redraw_man_t *rdman, mbe_t *cr) { |
2043 mbe_stroke(rdman->cr); | 2054 mbe_stroke(cr); |
2044 } | 2055 } |
2045 #else | 2056 #else |
2046 static void set_shape_stroke_param(shape_t *shape, mbe_t *cr) { | 2057 static void set_shape_stroke_param(shape_t *shape, mbe_t *cr) { |
2047 } | 2058 } |
2048 | 2059 |
2049 static void fill_path_preserve(redraw_man_t *rdman) { | 2060 static void fill_path_preserve(redraw_man_t *rdman, mbe_t *cr) { |
2050 } | 2061 } |
2051 | 2062 |
2052 static void fill_path(redraw_man_t *rdman) { | 2063 static void fill_path(redraw_man_t *rdman, mbe_t *cr) { |
2053 } | 2064 } |
2054 | 2065 |
2055 static void stroke_path(redraw_man_t *rdman) { | 2066 static void stroke_path(redraw_man_t *rdman, mbe_t *cr) { |
2056 } | 2067 } |
2057 #endif | 2068 #endif |
2058 | 2069 |
2059 static void draw_shape(redraw_man_t *rdman, mbe_t *cr, shape_t *shape) { | 2070 static void draw_shape(redraw_man_t *rdman, mbe_t *cr, shape_t *shape) { |
2060 paint_t *fill, *stroke; | 2071 paint_t *fill, *stroke; |
2092 | 2103 |
2093 fill = shape->fill; | 2104 fill = shape->fill; |
2094 if(shape->fill) { | 2105 if(shape->fill) { |
2095 fill->prepare(fill, cr); | 2106 fill->prepare(fill, cr); |
2096 if(shape->stroke) | 2107 if(shape->stroke) |
2097 fill_path_preserve(rdman); | 2108 fill_path_preserve(rdman, cr); |
2098 else | 2109 else |
2099 fill_path(rdman); | 2110 fill_path(rdman, cr); |
2100 } | 2111 } |
2101 | 2112 |
2102 stroke = shape->stroke; | 2113 stroke = shape->stroke; |
2103 if(stroke) { | 2114 if(stroke) { |
2104 stroke->prepare(stroke, cr); | 2115 stroke->prepare(stroke, cr); |
2105 set_shape_stroke_param(shape, cr); | 2116 set_shape_stroke_param(shape, cr); |
2106 stroke_path(rdman); | 2117 stroke_path(rdman, cr); |
2107 } | 2118 } |
2108 } | 2119 } |
2109 } | 2120 } |
2110 | 2121 |
2111 #ifndef UNITTEST | 2122 #ifndef UNITTEST |