EAPI void evas_object_map_enable_set(Evas_Object *obj, Eina_Bool enabled) { MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); return; MAGIC_CHECK_END(); enabled = !!enabled; if (obj->cur.usemap == enabled) return; obj->cur.usemap = enabled; if (enabled) { if (!obj->cur.map) obj->cur.map = _evas_map_new(4); evas_object_mapped_clip_across_mark(obj); // obj->cur.map->normal_geometry = obj->cur.geometry; } else { if (obj->cur.map) { _evas_map_calc_geom_change(obj); evas_object_mapped_clip_across_mark(obj); //FIXME: Since the last frame is not updated when map is //disabled, afterimage problem is happened in s/w rendering. //Need to find out the fundamental reason then fix it. evas_damage_rectangle_add(obj->layer->evas, 0, 0, obj->layer->evas->output.w, obj->layer->evas->output.h); } } _evas_map_calc_map_geometry(obj); /* This is a bit heavy handed, but it fixes the case of same geometry, but * changed colour or UV settings. */ evas_object_change(obj); }
static void _evas_map_calc_map_geometry(Evas_Object *eo_obj) { Evas_Coord x1, x2, yy1, yy2; const Evas_Map_Point *p, *p_end; Eina_Bool ch = EINA_FALSE; Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS); if (!obj->cur.map) return; // WARN: Do not merge below code to SLP until it is fixed. // It has an infinite loop bug. if (obj->prev.map) { if (obj->prev.map != obj->cur.map) { // FIXME: this causes an infinite loop somewhere... hard to debug if (obj->prev.map->count == obj->cur.map->count) { const Evas_Map_Point *p2; p = obj->cur.map->points; p2 = obj->prev.map->points; if (memcmp(p, p2, sizeof(Evas_Map_Point) * obj->prev.map->count) != 0) ch = EINA_TRUE; if (!ch) { if (obj->cache_map) evas_map_free(obj->cache_map); obj->cache_map = obj->cur.map; obj->cur.map = obj->prev.map; } } else ch = EINA_TRUE; } } else ch = EINA_TRUE; p = obj->cur.map->points; p_end = p + obj->cur.map->count; x1 = x2 = lround(p->x); yy1 = yy2 = lround(p->y); p++; for (; p < p_end; p++) { Evas_Coord x, y; x = lround(p->x); y = lround(p->y); if (x < x1) x1 = x; if (x > x2) x2 = x; if (y < yy1) yy1 = y; if (y > yy2) yy2 = y; } // this causes clip-out bugs now mapped objs canbe opaque!!! // // add 1 pixel of fuzz around the map region to ensure updates are correct // x1 -= 1; yy1 -= 1; // x2 += 1; yy2 += 1; if (obj->cur.map->normal_geometry.x != x1) ch = 1; if (obj->cur.map->normal_geometry.y != yy1) ch = 1; if (obj->cur.map->normal_geometry.w != (x2 - x1)) ch = 1; if (obj->cur.map->normal_geometry.h != (yy2 - yy1)) ch = 1; obj->cur.map->normal_geometry.x = x1; obj->cur.map->normal_geometry.y = yy1; obj->cur.map->normal_geometry.w = (x2 - x1); obj->cur.map->normal_geometry.h = (yy2 - yy1); obj->changed_map = ch; // This shouldn't really be needed, but without it we do have case // where the clip is wrong when a map doesn't change, so always forcing // it, as long as someone doesn't find a better fix. evas_object_clip_dirty(eo_obj, obj); if (ch) _evas_map_calc_geom_change(eo_obj); }
EAPI void evas_object_map_set(Evas_Object *obj, const Evas_Map *map) { MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); return; MAGIC_CHECK_END(); if (!map) { if (obj->cur.map) { if (obj->cur.map->surface) { obj->layer->evas->engine.func->image_map_surface_free (obj->layer->evas->engine.data.output, obj->cur.map->surface); obj->cur.map->surface = NULL; } obj->prev.geometry = obj->cur.map->normal_geometry; if (!obj->prev.map) { _evas_map_free(obj, obj->cur.map); obj->cur.map = NULL; evas_object_mapped_clip_across_mark(obj); return; } _evas_map_free(obj, obj->cur.map); obj->cur.map = NULL; if (!obj->cur.usemap) _evas_map_calc_geom_change(obj); else _evas_map_calc_map_geometry(obj); if (obj->cur.usemap) { evas_object_mapped_clip_across_mark(obj); //FIXME: Since the last frame is not updated when map is //disabled, afterimage problem is happened in s/w //rendering. Need to find out the fundamental reason //then fix it. evas_damage_rectangle_add(obj->layer->evas, 0, 0, obj->layer->evas->output.w, obj->layer->evas->output.h); } } return; } if ((obj->cur.map) && (obj->cur.map->count == map->count)) { Evas_Map *omap = obj->cur.map; obj->cur.map = _evas_map_new(map->count); memcpy(obj->cur.map, omap, sizeof(Evas_Map) + (map->count * sizeof(Evas_Map_Point))); _evas_map_copy(obj->cur.map, map); if (obj->prev.map == omap) obj->prev.map = NULL; free(omap); } else { if (obj->cur.map) evas_map_free(obj->cur.map); obj->cur.map = _evas_map_dup(map); if (obj->cur.usemap) evas_object_mapped_clip_across_mark(obj); } _evas_map_calc_map_geometry(obj); }
static void _evas_map_calc_map_geometry(Evas_Object *obj) { Evas_Coord x1, x2, y1, y2; const Evas_Map_Point *p, *p_end; Eina_Bool ch = EINA_FALSE; if (!obj->cur.map) return; // WARN: Do not merge below code to SLP until it is fixed. // It has an infinite loop bug. if (obj->prev.map) { // FIXME: this causes an infinite loop somewhere... hard to debug if (obj->prev.map->count == obj->cur.map->count) { const Evas_Map_Point *p2; p = obj->cur.map->points; p_end = p + obj->cur.map->count; p2 = obj->prev.map->points; for (; p < p_end; p++, p2++) { if ((p->a != p2->a) || (p->r != p2->r) || (p->g != p2->g) || (p->b != p2->b)) { ch = 1; break; } if ((p->x != p2->x) || (p->y != p2->y) || (p->z != p2->z)) { ch = 1; break; } } } else ch = 1; } else ch = 1; p = obj->cur.map->points; p_end = p + obj->cur.map->count; x1 = lround(p->x); x2 = lround(p->x); y1 = lround(p->y); y2 = lround(p->y); p++; for (; p < p_end; p++) { if (p->x < x1) x1 = p->x; if (p->x > x2) x2 = p->x; if (p->y < y1) y1 = p->y; if (p->y > y2) y2 = p->y; } // this causes clip-out bugs now mapped objs canbe opaque!!! // // add 1 pixel of fuzz around the map region to ensure updates are correct // x1 -= 1; y1 -= 1; // x2 += 1; y2 += 1; if (obj->cur.map->normal_geometry.x != x1) ch = 1; if (obj->cur.map->normal_geometry.y != y1) ch = 1; if (obj->cur.map->normal_geometry.w != (x2 - x1)) ch = 1; if (obj->cur.map->normal_geometry.h != (y2 - y1)) ch = 1; obj->cur.map->normal_geometry.x = x1; obj->cur.map->normal_geometry.y = y1; obj->cur.map->normal_geometry.w = (x2 - x1); obj->cur.map->normal_geometry.h = (y2 - y1); if (ch) _evas_map_calc_geom_change(obj); }