summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-12-22 20:18:51 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-01-17 14:35:28 +0900
commit301e80a10a7246c6aa4112088c91b91d1e45553f (patch)
treeffd764faddc0d53eb51cc241acfa236e9d96ced0 /src
parentc2ba0939d8df6b8f6bc076a75780d74f3e83a960 (diff)
evas: Remove most extra data from filter mixin
This should save a bit of memory for all image & text objects. This exploits the previous patch for the post-render job queue added to evas, and simplifies this bit of code.
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/canvas/evas_filter_mixin.c91
-rw-r--r--src/lib/evas/canvas/evas_object_main.c2
-rw-r--r--src/lib/evas/include/evas_private.h1
3 files changed, 35 insertions, 59 deletions
diff --git a/src/lib/evas/canvas/evas_filter_mixin.c b/src/lib/evas/canvas/evas_filter_mixin.c
index 3f211a4fab..f4f2265ece 100644
--- a/src/lib/evas/canvas/evas_filter_mixin.c
+++ b/src/lib/evas/canvas/evas_filter_mixin.c
@@ -20,14 +20,11 @@ typedef struct _Evas_Filter_Post_Render_Data Evas_Filter_Post_Render_Data;
20struct _Evas_Filter_Data 20struct _Evas_Filter_Data
21{ 21{
22 const Evas_Object_Filter_Data *data; 22 const Evas_Object_Filter_Data *data;
23 Evas_Object_Protected_Data *obj;
24 Eina_Bool has_cb;
25 SLK(lck);
26 Eina_List *post_data;
27}; 23};
28 24
29struct _Evas_Filter_Post_Render_Data 25struct _Evas_Filter_Post_Render_Data
30{ 26{
27 Evas_Filter_Data *pd;
31 Evas_Filter_Context *ctx; 28 Evas_Filter_Context *ctx;
32 Eina_Bool success; 29 Eina_Bool success;
33}; 30};
@@ -48,10 +45,6 @@ _filter_end_sync(Evas_Filter_Context *ctx, Evas_Object_Protected_Data *obj,
48 void *previous = pd->data->output; 45 void *previous = pd->data->output;
49 Eo *eo_obj = obj->object; 46 Eo *eo_obj = obj->object;
50 47
51#ifdef DEBUG
52 EINA_SAFETY_ON_FALSE_RETURN(eina_main_loop_is());
53#endif
54
55 if (!success) 48 if (!success)
56 { 49 {
57 ERR("Filter failed at runtime!"); 50 ERR("Filter failed at runtime!");
@@ -74,45 +67,44 @@ _filter_end_sync(Evas_Filter_Context *ctx, Evas_Object_Protected_Data *obj,
74} 67}
75 68
76static void 69static void
77_render_post_cb(void *data, const Efl_Event *event EINA_UNUSED) 70_filter_async_post_render_cb(void *data)
78{ 71{
79 Evas_Filter_Data *pd = data; 72 Evas_Filter_Post_Render_Data *task = data;
80 Evas_Object_Protected_Data *obj = pd->obj; 73 Evas_Filter_Data *pd = task->pd;
81 Eina_List *post_data;
82 Evas_Filter_Post_Render_Data *task;
83 74
84 SLKL(pd->lck); 75#ifdef DEBUG
85 post_data = pd->post_data; 76 EINA_SAFETY_ON_FALSE_RETURN(eina_main_loop_is());
86 pd->post_data = NULL; 77#endif
87 SLKU(pd->lck);
88 78
89 EINA_LIST_FREE(post_data, task) 79 _filter_end_sync(task->ctx, pd->data->obj, pd, task->success);
90 { 80 free(task);
91 _filter_end_sync(task->ctx, obj, pd, task->success);
92 free(task);
93 }
94} 81}
95 82
96static void 83static void
97_filter_cb(Evas_Filter_Context *ctx, void *data, Eina_Bool success) 84_filter_cb(Evas_Filter_Context *ctx, void *data, Eina_Bool success)
98{ 85{
99 Evas_Filter_Post_Render_Data *post_data; 86 Evas_Filter_Post_Render_Data *post_data;
87 Evas_Object_Protected_Data *obj;
100 Evas_Filter_Data *pd = data; 88 Evas_Filter_Data *pd = data;
101 89
102 if (!pd) 90#ifdef DEBUG
103 return; 91 EINA_SAFETY_ON_FALSE_RETURN(!eina_main_loop_is());
92#endif
93
94 obj = pd->data->obj;
95 EINA_SAFETY_ON_FALSE_RETURN(obj && obj->layer && obj->layer->evas);
96
104 if (!pd->data->async) 97 if (!pd->data->async)
105 { 98 {
106 _filter_end_sync(ctx, pd->obj, pd, success); 99 _filter_end_sync(ctx, pd->data->obj, pd, success);
107 return; 100 return;
108 } 101 }
109 102
110 post_data = calloc(1, sizeof(*post_data)); 103 post_data = calloc(1, sizeof(*post_data));
111 post_data->success = success; 104 post_data->success = success;
112 post_data->ctx = ctx; 105 post_data->ctx = ctx;
113 SLKL(pd->lck); 106 post_data->pd = pd;
114 pd->post_data = eina_list_append(pd->post_data, post_data); 107 evas_post_render_job_add(obj->layer->evas, _filter_async_post_render_cb, post_data);
115 SLKU(pd->lck);
116} 108}
117 109
118static void 110static void
@@ -155,7 +147,7 @@ _evas_filter_state_set_internal(Evas_Filter_Program *pgm, Evas_Filter_Data *pd)
155{ 147{
156 Efl_Canvas_Filter_State state = EFL_CANVAS_FILTER_STATE_DEFAULT; 148 Efl_Canvas_Filter_State state = EFL_CANVAS_FILTER_STATE_DEFAULT;
157 149
158 evas_filter_state_prepare(pd->obj->object, &state, NULL); 150 evas_filter_state_prepare(pd->data->obj->object, &state, NULL);
159 state.cur.name = pd->data->state.cur.name; 151 state.cur.name = pd->data->state.cur.name;
160 state.cur.value = pd->data->state.cur.value; 152 state.cur.value = pd->data->state.cur.value;
161 state.next.name = pd->data->state.next.name; 153 state.next.name = pd->data->state.next.name;
@@ -271,14 +263,6 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
271 263
272 if (!redraw) 264 if (!redraw)
273 { 265 {
274 if (pd->has_cb)
275 {
276 // Post render callback is not required anymore
277 Evas *e = obj->layer->evas->evas;
278 efl_event_callback_del(e, EFL_CANVAS_EVENT_RENDER_POST, _render_post_cb, pd);
279 pd->has_cb = EINA_FALSE;
280 }
281
282 // Render this image only 266 // Render this image only
283 ENFN->image_draw(ENDT, context, 267 ENFN->image_draw(ENDT, context,
284 surface, previous, 268 surface, previous,
@@ -331,12 +315,6 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
331 ENFN->context_free(ENDT, drawctx); 315 ENFN->context_free(ENDT, drawctx);
332 316
333 // Add post-run callback and run filter 317 // Add post-run callback and run filter
334 if (do_async && !pd->has_cb)
335 {
336 Evas *e = obj->layer->evas->evas;
337 efl_event_callback_add(e, EFL_CANVAS_EVENT_RENDER_POST, _render_post_cb, pd);
338 pd->has_cb = EINA_TRUE;
339 }
340 evas_filter_context_post_run_callback_set(filter, _filter_cb, pd); 318 evas_filter_context_post_run_callback_set(filter, _filter_cb, pd);
341 ok = evas_filter_run(filter); 319 ok = evas_filter_run(filter);
342 320
@@ -369,14 +347,15 @@ _efl_canvas_filter_internal_efl_gfx_filter_filter_program_set(Eo *eo_obj, Evas_F
369 Evas_Object_Filter_Data *fcow; 347 Evas_Object_Filter_Data *fcow;
370 Eina_Bool alpha; 348 Eina_Bool alpha;
371 349
372 if (!pd) return; 350 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
373 obj = pd->obj;
374 if (eina_streq(pd->data->code, code) && eina_streq(pd->data->name, name)) 351 if (eina_streq(pd->data->code, code) && eina_streq(pd->data->name, name))
375 return; 352 return;
376 353
377 evas_object_async_block(obj); 354 evas_object_async_block(obj);
378 fcow = FCOW_BEGIN(pd); 355 fcow = FCOW_BEGIN(pd);
379 { 356 {
357 fcow->obj = obj;
358
380 // Parse filter program 359 // Parse filter program
381 evas_filter_program_del(fcow->chain); 360 evas_filter_program_del(fcow->chain);
382 eina_stringshare_replace(&fcow->name, name); 361 eina_stringshare_replace(&fcow->name, name);
@@ -415,11 +394,12 @@ EOLIAN static void
415_efl_canvas_filter_internal_efl_gfx_filter_filter_source_set(Eo *eo_obj, Evas_Filter_Data *pd, 394_efl_canvas_filter_internal_efl_gfx_filter_filter_source_set(Eo *eo_obj, Evas_Filter_Data *pd,
416 const char *name, Efl_Gfx *eo_source) 395 const char *name, Efl_Gfx *eo_source)
417{ 396{
418 Evas_Object_Protected_Data *obj = pd->obj; 397 Evas_Object_Protected_Data *obj;
419 Evas_Filter_Proxy_Binding *pb, *pb_old = NULL; 398 Evas_Filter_Proxy_Binding *pb, *pb_old = NULL;
420 Evas_Object_Protected_Data *source = NULL; 399 Evas_Object_Protected_Data *source = NULL;
421 Evas_Object_Filter_Data *fcow = NULL; 400 Evas_Object_Filter_Data *fcow = NULL;
422 401
402 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
423 if (eo_source) 403 if (eo_source)
424 source = efl_data_scope_get(eo_source, EFL_CANVAS_OBJECT_CLASS); 404 source = efl_data_scope_get(eo_source, EFL_CANVAS_OBJECT_CLASS);
425 405
@@ -509,7 +489,7 @@ _efl_canvas_filter_internal_efl_gfx_filter_filter_state_set(Eo *eo_obj, Evas_Fil
509 const char *next_state, double next_val, 489 const char *next_state, double next_val,
510 double pos) 490 double pos)
511{ 491{
512 Evas_Object_Protected_Data *obj = pd->obj; 492 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
513 493
514 evas_object_async_block(obj); 494 evas_object_async_block(obj);
515 if ((cur_state != pd->data->state.cur.name) || 495 if ((cur_state != pd->data->state.cur.name) ||
@@ -593,8 +573,6 @@ _efl_canvas_filter_internal_efl_object_constructor(Eo *eo_obj, Evas_Filter_Data
593 573
594 obj = efl_constructor(efl_super(eo_obj, MY_CLASS)); 574 obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
595 pd->data = eina_cow_alloc(evas_object_filter_cow); 575 pd->data = eina_cow_alloc(evas_object_filter_cow);
596 pd->obj = efl_data_ref(eo_obj, EFL_CANVAS_OBJECT_CLASS);
597 SLKI(pd->lck);
598 576
599 return obj; 577 return obj;
600} 578}
@@ -602,19 +580,23 @@ _efl_canvas_filter_internal_efl_object_constructor(Eo *eo_obj, Evas_Filter_Data
602EOLIAN static void 580EOLIAN static void
603_efl_canvas_filter_internal_efl_object_destructor(Eo *eo_obj, Evas_Filter_Data *pd) 581_efl_canvas_filter_internal_efl_object_destructor(Eo *eo_obj, Evas_Filter_Data *pd)
604{ 582{
605 Evas_Object_Protected_Data *obj = pd->obj; 583 Evas_Object_Protected_Data *obj;
606 Evas_Filter_Data_Binding *db; 584 Evas_Filter_Data_Binding *db;
585 Evas_Public_Data *e;
607 Eina_Inlist *il; 586 Eina_Inlist *il;
608 587
609 if (!pd->data || (evas_object_filter_cow_default == pd->data)) 588 if (!pd->data || (evas_object_filter_cow_default == pd->data))
610 goto finish; 589 goto finish;
611 590
591 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
592 e = obj->layer->evas;
593
612 if (pd->data->output) 594 if (pd->data->output)
613 { 595 {
614 if (!pd->data->async) 596 if (!pd->data->async)
615 ENFN->image_free(ENDT, pd->data->output); 597 ENFN->image_free(ENDT, pd->data->output);
616 else 598 else
617 evas_unref_queue_image_put(obj->layer->evas, pd->data->output); 599 evas_unref_queue_image_put(e, pd->data->output);
618 } 600 }
619 eina_hash_free(pd->data->sources); 601 eina_hash_free(pd->data->sources);
620 EINA_INLIST_FOREACH_SAFE(pd->data->data, il, db) 602 EINA_INLIST_FOREACH_SAFE(pd->data->data, il, db)
@@ -630,13 +612,6 @@ _efl_canvas_filter_internal_efl_object_destructor(Eo *eo_obj, Evas_Filter_Data *
630 612
631finish: 613finish:
632 eina_cow_free(evas_object_filter_cow, (const Eina_Cow_Data **) &pd->data); 614 eina_cow_free(evas_object_filter_cow, (const Eina_Cow_Data **) &pd->data);
633 if (pd->has_cb)
634 {
635 Evas *e = obj->layer->evas->evas;
636 efl_event_callback_del(e, EFL_CANVAS_EVENT_RENDER_POST, _render_post_cb, pd);
637 }
638 SLKD(pd->lck);
639 efl_data_unref(eo_obj, pd->obj);
640 615
641 efl_destructor(efl_super(eo_obj, MY_CLASS)); 616 efl_destructor(efl_super(eo_obj, MY_CLASS));
642} 617}
diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c
index 810328119d..bd521b5b26 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -33,7 +33,7 @@ static const Evas_Object_Protected_State default_state = {
33 1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE 33 1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE
34}; 34};
35static const Evas_Object_Filter_Data default_filter = { 35static const Evas_Object_Filter_Data default_filter = {
36 NULL, NULL, NULL, NULL, NULL, NULL, { { NULL, 0.0 }, { NULL, 0.0 }, 0.0 }, EINA_FALSE, EINA_FALSE, EINA_TRUE 36 NULL, NULL, NULL, NULL, NULL, NULL, NULL, { { NULL, 0.0 }, { NULL, 0.0 }, 0.0 }, EINA_FALSE, EINA_FALSE, EINA_TRUE
37}; 37};
38const void * const evas_object_filter_cow_default = &default_filter; 38const void * const evas_object_filter_cow_default = &default_filter;
39static const Evas_Object_Mask_Data default_mask = { 39static const Evas_Object_Mask_Data default_mask = {
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 0d0d416e1e..257c05c3f8 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1278,6 +1278,7 @@ struct _Evas_Font_Description
1278 1278
1279struct _Evas_Object_Filter_Data 1279struct _Evas_Object_Filter_Data
1280{ 1280{
1281 Evas_Object_Protected_Data *obj;
1281 Eina_Stringshare *name; 1282 Eina_Stringshare *name;
1282 Eina_Stringshare *code; 1283 Eina_Stringshare *code;
1283 Evas_Filter_Program *chain; 1284 Evas_Filter_Program *chain;