1
0
Fork 0

clutter/blur: Make sigma a float

The shader already operates on floating point sigma, and
there's just no reason for us to force it to be an unsigned
integer. It's still important that sigma must be positive
though.

Make sigma a float, and make sure it's a positive number.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1646>
This commit is contained in:
Georges Basile Stavracas Neto 2020-12-17 01:30:47 -03:00 committed by Marge Bot
parent 925809ea75
commit 0b4b341e6c
4 changed files with 15 additions and 10 deletions

View file

@ -26,8 +26,8 @@ G_BEGIN_DECLS
typedef struct _ClutterBlur ClutterBlur;
ClutterBlur * clutter_blur_new (CoglTexture *texture,
unsigned int sigma);
ClutterBlur * clutter_blur_new (CoglTexture *texture,
float sigma);
void clutter_blur_apply (ClutterBlur *blur);

View file

@ -125,7 +125,7 @@ typedef struct
struct _ClutterBlur
{
CoglTexture *source_texture;
unsigned int sigma;
float sigma;
float downscale_factor;
BlurPass pass[2];
@ -341,8 +341,8 @@ clear_blur_pass (BlurPass *pass)
* Returns: (transfer full) (nullable): A newly created #ClutterBlur
*/
ClutterBlur *
clutter_blur_new (CoglTexture *texture,
unsigned int sigma)
clutter_blur_new (CoglTexture *texture,
float sigma)
{
ClutterBlur *blur;
unsigned int height;
@ -350,6 +350,9 @@ clutter_blur_new (CoglTexture *texture,
BlurPass *hpass;
BlurPass *vpass;
g_return_val_if_fail (texture != NULL, NULL);
g_return_val_if_fail (sigma >= 0.0, NULL);
width = cogl_texture_get_width (texture);
height = cogl_texture_get_height (texture);
@ -358,7 +361,7 @@ clutter_blur_new (CoglTexture *texture,
blur->source_texture = cogl_object_ref (texture);
blur->downscale_factor = calculate_downscale_factor (width, height, sigma);
if (sigma == 0)
if (G_APPROX_VALUE (sigma, 0.0, FLT_EPSILON))
goto out;
vpass = &blur->pass[VERTICAL];
@ -385,7 +388,7 @@ out:
void
clutter_blur_apply (ClutterBlur *blur)
{
if (blur->sigma == 0)
if (G_APPROX_VALUE (blur->sigma, 0.0, FLT_EPSILON))
return;
apply_blur_pass (&blur->pass[VERTICAL]);
@ -404,7 +407,7 @@ clutter_blur_apply (ClutterBlur *blur)
CoglTexture *
clutter_blur_get_texture (ClutterBlur *blur)
{
if (blur->sigma == 0)
if (G_APPROX_VALUE (blur->sigma, 0.0, FLT_EPSILON))
return blur->source_texture;
else
return blur->pass[HORIZONTAL].texture;

View file

@ -1915,7 +1915,7 @@ clutter_blur_node_init (ClutterBlurNode *blur_node)
ClutterPaintNode *
clutter_blur_node_new (unsigned int width,
unsigned int height,
unsigned int sigma)
float sigma)
{
g_autoptr (CoglOffscreen) offscreen = NULL;
g_autoptr (GError) error = NULL;
@ -1926,6 +1926,8 @@ clutter_blur_node_new (unsigned int width,
CoglTexture *texture;
ClutterBlur *blur;
g_return_val_if_fail (sigma >= 0.0, NULL);
blur_node = _clutter_paint_node_create (CLUTTER_TYPE_BLUR_NODE);
blur_node->sigma = sigma;
context = clutter_backend_get_cogl_context (clutter_get_default_backend ());

View file

@ -282,7 +282,7 @@ GType clutter_blur_node_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
ClutterPaintNode * clutter_blur_node_new (unsigned int width,
unsigned int height,
unsigned int sigma);
float sigma);
G_END_DECLS