summaryrefslogtreecommitdiff
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
parent0d9ffc262455f7ea7a4727a54a3c20844df28d06 (diff)
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
1042evas_filter_command_grow_add(Evas_Filter_Context *ctx, void *draw_context, 1042evas_filter_command_grow_add(Evas_Filter_Context *ctx, void *draw_context,
1043 int inbuf, int outbuf, int radius, Eina_Bool smooth) 1043 int inbuf, int outbuf, int radius, Eina_Bool smooth)
1044{ 1044{
1045 int blurcmd, threshcmd, tmin = 0; 1045 int blurcmd, threshcmd, blendcmd, tmin = 0, growbuf;
1046 int diam = abs(radius) * 2 + 1; 1046 int diam = abs(radius) * 2 + 1;
1047 DATA8 curve[256] = {0}; 1047 DATA8 curve[256] = {0};
1048 Evas_Filter_Buffer *tmp = NULL, *in;
1048 1049
1049 EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, -1); 1050 EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, -1);
1050 1051
1051 blurcmd = evas_filter_command_blur_add(ctx, draw_context, inbuf, outbuf, 1052 in = _filter_buffer_get(ctx, inbuf);
1053 EINA_SAFETY_ON_NULL_RETURN_VAL(in, -1);
1054
1055 if (inbuf != outbuf)
1056 {
1057 tmp = evas_filter_temporary_buffer_get(ctx, in->w, in->h, in->alpha_only);
1058 EINA_SAFETY_ON_NULL_RETURN_VAL(tmp, -1);
1059 growbuf = tmp->id;
1060 }
1061 else
1062 growbuf = outbuf;
1063
1064 blurcmd = evas_filter_command_blur_add(ctx, draw_context, inbuf, growbuf,
1052 EVAS_FILTER_BLUR_DEFAULT, 1065 EVAS_FILTER_BLUR_DEFAULT,
1053 abs(radius), abs(radius), 0, 0); 1066 abs(radius), abs(radius), 0, 0);
1054 if (blurcmd < 0) return -1; 1067 if (blurcmd < 0) return -1;
@@ -1076,7 +1089,7 @@ evas_filter_command_grow_add(Evas_Filter_Context *ctx, void *draw_context,
1076 memset(curve + end, 255, 256 - end); 1089 memset(curve + end, 255, 256 - end);
1077 } 1090 }
1078 1091
1079 threshcmd = evas_filter_command_curve_add(ctx, draw_context, outbuf, outbuf, 1092 threshcmd = evas_filter_command_curve_add(ctx, draw_context, growbuf, growbuf,
1080 curve, EVAS_FILTER_CHANNEL_ALPHA); 1093 curve, EVAS_FILTER_CHANNEL_ALPHA);
1081 if (threshcmd < 0) 1094 if (threshcmd < 0)
1082 { 1095 {
@@ -1084,6 +1097,19 @@ evas_filter_command_grow_add(Evas_Filter_Context *ctx, void *draw_context,
1084 return -1; 1097 return -1;
1085 } 1098 }
1086 1099
1100 if (tmp)
1101 {
1102 blendcmd = evas_filter_command_blend_add(ctx, draw_context, tmp->id,
1103 outbuf, 0, 0,
1104 EVAS_FILTER_FILL_MODE_NONE);
1105 if (blendcmd < 0)
1106 {
1107 _command_del(ctx, _evas_filter_command_get(ctx, threshcmd));
1108 _command_del(ctx, _evas_filter_command_get(ctx, blurcmd));
1109 return -1;
1110 }
1111 }
1112
1087 return blurcmd; 1113 return blurcmd;
1088} 1114}
1089 1115
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
2107_instr2cmd_grow(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm, 2107_instr2cmd_grow(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2108 Evas_Filter_Instruction *instr, void *dc) 2108 Evas_Filter_Instruction *instr, void *dc)
2109{ 2109{
2110 Evas_Filter_Command *cmd;
2110 const char *src, *dst; 2111 const char *src, *dst;
2111 Buffer *in, *out; 2112 Buffer *in, *out;
2112 Eina_Bool smooth; 2113 Eina_Bool smooth;
@@ -2123,6 +2124,9 @@ _instr2cmd_grow(Evas_Filter_Context *ctx, Evas_Filter_Program *pgm,
2123 cmdid = evas_filter_command_grow_add(ctx, dc, in->cid, out->cid, 2124 cmdid = evas_filter_command_grow_add(ctx, dc, in->cid, out->cid,
2124 radius, smooth); 2125 radius, smooth);
2125 2126
2127 cmd = _evas_filter_command_get(ctx, cmdid);
2128 if (cmd) cmd->draw.need_temp_buffer = EINA_TRUE;
2129
2126 return cmdid; 2130 return cmdid;
2127} 2131}
2128 2132