Revert "evas image: Support android 9 patch feature."
authorHermet Park <chuneon.park@samsung.com>
Tue, 19 May 2020 03:34:05 +0000 (12:34 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 25 May 2020 21:38:27 +0000 (06:38 +0900)
This reverts commit 23d4e94b3479f7e557c13f9557f43dd765c6d7b5.

9 patch feature was introduced by an another approach.

Change-Id: I8ce722d6a1163302d41dfc3215dd7a8850f997d2

src/lib/elementary/efl_ui_image.c
src/lib/evas/canvas/efl_canvas_image.c
src/lib/evas/canvas/evas_image_private.h
src/lib/evas/canvas/evas_main.c
src/lib/evas/canvas/evas_object_image.c

index ce47241..50156b2 100644 (file)
@@ -786,10 +786,6 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd)
      {
         if (!elm_widget_is_legacy(obj))
           sd->scale = efl_gfx_entity_scale_get(obj) * elm_config_scale_get();
-
-        /* TIZEN_ONLY(20190507): Android style Nine-Patch feature */
-        if (sd->img && !sd->edje)
-          evas_object_image_border_scale_set(sd->img, efl_gfx_entity_scale_get(obj) * elm_config_scale_get());
      }
      /* END */
 
index 898387b..822c946 100644 (file)
@@ -53,8 +53,6 @@ _evas_image_file_load(Eo *eo_obj, Evas_Image_Data *o)
           return EINA_TRUE;
      }
 
-   tizen_9patch_apply(o, f);  //TIZEN_ONLY(190509): Android style Nine-Patch feature
-
    obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
    evas_object_async_block(obj);
    _evas_image_init_set(f, key, eo_obj, obj, o, &lo);
index afe50bf..d421c7d 100755 (executable)
@@ -46,10 +46,6 @@ struct _Evas_Object_Image_Load_Opts
    } scale_load;
    Eina_Bool  orientation : 1;
    Eina_Bool  can_load_colormap : 1;
-
-   /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-   Eina_Bool  tizen_9patch_enabled : 1;
-   Eina_Bool  tizen_9patch_fetched :1;
 };
 
 struct _Evas_Object_Image_Pixels
@@ -237,17 +233,6 @@ void *_evas_image_data_convert_internal(Evas_Image_Data *o, void *data, Evas_Col
 void _evas_image_unload(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Eina_Bool dirty);
 void _evas_image_load(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o);
 
-/* TIZEN_ONLY(190509): Android style Nine-Patch feature */
-typedef struct
-{
-   int l, r, t, b;
-} tizen_9patch_data;
-
-extern Eina_Hash *tizen_9patch_hash;
-void tizen_9patch_apply(Evas_Image_Data *o, const Eina_File *f);
-void tizen_9patch_fetch(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o);
-//
-
 # define EINA_COW_IMAGE_STATE_WRITE_BEGIN(Obj, Write) \
   EINA_COW_WRITE_BEGIN(evas_object_image_state_cow, Obj->cur, Evas_Object_Image_State, Write)
 
index fd58f7e..1d62775 100644 (file)
@@ -208,9 +208,6 @@ evas_init(void)
 
    _efl_gfx_image_load_error_init();
 
-   /* TIZEN_ONLY(190509): Android style Nine-Patch feature */
-   tizen_9patch_hash = eina_hash_string_superfast_new(free);
-
    eina_content_converter_conversion_register("application/x-elementary-markup", "text/plain;charset=utf-8", _markup_to_utf8);
    eina_content_converter_conversion_register("text/plain;charset=utf-8", "application/x-elementary-markup", _utf8_to_markup);
 
@@ -253,11 +250,6 @@ evas_shutdown(void)
    if (--_evas_init_count != 0)
      return _evas_init_count;
 
-   /* TIZEN_ONLY(190509): Android style Nine-Patch feature */
-   eina_hash_free(tizen_9patch_hash);
-   tizen_9patch_hash = NULL;
-   //
-
    eina_log_timing(_evas_log_dom_global,
                    EINA_LOG_STATE_START,
                    EINA_LOG_STATE_SHUTDOWN);
index 3f78f5b..4164308 100755 (executable)
@@ -84,8 +84,7 @@ static const Evas_Object_Func object_func =
 };
 
 static const Evas_Object_Image_Load_Opts default_load_opts = {
-   0, 0.0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0 }, 0,
-   EINA_FALSE, EINA_FALSE  //TIZEN_ONLY(190507): Android style Nine-Patch feature
+   0, 0.0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0 }, 0
 };
 
 static const Evas_Object_Image_Pixels default_pixels = {
@@ -624,13 +623,6 @@ _efl_canvas_image_internal_efl_gfx_image_border_insets_set(Eo *eo_obj, Evas_Imag
       state_write->border.b = b;
    }
    EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
-
-   /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-   EINA_COW_LOAD_OPTS_WRITE_BEGIN(o, load_write)
-      load_write->tizen_9patch_enabled = EINA_FALSE;
-      load_write->tizen_9patch_fetched = EINA_FALSE;
-   EINA_COW_LOAD_OPTS_WRITE_END(o, load_write);
-
    o->changed = EINA_TRUE;
    evas_object_change(eo_obj, obj);
 }
@@ -2906,13 +2898,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                   inw = bl; inh = bt;
                   outx = ox; outy = oy;
                   outw = bsl; outh = bst;
-
-                   /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                  if (o->load_opts->tizen_9patch_fetched)
-                    {
-                       ++inx; ++iny;
-                    }
-
                   _draw_image(obj, engine, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur->smooth_scale, do_async);
                   // .##.
                   // |  |
@@ -2921,13 +2906,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                   inw = imw - bl - br; inh = bt;
                   outx = ox + bsl; outy = oy;
                   outw = iw - bsl - bsr; outh = bst;
-
-                   /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                  if (o->load_opts->tizen_9patch_fetched)
-                    {
-                       ++inx; ++iny; inw -=2;
-                    }
-
                   _draw_image(obj, engine, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur->smooth_scale, do_async);
                   // .--#
                   // |  |
@@ -2936,13 +2914,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                   inw = br; inh = bt;
                   outx = ox + iw - bsr; outy = oy;
                   outw = bsr; outh = bst;
-
-                   /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                  if (o->load_opts->tizen_9patch_fetched)
-                    {
-                       --inx; ++iny;
-                    }
-
                   _draw_image(obj, engine, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur->smooth_scale, do_async);
                   // .--.
                   // #  |
@@ -2951,13 +2922,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                   inw = bl; inh = imh - bt - bb;
                   outx = ox; outy = oy + bst;
                   outw = bsl; outh = ih - bst - bsb;
-
-                   /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                  if (o->load_opts->tizen_9patch_fetched)
-                    {
-                       ++inx; ++iny; inh -= 2;
-                    }
-
                   _draw_image(obj, engine, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur->smooth_scale, do_async);
                   // .--.
                   // |##|
@@ -2968,13 +2932,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                        inw = imw - bl - br; inh = imh - bt - bb;
                        outx = ox + bsl; outy = oy + bst;
                        outw = iw - bsl - bsr; outh = ih - bst - bsb;
-
-                       /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                       if (o->load_opts->tizen_9patch_fetched)
-                         {
-                            ++inx; ++iny; inw -= 2; inh -=2;
-                         }
-
                        if ((o->cur->border.fill == EVAS_BORDER_FILL_SOLID) &&
                            (obj->cur->cache.clip.a == 255) &&
                            (!obj->clip.mask) &&
@@ -2994,13 +2951,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                   inw = br; inh = imh - bt - bb;
                   outx = ox + iw - bsr; outy = oy + bst;
                   outw = bsr; outh = ih - bst - bsb;
-
-                  /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                  if (o->load_opts->tizen_9patch_fetched)
-                    {
-                       --inx; ++iny; inh -= 2;
-                    }
-
                   _draw_image(obj, engine, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur->smooth_scale, do_async);
                   // .--.
                   // |  |
@@ -3009,13 +2959,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                   inw = bl; inh = bb;
                   outx = ox; outy = oy + ih - bsb;
                   outw = bsl; outh = bsb;
-
-                  /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                  if (o->load_opts->tizen_9patch_fetched)
-                    {
-                       ++inx; --iny;
-                    }
-
                   _draw_image(obj, engine, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur->smooth_scale, do_async);
                   // .--.
                   // |  |
@@ -3024,13 +2967,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                   inw = imw - bl - br; inh = bb;
                   outx = ox + bsl; outy = oy + ih - bsb;
                   outw = iw - bsl - bsr; outh = bsb;
-
-                  /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                  if (o->load_opts->tizen_9patch_fetched)
-                    {
-                       ++inx; --iny; inw -= 2;
-                    }
-
                   _draw_image(obj, engine, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur->smooth_scale, do_async);
                   // .--.
                   // |  |
@@ -3039,13 +2975,6 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
                   inw = br; inh = bb;
                   outx = ox + iw - bsr; outy = oy + ih - bsb;
                   outw = bsr; outh = bsb;
-
-                  /* TIZEN_ONLY(190507): Android style Nine-Patch feature */
-                  if (o->load_opts->tizen_9patch_fetched)
-                    {
-                       --inx; --iny;
-                    }
-
                   _draw_image(obj, engine, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur->smooth_scale, do_async);
                }
              idy += idh;
@@ -3080,8 +3009,6 @@ evas_object_image_render_pre(Evas_Object *eo_obj,
 
    if ((o->cur->fill.w < 1) || (o->cur->fill.h < 1)) return;
 
-   tizen_9patch_fetch(eo_obj, obj, o);  //TIZEN_ONLY(190509): Android style Nine-Patch feature
-
    /* if someone is clipping this obj - go calculate the clipper */
    if (obj->cur->clipper)
      {
@@ -4347,197 +4274,6 @@ _efl_canvas_image_internal_efl_object_debug_name_override(Eo *eo_obj, Evas_Image
      }
 }
 
-/* TIZEN_ONLY(190509): Android style Nine-Patch feature */
-Eina_Hash *tizen_9patch_hash = NULL;
-
-void
-tizen_9patch_apply(Evas_Image_Data *o, const Eina_File *f)
-{
-   const char *filename = eina_file_filename_get(f);
-   if (!filename) return;
-
-   int len = strlen(filename);
-   if (len <= 6) return;
-
-   //Support only png format
-   if (!strncmp(filename + (len - 6),".#.png", 6))
-     {
-        EINA_COW_LOAD_OPTS_WRITE_BEGIN(o, load_write)
-           load_write->tizen_9patch_enabled = EINA_TRUE;
-        EINA_COW_LOAD_OPTS_WRITE_END(o, load_write);
-     }
-   else
-     {
-        EINA_COW_LOAD_OPTS_WRITE_BEGIN(o, load_write)
-           load_write->tizen_9patch_enabled = EINA_FALSE;
-        EINA_COW_LOAD_OPTS_WRITE_END(o, load_write);
-     }
-}
-
-void
-tizen_9patch_fetch(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o)
-{
-   const char *filename;
-   tizen_9patch_data *t9d = NULL;
-
-   if (!o->load_opts->tizen_9patch_enabled || o->load_opts->tizen_9patch_fetched) return;
-
-   //Possibly user set borders manually...
-   if ((o->cur->border.l > 0) || (o->cur->border.r > 0) ||
-       (o->cur->border.t > 0) || (o->cur->border.b > 0))
-     goto disable_9patch;
-
-   //Try cached 9patch info.
-   filename = eina_file_filename_get(o->cur->f);
-
-   if (filename)
-     {
-        t9d = eina_hash_find(tizen_9patch_hash, filename);
-        if (t9d)
-          {
-             EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
-               {
-                  state_write->border.l = t9d->l;
-                  state_write->border.r = t9d->r;
-                  state_write->border.t = t9d->t;
-                  state_write->border.b = t9d->b;
-               }
-             EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
-
-             EINA_COW_LOAD_OPTS_WRITE_BEGIN(o, load_write)
-                load_write->tizen_9patch_fetched = EINA_TRUE;
-             EINA_COW_LOAD_OPTS_WRITE_END(o, load_write);
-
-             return;
-          }
-     }
-
-
-   void *output = _evas_object_image_output_find(obj);
-   if (!output) goto err;
-
-   int imagew, imageh, uvw, uvh;
-   void *image = _evas_image_pixels_get(eo_obj, obj, ENC, output, NULL, NULL, 0, 0,
-                                        &imagew, &imageh, &uvw, &uvh, EINA_TRUE, EINA_FALSE);
-   if (!image) goto err;
-
-   //We assume the 9 patch image is PNG
-   Evas_Colorspace cspace = ENFN->image_file_colorspace_get(ENC, image);
-   if (cspace != EVAS_COLORSPACE_ARGB8888)
-     {
-        ERR("Only allow PNG format as the 9 patch image!, obj = %p", obj);
-        goto disable_9patch;
-     }
-
-   DATA32 *pixels = NULL;
-
-   if (ENFN->image_data_direct_get)
-     {
-        Eina_Slice sl;
-        if (ENFN->image_data_direct_get(ENC, image, 0, &sl, &cspace, EINA_TRUE, NULL))
-          pixels = (DATA32 *)sl.mem;
-     }
-   if (!pixels)
-     {
-        //Try other methods?
-        goto err;
-     }
-
-   //Start fetching...
-   DATA32 *p;
-   int l = 0, r = 0, t = 0, b = 0;
-
-   //Left border
-   p = pixels;
-   for (int i = 0; i < imagew; ++i)
-     {
-        if (*p == 0xff000000)
-          {
-             l = (i - 1);
-             break;
-          }
-        ++p;
-     }
-   //Right border
-   p = pixels + (imagew - 1);
-   for (int i = 0; i < imagew; ++i)
-     {
-        if (*p == 0xff000000)
-          {
-             r = (i - 1);
-             break;
-          }
-        --p;
-     }
-   //Top border
-   p = pixels;
-   for (int i = 0; i < imageh; ++i)
-     {
-        if (*p == 0xff000000)
-          {
-             t = (i - 1);
-             break;
-          }
-        p += imagew;
-     }
-   //Bottom border
-   p = pixels + (imagew * (imageh - 1));
-   for (int i = 0; i < imageh; ++i)
-     {
-        if (*p == 0xff000000)
-          {
-             b = (i - 1);
-             break;
-          }
-        p -= imagew;
-     }
-
-   //Verify
-   if ((l < 0) || (r < 0) || (t < 0) || (b < 0) ||
-       (l + r >= imagew) || (t + b >= imageh))
-     goto err;
-
-   //Setup border size
-   EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
-     {
-        state_write->border.l = l;
-        state_write->border.r = r;
-        state_write->border.t = t;
-        state_write->border.b = b;
-     }
-   EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
-
-   EINA_COW_LOAD_OPTS_WRITE_BEGIN(o, load_write)
-      load_write->tizen_9patch_fetched = EINA_TRUE;
-   EINA_COW_LOAD_OPTS_WRITE_END(o, load_write);
-
-   //Cache 9patch info
-   if (filename)
-     {
-        t9d = (tizen_9patch_data*) malloc(sizeof(tizen_9patch_data));
-        if (!t9d) return;
-        t9d->l = l;
-        t9d->r = r;
-        t9d->t = t;
-        t9d->b = b;
-        if (!eina_hash_add(tizen_9patch_hash, filename, t9d))
-          {
-             ERR("Filed to add a 9patch cache data!");
-             free(t9d);
-          }
-     }
-   return;
-
-err:
-   ERR("Couldn't fetch 9 patch!, obj = %p", obj);
-
-disable_9patch:
-   EINA_COW_LOAD_OPTS_WRITE_BEGIN(o, load_write)
-      load_write->tizen_9patch_enabled = EINA_FALSE;
-   EINA_COW_LOAD_OPTS_WRITE_END(o, load_write);
-}
-//
-
 #define EFL_CANVAS_IMAGE_INTERNAL_EXTRA_OPS \
   EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _efl_canvas_image_internal_efl_object_dbg_info_get)