summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@profusion.mobi>2013-01-11 19:54:12 +0000
committerUlisses Furquim <ulisses@profusion.mobi>2013-01-11 19:54:12 +0000
commited79c2182e3e8522866ed57d179e4030825cfdc2 (patch)
tree9e9c1660f6cb5d8b681862995edbc3873d4ca82c /src/lib
parenta868276f114189cc74c7fad401ba349c2f21180c (diff)
downloadefl-ed79c2182e3e8522866ed57d179e4030825cfdc2.tar.gz
evas/async_render: do not use async event to unref images
Patch by: Leandro Pereira <leandro@profusion.mobi> SVN revision: 82661
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/evas/canvas/evas_main.c2
-rw-r--r--src/lib/evas/canvas/evas_object_image.c55
-rw-r--r--src/lib/evas/canvas/evas_render.c23
-rw-r--r--src/lib/evas/include/evas_private.h4
4 files changed, 69 insertions, 15 deletions
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index e8f45ffcd2..7e838ba241 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -142,6 +142,7 @@ _constructor(Eo *eo_obj, void *class_data, va_list *list EINA_UNUSED)
EVAS_ARRAY_SET(e, temporary_objects);
EVAS_ARRAY_SET(e, calculate_objects);
EVAS_ARRAY_SET(e, clip_changes);
+ EVAS_ARRAY_SET(e, image_unref_queue);
#undef EVAS_ARRAY_SET
}
@@ -247,6 +248,7 @@ _destructor(Eo *eo_e, void *_pd, va_list *list EINA_UNUSED)
eina_array_flush(&e->temporary_objects);
eina_array_flush(&e->calculate_objects);
eina_array_flush(&e->clip_changes);
+ eina_array_flush(&e->image_unref_queue);
EINA_LIST_FREE(e->touch_points, touch_point)
free(touch_point);
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index a18bf5c119..655800014a 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -3138,6 +3138,33 @@ evas_object_image_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
}
static void
+_draw_image(Evas_Object_Protected_Data *obj,
+ void *data, void *context, void *surface, void *image,
+ int src_x, int src_y, int src_w, int src_h, int dst_x,
+ int dst_y, int dst_w, int dst_h, int smooth,
+ Eina_Bool do_async)
+{
+ Eina_Bool async_unref;
+
+ async_unref = obj->layer->evas->engine.func->image_draw(data, context, surface,
+ image, src_x, src_y,
+ src_w, src_h, dst_x,
+ dst_y, dst_w, dst_h,
+ smooth, do_async);
+ if (do_async && async_unref)
+ {
+#ifdef EVAS_CSERVE2
+ if (evas_cserve2_use_get())
+ evas_cache2_image_ref((Image_Entry *)image);
+ else
+#endif
+ evas_cache_image_ref((Image_Entry *)image);
+
+ evas_unref_queue_image_put(obj->layer->evas, image);
+ }
+}
+
+static void
evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, void *output, void *context, void *surface, int x, int y, Eina_Bool do_async)
{
Evas_Object_Image *o = eo_data_get(eo_obj, MY_CLASS);
@@ -3360,8 +3387,8 @@ evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, v
h = ih;
}
- obj->layer->evas->engine.func->image_draw
- (output, context, surface, data,
+ _draw_image
+ (obj, output, context, surface, data,
0, 0,
w, h,
obj->cur.geometry.x + ix + x,
@@ -3373,8 +3400,8 @@ evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, v
else
#endif
{
- obj->layer->evas->engine.func->image_draw
- (output, context, surface, pixels,
+ _draw_image
+ (obj, output, context, surface, pixels,
0, 0,
imagew, imageh,
obj->cur.geometry.x + ix + x,
@@ -3435,28 +3462,28 @@ evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, v
inw = bl; inh = bt;
outx = ox; outy = oy;
outw = bsl; outh = bst;
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
// .##
// |
inx = bl; iny = 0;
inw = imw - bl - br; inh = bt;
outx = ox + bsl; outy = oy;
outw = iw - bsl - bsr; outh = bst;
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
// --#
// |
inx = imw - br; iny = 0;
inw = br; inh = bt;
outx = ox + iw - bsr; outy = oy;
outw = bsr; outh = bst;
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
// .--
// #
inx = 0; iny = bt;
inw = bl; inh = imh - bt - bb;
outx = ox; outy = oy + bst;
outw = bsl; outh = ih - bst - bsb;
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
// .--.
// |##|
if (o->cur.border.fill > EVAS_BORDER_FILL_NONE)
@@ -3471,12 +3498,12 @@ evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, v
{
obj->layer->evas->engine.func->context_render_op_set(output, context,
EVAS_RENDER_COPY);
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
obj->layer->evas->engine.func->context_render_op_set(output, context,
obj->cur.render_op);
}
else
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
}
// --.
// #
@@ -3484,28 +3511,28 @@ evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, v
inw = br; inh = imh - bt - bb;
outx = ox + iw - bsr; outy = oy + bst;
outw = bsr; outh = ih - bst - bsb;
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
// |
// #--
inx = 0; iny = imh - bb;
inw = bl; inh = bb;
outx = ox; outy = oy + ih - bsb;
outw = bsl; outh = bsb;
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
// |
// .##
inx = bl; iny = imh - bb;
inw = imw - bl - br; inh = bb;
outx = ox + bsl; outy = oy + ih - bsb;
outw = iw - bsl - bsr; outh = bsb;
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
// |
// --#
inx = imw - br; iny = imh - bb;
inw = br; inh = bb;
outx = ox + iw - bsr; outy = oy + ih - bsb;
outw = bsr; outh = bsb;
- obj->layer->evas->engine.func->image_draw(output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
+ _draw_image(obj, output, context, surface, pixels, inx, iny, inw, inh, outx, outy, outw, outh, o->cur.smooth_scale, do_async);
}
idy += idh;
if (dobreak_h) break;
diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c
index 495caf79f9..a20e624048 100644
--- a/src/lib/evas/canvas/evas_render.c
+++ b/src/lib/evas/canvas/evas_render.c
@@ -1307,6 +1307,19 @@ evas_render_rendering_wait(Evas_Public_Data *evas)
}
static Eina_Bool
+_drop_image_cache_ref(const void *container EINA_UNUSED, void *data, void *fdata EINA_UNUSED)
+{
+#ifdef EVAS_CSERVE2
+ if (evas_cserve2_use_get())
+ evas_cache2_image_close((Image_Entry *)data);
+ else
+#endif
+ evas_cache_image_drop((Image_Entry *)data);
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
evas_render_updates_internal(Evas *eo_e,
unsigned char make_updates,
unsigned char do_draw,
@@ -1855,6 +1868,10 @@ evas_render_wakeup(Evas *eo_e)
/* clear redraws */
e->engine.func->output_redraws_clear(e->engine.data.output);
+ /* unref queue */
+ eina_array_foreach(&e->image_unref_queue, _drop_image_cache_ref, NULL);
+ eina_array_clean(&e->image_unref_queue);
+
evas_event_callback_call(eo_e, EVAS_CALLBACK_RENDER_POST, NULL);
if (e->render.updates_cb)
@@ -2126,4 +2143,10 @@ evas_render_object_recalc(Evas_Object *eo_obj)
}
}
+void
+evas_unref_queue_image_put(Evas_Public_Data *pd, void *image)
+{
+ eina_array_push(&pd->image_unref_queue, image);
+}
+
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 876401dc42..20aa6a4d92 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -386,6 +386,7 @@ struct _Evas_Public_Data
Eina_Array temporary_objects;
Eina_Array calculate_objects;
Eina_Array clip_changes;
+ Eina_Array image_unref_queue;
Eina_Clist calc_list;
Eina_Clist calc_done;
@@ -818,7 +819,7 @@ struct _Evas_Func
int (*image_alpha_get) (void *data, void *image);
void *(*image_border_set) (void *data, void *image, int l, int r, int t, int b);
void (*image_border_get) (void *data, void *image, int *l, int *r, int *t, int *b);
- void (*image_draw) (void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth, Eina_Bool do_async);
+ Eina_Bool (*image_draw) (void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth, Eina_Bool do_async);
char *(*image_comment_get) (void *data, void *image, char *key);
char *(*image_format_get) (void *data, void *image);
void (*image_colorspace_set) (void *data, void *image, int cspace);
@@ -1048,6 +1049,7 @@ void evas_text_style_pad_get(Evas_Text_Style_Type style, int *l, int *r, int *t,
void _evas_object_text_rehint(Evas_Object *obj);
void _evas_object_textblock_rehint(Evas_Object *obj);
+void evas_unref_queue_image_put(Evas_Public_Data *pd, void *image);
void _freeze_events_set(Eo *obj, void *_pd, va_list *list);
void _freeze_events_get(Eo *obj, void *_pd, va_list *list);