Evas filters: Allow use of a color multiplier

We couldn't do evas_object_color_set() on a filtered text
object simply because the color was not properly taken into
account.

This should simplify some effects as it'll be much easier to
set a color or alpha value to the text regardless of the filter.

Hmm, is this a fix or feature? O_o
This commit is contained in:
Jean-Philippe Andre 2014-06-11 15:59:31 +09:00
parent 873eb4151f
commit c99449ea09
3 changed files with 31 additions and 0 deletions

View File

@ -1735,6 +1735,18 @@ evas_object_text_render(Evas_Object *eo_obj,
X = obj->cur->geometry.x;
Y = obj->cur->geometry.y;
// Prepare color multiplier
ENFN->context_color_set(ENDT, context, 255, 255, 255, 255);
if ((obj->cur->cache.clip.r == 255) && (obj->cur->cache.clip.g == 255) &&
(obj->cur->cache.clip.b == 255) && (obj->cur->cache.clip.a == 255))
ENFN->context_multiplier_unset(ENDT, context);
else
ENFN->context_multiplier_set(ENDT, context,
obj->cur->cache.clip.r,
obj->cur->cache.clip.g,
obj->cur->cache.clip.b,
obj->cur->cache.clip.a);
if (!o->cur.filter.chain)
{
Evas_Filter_Program *pgm;

View File

@ -1619,6 +1619,12 @@ evas_filter_target_set(Evas_Filter_Context *ctx, void *draw_context,
ctx->target.clip_use = ENFN->context_clip_get
(ENDT, draw_context, &ctx->target.cx, &ctx->target.cy,
&ctx->target.cw, &ctx->target.ch);
ctx->target.color_use = ENFN->context_multiplier_get
(ENDT, draw_context, &ctx->target.r, &ctx->target.g,
&ctx->target.b, &ctx->target.a);
if (ctx->target.r == 255 && ctx->target.g == 255 &&
ctx->target.b == 255 && ctx->target.a == 255)
ctx->target.color_use = EINA_FALSE;
if (ctx->gl_engine)
{
@ -1693,6 +1699,17 @@ _filter_target_render(Evas_Filter_Context *ctx)
ctx->target.cw, ctx->target.ch);
}
if (ctx->target.color_use)
{
ENFN->context_multiplier_set(ENDT, drawctx,
ctx->target.r, ctx->target.g,
ctx->target.b, ctx->target.a);
}
else
{
ENFN->context_multiplier_unset(ENDT, drawctx);
}
ENFN->image_draw(ENDT, drawctx, surface, image,
0, 0, src->w, src->h,
ctx->target.x, ctx->target.y, src->w, src->h,

View File

@ -100,7 +100,9 @@ struct _Evas_Filter_Context
void *context;
int x, y;
int cx, cy, cw, ch; // clip
int r, g, b, a; // clip color
Eina_Bool clip_use : 1;
Eina_Bool color_use : 1;
} target;
Eina_Bool async : 1;