mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
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:
parent
925809ea75
commit
0b4b341e6c
@ -26,8 +26,8 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
typedef struct _ClutterBlur ClutterBlur;
|
typedef struct _ClutterBlur ClutterBlur;
|
||||||
|
|
||||||
ClutterBlur * clutter_blur_new (CoglTexture *texture,
|
ClutterBlur * clutter_blur_new (CoglTexture *texture,
|
||||||
unsigned int sigma);
|
float sigma);
|
||||||
|
|
||||||
void clutter_blur_apply (ClutterBlur *blur);
|
void clutter_blur_apply (ClutterBlur *blur);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ typedef struct
|
|||||||
struct _ClutterBlur
|
struct _ClutterBlur
|
||||||
{
|
{
|
||||||
CoglTexture *source_texture;
|
CoglTexture *source_texture;
|
||||||
unsigned int sigma;
|
float sigma;
|
||||||
float downscale_factor;
|
float downscale_factor;
|
||||||
|
|
||||||
BlurPass pass[2];
|
BlurPass pass[2];
|
||||||
@ -341,8 +341,8 @@ clear_blur_pass (BlurPass *pass)
|
|||||||
* Returns: (transfer full) (nullable): A newly created #ClutterBlur
|
* Returns: (transfer full) (nullable): A newly created #ClutterBlur
|
||||||
*/
|
*/
|
||||||
ClutterBlur *
|
ClutterBlur *
|
||||||
clutter_blur_new (CoglTexture *texture,
|
clutter_blur_new (CoglTexture *texture,
|
||||||
unsigned int sigma)
|
float sigma)
|
||||||
{
|
{
|
||||||
ClutterBlur *blur;
|
ClutterBlur *blur;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
@ -350,6 +350,9 @@ clutter_blur_new (CoglTexture *texture,
|
|||||||
BlurPass *hpass;
|
BlurPass *hpass;
|
||||||
BlurPass *vpass;
|
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);
|
width = cogl_texture_get_width (texture);
|
||||||
height = cogl_texture_get_height (texture);
|
height = cogl_texture_get_height (texture);
|
||||||
|
|
||||||
@ -358,7 +361,7 @@ 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)
|
if (G_APPROX_VALUE (sigma, 0.0, FLT_EPSILON))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
vpass = &blur->pass[VERTICAL];
|
vpass = &blur->pass[VERTICAL];
|
||||||
@ -385,7 +388,7 @@ out:
|
|||||||
void
|
void
|
||||||
clutter_blur_apply (ClutterBlur *blur)
|
clutter_blur_apply (ClutterBlur *blur)
|
||||||
{
|
{
|
||||||
if (blur->sigma == 0)
|
if (G_APPROX_VALUE (blur->sigma, 0.0, FLT_EPSILON))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
apply_blur_pass (&blur->pass[VERTICAL]);
|
apply_blur_pass (&blur->pass[VERTICAL]);
|
||||||
@ -404,7 +407,7 @@ clutter_blur_apply (ClutterBlur *blur)
|
|||||||
CoglTexture *
|
CoglTexture *
|
||||||
clutter_blur_get_texture (ClutterBlur *blur)
|
clutter_blur_get_texture (ClutterBlur *blur)
|
||||||
{
|
{
|
||||||
if (blur->sigma == 0)
|
if (G_APPROX_VALUE (blur->sigma, 0.0, FLT_EPSILON))
|
||||||
return blur->source_texture;
|
return blur->source_texture;
|
||||||
else
|
else
|
||||||
return blur->pass[HORIZONTAL].texture;
|
return blur->pass[HORIZONTAL].texture;
|
||||||
|
@ -1915,7 +1915,7 @@ clutter_blur_node_init (ClutterBlurNode *blur_node)
|
|||||||
ClutterPaintNode *
|
ClutterPaintNode *
|
||||||
clutter_blur_node_new (unsigned int width,
|
clutter_blur_node_new (unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
unsigned int sigma)
|
float sigma)
|
||||||
{
|
{
|
||||||
g_autoptr (CoglOffscreen) offscreen = NULL;
|
g_autoptr (CoglOffscreen) offscreen = NULL;
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
@ -1926,6 +1926,8 @@ clutter_blur_node_new (unsigned int width,
|
|||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
ClutterBlur *blur;
|
ClutterBlur *blur;
|
||||||
|
|
||||||
|
g_return_val_if_fail (sigma >= 0.0, NULL);
|
||||||
|
|
||||||
blur_node = _clutter_paint_node_create (CLUTTER_TYPE_BLUR_NODE);
|
blur_node = _clutter_paint_node_create (CLUTTER_TYPE_BLUR_NODE);
|
||||||
blur_node->sigma = sigma;
|
blur_node->sigma = sigma;
|
||||||
context = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
context = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||||
|
@ -282,7 +282,7 @@ GType clutter_blur_node_get_type (void) G_GNUC_CONST;
|
|||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
ClutterPaintNode * clutter_blur_node_new (unsigned int width,
|
ClutterPaintNode * clutter_blur_node_new (unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
unsigned int sigma);
|
float sigma);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user