summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:51:53 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:51:53 -0700
commitfc1b7f7835116bd03878e4b0c1ec2243665fc859 (patch)
tree7c6add463dcc2fb734eee2c1111921ab5e28639d
parentf3f6a7e535bd3338482c462a14f7d43f469fc85c (diff)
evas: make filter handle multi output.
-rw-r--r--src/lib/evas/canvas/evas_filter_mixin.c6
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c4
-rw-r--r--src/lib/evas/filters/evas_filter.c66
-rw-r--r--src/lib/evas/filters/evas_filter_parser.c11
-rw-r--r--src/lib/evas/filters/evas_filter_private.h2
-rw-r--r--src/lib/evas/include/evas_filter.h4
6 files changed, 57 insertions, 36 deletions
diff --git a/src/lib/evas/canvas/evas_filter_mixin.c b/src/lib/evas/canvas/evas_filter_mixin.c
index ab9a8191d0..3f3292ec04 100644
--- a/src/lib/evas/canvas/evas_filter_mixin.c
+++ b/src/lib/evas/canvas/evas_filter_mixin.c
@@ -387,7 +387,7 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
387 387
388 if (filter) 388 if (filter)
389 { 389 {
390 ok = evas_filter_context_program_use(filter, pd->data->chain, EINA_TRUE, X, Y); 390 ok = evas_filter_context_program_use(engine, output, filter, pd->data->chain, EINA_TRUE, X, Y);
391 if (!ok) 391 if (!ok)
392 { 392 {
393 evas_filter_context_destroy(filter); 393 evas_filter_context_destroy(filter);
@@ -401,7 +401,7 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
401 filter = evas_filter_context_new(obj->layer->evas, do_async, 0); 401 filter = evas_filter_context_new(obj->layer->evas, do_async, 0);
402 402
403 // Run script 403 // Run script
404 ok = evas_filter_context_program_use(filter, pd->data->chain, EINA_FALSE, X, Y); 404 ok = evas_filter_context_program_use(engine, output, filter, pd->data->chain, EINA_FALSE, X, Y);
405 if (!filter || !ok) 405 if (!filter || !ok)
406 { 406 {
407 ERR("Parsing failed?"); 407 ERR("Parsing failed?");
@@ -449,7 +449,7 @@ evas_filter_object_render(Eo *eo_obj, Evas_Object_Protected_Data *obj,
449 449
450 // Run the filter now (maybe async) 450 // Run the filter now (maybe async)
451 efl_ref(eo_obj); 451 efl_ref(eo_obj);
452 ok = evas_filter_context_run(filter); 452 ok = evas_filter_context_run(engine, output, filter);
453 if (!ok) ERR("Filter program failed to run!"); 453 if (!ok) ERR("Filter program failed to run!");
454 454
455 return ok; 455 return ok;
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index a5325e6c1d..79abde8b94 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -13505,7 +13505,7 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
13505 ctx = evas_filter_context_new(obj->layer->evas, do_async, ti->gfx_filter); 13505 ctx = evas_filter_context_new(obj->layer->evas, do_async, ti->gfx_filter);
13506 evas_filter_state_prepare(eo_obj, &state, ti); 13506 evas_filter_state_prepare(eo_obj, &state, ti);
13507 evas_filter_program_state_set(pgm, &state); 13507 evas_filter_program_state_set(pgm, &state);
13508 ok = evas_filter_context_program_use(ctx, pgm, EINA_FALSE, 0, 0); 13508 ok = evas_filter_context_program_use(engine, output, ctx, pgm, EINA_FALSE, 0, 0);
13509 if (!ok) 13509 if (!ok)
13510 { 13510 {
13511 evas_filter_context_destroy(ctx); 13511 evas_filter_context_destroy(ctx);
@@ -13819,7 +13819,7 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
13819 else if (ctx) 13819 else if (ctx)
13820 { 13820 {
13821 evas_filter_context_post_run_callback_set(ctx, _filter_cb, obj->layer->evas); 13821 evas_filter_context_post_run_callback_set(ctx, _filter_cb, obj->layer->evas);
13822 evas_filter_context_run(ctx); 13822 evas_filter_context_run(engine, output, ctx);
13823 } 13823 }
13824 } 13824 }
13825 } 13825 }
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index ca03b5dbbe..e95296258b 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -169,7 +169,7 @@ evas_filter_context_proxy_render_all(Evas_Filter_Context *ctx, Eo *eo_obj,
169} 169}
170 170
171void 171void
172_evas_filter_context_program_reuse(Evas_Filter_Context *ctx) 172_evas_filter_context_program_reuse(void *engine, void *output, Evas_Filter_Context *ctx)
173{ 173{
174 Evas_Filter_Buffer *fb; 174 Evas_Filter_Buffer *fb;
175 Eina_List *li; 175 Eina_List *li;
@@ -189,11 +189,11 @@ _evas_filter_context_program_reuse(Evas_Filter_Context *ctx)
189 surface = evas_ector_buffer_render_image_get(fb->buffer); 189 surface = evas_ector_buffer_render_image_get(fb->buffer);
190 if (!surface) continue; 190 if (!surface) continue;
191 191
192 dc = ENFN->context_new(ENC); 192 dc = ENFN->context_new(engine);
193 ENFN->context_color_set(ENC, dc, 0, 0, 0, 0); 193 ENFN->context_color_set(engine, dc, 0, 0, 0, 0);
194 ENFN->context_render_op_set(ENC, dc, EVAS_RENDER_COPY); 194 ENFN->context_render_op_set(engine, dc, EVAS_RENDER_COPY);
195 ENFN->rectangle_draw(ENC, ENDT, dc, surface, 0, 0, fb->w, fb->h, ctx->async); 195 ENFN->rectangle_draw(engine, output, dc, surface, 0, 0, fb->w, fb->h, ctx->async);
196 ENFN->context_free(ENC, dc); 196 ENFN->context_free(engine, dc);
197 fb->dirty = EINA_FALSE; 197 fb->dirty = EINA_FALSE;
198 198
199 evas_ector_buffer_engine_image_release(fb->buffer, surface); 199 evas_ector_buffer_engine_image_release(fb->buffer, surface);
@@ -1578,14 +1578,14 @@ evas_filter_target_set(Evas_Filter_Context *ctx, void *draw_context,
1578} 1578}
1579 1579
1580static Eina_Bool 1580static Eina_Bool
1581_filter_target_render(Evas_Filter_Context *ctx) 1581_filter_target_render(void *engine, void *output, Evas_Filter_Context *ctx)
1582{ 1582{
1583 Evas_Filter_Buffer *src; 1583 Evas_Filter_Buffer *src;
1584 void *drawctx, *image = NULL, *surface; 1584 void *drawctx, *image = NULL, *surface;
1585 1585
1586 EINA_SAFETY_ON_NULL_RETURN_VAL(ctx->target.surface, EINA_FALSE); 1586 EINA_SAFETY_ON_NULL_RETURN_VAL(ctx->target.surface, EINA_FALSE);
1587 1587
1588 drawctx = ENFN->context_new(ENC); 1588 drawctx = ENFN->context_new(engine);
1589 surface = ctx->target.surface; 1589 surface = ctx->target.surface;
1590 1590
1591 src = _filter_buffer_get(ctx, EVAS_FILTER_BUFFER_OUTPUT_ID); 1591 src = _filter_buffer_get(ctx, EVAS_FILTER_BUFFER_OUTPUT_ID);
@@ -1598,48 +1598,48 @@ _filter_target_render(Evas_Filter_Context *ctx)
1598 1598
1599 if (ctx->target.clip_use) 1599 if (ctx->target.clip_use)
1600 { 1600 {
1601 ENFN->context_clip_set(ENC, drawctx, ctx->target.cx, ctx->target.cy, 1601 ENFN->context_clip_set(engine, drawctx, ctx->target.cx, ctx->target.cy,
1602 ctx->target.cw, ctx->target.ch); 1602 ctx->target.cw, ctx->target.ch);
1603 } 1603 }
1604 1604
1605 if (ctx->target.color_use) 1605 if (ctx->target.color_use)
1606 { 1606 {
1607 ENFN->context_multiplier_set(ENC, drawctx, 1607 ENFN->context_multiplier_set(engine, drawctx,
1608 ctx->target.r, ctx->target.g, 1608 ctx->target.r, ctx->target.g,
1609 ctx->target.b, ctx->target.a); 1609 ctx->target.b, ctx->target.a);
1610 } 1610 }
1611 1611
1612 if (ctx->target.mask) 1612 if (ctx->target.mask)
1613 { 1613 {
1614 ENFN->context_clip_image_set(ENC, drawctx, ctx->target.mask, 1614 ENFN->context_clip_image_set(engine, drawctx, ctx->target.mask,
1615 ctx->target.mask_x, ctx->target.mask_y, 1615 ctx->target.mask_x, ctx->target.mask_y,
1616 ctx->evas, EINA_FALSE); 1616 ctx->evas, EINA_FALSE);
1617 } 1617 }
1618 1618
1619 ENFN->context_render_op_set(ENC, drawctx, ctx->target.rop); 1619 ENFN->context_render_op_set(engine, drawctx, ctx->target.rop);
1620 if (ctx->target.map) 1620 if (ctx->target.map)
1621 { 1621 {
1622 ENFN->image_map_draw(ENC, ENDT, drawctx, surface, image, 1622 ENFN->image_map_draw(engine, output, drawctx, surface, image,
1623 ctx->target.map, EINA_TRUE, 0, EINA_FALSE); 1623 ctx->target.map, EINA_TRUE, 0, EINA_FALSE);
1624 } 1624 }
1625 else 1625 else
1626 { 1626 {
1627 ENFN->image_draw(ENC, ENDT, drawctx, surface, image, 1627 ENFN->image_draw(engine, output, drawctx, surface, image,
1628 0, 0, src->w, src->h, 1628 0, 0, src->w, src->h,
1629 ctx->target.x, ctx->target.y, src->w, src->h, 1629 ctx->target.x, ctx->target.y, src->w, src->h,
1630 EINA_TRUE, EINA_FALSE); 1630 EINA_TRUE, EINA_FALSE);
1631 } 1631 }
1632 1632
1633 ENFN->context_free(ENC, drawctx); 1633 ENFN->context_free(engine, drawctx);
1634 evas_ector_buffer_engine_image_release(src->buffer, image); 1634 evas_ector_buffer_engine_image_release(src->buffer, image);
1635 1635
1636 ENFN->image_free(ENC, surface); 1636 ENFN->image_free(engine, surface);
1637 ctx->target.surface = NULL; 1637 ctx->target.surface = NULL;
1638 1638
1639 return EINA_TRUE; 1639 return EINA_TRUE;
1640 1640
1641fail: 1641fail:
1642 ENFN->image_free(ENC, surface); 1642 ENFN->image_free(engine, surface);
1643 ctx->target.surface = NULL; 1643 ctx->target.surface = NULL;
1644 1644
1645 ERR("Failed to render filter to target canvas!"); 1645 ERR("Failed to render filter to target canvas!");
@@ -1797,7 +1797,7 @@ _filter_command_run(Evas_Filter_Command *cmd)
1797} 1797}
1798 1798
1799static Eina_Bool 1799static Eina_Bool
1800_filter_chain_run(Evas_Filter_Context *ctx) 1800_filter_chain_run(void *engine, void *output, Evas_Filter_Context *ctx)
1801{ 1801{
1802 Evas_Filter_Command *cmd; 1802 Evas_Filter_Command *cmd;
1803 Eina_Bool ok = EINA_FALSE; 1803 Eina_Bool ok = EINA_FALSE;
@@ -1814,7 +1814,7 @@ _filter_chain_run(Evas_Filter_Context *ctx)
1814 } 1814 }
1815 } 1815 }
1816 1816
1817 ok = _filter_target_render(ctx); 1817 ok = _filter_target_render(engine, output, ctx);
1818 1818
1819end: 1819end:
1820 ctx->running = EINA_FALSE; 1820 ctx->running = EINA_FALSE;
@@ -1826,10 +1826,21 @@ end:
1826 return ok; 1826 return ok;
1827} 1827}
1828 1828
1829typedef struct _Filter_Thread_Data Filter_Thread_Data;
1830struct _Filter_Thread_Data
1831{
1832 void *engine;
1833 void *output;
1834 Evas_Filter_Context *ctx;
1835};
1836
1829static void 1837static void
1830_filter_thread_run_cb(void *data) 1838_filter_thread_run_cb(void *data)
1831{ 1839{
1832 _filter_chain_run(data); 1840 Filter_Thread_Data *ftd = data;
1841
1842 _filter_chain_run(ftd->engine, ftd->output, ftd->ctx);
1843 free(ftd);
1833} 1844}
1834 1845
1835static void 1846static void
@@ -1882,7 +1893,7 @@ _filter_obscured_region_calc(Evas_Filter_Context *ctx)
1882} 1893}
1883 1894
1884Eina_Bool 1895Eina_Bool
1885evas_filter_context_run(Evas_Filter_Context *ctx) 1896evas_filter_context_run(void *engine, void *output, Evas_Filter_Context *ctx)
1886{ 1897{
1887 _filter_obscured_region_calc(ctx); 1898 _filter_obscured_region_calc(ctx);
1888 1899
@@ -1890,11 +1901,20 @@ evas_filter_context_run(Evas_Filter_Context *ctx)
1890 ctx->running = EINA_TRUE; 1901 ctx->running = EINA_TRUE;
1891 if (ctx->async) 1902 if (ctx->async)
1892 { 1903 {
1893 evas_thread_queue_flush(_filter_thread_run_cb, ctx); 1904 Filter_Thread_Data *ftd;
1905
1906 ftd = calloc(1, sizeof (Filter_Thread_Data));
1907 if (!ftd) return EINA_FALSE;
1908
1909 ftd->engine = engine;
1910 ftd->output = output;
1911 ftd->ctx = ctx;
1912
1913 evas_thread_queue_flush(_filter_thread_run_cb, ftd);
1894 return EINA_TRUE; 1914 return EINA_TRUE;
1895 } 1915 }
1896 1916
1897 return _filter_chain_run(ctx); 1917 return _filter_chain_run(engine, output, ctx);
1898} 1918}
1899 1919
1900 1920
diff --git a/src/lib/evas/filters/evas_filter_parser.c b/src/lib/evas/filters/evas_filter_parser.c
index c9fbe1e387..d01299c5bd 100644
--- a/src/lib/evas/filters/evas_filter_parser.c
+++ b/src/lib/evas/filters/evas_filter_parser.c
@@ -3475,7 +3475,8 @@ _instruction_dump(Evas_Filter_Instruction *instr)
3475#endif 3475#endif
3476 3476
3477Eina_Bool 3477Eina_Bool
3478evas_filter_context_program_use(Evas_Filter_Context *ctx, 3478evas_filter_context_program_use(void *engine, void *output,
3479 Evas_Filter_Context *ctx,
3479 Evas_Filter_Program *pgm, 3480 Evas_Filter_Program *pgm,
3480 Eina_Bool reuse, int object_x, int object_y) 3481 Eina_Bool reuse, int object_x, int object_y)
3481{ 3482{
@@ -3489,7 +3490,7 @@ evas_filter_context_program_use(Evas_Filter_Context *ctx,
3489 3490
3490 XDBG("Using program '%s' for context %p", pgm->name, ctx); 3491 XDBG("Using program '%s' for context %p", pgm->name, ctx);
3491 3492
3492 if (reuse) _evas_filter_context_program_reuse(ctx); 3493 if (reuse) _evas_filter_context_program_reuse(engine, output, ctx);
3493 3494
3494 // Copy current state (size, edje state val, color class, etc...) 3495 // Copy current state (size, edje state val, color class, etc...)
3495 ctx->w = pgm->state.w; 3496 ctx->w = pgm->state.w;
@@ -3521,8 +3522,8 @@ evas_filter_context_program_use(Evas_Filter_Context *ctx,
3521 // Compute and save padding info 3522 // Compute and save padding info
3522 evas_filter_program_padding_get(pgm, &ctx->pad.final, &ctx->pad.calculated); 3523 evas_filter_program_padding_get(pgm, &ctx->pad.final, &ctx->pad.calculated);
3523 3524
3524 dc = ENFN->context_new(ENC); 3525 dc = ENFN->context_new(engine);
3525 ENFN->context_color_set(ENC, dc, 255, 255, 255, 255); 3526 ENFN->context_color_set(engine, dc, 255, 255, 255, 255);
3526 3527
3527 // Apply all commands 3528 // Apply all commands
3528 EINA_INLIST_FOREACH(pgm->instructions, instr) 3529 EINA_INLIST_FOREACH(pgm->instructions, instr)
@@ -3537,7 +3538,7 @@ evas_filter_context_program_use(Evas_Filter_Context *ctx,
3537 3538
3538end: 3539end:
3539 if (!success) evas_filter_context_clear(ctx, EINA_FALSE); 3540 if (!success) evas_filter_context_clear(ctx, EINA_FALSE);
3540 if (dc) ENFN->context_free(ENC, dc); 3541 if (dc) ENFN->context_free(engine, dc);
3541 return success; 3542 return success;
3542} 3543}
3543 3544
diff --git a/src/lib/evas/filters/evas_filter_private.h b/src/lib/evas/filters/evas_filter_private.h
index f6faea3838..5cc22befe0 100644
--- a/src/lib/evas/filters/evas_filter_private.h
+++ b/src/lib/evas/filters/evas_filter_private.h
@@ -301,7 +301,7 @@ Evas_Filter_Buffer *evas_filter_buffer_scaled_get(Evas_Filter_Context *ctx, Evas
301Eina_Bool evas_filter_interpolate(DATA8* output /* 256 values */, int *points /* 256 values */, Evas_Filter_Interpolation_Mode mode); 301Eina_Bool evas_filter_interpolate(DATA8* output /* 256 values */, int *points /* 256 values */, Evas_Filter_Interpolation_Mode mode);
302int evas_filter_smallest_pow2_larger_than(int val); 302int evas_filter_smallest_pow2_larger_than(int val);
303 303
304void _evas_filter_context_program_reuse(Evas_Filter_Context *ctx); 304void _evas_filter_context_program_reuse(void *engine, void *output, Evas_Filter_Context *ctx);
305void evas_filter_parser_shutdown(void); 305void evas_filter_parser_shutdown(void);
306 306
307#define E_READ ECTOR_BUFFER_ACCESS_FLAG_READ 307#define E_READ ECTOR_BUFFER_ACCESS_FLAG_READ
diff --git a/src/lib/evas/include/evas_filter.h b/src/lib/evas/include/evas_filter.h
index 3f88970dc0..175069c7a7 100644
--- a/src/lib/evas/include/evas_filter.h
+++ b/src/lib/evas/include/evas_filter.h
@@ -151,7 +151,7 @@ void *evas_filter_context_data_get(Evas_Filter_Context *ctx);
151Eina_Bool evas_filter_context_async_get(Evas_Filter_Context *ctx); 151Eina_Bool evas_filter_context_async_get(Evas_Filter_Context *ctx);
152void evas_filter_context_size_get(Evas_Filter_Context *ctx, int *w, int *H); 152void evas_filter_context_size_get(Evas_Filter_Context *ctx, int *w, int *H);
153void evas_filter_context_destroy(Evas_Filter_Context *ctx); 153void evas_filter_context_destroy(Evas_Filter_Context *ctx);
154Eina_Bool evas_filter_context_program_use(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, Eina_Bool reuse, int object_x, int object_y); 154Eina_Bool evas_filter_context_program_use(void *engine, void *output, Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, Eina_Bool reuse, int object_x, int object_y);
155void evas_filter_context_proxy_render_all(Evas_Filter_Context *ctx, Eo *eo_obj, Eina_Bool do_async); 155void evas_filter_context_proxy_render_all(Evas_Filter_Context *ctx, Eo *eo_obj, Eina_Bool do_async);
156void evas_filter_context_post_run_callback_set(Evas_Filter_Context *ctx, Evas_Filter_Cb cb, void *data); 156void evas_filter_context_post_run_callback_set(Evas_Filter_Context *ctx, Evas_Filter_Cb cb, void *data);
157#define evas_filter_context_autodestroy(ctx) evas_filter_context_post_run_callback_set(ctx, ((Evas_Filter_Cb) evas_filter_context_destroy), ctx) 157#define evas_filter_context_autodestroy(ctx) evas_filter_context_post_run_callback_set(ctx, ((Evas_Filter_Cb) evas_filter_context_destroy), ctx)
@@ -163,7 +163,7 @@ int evas_filter_buffer_proxy_new(Evas_Filter_Context *ctx,
163void *evas_filter_buffer_backing_get(Evas_Filter_Context *ctx, int bufid, Eina_Bool render); 163void *evas_filter_buffer_backing_get(Evas_Filter_Context *ctx, int bufid, Eina_Bool render);
164Eina_Bool evas_filter_buffer_backing_set(Evas_Filter_Context *ctx, int bufid, void *engine_buffer); 164Eina_Bool evas_filter_buffer_backing_set(Evas_Filter_Context *ctx, int bufid, void *engine_buffer);
165 165
166Eina_Bool evas_filter_context_run(Evas_Filter_Context *ctx); 166Eina_Bool evas_filter_context_run(void *engine, void *output, Evas_Filter_Context *ctx);
167 167
168Eina_Bool evas_filter_font_draw(Evas_Filter_Context *ctx, void *engine, void *output, void *draw_context, int bufid, Evas_Font_Set *font, int x, int y, Evas_Text_Props *text_props, Eina_Bool do_async); 168Eina_Bool evas_filter_font_draw(Evas_Filter_Context *ctx, void *engine, void *output, void *draw_context, int bufid, Evas_Font_Set *font, int x, int y, Evas_Text_Props *text_props, Eina_Bool do_async);
169Eina_Bool evas_filter_target_set(Evas_Filter_Context *ctx, void *draw_context, void *surface, int x, int y, const RGBA_Map *map); 169Eina_Bool evas_filter_target_set(Evas_Filter_Context *ctx, void *draw_context, void *surface, int x, int y, const RGBA_Map *map);