Commit 435d0228 authored by Marco Trevisan's avatar Marco Trevisan 🎺

clutter/offscreen-effect: Make sure we use linear filter for fractional scaling

When we try to update the FB, we might face the case in which the effect target
framebuffer does not need any redraw, because it's already properly sized and
scaled, but the filter applied to the pipeline is not, because it has been
computed for a non-fractional scaling.

This is happens for example to clutter actors with a flattening effect (i.e.
override redirect mode set), that might have been generated properly for a
celied scaling level, but when we go fractional we need to ensure to use a
linear filter, as the 1:1 texel:pixel assumption is not true anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
parent 6e738696
......@@ -143,6 +143,30 @@ clutter_offscreen_effect_real_create_texture (ClutterOffscreenEffect *effect,
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
}
static void
ensure_proper_pipeline_filter_for_scale (ClutterOffscreenEffect *self,
float resource_scale)
{
CoglPipelineFilter filter;
if (!self->priv->target)
return;
/* If no fractional scaling is set, we're always going to render the texture
at a 1:1 texel:pixel ratio so, in such case we can use 'nearest' filtering
to decrease the effects of rounding errors in the geometry calculation;
if instead we we're using a global fractional scaling we need to make sure
that we're using the default linear effect, not to create artifacts when
scaling down the texture */
if (fmodf (resource_scale, 1.0f) == 0)
filter = COGL_PIPELINE_FILTER_NEAREST;
else
filter = COGL_PIPELINE_FILTER_LINEAR;
cogl_pipeline_set_layer_filters (self->priv->target, 0 /* layer_index */,
filter, filter);
}
static gboolean
update_fbo (ClutterEffect *effect,
int target_width,
......@@ -165,7 +189,10 @@ update_fbo (ClutterEffect *effect,
if (priv->target_width == target_width &&
priv->target_height == target_height &&
priv->offscreen != NULL)
{
ensure_proper_pipeline_filter_for_scale (self, resource_scale);
return TRUE;
}
if (priv->target == NULL)
{
......@@ -173,17 +200,7 @@ update_fbo (ClutterEffect *effect,
clutter_backend_get_cogl_context (clutter_get_default_backend ());
priv->target = cogl_pipeline_new (ctx);
if (fmodf (resource_scale, 1.0f) == 0)
{
/* We're always going to render the texture at a 1:1 texel:pixel
ratio so we can use 'nearest' filtering to decrease the
effects of rounding errors in the geometry calculation */
cogl_pipeline_set_layer_filters (priv->target,
0, /* layer_index */
COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST);
}
ensure_proper_pipeline_filter_for_scale (self, resource_scale);
}
if (priv->texture != NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment