diff --git a/src/bin/elementary/test_evas_mask.c b/src/bin/elementary/test_evas_mask.c index a3e5ac1c5f..a107c017e5 100644 --- a/src/bin/elementary/test_evas_mask.c +++ b/src/bin/elementary/test_evas_mask.c @@ -84,8 +84,8 @@ _toggle_map(void *data, const Efl_Event *ev EINA_UNUSED) if (!efl_gfx_map_enable_get(ly)) { int x, y, w, h; + efl_gfx_map_reset(ly); efl_gfx_geometry_get(ly, &x, &y, &w, &h); - efl_gfx_map_populate(ly, 0.0); efl_gfx_map_zoom(ly, 0.8, 0.8, x + w / 2, y + h / 2); efl_gfx_map_enable_set(ly, 1); } diff --git a/src/bin/elementary/test_evas_snapshot.c b/src/bin/elementary/test_evas_snapshot.c index 1567bd960a..2d5db2c602 100644 --- a/src/bin/elementary/test_evas_snapshot.c +++ b/src/bin/elementary/test_evas_snapshot.c @@ -131,7 +131,7 @@ _map_do(void *data, const Efl_Event *ev EINA_UNUSED) if (here) return; here = 1; - efl_gfx_map_populate(snap, 0); + efl_gfx_map_reset(snap); efl_gfx_geometry_get(snap, &x, &y, &w, &h); efl_gfx_map_zoom(snap, 0.8, 0.8, x + w/2., y + h/2.); efl_gfx_map_rotate(snap, 45., x + w/2., y + h/2.); diff --git a/src/lib/evas/canvas/efl_gfx_map.c b/src/lib/evas/canvas/efl_gfx_map.c index dbf45a1035..5667a1c944 100644 --- a/src/lib/evas/canvas/efl_gfx_map.c +++ b/src/lib/evas/canvas/efl_gfx_map.c @@ -15,6 +15,36 @@ _evas_map_util_points_populate(m, obj->cur->geometry.x, obj->cur->geometry.y, \ obj->cur->geometry.w, obj->cur->geometry.h, z) +static Eina_Bool +_map_populate(Eo *eo_obj, int z) +{ + Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj, EINA_FALSE); + Evas_Map *m; + + if (!obj->map->cur.map) + { + m = _evas_map_new(4, EINA_TRUE); + if (!m) return EINA_FALSE; + MAP_POPULATE_DEFAULT(m, z); + evas_object_map_set(eo_obj, m); + evas_map_free(m); + } + else + { + m = (Evas_Map *) obj->map->cur.map; + MAP_POPULATE_DEFAULT(m, z); + MAP_OBJ_CHANGE(); + } + + return EINA_TRUE; +} + +EOLIAN static void +_efl_gfx_map_map_reset(Eo *eo_obj, void *_pd EINA_UNUSED) +{ + evas_object_map_set(eo_obj, NULL); +} + EOLIAN static Eina_Bool _efl_gfx_map_map_clockwise_get(Eo *eo_obj, void *_pd EINA_UNUSED) { @@ -30,7 +60,7 @@ _efl_gfx_map_map_smooth_set(Eo *eo_obj, void *_pd EINA_UNUSED, Eina_Bool smooth) if (!obj->map->cur.map) { if (smooth) return; - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return; } @@ -55,7 +85,7 @@ _efl_gfx_map_map_alpha_set(Eo *eo_obj, void *_pd EINA_UNUSED, Eina_Bool alpha) if (!obj->map->cur.map) { if (alpha) return; - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return; } @@ -79,7 +109,7 @@ _efl_gfx_map_map_point_coord_set(Eo *eo_obj, void *_pd EINA_UNUSED, int idx, dou Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj); Evas_Map *m; - if (!obj->map->cur.map && !efl_gfx_map_populate(eo_obj, 0)) + if (!obj->map->cur.map && !_map_populate(eo_obj, 0)) return; m = (Evas_Map *) obj->map->cur.map; @@ -102,7 +132,7 @@ _efl_gfx_map_map_point_image_uv_set(Eo *eo_obj, void *_pd EINA_UNUSED, int idx, Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj); Evas_Map *m; - if (!obj->map->cur.map && !efl_gfx_map_populate(eo_obj, 0)) + if (!obj->map->cur.map && !_map_populate(eo_obj, 0)) return; m = (Evas_Map *) obj->map->cur.map; @@ -126,7 +156,7 @@ _efl_gfx_map_map_color_set(Eo *eo_obj, void *_pd EINA_UNUSED, int idx, int r, in Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj); Evas_Map *m; - if (!obj->map->cur.map && !efl_gfx_map_populate(eo_obj, 0)) + if (!obj->map->cur.map && !_map_populate(eo_obj, 0)) return; m = (Evas_Map *) obj->map->cur.map; @@ -154,7 +184,7 @@ _efl_gfx_map_map_move_sync_set(Eo *eo_obj, void *_pd EINA_UNUSED, Eina_Bool enab if (!obj->map->cur.map) { if (enable) return; - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return; } @@ -171,54 +201,6 @@ _efl_gfx_map_map_move_sync_get(Eo *eo_obj, void *_pd EINA_UNUSED) return om ? om->move_sync.enabled : EINA_TRUE; } -EOLIAN static Eina_Bool -_efl_gfx_map_map_populate(Eo *eo_obj, void *_pd EINA_UNUSED, double z) -{ - Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj, EINA_FALSE); - Evas_Map *m; - - if (!obj->map->cur.map) - { - m = _evas_map_new(4, EINA_TRUE); - if (!m) return EINA_FALSE; - MAP_POPULATE_DEFAULT(m, z); - evas_object_map_set(eo_obj, m); - evas_map_free(m); - } - else - { - m = (Evas_Map *) obj->map->cur.map; - MAP_POPULATE_DEFAULT(m, z); - MAP_OBJ_CHANGE(); - } - - return EINA_TRUE; -} - -EOLIAN static Eina_Bool -_efl_gfx_map_map_populate_manual(Eo *eo_obj, void *_pd EINA_UNUSED, double x, double y, double w, double h, double z) -{ - Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj, EINA_FALSE); - Evas_Map *m; - - if (!obj->map->cur.map) - { - m = _evas_map_new(4, EINA_TRUE); - if (!m) return EINA_FALSE; - _evas_map_util_points_populate(m, x, y, w, h, z); - evas_object_map_set(eo_obj, m); - evas_map_free(m); - } - else - { - m = (Evas_Map *) obj->map->cur.map; - _evas_map_util_points_populate(m, x, y, w, h, z); - MAP_OBJ_CHANGE(); - } - - return EINA_TRUE; -} - EOLIAN static Eina_Bool _efl_gfx_map_map_rotate(Eo *eo_obj, void *_pd EINA_UNUSED, double degrees, double cx, double cy) { @@ -227,7 +209,7 @@ _efl_gfx_map_map_rotate(Eo *eo_obj, void *_pd EINA_UNUSED, double degrees, doubl if (!obj->map->cur.map) { - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return EINA_FALSE; } @@ -246,7 +228,7 @@ _efl_gfx_map_map_zoom(Eo *eo_obj, void *_pd EINA_UNUSED, double zoomx, double zo if (!obj->map->cur.map) { - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return EINA_FALSE; } @@ -265,7 +247,7 @@ _efl_gfx_map_map_rotate_3d(Eo *eo_obj, void *_pd EINA_UNUSED, double dx, double if (!obj->map->cur.map) { - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return EINA_FALSE; } @@ -284,7 +266,7 @@ _efl_gfx_map_map_quat_rotate(Eo *eo_obj, void *_pd EINA_UNUSED, double qx, doubl if (!obj->map->cur.map) { - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return EINA_FALSE; } @@ -303,7 +285,7 @@ _efl_gfx_map_map_lightning_3d(Eo *eo_obj, void *_pd EINA_UNUSED, double lx, doub if (!obj->map->cur.map) { - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return EINA_FALSE; } @@ -322,7 +304,7 @@ _efl_gfx_map_map_perspective_3d(Eo *eo_obj, void *_pd EINA_UNUSED, double px, do if (!obj->map->cur.map) { - if (!efl_gfx_map_populate(eo_obj, 0)) + if (!_map_populate(eo_obj, 0)) return EINA_FALSE; } @@ -333,18 +315,6 @@ _efl_gfx_map_map_perspective_3d(Eo *eo_obj, void *_pd EINA_UNUSED, double px, do return EINA_TRUE; } -EOLIAN static double -_efl_gfx_map_map_point_z_get(Eo *eo_obj, void *_pd EINA_UNUSED, int idx) -{ - Evas_Object_Protected_Data *obj = EVAS_OBJ_GET_OR_RETURN(eo_obj, 0.0); - EINA_SAFETY_ON_FALSE_RETURN_VAL((idx >= 0) && (idx < 4), 0.0); - - const Evas_Map *m = obj->map->cur.map; - const Evas_Map_Point *p = m ? (m->points + idx) : NULL; - - return p ? p->z : 0.0; -} - EOLIAN static Eina_Bool _efl_gfx_map_map_dup(Eo *eo_obj, void *_pd EINA_UNUSED, const Efl_Gfx_Map *other) { diff --git a/src/lib/evas/canvas/efl_gfx_map.eo b/src/lib/evas/canvas/efl_gfx_map.eo index 6c93d9eefd..720a972875 100644 --- a/src/lib/evas/canvas/efl_gfx_map.eo +++ b/src/lib/evas/canvas/efl_gfx_map.eo @@ -14,17 +14,9 @@ mixin Efl.Gfx.Map (Efl.Interface, Efl.Object) 3D effects. At the moment of writing, maps can only have 4 points (no more, no less). - Usually, it will be necessary to update the map points (start afresh with - @.map_populate) whenever the object geometry changes. Note: For now this mixin is only compatible with $Efl.Canvas.Object and shouldn't be used anywhere else. - - Note: There are a few differences with legacy $Evas_Map: - - A map is now a property of an object, rather than a separate entity. - - @.map_move_sync is enabled by default - - @.map_populate will be called automatically if another map function - is called while the object has no map info. ]] data: null; methods { @@ -49,6 +41,16 @@ mixin Efl.Gfx.Map (Efl.Interface, Efl.Object) enabled: bool; [[Enabled state.]] } } + map_reset { + [[Resets the map transformation to its default state. + + This will reset all transformations to identity, meaning the points' + colors, positions and UV coordinates will be reset to their default + values. This does not reset the @.map_enable flag. + + @since 1.20 + ]] + } @property map_clockwise { [[Clockwise state of a map (read-only). @@ -163,46 +165,6 @@ mixin Efl.Gfx.Map (Efl.Interface, Efl.Object) enable: bool; [[$true by default.]] } } - @property map_point_z { - [[Value of Z coordinate of point $idx. - - Useful to call @.map_populate without changing Z. - ]] - get {} - keys { - idx: int; [[Point]] - } - values { - z: double; [[Z coordinate for point]] - } - } - map_populate { - [[Populate source and destination map points to match this object. - ]] - params { - z: double @optional; [[Point Z coordinate (pre-pesrpective transform), - used for all 4 points. 0 by default.]] - } - return: bool; [[$false in case of error.]] - } - map_populate_manual { - [[Populate source and destination map points to match given geometry. - - Similar to @.map_populate, this call takes raw values instead of - querying this object's unmapped geometry. The given size will be - used to calculate destination points (@.map_point_coord) and set the - image uv (@.map_point_image_uv). - ]] - params { - x: double; [[X coordinate]] - y: double; [[Y coordinate]] - w: double; [[Width]] - h: double; [[Height]] - z: double @optional; [[Point Z coordinate (pre-perspective transform), - used for all 4 points. 0 by default.]] - } - return: bool; [[$false in case of error.]] - } map_rotate { [[Change the map to apply the given rotation. diff --git a/src/lib/evas/canvas/evas_map.c b/src/lib/evas/canvas/evas_map.c index 523a83642d..820c0da2a6 100644 --- a/src/lib/evas/canvas/evas_map.c +++ b/src/lib/evas/canvas/evas_map.c @@ -1251,7 +1251,6 @@ evas_map_util_clockwise_get(Evas_Map *m) return EINA_FALSE; } - /****************************************************************************/ /* If the return value is true, the map surface should be redrawn. */ /****************************************************************************/