[mutter] clutter/blur: Make sigma a float
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter/blur: Make sigma a float
- Date: Thu, 17 Dec 2020 13:48:14 +0000 (UTC)
commit 0b4b341e6c8978c1ed1f86a12c2b5fa1bd19b942
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Dec 17 01:30:47 2020 -0300
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>
clutter/clutter/clutter-blur-private.h | 4 ++--
clutter/clutter/clutter-blur.c | 15 +++++++++------
clutter/clutter/clutter-paint-nodes.c | 4 +++-
clutter/clutter/clutter-paint-nodes.h | 2 +-
4 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/clutter/clutter/clutter-blur-private.h b/clutter/clutter/clutter-blur-private.h
index feb288f31e..cf7cfd2f5e 100644
--- a/clutter/clutter/clutter-blur-private.h
+++ b/clutter/clutter/clutter-blur-private.h
@@ -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);
diff --git a/clutter/clutter/clutter-blur.c b/clutter/clutter/clutter-blur.c
index c60451d0a1..9a8153e8f9 100644
--- a/clutter/clutter/clutter-blur.c
+++ b/clutter/clutter/clutter-blur.c
@@ -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;
diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c
index 9da5b450f0..3fb7d384a9 100644
--- a/clutter/clutter/clutter-paint-nodes.c
+++ b/clutter/clutter/clutter-paint-nodes.c
@@ -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 ());
diff --git a/clutter/clutter/clutter-paint-nodes.h b/clutter/clutter/clutter-paint-nodes.h
index 8c01dd7d25..7f0d12857a 100644
--- a/clutter/clutter/clutter-paint-nodes.h
+++ b/clutter/clutter/clutter-paint-nodes.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]