summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_map.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2013-01-22 03:56:00 +0000
committerCedric BAIL <cedric.bail@free.fr>2013-01-22 03:56:00 +0000
commit3070dfac2d5f88dc95e3ec8285176f623d1c46c6 (patch)
tree085ad5c2f408678ecd52270caf3a8449949ee74b /src/lib/evas/canvas/evas_map.c
parent94b31ce5da894ca27b4b31cde7e2628bd09e8af2 (diff)
efl: move Evas_Object map data to there own Eina_Cow pointer.
NOTE: Overall speedup of 7%. No benchmark on memory consumption yet as they are still running ask me directly to get the number later today. SVN revision: 83052
Diffstat (limited to 'src/lib/evas/canvas/evas_map.c')
-rw-r--r--src/lib/evas/canvas/evas_map.c250
1 files changed, 150 insertions, 100 deletions
diff --git a/src/lib/evas/canvas/evas_map.c b/src/lib/evas/canvas/evas_map.c
index 71a59ab..3f5b406 100644
--- a/src/lib/evas/canvas/evas_map.c
+++ b/src/lib/evas/canvas/evas_map.c
@@ -39,28 +39,32 @@ _evas_map_calc_map_geometry(Evas_Object *eo_obj)
39 39
40 Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS); 40 Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
41 if (!obj) return; 41 if (!obj) return;
42 if (!obj->map.cur.map) return; 42 if (!obj->map->cur.map) return;
43 // WARN: Do not merge below code to SLP until it is fixed. 43 // WARN: Do not merge below code to SLP until it is fixed.
44 // It has an infinite loop bug. 44 // It has an infinite loop bug.
45 if (obj->map.prev.map) 45 if (obj->map->prev.map)
46 { 46 {
47 if (obj->map.prev.map != obj->map.cur.map) 47 if (obj->map->prev.map != obj->map->cur.map)
48 { 48 {
49 // FIXME: this causes an infinite loop somewhere... hard to debug 49 // FIXME: this causes an infinite loop somewhere... hard to debug
50 if (obj->map.prev.map->count == obj->map.cur.map->count) 50 if (obj->map->prev.map->count == obj->map->cur.map->count)
51 { 51 {
52 const Evas_Map_Point *p2; 52 const Evas_Map_Point *p2;
53 53
54 p = obj->map.cur.map->points; 54 p = obj->map->cur.map->points;
55 p2 = obj->map.prev.map->points; 55 p2 = obj->map->prev.map->points;
56 if (memcmp(p, p2, sizeof(Evas_Map_Point) * 56 if (memcmp(p, p2, sizeof(Evas_Map_Point) *
57 obj->map.prev.map->count) != 0) 57 obj->map->prev.map->count) != 0)
58 ch = EINA_TRUE; 58 ch = EINA_TRUE;
59 if (!ch) 59 if (!ch)
60 { 60 {
61 if (obj->map.cache_map) evas_map_free(obj->map.cache_map); 61 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
62 obj->map.cache_map = obj->map.cur.map; 62 {
63 obj->map.cur.map = obj->map.prev.map; 63 if (map_write->cache_map) evas_map_free(map_write->cache_map);
64 map_write->cache_map = map_write->cur.map;
65 map_write->cur.map = map_write->prev.map;
66 }
67 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
64 } 68 }
65 } 69 }
66 else 70 else
@@ -70,8 +74,8 @@ _evas_map_calc_map_geometry(Evas_Object *eo_obj)
70 else 74 else
71 ch = EINA_TRUE; 75 ch = EINA_TRUE;
72 76
73 p = obj->map.cur.map->points; 77 p = obj->map->cur.map->points;
74 p_end = p + obj->map.cur.map->count; 78 p_end = p + obj->map->cur.map->count;
75 x1 = x2 = lround(p->x); 79 x1 = x2 = lround(p->x);
76 yy1 = yy2 = lround(p->y); 80 yy1 = yy2 = lround(p->y);
77 p++; 81 p++;
@@ -90,14 +94,14 @@ _evas_map_calc_map_geometry(Evas_Object *eo_obj)
90// // add 1 pixel of fuzz around the map region to ensure updates are correct 94// // add 1 pixel of fuzz around the map region to ensure updates are correct
91// x1 -= 1; yy1 -= 1; 95// x1 -= 1; yy1 -= 1;
92// x2 += 1; yy2 += 1; 96// x2 += 1; yy2 += 1;
93 if (obj->map.cur.map->normal_geometry.x != x1) ch = 1; 97 if (obj->map->cur.map->normal_geometry.x != x1) ch = 1;
94 if (obj->map.cur.map->normal_geometry.y != yy1) ch = 1; 98 if (obj->map->cur.map->normal_geometry.y != yy1) ch = 1;
95 if (obj->map.cur.map->normal_geometry.w != (x2 - x1)) ch = 1; 99 if (obj->map->cur.map->normal_geometry.w != (x2 - x1)) ch = 1;
96 if (obj->map.cur.map->normal_geometry.h != (yy2 - yy1)) ch = 1; 100 if (obj->map->cur.map->normal_geometry.h != (yy2 - yy1)) ch = 1;
97 obj->map.cur.map->normal_geometry.x = x1; 101 obj->map->cur.map->normal_geometry.x = x1;
98 obj->map.cur.map->normal_geometry.y = yy1; 102 obj->map->cur.map->normal_geometry.y = yy1;
99 obj->map.cur.map->normal_geometry.w = (x2 - x1); 103 obj->map->cur.map->normal_geometry.w = (x2 - x1);
100 obj->map.cur.map->normal_geometry.h = (yy2 - yy1); 104 obj->map->cur.map->normal_geometry.h = (yy2 - yy1);
101 obj->changed_map = ch; 105 obj->changed_map = ch;
102 // This shouldn't really be needed, but without it we do have case 106 // This shouldn't really be needed, but without it we do have case
103 // where the clip is wrong when a map doesn't change, so always forcing 107 // where the clip is wrong when a map doesn't change, so always forcing
@@ -170,11 +174,15 @@ _evas_map_free(Evas_Object *eo_obj, Evas_Map *m)
170 if (eo_obj) 174 if (eo_obj)
171 { 175 {
172 Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS); 176 Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
173 if ((obj) && (obj->map.spans)) 177 if ((obj) && (obj->map->spans))
174 { 178 {
175 obj->layer->evas->engine.func->image_map_clean(obj->layer->evas->engine.data.output, obj->map.spans); 179 obj->layer->evas->engine.func->image_map_clean(obj->layer->evas->engine.data.output, obj->map->spans);
176 free(obj->map.spans); 180 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
177 obj->map.spans = NULL; 181 {
182 free(map_write->spans);
183 map_write->spans = NULL;
184 }
185 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
178 } 186 }
179 } 187 }
180 m->magic = 0; 188 m->magic = 0;
@@ -412,7 +420,7 @@ _evas_object_map_parent_check(Evas_Object *eo_parent)
412 if (!parent) return EINA_FALSE; 420 if (!parent) return EINA_FALSE;
413 list = evas_object_smart_members_get_direct(parent->smart.parent); 421 list = evas_object_smart_members_get_direct(parent->smart.parent);
414 EINA_INLIST_FOREACH(list, o) 422 EINA_INLIST_FOREACH(list, o)
415 if (o->map.cur.usemap) break ; 423 if (o->map->cur.usemap) break ;
416 if (o) return EINA_FALSE; /* Still some child have a map enable */ 424 if (o) return EINA_FALSE; /* Still some child have a map enable */
417 parent->child_has_map = EINA_FALSE; 425 parent->child_has_map = EINA_FALSE;
418 _evas_object_map_parent_check(parent->smart.parent); 426 _evas_object_map_parent_check(parent->smart.parent);
@@ -437,26 +445,38 @@ _map_enable_set(Eo *eo_obj, void *_pd, va_list *list)
437 Eina_Bool pchange = EINA_FALSE; 445 Eina_Bool pchange = EINA_FALSE;
438 446
439 enabled = !!enabled; 447 enabled = !!enabled;
440 if (obj->map.cur.usemap == enabled) return; 448 if (obj->map->cur.usemap == enabled) return;
441 pchange = obj->changed; 449 pchange = obj->changed;
442 obj->map.cur.usemap = enabled; 450
451 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
452 map_write->cur.usemap = enabled;
453 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
454
443 if (enabled) 455 if (enabled)
444 { 456 {
445 if (!obj->map.cur.map) 457 if (!obj->map->cur.map)
446 obj->map.cur.map = _evas_map_new(4); 458 {
459 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
460 map_write->cur.map = _evas_map_new(4);
461 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
462 }
447 evas_object_mapped_clip_across_mark(eo_obj, obj); 463 evas_object_mapped_clip_across_mark(eo_obj, obj);
448// obj->map.cur.map->normal_geometry = obj->cur.geometry; 464 // obj->map->cur.map->normal_geometry = obj->cur.geometry;
449 } 465 }
450 else 466 else
451 { 467 {
452 if (obj->map.surface) 468 if (obj->map->surface)
453 { 469 {
454 obj->layer->evas->engine.func->image_map_surface_free 470 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
455 (obj->layer->evas->engine.data.output, 471 {
456 obj->map.surface); 472 obj->layer->evas->engine.func->image_map_surface_free
457 obj->map.surface = NULL; 473 (obj->layer->evas->engine.data.output,
474 map_write->surface);
475 map_write->surface = NULL;
476 }
477 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
458 } 478 }
459 if (obj->map.cur.map) 479 if (obj->map->cur.map)
460 { 480 {
461 _evas_map_calc_geom_change(eo_obj); 481 _evas_map_calc_geom_change(eo_obj);
462 evas_object_mapped_clip_across_mark(eo_obj, obj); 482 evas_object_mapped_clip_across_mark(eo_obj, obj);
@@ -503,7 +523,7 @@ _map_enable_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
503{ 523{
504 Eina_Bool *enabled = va_arg(*list, Eina_Bool *); 524 Eina_Bool *enabled = va_arg(*list, Eina_Bool *);
505 const Evas_Object_Protected_Data *obj = _pd; 525 const Evas_Object_Protected_Data *obj = _pd;
506 *enabled = obj->map.cur.usemap; 526 *enabled = obj->map->cur.usemap;
507} 527}
508 528
509EAPI void 529EAPI void
@@ -523,62 +543,80 @@ _map_set(Eo *eo_obj, void *_pd, va_list *list)
523 543
524 if ((!map) || (map->count < 4)) 544 if ((!map) || (map->count < 4))
525 { 545 {
526 if (obj->map.surface) 546 if (obj->map->surface)
527 { 547 {
528 obj->layer->evas->engine.func->image_map_surface_free 548 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
529 (obj->layer->evas->engine.data.output, 549 {
530 obj->map.surface); 550 obj->layer->evas->engine.func->image_map_surface_free
531 obj->map.surface = NULL; 551 (obj->layer->evas->engine.data.output,
552 map_write->surface);
553 map_write->surface = NULL;
554 }
555 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
532 } 556 }
533 if (obj->map.cur.map) 557 if (obj->map->cur.map)
534 { 558 {
535 obj->changed_map = EINA_TRUE; 559 obj->changed_map = EINA_TRUE;
536 obj->prev.geometry = obj->map.cur.map->normal_geometry; 560 obj->prev.geometry = obj->map->cur.map->normal_geometry;
537 561
538 if (obj->map.prev.map == obj->map.cur.map) 562 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
539 obj->map.cur.map = NULL;
540 else if (!obj->map.cache_map)
541 { 563 {
542 obj->map.cache_map = obj->map.cur.map; 564 if (map_write->prev.map == map_write->cur.map)
543 obj->map.cur.map = NULL; 565 map_write->cur.map = NULL;
544 } 566 else if (!map_write->cache_map)
545 else 567 {
546 { 568 map_write->cache_map = map_write->cur.map;
547 _evas_map_free(eo_obj, obj->map.cur.map); 569 map_write->cur.map = NULL;
548 obj->map.cur.map = NULL; 570 }
571 else
572 {
573 _evas_map_free(eo_obj, map_write->cur.map);
574 map_write->cur.map = NULL;
575 }
549 } 576 }
577 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
550 578
551 if (!obj->map.prev.map) 579 if (!obj->map->prev.map)
552 { 580 {
553 evas_object_mapped_clip_across_mark(eo_obj, obj); 581 evas_object_mapped_clip_across_mark(eo_obj, obj);
554 return; 582 return;
555 } 583 }
556 584
557 if (!obj->map.cur.usemap) _evas_map_calc_geom_change(eo_obj); 585 if (!obj->map->cur.usemap) _evas_map_calc_geom_change(eo_obj);
558 else _evas_map_calc_map_geometry(eo_obj); 586 else _evas_map_calc_map_geometry(eo_obj);
559 if (obj->map.cur.usemap) 587 if (obj->map->cur.usemap)
560 evas_object_mapped_clip_across_mark(eo_obj, obj); 588 evas_object_mapped_clip_across_mark(eo_obj, obj);
561 } 589 }
562 return; 590 return;
563 } 591 }
564 592
565 if (obj->map.prev.map == obj->map.cur.map) 593 if (obj->map->prev.map == obj->map->cur.map)
566 obj->map.cur.map = NULL; 594 {
595 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
596 map_write->cur.map = NULL;
597 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
598 }
567 599
568 if (!obj->map.cur.map) 600 if (!obj->map->cur.map)
569 { 601 {
570 obj->map.cur.map = obj->map.cache_map; 602 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
571 obj->map.cache_map = NULL; 603 {
604 map_write->cur.map = map_write->cache_map;
605 map_write->cache_map = NULL;
606 }
607 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
572 } 608 }
573 609
574 // We do have the same exact count of point in this map, so just copy it 610 // We do have the same exact count of point in this map, so just copy it
575 if ((obj->map.cur.map) && (obj->map.cur.map->count == map->count)) 611 if ((obj->map->cur.map) && (obj->map->cur.map->count == map->count))
576 _evas_map_copy(obj->map.cur.map, map); 612 _evas_map_copy(obj->map->cur.map, map);
577 else 613 else
578 { 614 {
579 if (obj->map.cur.map) _evas_map_free(eo_obj, obj->map.cur.map); 615 if (obj->map->cur.map) _evas_map_free(eo_obj, obj->map->cur.map);
580 obj->map.cur.map = _evas_map_dup(map); 616 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
581 if (obj->map.cur.usemap) 617 map_write->cur.map = _evas_map_dup(map);
618 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
619 if (obj->map->cur.usemap)
582 evas_object_mapped_clip_across_mark(eo_obj, obj); 620 evas_object_mapped_clip_across_mark(eo_obj, obj);
583 } 621 }
584 622
@@ -602,7 +640,7 @@ _map_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
602 const Evas_Map **map = va_arg(*list, const Evas_Map **); 640 const Evas_Map **map = va_arg(*list, const Evas_Map **);
603 const Evas_Object_Protected_Data *obj = _pd; 641 const Evas_Object_Protected_Data *obj = _pd;
604 642
605 *map = obj->map.cur.map; 643 *map = obj->map->cur.map;
606} 644}
607 645
608EAPI Evas_Map * 646EAPI Evas_Map *
@@ -1184,11 +1222,11 @@ evas_object_map_update(Evas_Object *eo_obj,
1184 RGBA_Map_Point *pts, *pt; 1222 RGBA_Map_Point *pts, *pt;
1185 1223
1186 if (!obj) return; 1224 if (!obj) return;
1187 if (obj->map.spans) 1225 if (obj->map->spans)
1188 { 1226 {
1189 if (obj->map.spans->x != x || obj->map.spans->y != y || 1227 if (obj->map->spans->x != x || obj->map->spans->y != y ||
1190 obj->map.spans->image.w != imagew || obj->map.spans->image.h != imageh || 1228 obj->map->spans->image.w != imagew || obj->map->spans->image.h != imageh ||
1191 obj->map.spans->uv.w != uvw || obj->map.spans->uv.h != uvh) 1229 obj->map->spans->uv.w != uvw || obj->map->spans->uv.h != uvh)
1192 obj->changed_map = EINA_TRUE; 1230 obj->changed_map = EINA_TRUE;
1193 } 1231 }
1194 else 1232 else
@@ -1198,40 +1236,52 @@ evas_object_map_update(Evas_Object *eo_obj,
1198 1236
1199 if (!obj->changed_map) return ; 1237 if (!obj->changed_map) return ;
1200 1238
1201 if (obj->map.cur.map && obj->map.spans && obj->map.cur.map->count != obj->map.spans->count) 1239 if (obj->map->cur.map && obj->map->spans && obj->map->cur.map->count != obj->map->spans->count)
1202 { 1240 {
1203 if (obj->map.spans) 1241 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
1204 { 1242 {
1205 // Destroy engine side spans 1243 if (map_write->spans)
1206 free(obj->map.spans); 1244 {
1245 // Destroy engine side spans
1246 free(map_write->spans);
1247 }
1248 map_write->spans = NULL;
1207 } 1249 }
1208 obj->map.spans = NULL; 1250 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
1209 } 1251 }
1210 1252
1211 if (!obj->map.spans) 1253 if (!obj->map->spans)
1212 obj->map.spans = calloc(1, sizeof (RGBA_Map) + 1254 {
1213 sizeof (RGBA_Map_Point) * (obj->map.cur.map->count - 1)); 1255 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
1214 1256 map_write->spans = calloc(1, sizeof (RGBA_Map) +
1215 if (!obj->map.spans) return ; 1257 sizeof (RGBA_Map_Point) * (map_write->cur.map->count - 1));
1216 1258 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
1217 obj->map.spans->count = obj->map.cur.map->count; 1259 }
1218 obj->map.spans->x = x;
1219 obj->map.spans->y = y;
1220 obj->map.spans->uv.w = uvw;
1221 obj->map.spans->uv.h = uvh;
1222 obj->map.spans->image.w = imagew;
1223 obj->map.spans->image.h = imageh;
1224 1260
1225 pts = obj->map.spans->pts; 1261 if (!obj->map->spans) return ;
1226 1262
1227 p = obj->map.cur.map->points; 1263 EINA_COW_WRITE_BEGIN(evas_object_map_cow, obj->map, Evas_Object_Map_Data, map_write)
1228 p_end = p + obj->map.cur.map->count; 1264 {
1229 pt = pts; 1265 map_write->spans->count = obj->map->cur.map->count;
1266 map_write->spans->x = x;
1267 map_write->spans->y = y;
1268 map_write->spans->uv.w = uvw;
1269 map_write->spans->uv.h = uvh;
1270 map_write->spans->image.w = imagew;
1271 map_write->spans->image.h = imageh;
1272
1273 pts = obj->map->spans->pts;
1274
1275 p = obj->map->cur.map->points;
1276 p_end = p + obj->map->cur.map->count;
1277 pt = pts;
1278 }
1279 EINA_COW_WRITE_END(evas_object_map_cow, obj->map, map_write);
1230 1280
1231 pts[0].px = obj->map.cur.map->persp.px << FP; 1281 pts[0].px = obj->map->cur.map->persp.px << FP;
1232 pts[0].py = obj->map.cur.map->persp.py << FP; 1282 pts[0].py = obj->map->cur.map->persp.py << FP;
1233 pts[0].foc = obj->map.cur.map->persp.foc << FP; 1283 pts[0].foc = obj->map->cur.map->persp.foc << FP;
1234 pts[0].z0 = obj->map.cur.map->persp.z0 << FP; 1284 pts[0].z0 = obj->map->cur.map->persp.z0 << FP;
1235 // draw geom +x +y 1285 // draw geom +x +y
1236 for (; p < p_end; p++, pt++) 1286 for (; p < p_end; p++, pt++)
1237 { 1287 {
@@ -1251,9 +1301,9 @@ evas_object_map_update(Evas_Object *eo_obj,
1251 else if (pt->v > (imageh * FP1)) pt->v = (imageh * FP1); 1301 else if (pt->v > (imageh * FP1)) pt->v = (imageh * FP1);
1252 pt->col = ARGB_JOIN(p->a, p->r, p->g, p->b); 1302 pt->col = ARGB_JOIN(p->a, p->r, p->g, p->b);
1253 } 1303 }
1254 if (obj->map.cur.map->count & 0x1) 1304 if (obj->map->cur.map->count & 0x1)
1255 { 1305 {
1256 pts[obj->map.cur.map->count] = pts[obj->map.cur.map->count -1]; 1306 pts[obj->map->cur.map->count] = pts[obj->map->cur.map->count -1];
1257 } 1307 }
1258 1308
1259 // Request engine to update it's point 1309 // Request engine to update it's point