aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-19 19:38:58 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-20 13:27:42 +0900
commit74d84032172c01034119930643631a91c7fe54a5 (patch)
tree863be747f230468f33698f0ae3409460ed56b39f /src
parentEvas filters: Fix padding in blur with offset (diff)
downloadefl-74d84032172c01034119930643631a91c7fe54a5.tar.gz
Evas filters: Grow filter should gracefully blend
If grow() was used on top of another effect, it was simply erasing all pixels. We need to use a temporary buffer and blend it to the output.
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/filters/evas_filter.c32
-rw-r--r--src/lib/evas/filters/evas_filter_parser.c4
2 files changed, 33 insertions, 3 deletions
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index b8c2afcbe4..4c2d9dd010 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -1042,13 +1042,26 @@ int
evas_filter_command_grow_add(Evas_Filter_Context *ctx, void *draw_context,
int inbuf, int outbuf, int radius, Eina_Bool smooth)
{
- int blurcmd, threshcmd, tmin = 0;
+ int blurcmd, threshcmd, blendcmd, tmin = 0, growbuf;
int diam = abs(radius) * 2 + 1;
DATA8 curve[256] = {0};
+ Evas_Filter_Buffer *tmp = NULL, *in;
EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, -1);
- blurcmd = evas_filter_command_blur_add(ctx, draw_context, inbuf, outbuf,
+ in = _filter_buffer_get(ctx, inbuf);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1);
+
+ if (inbuf != outbuf)
+ {
+ tmp = evas_filter_temporary_buffer_get(ctx, in->w, in->h, in->alpha_only);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(tmp, -1);
+ growbuf = tmp->id;
+ }
+ else
+ growbuf = outbuf;
+
+ blurcmd = evas_filter_command_blur_add(ctx, draw_context, inbuf, growbuf,
EVAS_FILTER_BLUR_DEFAULT,
abs(radius), abs(radius), 0, 0);
if (blurcmd < 0) return -1;
@@ -1076,7 +1089,7 @@ evas_filter_command_grow_add(Evas_Filter_Context *ctx, void *draw_context,
memset(curve + end, 255, 256 - end);
}
- threshcmd = evas_filter_command_curve_add(ctx, draw_context, outbuf, outbuf,
+ threshcmd = evas_filter_command_curve_add(ctx, draw_context, growbuf, growbuf,
curve, EVAS_FILTER_CHANNEL_ALPHA);
if (threshcmd < 0)
{
@@ -1084,6 +1097,19 @@ evas_filter_command_grow_add(Evas_Filter_Context *ctx, void *draw_context,
return -1;
}
+ if (tmp)
+ {
+ blendcmd = evas_filter_command_blend_add(ctx, draw_context, tmp->id,
+ outbuf, 0, 0,
+ EVAS_FILTER_FILL_MODE_NONE);
+ if (blendcmd < 0)
+ {
+ _command_del(ctx, _evas_filter_command_get(ctx, threshcmd));
+ _command_del(ctx, _evas_filter_command_get(ctx, blurcmd));
+ return -1;
+ }
+ }
+
return blurcmd;
}
diff --git a/src/lib/evas/filters/evas_filter_parser.c b/src/lib/evas/filters/evas_filter_parser.c
index 361dba0b06..cb9c18a015 100644
--- a/src/lib/evas/filters/evas_filter_parser.c
+++ b/src/lib/evas/filters/evas_filter_parser.c
@@ -2107,6 +2107,7 @@ static int
_instr2cmd_grow(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
Evas_Filter_Instruction *instr, void *dc)
{
+ Evas_Filter_Command *cmd;
const char *src, *dst;
Buffer *in, *out;
Eina_Bool smooth;
@@ -2123,6 +2124,9 @@ _instr2cmd_grow(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
cmdid = evas_filter_command_grow_add(ctx, dc, in->cid, out->cid,
radius, smooth);
+ cmd = _evas_filter_command_get(ctx, cmdid);
+ if (cmd) cmd->draw.need_temp_buffer = EINA_TRUE;
+
return cmdid;
}