aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/elementary/efl_ui_win.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-02-16 20:40:22 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-02-16 21:05:32 +0900
commitc09b921e34545ad93bd9091e35a816e687276310 (patch)
tree350a80dcd5c843f2f0e8b15bc92421fbb7dd6009 /src/lib/elementary/efl_ui_win.c
parentevas: Flush post-event callbacks only when needed (diff)
downloadefl-c09b921e34545ad93bd9091e35a816e687276310.tar.gz
win: Avoid malloc in icon_object_set
Also support both Evas.Image and EO Efl.Canvas.Image classes. Add a test case in elm_test (under "Icon"). I'm not so happy about this patch... it shows that the API barrier between legacy and EO implemented for images may not be such a great idea after all :(
Diffstat (limited to 'src/lib/elementary/efl_ui_win.c')
-rw-r--r--src/lib/elementary/efl_ui_win.c73
1 files changed, 49 insertions, 24 deletions
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index f558430860..06d3bd501b 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -3185,46 +3185,71 @@ _elm_win_xwin_update(Efl_Ui_Win_Data *sd)
// set window icon
if (sd->icon)
{
- void *data;
+ Eo *image = NULL;
if (efl_isa(sd->icon, EFL_CANVAS_IMAGE_INTERNAL_CLASS))
+ image = sd->icon;
+
+ if (image)
{
- data = evas_object_image_data_get(sd->icon, EINA_FALSE);
- if (data)
+ int w = 0, h = 0, stride, x, y;
+ Eina_Bool unmap = EINA_FALSE;
+ Eina_Rw_Slice sl = {};
+
+ if (efl_isa(image, EFL_CANVAS_IMAGE_CLASS))
+ {
+ unmap = EINA_TRUE;
+ efl_gfx_buffer_size_get(image, &w, &h);
+ efl_gfx_buffer_map(image, &sl, EFL_GFX_BUFFER_ACCESS_MODE_READ,
+ 0, 0, w, h, EFL_GFX_COLORSPACE_ARGB8888, 0,
+ &stride);
+ }
+ else
+ {
+ evas_object_image_size_get(image, &w, &h);
+ stride = evas_object_image_stride_get(image);
+ sl.mem = evas_object_image_data_get(image, EINA_FALSE);
+ }
+
+ if (sl.mem)
{
Ecore_X_Icon ic;
- int w = 0, h = 0, stride, x, y;
- unsigned char *p;
- unsigned int *p2;
- evas_object_image_size_get(sd->icon, &w, &h);
- stride = evas_object_image_stride_get(sd->icon);
+ ic.width = w;
+ ic.height = h;
if ((w > 0) && (h > 0) &&
(stride >= (int)(w * sizeof(unsigned int))))
{
- ic.width = w;
- ic.height = h;
- ic.data = malloc(w * h * sizeof(unsigned int));
-
- if (ic.data)
+ if (stride == (int)(w * sizeof(unsigned int)))
{
- p = (unsigned char *)data;
- p2 = (unsigned int *)ic.data;
- for (y = 0; y < h; y++)
+ ic.data = sl.mem;
+ ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
+ }
+ else
+ {
+ ic.data = malloc(w * h * sizeof(unsigned int));
+ if (ic.data)
{
- for (x = 0; x < w; x++)
+ unsigned char *p = sl.mem;
+ unsigned int *p2 = ic.data;
+
+ for (y = 0; y < h; y++)
{
- *p2 = *((unsigned int *)p);
- p += sizeof(unsigned int);
- p2++;
+ for (x = 0; x < w; x++)
+ {
+ *p2 = *((unsigned int *)p);
+ p += sizeof(unsigned int);
+ p2++;
+ }
+ p += (stride - (w * sizeof(unsigned int)));
}
- p += (stride - (w * sizeof(unsigned int)));
+ ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
+ free(ic.data);
}
- ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
- free(ic.data);
}
}
- evas_object_image_data_set(sd->icon, data);
+ if (unmap) efl_gfx_buffer_unmap(image, &sl);
+ else evas_object_image_data_set(image, sl.mem);
}
}
}