};
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 = {
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);
}
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);
// .##.
// | |
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);
// .--#
// | |
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);
// .--.
// # |
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);
// .--.
// |##|
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) &&
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);
// .--.
// | |
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);
// .--.
// | |
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);
// .--.
// | |
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;
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)
{
}
}
-/* 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)