clutter/blur: Shortcircuit when sigma is 0

When there's no blur to be performed, don't do any; instead,
return the original texture, and don't run the vertical and
horizontal blur pipelines.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1637>
This commit is contained in:
Georges Basile Stavracas Neto 2020-12-15 09:48:01 -03:00 committed by Marge Bot
parent 7de5f79ddb
commit d717cc9231

View File

@ -355,6 +355,9 @@ clutter_blur_new (CoglTexture *texture,
blur->source_texture = cogl_object_ref (texture); blur->source_texture = cogl_object_ref (texture);
blur->downscale_factor = calculate_downscale_factor (width, height, sigma); blur->downscale_factor = calculate_downscale_factor (width, height, sigma);
if (sigma == 0)
goto out;
vpass = &blur->pass[VERTICAL]; vpass = &blur->pass[VERTICAL];
hpass = &blur->pass[HORIZONTAL]; hpass = &blur->pass[HORIZONTAL];
@ -365,6 +368,7 @@ clutter_blur_new (CoglTexture *texture,
return NULL; return NULL;
} }
out:
return g_steal_pointer (&blur); return g_steal_pointer (&blur);
} }
@ -378,6 +382,9 @@ clutter_blur_new (CoglTexture *texture,
void void
clutter_blur_apply (ClutterBlur *blur) clutter_blur_apply (ClutterBlur *blur)
{ {
if (blur->sigma == 0)
return;
apply_blur_pass (&blur->pass[VERTICAL]); apply_blur_pass (&blur->pass[VERTICAL]);
apply_blur_pass (&blur->pass[HORIZONTAL]); apply_blur_pass (&blur->pass[HORIZONTAL]);
} }
@ -394,7 +401,10 @@ clutter_blur_apply (ClutterBlur *blur)
CoglTexture * CoglTexture *
clutter_blur_get_texture (ClutterBlur *blur) clutter_blur_get_texture (ClutterBlur *blur)
{ {
return blur->pass[HORIZONTAL].texture; if (blur->sigma == 0)
return blur->source_texture;
else
return blur->pass[HORIZONTAL].texture;
} }
/** /**