diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-01-05 17:56:04 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-01-17 14:35:29 +0900 |
commit | 93965db815d7ca1e3951b7cda9f74e821975d648 (patch) | |
tree | 5df9f929c30af74f97f4f5f24f4d071f2a732137 /src/lib/evas | |
parent | 1512741b488e212c825ccc78d626d8f666ab1344 (diff) |
evas: Implement filter sources support for textblock
Diffstat (limited to '')
-rw-r--r-- | src/lib/evas/canvas/efl_canvas_text.eo | 1 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_filter_mixin.c | 6 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_textblock.c | 65 | ||||
-rw-r--r-- | src/lib/evas/include/evas_filter.h | 3 |
4 files changed, 71 insertions, 4 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_text.eo b/src/lib/evas/canvas/efl_canvas_text.eo index e39544ee54..c018d11fca 100644 --- a/src/lib/evas/canvas/efl_canvas_text.eo +++ b/src/lib/evas/canvas/efl_canvas_text.eo | |||
@@ -369,6 +369,7 @@ class Efl.Canvas.Text (Efl.Canvas.Object, Efl.Text, Efl.Canvas.Filter.Internal) | |||
369 | Efl.Text.text { get; set; } | 369 | Efl.Text.text { get; set; } |
370 | Efl.Gfx.Filter.filter_program { get; set; } | 370 | Efl.Gfx.Filter.filter_program { get; set; } |
371 | Efl.Gfx.Filter.filter_data { get; set; } | 371 | Efl.Gfx.Filter.filter_data { get; set; } |
372 | Efl.Gfx.Filter.filter_source { get; set; } | ||
372 | Efl.Canvas.Filter.Internal.filter_dirty; | 373 | Efl.Canvas.Filter.Internal.filter_dirty; |
373 | Efl.Canvas.Filter.Internal.filter_input_render; | 374 | Efl.Canvas.Filter.Internal.filter_input_render; |
374 | Efl.Canvas.Filter.Internal.filter_state_prepare; | 375 | Efl.Canvas.Filter.Internal.filter_state_prepare; |
diff --git a/src/lib/evas/canvas/evas_filter_mixin.c b/src/lib/evas/canvas/evas_filter_mixin.c index 1f6ea23216..d28280b7bb 100644 --- a/src/lib/evas/canvas/evas_filter_mixin.c +++ b/src/lib/evas/canvas/evas_filter_mixin.c | |||
@@ -107,8 +107,8 @@ _filter_cb(Evas_Filter_Context *ctx, void *data, Eina_Bool success) | |||
107 | evas_post_render_job_add(obj->layer->evas, _filter_async_post_render_cb, post_data); | 107 | evas_post_render_job_add(obj->layer->evas, _filter_async_post_render_cb, post_data); |
108 | } | 108 | } |
109 | 109 | ||
110 | static void | 110 | void |
111 | _filter_source_hash_free_cb(void *data) | 111 | _evas_filter_source_hash_free_cb(void *data) |
112 | { | 112 | { |
113 | Evas_Filter_Proxy_Binding *pb = data; | 113 | Evas_Filter_Proxy_Binding *pb = data; |
114 | Evas_Object_Protected_Data *proxy, *source; | 114 | Evas_Object_Protected_Data *proxy, *source; |
@@ -423,7 +423,7 @@ _efl_canvas_filter_internal_efl_gfx_filter_filter_source_set(Eo *eo_obj, Evas_Fi | |||
423 | 423 | ||
424 | fcow = FCOW_BEGIN(pd); | 424 | fcow = FCOW_BEGIN(pd); |
425 | if (!fcow->sources) | 425 | if (!fcow->sources) |
426 | fcow->sources = eina_hash_string_small_new(EINA_FREE_CB(_filter_source_hash_free_cb)); | 426 | fcow->sources = eina_hash_string_small_new(_evas_filter_source_hash_free_cb); |
427 | else if (pb_old) | 427 | else if (pb_old) |
428 | eina_hash_del(fcow->sources, name, pb_old); | 428 | eina_hash_del(fcow->sources, name, pb_old); |
429 | 429 | ||
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index bec6c8857c..ca0ef1a00b 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c | |||
@@ -598,6 +598,7 @@ struct _Evas_Object_Textblock | |||
598 | struct { | 598 | struct { |
599 | Efl_Canvas_Text_Filter_Program *programs; | 599 | Efl_Canvas_Text_Filter_Program *programs; |
600 | Evas_Filter_Data_Binding *data_bindings; | 600 | Evas_Filter_Data_Binding *data_bindings; |
601 | Eina_Hash *sources; | ||
601 | } gfx_filter; | 602 | } gfx_filter; |
602 | Eina_Bool redraw : 1; | 603 | Eina_Bool redraw : 1; |
603 | Eina_Bool changed : 1; | 604 | Eina_Bool changed : 1; |
@@ -4378,6 +4379,7 @@ _format_filter_program_get(Efl_Canvas_Text_Data *o, Evas_Object_Textblock_Format | |||
4378 | { | 4379 | { |
4379 | pgm = evas_filter_program_new(program->name, EINA_FALSE); | 4380 | pgm = evas_filter_program_new(program->name, EINA_FALSE); |
4380 | evas_filter_program_data_set_all(pgm, EINA_INLIST_GET(o->gfx_filter.data_bindings)); | 4381 | evas_filter_program_data_set_all(pgm, EINA_INLIST_GET(o->gfx_filter.data_bindings)); |
4382 | evas_filter_program_source_set_all(pgm, o->gfx_filter.sources); | ||
4381 | if (!evas_filter_program_parse(pgm, program->code)) | 4383 | if (!evas_filter_program_parse(pgm, program->code)) |
4382 | { | 4384 | { |
4383 | evas_filter_program_del(pgm); | 4385 | evas_filter_program_del(pgm); |
@@ -12875,6 +12877,7 @@ evas_object_textblock_free(Evas_Object *eo_obj) | |||
12875 | eina_stringshare_del(db->value); | 12877 | eina_stringshare_del(db->value); |
12876 | free(db); | 12878 | free(db); |
12877 | } | 12879 | } |
12880 | eina_hash_free(o->gfx_filter.sources); | ||
12878 | 12881 | ||
12879 | while (evas_object_textblock_style_user_peek(eo_obj)) | 12882 | while (evas_object_textblock_style_user_peek(eo_obj)) |
12880 | { | 12883 | { |
@@ -13285,7 +13288,6 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED, | |||
13285 | filter->contexts = eina_array_new(8); | 13288 | filter->contexts = eina_array_new(8); |
13286 | filter_id = eina_array_count(filter->contexts); | 13289 | filter_id = eina_array_count(filter->contexts); |
13287 | 13290 | ||
13288 | // TODO: sources set | ||
13289 | ctx = evas_filter_context_new(obj->layer->evas, do_async, filter_id); | 13291 | ctx = evas_filter_context_new(obj->layer->evas, do_async, filter_id); |
13290 | evas_filter_state_prepare(eo_obj, &state, ti); | 13292 | evas_filter_state_prepare(eo_obj, &state, ti); |
13291 | evas_filter_program_state_set(pgm, &state); | 13293 | evas_filter_program_state_set(pgm, &state); |
@@ -13309,6 +13311,7 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED, | |||
13309 | evas_filter_program_padding_get(pgm, | 13311 | evas_filter_program_padding_get(pgm, |
13310 | &filter->pad.l, &filter->pad.r, | 13312 | &filter->pad.l, &filter->pad.r, |
13311 | &filter->pad.t, &filter->pad.b); | 13313 | &filter->pad.t, &filter->pad.b); |
13314 | evas_filter_context_proxy_render_all(ctx, eo_obj, EINA_FALSE); | ||
13312 | evas_filter_context_buffers_allocate_all(ctx); | 13315 | evas_filter_context_buffers_allocate_all(ctx); |
13313 | evas_filter_target_set(ctx, context, surface, | 13316 | evas_filter_target_set(ctx, context, surface, |
13314 | obj->cur->geometry.x + ln->x + ti->parent.x + x - filter->pad.l, | 13317 | obj->cur->geometry.x + ln->x + ti->parent.x + x - filter->pad.l, |
@@ -13776,6 +13779,66 @@ _efl_canvas_text_efl_gfx_filter_filter_data_get(Eo *obj EINA_UNUSED, Efl_Canvas_ | |||
13776 | if (execute) *execute = db->execute; | 13779 | if (execute) *execute = db->execute; |
13777 | } | 13780 | } |
13778 | 13781 | ||
13782 | EOLIAN static void | ||
13783 | _efl_canvas_text_efl_gfx_filter_filter_source_set(Eo *eo_obj, Efl_Canvas_Text_Data *pd, const char *name, Efl_Gfx *eo_source) | ||
13784 | { | ||
13785 | Evas_Object_Protected_Data *obj, *source; | ||
13786 | Evas_Filter_Proxy_Binding *pb; | ||
13787 | |||
13788 | if (!name) return; | ||
13789 | |||
13790 | obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); | ||
13791 | source = efl_data_scope_get(eo_source, EFL_CANVAS_OBJECT_CLASS); | ||
13792 | evas_object_async_block(obj); | ||
13793 | |||
13794 | pb = eina_hash_find(pd->gfx_filter.sources, name); | ||
13795 | if (pb) | ||
13796 | { | ||
13797 | if (pb->eo_source == eo_source) return; | ||
13798 | eina_hash_del(pd->gfx_filter.sources, name, pb); | ||
13799 | } | ||
13800 | else if (!eo_source) | ||
13801 | { | ||
13802 | return; | ||
13803 | } | ||
13804 | else | ||
13805 | { | ||
13806 | pb = calloc(1, sizeof(*pb)); | ||
13807 | pb->eo_proxy = eo_obj; | ||
13808 | pb->eo_source = eo_source; | ||
13809 | pb->name = eina_stringshare_add(name); | ||
13810 | } | ||
13811 | |||
13812 | if (!pd->gfx_filter.sources) | ||
13813 | pd->gfx_filter.sources = eina_hash_string_small_new(_evas_filter_source_hash_free_cb); | ||
13814 | eina_hash_set(pd->gfx_filter.sources, name, pb); | ||
13815 | |||
13816 | if (!eina_list_data_find(source->proxy->proxies, eo_obj)) | ||
13817 | { | ||
13818 | EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, source->proxy, Evas_Object_Proxy_Data, source_write) | ||
13819 | source_write->proxies = eina_list_append(source_write->proxies, eo_obj); | ||
13820 | EINA_COW_WRITE_END(evas_object_proxy_cow, source->proxy, source_write) | ||
13821 | } | ||
13822 | |||
13823 | if (!obj->proxy->is_proxy) | ||
13824 | { | ||
13825 | EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, obj->proxy, Evas_Object_Proxy_Data, proxy_write) | ||
13826 | proxy_write->is_proxy = EINA_TRUE; | ||
13827 | EINA_COW_WRITE_END(evas_object_proxy_cow, obj->proxy, proxy_write) | ||
13828 | } | ||
13829 | |||
13830 | pd->format_changed = EINA_TRUE; | ||
13831 | _evas_textblock_invalidate_all(pd); | ||
13832 | _evas_textblock_changed(pd, eo_obj); | ||
13833 | evas_object_change(eo_obj, obj); | ||
13834 | } | ||
13835 | |||
13836 | EOLIAN static Efl_Gfx * | ||
13837 | _efl_canvas_text_efl_gfx_filter_filter_source_get(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *pd, const char *name) | ||
13838 | { | ||
13839 | return eina_hash_find(pd->gfx_filter.sources, name); | ||
13840 | } | ||
13841 | |||
13779 | static void | 13842 | static void |
13780 | evas_object_textblock_coords_recalc(Evas_Object *eo_obj, | 13843 | evas_object_textblock_coords_recalc(Evas_Object *eo_obj, |
13781 | Evas_Object_Protected_Data *obj, | 13844 | Evas_Object_Protected_Data *obj, |
diff --git a/src/lib/evas/include/evas_filter.h b/src/lib/evas/include/evas_filter.h index 75a80a92d7..0ee3f30e9d 100644 --- a/src/lib/evas/include/evas_filter.h +++ b/src/lib/evas/include/evas_filter.h | |||
@@ -157,6 +157,9 @@ Eina_Bool evas_filter_font_draw(Evas_Filter_Context *ctx, void *d | |||
157 | Eina_Bool evas_filter_image_draw(Evas_Filter_Context *ctx, void *draw_context, int bufid, void *image, Eina_Bool do_async); | 157 | Eina_Bool evas_filter_image_draw(Evas_Filter_Context *ctx, void *draw_context, int bufid, void *image, Eina_Bool do_async); |
158 | Eina_Bool evas_filter_target_set(Evas_Filter_Context *ctx, void *draw_context, void *surface, int x, int y); | 158 | Eina_Bool evas_filter_target_set(Evas_Filter_Context *ctx, void *draw_context, void *surface, int x, int y); |
159 | 159 | ||
160 | // utility function | ||
161 | void _evas_filter_source_hash_free_cb(void *data); | ||
162 | |||
160 | /** | 163 | /** |
161 | * @brief Blend a source buffer into a destination buffer, allowing X,Y offsets, Alpha to RGBA conversion with color | 164 | * @brief Blend a source buffer into a destination buffer, allowing X,Y offsets, Alpha to RGBA conversion with color |
162 | * @param ctx Current filter chain | 165 | * @param ctx Current filter chain |