summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/software_generic/evas_engine.c
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:27:52 +0900
commitfa91360309a3e18783d7fbc125628c62fa1d64a9 (patch)
tree44f4e5ee477535fe0ac0cc5bcf844b06483d343b /src/modules/evas/engines/software_generic/evas_engine.c
parent61a445f547ad8c7965ca21966d2fd1aa4d331a82 (diff)
canvas engine: ++safety code
added null checking, no logical changes.
Diffstat (limited to '')
-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)
3975 box = region_rects(region); 3975 box = region_rects(region);
3976 n = region_rects_num(region); 3976 n = region_rects_num(region);
3977 merged = calloc(1, n * sizeof(Tilebuf_Rect)); 3977 merged = calloc(1, n * sizeof(Tilebuf_Rect));
3978 j = 0; 3978 if (merged) {
3979 j = 0;
3979#if 1 3980#if 1
3980 // regions sometimes produce box sets like: 3981 // regions sometimes produce box sets like:
3981 // +---+ 3982 // +---+
3982 // | | 3983 // | |
3983 // +---+ +-------+ 3984 // +---+ +-------+
3984 // | | | | 3985 // | | | |
3985 // +---+ +-------+---------+ 3986 // +---+ +-------+---------+
3986 // | | 3987 // | |
3987 // | | 3988 // | |
3988 // +-----------------+ 3989 // +-----------------+
3989 // so the upper-left 2 boxes can be merged into 1 and they have the same 3990 // so the upper-left 2 boxes can be merged into 1 and they have the same
3990 // x coords and are flush-aligned one above the other. that is what 3991 // x coords and are flush-aligned one above the other. that is what
3991 // this does - find these and merge them to have fewer rects 3992 // this does - find these and merge them to have fewer rects
3992 for (i = 0; i < n; i++) 3993 for (i = 0; i < n; i++)
3993 {
3994 // skip empty boxes
3995 if (box[i].x1 == box[i].x2) continue;
3996 // walk all following boxes after this and see if they can be merged
3997 // into box i
3998 for (k = i + 1; k < n; k++)
3999 { 3994 {
4000 // skip empty boxes after i 3995 // skip empty boxes
4001 if (box[k].x1 == box[k].x2) continue; 3996 if (box[i].x1 == box[i].x2) continue;
4002 // match x coords 3997 // walk all following boxes after this and see if they can be merged
4003 if ((box[i].x1 == box[k].x1) && // if aligned vertically 3998 // into box i
4004 (box[i].x2 == box[k].x2)) // exactly above/below 3999 for (k = i + 1; k < n; k++)
4005 { 4000 {
4006 // right below, or right above 4001 // skip empty boxes after i
4007 if (box[i].y2 == box[k].y1) // this box flush below 4002 if (box[k].x1 == box[k].x2) continue;
4008 { 4003 // match x coords
4009 box[i].y2 = box[k].y2; // merge below i 4004 if ((box[i].x1 == box[k].x1) && // if aligned vertically
4010 box[k].x2 = box[k].x1; // empty this box - merged 4005 (box[i].x2 == box[k].x2)) // exactly above/below
4011 }
4012 else if (box[i].y1 == box[k].y2) // this box flush above
4013 { 4006 {
4014 box[i].y2 = box[k].y2; // merge above i 4007 // right below, or right above
4015 box[k].x2 = box[k].x1; // empty this box - merged 4008 if (box[i].y2 == box[k].y1) // this box flush below
4009 {
4010 box[i].y2 = box[k].y2; // merge below i
4011 box[k].x2 = box[k].x1; // empty this box - merged
4012 }
4013 else if (box[i].y1 == box[k].y2) // this box flush above
4014 {
4015 box[i].y2 = box[k].y2; // merge above i
4016 box[k].x2 = box[k].x1; // empty this box - merged
4017 }
4016 } 4018 }
4017 } 4019 }
4020 // i may have expanded but will not be empty. future boxes after
4021 // this may be empty though but handled at top of loop
4022 merged[j].x = box[i].x1;
4023 merged[j].y = box[i].y1;
4024 merged[j].w = box[i].x2 - box[i].x1;
4025 merged[j].h = box[i].y2 - box[i].y1;
4026 mergelist = (Tilebuf_Rect *)eina_inlist_append
4027 (EINA_INLIST_GET(mergelist), EINA_INLIST_GET(&(merged[j])));
4028 j++;
4018 } 4029 }
4019 // i may have expanded but will not be empty. future boxes after
4020 // this may be empty though but handled at top of loop
4021 merged[j].x = box[i].x1;
4022 merged[j].y = box[i].y1;
4023 merged[j].w = box[i].x2 - box[i].x1;
4024 merged[j].h = box[i].y2 - box[i].y1;
4025 mergelist = (Tilebuf_Rect *)eina_inlist_append
4026 (EINA_INLIST_GET(mergelist), EINA_INLIST_GET(&(merged[j])));
4027 j++;
4028 }
4029#endif 4030#endif
4031 }
4030 region_free(region); 4032 region_free(region);
4031 rects = mergelist; 4033 rects = mergelist;
4032 4034