thiep pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4f77bb2f5af465eff7ebe0d7fa98347a2a624d2b

commit 4f77bb2f5af465eff7ebe0d7fa98347a2a624d2b
Author: Thiep Ha <thie...@gmail.com>
Date:   Thu Jun 8 15:11:21 2017 +0900

    evas_map: support map with number of points as multiples of 4
    
    Currently, in evas map, we only support map with 4 points.
    This patch adds support for map with number of points as
    multiples of 4.
    
    @feature
---
 src/Makefile_Elementary.am                         |  1 +
 src/bin/elementary/test.c                          |  2 +
 src/bin/elementary/test_evas_map.c                 | 77 ++++++++++++++++++++++
 src/lib/evas/canvas/evas_map.c                     |  4 +-
 src/modules/evas/engines/gl_common/evas_gl_image.c | 16 +++--
 .../evas/engines/software_generic/evas_engine.c    |  8 +--
 6 files changed, 97 insertions(+), 11 deletions(-)

diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index d4a17ea8ad..cde70880d3 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -776,6 +776,7 @@ bin/elementary/test_entry_anchor.c \
 bin/elementary/test_entry_anchor2.c \
 bin/elementary/test_events.c \
 bin/elementary/test_evas_mask.c \
+bin/elementary/test_evas_map.c \
 bin/elementary/test_evas_snapshot.c \
 bin/elementary/test_external.c \
 bin/elementary/test_fileselector_button.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 49869bf525..554cdb2cd7 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -311,6 +311,7 @@ void test_efl_ui_text_label(void *data, Evas_Object *obj, 
void *event_info);
 void test_evas_mask(void *data, Edje_Object *obj, void *event_info);
 void test_gfx_filters(void *data, Evas_Object *obj, void *event_info);
 void test_evas_snapshot(void *data, Evas_Object *obj, void *event_info);
+void test_evas_map(void *data, Edje_Object *obj, void *event_info);
 
 Evas_Object *win, *tbx; // TODO: refactoring
 void *tt;
@@ -1030,6 +1031,7 @@ add_tests:
    ADD_TEST(NULL, "Evas", "Masking", test_evas_mask);
    ADD_TEST(NULL, "Evas", "Gfx Filters", test_gfx_filters);
    ADD_TEST(NULL, "Evas", "Snapshot", test_evas_snapshot);
+   ADD_TEST(NULL, "Evas", "Map", test_evas_map);
 
    //------------------------------//
    ADD_TEST(NULL, "Widgets Disable/Enable", "Box", test_box_disable);
diff --git a/src/bin/elementary/test_evas_map.c 
b/src/bin/elementary/test_evas_map.c
new file mode 100644
index 0000000000..48f29e2227
--- /dev/null
+++ b/src/bin/elementary/test_evas_map.c
@@ -0,0 +1,77 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+#include <Elementary.h>
+
+static void
+_map_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
+{
+   Evas_Map *map;
+
+   map = evas_map_new(8);
+   //1st rect
+   evas_map_point_coord_set(map, 0, 100, 0, 0);
+   evas_map_point_coord_set(map, 1, 200, 0, 0);
+   evas_map_point_coord_set(map, 2, 200, 100, 0);
+   evas_map_point_coord_set(map, 3, 100, 100, 0);
+   //2nd rect
+   evas_map_point_coord_set(map, 4, 200, 0, 0);
+   evas_map_point_coord_set(map, 5, 100, 200, 0);
+   evas_map_point_coord_set(map, 6, 100, 300, 0);
+   evas_map_point_coord_set(map, 7, 200, 100, 0);
+
+   //uv: 1st rect
+   evas_map_point_image_uv_set(map, 0, 0, 0);
+   evas_map_point_image_uv_set(map, 1, w / 2, 0);
+   evas_map_point_image_uv_set(map, 2, w / 2, h);
+   evas_map_point_image_uv_set(map, 3, 0, h);
+   //uv: 2nd rect
+   evas_map_point_image_uv_set(map, 4, w / 2, 0);
+   evas_map_point_image_uv_set(map, 5, w, 0);
+   evas_map_point_image_uv_set(map, 6, w, h);
+   evas_map_point_image_uv_set(map, 7, w / 2, h);
+
+   evas_object_map_enable_set(obj, EINA_TRUE);
+   evas_object_map_set(obj, map);
+   evas_map_free(map);
+}
+
+static void
+_image_resize_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object 
*obj, void *event_info EINA_UNUSED)
+{
+   Evas_Coord w, h;
+
+   efl_gfx_geometry_get(obj, NULL, NULL, &w, &h);
+   _map_set(obj, w, h);
+}
+
+void
+test_evas_map(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+              void *event_info EINA_UNUSED)
+{
+   const Evas_Coord W = 300, H = 300;
+   Evas_Object *win, *img;
+   char buf[PATH_MAX];
+
+   win = efl_add(EFL_UI_WIN_CLASS, NULL,
+                 efl_text_set(efl_added, "Evas Map"),
+                 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
+
+   /* image with a min size */
+   snprintf(buf, sizeof(buf), "%s/images/rock_02.jpg", elm_app_data_dir_get());
+   img = efl_add(EFL_UI_IMAGE_CLASS, win,
+                 efl_gfx_size_hint_align_set(efl_added, 
EFL_GFX_SIZE_HINT_FILL, EFL_GFX_SIZE_HINT_FILL),
+                 efl_gfx_size_hint_weight_set(efl_added, 
EFL_GFX_SIZE_HINT_EXPAND, EFL_GFX_SIZE_HINT_EXPAND),
+                 efl_gfx_size_hint_min_set(efl_added, 64, 64),
+                 efl_file_set(efl_added, buf, NULL),
+                 efl_gfx_visible_set(efl_added, EINA_TRUE));
+   efl_ui_image_scale_type_set(img, EFL_UI_IMAGE_SCALE_TYPE_FILL);
+   evas_object_event_callback_add(img, EVAS_CALLBACK_RESIZE,
+                                  _image_resize_cb, NULL);
+
+   _map_set(img, W, H);
+
+   efl_content_set(win, img);
+   efl_gfx_size_set(win, W, H);
+   efl_gfx_visible_set(win, EINA_TRUE);
+}
diff --git a/src/lib/evas/canvas/evas_map.c b/src/lib/evas/canvas/evas_map.c
index 09e65d853e..8ccd4ec418 100644
--- a/src/lib/evas/canvas/evas_map.c
+++ b/src/lib/evas/canvas/evas_map.c
@@ -649,9 +649,9 @@ evas_object_map_get(const Evas_Object *eo_obj)
 EAPI Evas_Map *
 evas_map_new(int count)
 {
-   if (count != 4)
+   if (count % 4 != 0)
      {
-        ERR("map point count (%i) != 4 is unsupported!", count);
+        ERR("map point count (%i) should be multiples of 4!", count);
         return NULL;
      }
 
diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c 
b/src/modules/evas/engines/gl_common/evas_gl_image.c
index d1feacf3ce..cea4b1cdff 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -1207,6 +1207,7 @@ evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, 
Evas_GL_Image *im,
    Eina_Bool mask_color = EINA_FALSE;
    int r, g, b, a;
    int c, cx, cy, cw, ch;
+   int offset = 0;
 
    if (dc->mul.use)
      {
@@ -1245,11 +1246,16 @@ evas_gl_common_image_map_draw(Evas_Engine_GL_Context 
*gc, Evas_GL_Image *im,
         else mtex = NULL;
      }
 
-   evas_gl_common_context_image_map_push(gc, im->tex, npoints, p,
-                                         c, cx, cy, cw, ch,
-                                         mtex, mx, my, mw, mh, mask_smooth, 
mask_color,
-                                         r, g, b, a, smooth, im->tex_only,
-                                         im->cs.space);
+   while (npoints >= 4)
+     {
+        evas_gl_common_context_image_map_push(gc, im->tex, npoints, &p[offset],
+                                              c, cx, cy, cw, ch,
+                                              mtex, mx, my, mw, mh, 
mask_smooth, mask_color,
+                                              r, g, b, a, smooth, im->tex_only,
+                                              im->cs.space);
+        offset += 4;
+        npoints -= 4;
+     }
 }
 
 static void
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c 
b/src/modules/evas/engines/software_generic/evas_engine.c
index 1c44b1e3d4..dfd3018599 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -2669,7 +2669,7 @@ _draw_thread_map_draw(void *data)
 
    do
      {
-        if (m->count - offset < 3) goto free_out;
+        if (m->count - offset < 4) goto free_out;
 
         //Fully Transparency. Skip this.
         if (!(m->pts[0 + offset].col & 0xff000000) &&
@@ -2677,7 +2677,7 @@ _draw_thread_map_draw(void *data)
             !(m->pts[2 + offset].col & 0xff000000) &&
             !(m->pts[3 + offset].col & 0xff000000))
           {
-             offset += 2;
+             offset += 4;
              continue;
           }
 
@@ -2739,9 +2739,9 @@ _draw_thread_map_draw(void *data)
 
         evas_common_cpu_end_opt();
 
-        offset += 2;
+        offset += 4;
      }
-   while ((m->count > 4) && (m->count - offset >= 3));
+   while ((m->count > 4) && (m->count - offset >= 4));
 
  free_out:
    free(m);

-- 


Reply via email to