summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2013-02-07 07:32:45 +0000
committerCedric BAIL <cedric.bail@free.fr>2013-02-07 07:32:45 +0000
commite684f5a8237658dac36c82437b0b752bb2908335 (patch)
tree662541fd94cb90e46fdb4e993c73e294ffcb3b5e /src/lib
parent5d3e2e48d2d4abbaa61ada8e0c557e1d0297aa4f (diff)
efl/eina: Eina_Tiler take tile size into account.
SVN revision: 83708
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/eina/eina_tiler.c67
1 files changed, 43 insertions, 24 deletions
diff --git a/src/lib/eina/eina_tiler.c b/src/lib/eina/eina_tiler.c
index 2afb4f7a20..51e36e3de6 100644
--- a/src/lib/eina/eina_tiler.c
+++ b/src/lib/eina/eina_tiler.c
@@ -109,6 +109,8 @@ struct _Eina_Tiler
109 Eina_Rectangle area; 109 Eina_Rectangle area;
110 EINA_MAGIC 110 EINA_MAGIC
111 splitter_t splitter; 111 splitter_t splitter;
112
113 Eina_Bool rounding : 1;
112}; 114};
113 115
114#define EINA_MAGIC_CHECK_TILER(d, ...) \ 116#define EINA_MAGIC_CHECK_TILER(d, ...) \
@@ -1009,23 +1011,25 @@ static inline Eina_Bool _splitter_rect_add(Eina_Tiler *t, Eina_Rectangle *rect)
1009 rect_node_t *rn; 1011 rect_node_t *rn;
1010 1012
1011 //printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h); 1013 //printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
1012 rect->x >>= 1; 1014 if (t->rounding)
1013 rect->y >>= 1; 1015 {
1014 rect->w += 2; 1016 rect->x >>= 1;
1015 rect->w >>= 1; 1017 rect->y >>= 1;
1016 rect->h += 2; 1018 rect->w += 2;
1017 rect->h >>= 1; 1019 rect->w >>= 1;
1020 rect->h += 2;
1021 rect->h >>= 1;
1022 }
1018 1023
1019 rn = (rect_node_t *)rect_list_node_pool_get(); 1024 rn = (rect_node_t *)rect_list_node_pool_get();
1020 rn->_lst = list_node_zeroed; 1025 rn->_lst = list_node_zeroed;
1021 rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h); 1026 rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
1022 //printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h); 1027 //printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
1023 //testing on my core2 duo desktop - fuzz of 32 or 48 is best. 1028 //testing on my core2 duo desktop - fuzz of 32 or 48 is best.
1024#define FUZZ 32
1025 rect_list_add_split_fuzzy_and_merge(&t->splitter.rects, 1029 rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
1026 (list_node_t *)rn, 1030 (list_node_t *)rn,
1027 FUZZ * FUZZ, 1031 t->tile.w * t->tile.h,
1028 FUZZ * FUZZ); 1032 t->tile.w * t->tile.h);
1029 return EINA_TRUE; 1033 return EINA_TRUE;
1030} 1034}
1031 1035
@@ -1036,14 +1040,17 @@ static inline void _splitter_rect_del(Eina_Tiler *t, Eina_Rectangle *rect)
1036 if (!t->splitter.rects.head) 1040 if (!t->splitter.rects.head)
1037 return; 1041 return;
1038 1042
1039 rect->x += 1; 1043 if (t->rounding)
1040 rect->y += 1; 1044 {
1041 rect->x >>= 1; 1045 rect->x += 1;
1042 rect->y >>= 1; 1046 rect->y += 1;
1043 rect->w -= 1; 1047 rect->x >>= 1;
1044 rect->w >>= 1; 1048 rect->y >>= 1;
1045 rect->h -= 1; 1049 rect->w -= 1;
1046 rect->h >>= 1; 1050 rect->w >>= 1;
1051 rect->h -= 1;
1052 rect->h >>= 1;
1053 }
1047 1054
1048 if ((rect->w <= 0) || (rect->h <= 0)) 1055 if ((rect->w <= 0) || (rect->h <= 0))
1049 return; 1056 return;
@@ -1073,10 +1080,20 @@ static Eina_Bool _iterator_next(Eina_Iterator_Tiler *it, void **data)
1073 1080
1074 cur = ((rect_node_t *)n)->rect; 1081 cur = ((rect_node_t *)n)->rect;
1075 1082
1076 it->r.x = cur.left << 1; 1083 if (it->tiler->rounding)
1077 it->r.y = cur.top << 1; 1084 {
1078 it->r.w = cur.width << 1; 1085 it->r.x = cur.left << 1;
1079 it->r.h = cur.height << 1; 1086 it->r.y = cur.top << 1;
1087 it->r.w = cur.width << 1;
1088 it->r.h = cur.height << 1;
1089 }
1090 else
1091 {
1092 it->r.x = cur.left;
1093 it->r.y = cur.top;
1094 it->r.w = cur.width;
1095 it->r.h = cur.height;
1096 }
1080 1097
1081 if (eina_rectangle_intersection(&it->r, &it->tiler->area) == EINA_FALSE) 1098 if (eina_rectangle_intersection(&it->r, &it->tiler->area) == EINA_FALSE)
1082 continue; 1099 continue;
@@ -1121,8 +1138,9 @@ EAPI Eina_Tiler *eina_tiler_new(int w, int h)
1121 t = calloc(1, sizeof(Eina_Tiler)); 1138 t = calloc(1, sizeof(Eina_Tiler));
1122 t->area.w = w; 1139 t->area.w = w;
1123 t->area.h = h; 1140 t->area.h = h;
1124 t->tile.w = w; 1141 t->tile.w = 32;
1125 t->tile.h = h; 1142 t->tile.h = 32;
1143 t->rounding = EINA_TRUE;
1126 EINA_MAGIC_SET(t, EINA_MAGIC_TILER); 1144 EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
1127 _splitter_new(t); 1145 _splitter_new(t);
1128 return t; 1146 return t;
@@ -1144,6 +1162,7 @@ EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h)
1144 if ((w <= 0) || (h <= 0)) 1162 if ((w <= 0) || (h <= 0))
1145 return; 1163 return;
1146 1164
1165 if (w == 1 || h == 1) t->rounding = EINA_FALSE;
1147 t->tile.w = w; 1166 t->tile.w = w;
1148 t->tile.h = h; 1167 t->tile.h = h;
1149 _splitter_tile_size_set(t, w, h); 1168 _splitter_tile_size_set(t, w, h);
@@ -1216,7 +1235,7 @@ EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t)
1216 sp = (splitter_t *)&(t->splitter); 1235 sp = (splitter_t *)&(t->splitter);
1217 to_merge = t->splitter.rects; 1236 to_merge = t->splitter.rects;
1218 sp->rects = list_zeroed; 1237 sp->rects = list_zeroed;
1219 rect_list_merge_rects(&sp->rects, &to_merge, FUZZ * FUZZ); 1238 rect_list_merge_rects(&sp->rects, &to_merge, t->tile.w * t->tile.h);
1220 sp->need_merge = 0; 1239 sp->need_merge = 0;
1221 } 1240 }
1222 1241