forked from enlightenment/efl
evas filters: Fix artifacts when scaling up & down
An odd-sized image scaled down by 2 was losing 1 pixel during the downscale, and it was not restored after scaling up. The same happened with downscaling by 4 except the effect was even more visible. This meant that a moving snapshot with a large blur would trigger some really ugly sampling issues if the content below was precise (such a text).
This commit is contained in:
parent
4cbff5f0ea
commit
5467d1eb3e
|
@ -725,7 +725,9 @@ evas_filter_command_blur_add_gl(Evas_Filter_Context *ctx,
|
|||
|
||||
if (down_x > 1 && down_y > 1)
|
||||
{
|
||||
tmp = evas_filter_temporary_buffer_get(ctx, ctx->w / down_x, ctx->h / down_y,
|
||||
tmp = evas_filter_temporary_buffer_get(ctx,
|
||||
ceil(ctx->w / down_x),
|
||||
ceil(ctx->h / down_y),
|
||||
in->alpha_only, EINA_TRUE);
|
||||
if (!tmp) goto fail;
|
||||
|
||||
|
|
|
@ -163,6 +163,7 @@ _gl_filter_blend(Render_Engine_GL_Generic *re, Evas_Filter_Command *cmd)
|
|||
Evas_Engine_GL_Context *gc;
|
||||
Evas_GL_Image *image, *surface;
|
||||
RGBA_Draw_Context *dc_save;
|
||||
int src_w, src_h, dst_w, dst_h;
|
||||
|
||||
DEBUG_TIME_BEGIN();
|
||||
|
||||
|
@ -182,12 +183,45 @@ _gl_filter_blend(Render_Engine_GL_Generic *re, Evas_Filter_Command *cmd)
|
|||
evas_common_draw_context_set_multiplier(gc->dc, cmd->draw.R, cmd->draw.G, cmd->draw.B, cmd->draw.A);
|
||||
gc->dc->render_op = _gfx_to_evas_render_op(cmd->draw.rop);
|
||||
|
||||
// FIXME: Maybe need to clear buffer in case of COPY mode?
|
||||
// FIXME: Maybe need to clear buffer in case of COPY mode with an offset?
|
||||
|
||||
if ((cmd->draw.fillmode == EVAS_FILTER_FILL_MODE_STRETCH_XY) &&
|
||||
((image->w != surface->w) || (image->h != surface->h)))
|
||||
{
|
||||
int scale_w, scale_h;
|
||||
|
||||
if ((image->w >= surface->w) ||
|
||||
(image->h >= surface->h))
|
||||
{
|
||||
scale_w = image->w / surface->w;
|
||||
scale_h = image->h / surface->h;
|
||||
src_w = ((image->w + (scale_w - 1)) / scale_w) * scale_w;
|
||||
src_h = ((image->h + (scale_h - 1)) / scale_h) * scale_h;
|
||||
dst_w = surface->w;
|
||||
dst_h = surface->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale_w = surface->w / image->w;
|
||||
scale_h = surface->h / image->h;
|
||||
src_w = image->w;
|
||||
src_h = image->h;
|
||||
dst_w = ((surface->w + (scale_w - 1)) / scale_w) * scale_w;
|
||||
dst_h = ((surface->h + (scale_h - 1)) / scale_h) * scale_h;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
src_w = image->w;
|
||||
src_h = image->h;
|
||||
dst_w = surface->w;
|
||||
dst_h = surface->h;
|
||||
}
|
||||
|
||||
DBG("blend %d @%p -> %d @%p", cmd->input->id, cmd->input->buffer,
|
||||
cmd->output->id, cmd->output->buffer);
|
||||
_mapped_blend(gc, image, cmd->draw.fillmode, 0, 0, image->w, image->h,
|
||||
cmd->draw.ox, cmd->draw.oy, cmd->output->w, cmd->output->h);
|
||||
_mapped_blend(gc, image, cmd->draw.fillmode, 0, 0, src_w, src_h,
|
||||
cmd->draw.ox, cmd->draw.oy, dst_w, dst_h);
|
||||
|
||||
evas_common_draw_context_free(gc->dc);
|
||||
gc->dc = dc_save;
|
||||
|
|
Loading…
Reference in New Issue