summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <chuneon.park@samsung.com>2020-07-27 14:27:52 +0900
committerHermet Park <chuneon.park@samsung.com>2020-07-27 14:29:03 +0900
commitfb33fcb370fb58c4aeefbf897785b59b919c7f61 (patch)
tree6262e981da4405f3797991e964a39151e5629f43
parent29a72e9c6cb917b6f750278ba49471c6435a32d2 (diff)
downloadefl-fb33fcb370fb58c4aeefbf897785b59b919c7f61.tar.gz
canvas engine: ++safety code
added null checking, no logical changes.
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c90
1 files changed, 46 insertions, 44 deletions
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index aca24c4936..3d6a7f19b3 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -3975,58 +3975,60 @@ _smart_merge(Tilebuf *tb, Tilebuf_Rect *rects)
box = region_rects(region);
n = region_rects_num(region);
merged = calloc(1, n * sizeof(Tilebuf_Rect));
- j = 0;
+ if (merged) {
+ j = 0;
#if 1
- // regions sometimes produce box sets like:
- // +---+
- // | |
- // +---+ +-------+
- // | | | |
- // +---+ +-------+---------+
- // | |
- // | |
- // +-----------------+
- // so the upper-left 2 boxes can be merged into 1 and they have the same
- // x coords and are flush-aligned one above the other. that is what
- // this does - find these and merge them to have fewer rects
- for (i = 0; i < n; i++)
- {
- // skip empty boxes
- if (box[i].x1 == box[i].x2) continue;
- // walk all following boxes after this and see if they can be merged
- // into box i
- for (k = i + 1; k < n; k++)
+ // regions sometimes produce box sets like:
+ // +---+
+ // | |
+ // +---+ +-------+
+ // | | | |
+ // +---+ +-------+---------+
+ // | |
+ // | |
+ // +-----------------+
+ // so the upper-left 2 boxes can be merged into 1 and they have the same
+ // x coords and are flush-aligned one above the other. that is what
+ // this does - find these and merge them to have fewer rects
+ for (i = 0; i < n; i++)
{
- // skip empty boxes after i
- if (box[k].x1 == box[k].x2) continue;
- // match x coords
- if ((box[i].x1 == box[k].x1) && // if aligned vertically
- (box[i].x2 == box[k].x2)) // exactly above/below
+ // skip empty boxes
+ if (box[i].x1 == box[i].x2) continue;
+ // walk all following boxes after this and see if they can be merged
+ // into box i
+ for (k = i + 1; k < n; k++)
{
- // right below, or right above
- if (box[i].y2 == box[k].y1) // this box flush below
- {
- box[i].y2 = box[k].y2; // merge below i
- box[k].x2 = box[k].x1; // empty this box - merged
- }
- else if (box[i].y1 == box[k].y2) // this box flush above
+ // skip empty boxes after i
+ if (box[k].x1 == box[k].x2) continue;
+ // match x coords
+ if ((box[i].x1 == box[k].x1) && // if aligned vertically
+ (box[i].x2 == box[k].x2)) // exactly above/below
{
- box[i].y2 = box[k].y2; // merge above i
- box[k].x2 = box[k].x1; // empty this box - merged
+ // right below, or right above
+ if (box[i].y2 == box[k].y1) // this box flush below
+ {
+ box[i].y2 = box[k].y2; // merge below i
+ box[k].x2 = box[k].x1; // empty this box - merged
+ }
+ else if (box[i].y1 == box[k].y2) // this box flush above
+ {
+ box[i].y2 = box[k].y2; // merge above i
+ box[k].x2 = box[k].x1; // empty this box - merged
+ }
}
}
+ // i may have expanded but will not be empty. future boxes after
+ // this may be empty though but handled at top of loop
+ merged[j].x = box[i].x1;
+ merged[j].y = box[i].y1;
+ merged[j].w = box[i].x2 - box[i].x1;
+ merged[j].h = box[i].y2 - box[i].y1;
+ mergelist = (Tilebuf_Rect *)eina_inlist_append
+ (EINA_INLIST_GET(mergelist), EINA_INLIST_GET(&(merged[j])));
+ j++;
}
- // i may have expanded but will not be empty. future boxes after
- // this may be empty though but handled at top of loop
- merged[j].x = box[i].x1;
- merged[j].y = box[i].y1;
- merged[j].w = box[i].x2 - box[i].x1;
- merged[j].h = box[i].y2 - box[i].y1;
- mergelist = (Tilebuf_Rect *)eina_inlist_append
- (EINA_INLIST_GET(mergelist), EINA_INLIST_GET(&(merged[j])));
- j++;
- }
#endif
+ }
region_free(region);
rects = mergelist;