[gegl] Issue #97 - Drop Shadow crashes GIMP if opacity is adjusted to 1.000 ...
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Issue #97 - Drop Shadow crashes GIMP if opacity is adjusted to 1.000 ...
- Date: Wed, 12 Sep 2018 11:55:07 +0000 (UTC)
commit dfdec2063f0053e1e30527c0c90c219ddd3db153
Author: Ell <ell_se yahoo com>
Date: Tue Sep 11 13:34:53 2018 -0400
Issue #97 - Drop Shadow crashes GIMP if opacity is adjusted to 1.000 ...
... with the GUI arrow buttons
In gegl:opacity, use fuzzy comparisson for checking if the "value"
property equals 1, and the op is a pass-through.
This test was previously performed using exact comparison, in a
context where "value" is a double, and then later asserted-on in a
context where "value" is a float, which could lead to a different
result, aborting the program. This commit performs all such tests
with "value" as a float, and removes the assertion.
operations/common/opacity.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/operations/common/opacity.c b/operations/common/opacity.c
index 3c16073d6..c3996818f 100644
--- a/operations/common/opacity.c
+++ b/operations/common/opacity.c
@@ -36,6 +36,9 @@ property_double (value, _("Opacity"), 1.0)
#include "gegl-op.h"
#include <stdio.h>
+#include <math.h>
+
+#define EPSILON 1e-6f
static void
prepare (GeglOperation *self)
@@ -103,7 +106,6 @@ process_RaGaBaAfloat (GeglOperation *op,
if (aux == NULL)
{
- g_assert (value != 1.0); /* buffer should have been passed through */
while (samples--)
{
gint j;
@@ -113,7 +115,7 @@ process_RaGaBaAfloat (GeglOperation *op,
out += 4;
}
}
- else if (value == 1.0)
+ else if (fabsf (value - 1.0f) <= EPSILON)
while (samples--)
{
gint j;
@@ -152,7 +154,6 @@ process_RGBAfloat (GeglOperation *op,
if (aux == NULL)
{
- g_assert (value != 1.0); /* buffer should have been passed through */
while (samples--)
{
gint j;
@@ -163,7 +164,7 @@ process_RGBAfloat (GeglOperation *op,
out += 4;
}
}
- else if (value == 1.0)
+ else if (fabsf (value - 1.0f) <= EPSILON)
while (samples--)
{
gint j;
@@ -266,13 +267,14 @@ static gboolean operation_process (GeglOperation *operation,
{
GeglOperationClass *operation_class;
gpointer in, aux;
+ gfloat value = GEGL_PROPERTIES (operation)->value;
operation_class = GEGL_OPERATION_CLASS (gegl_op_parent_class);
/* get the raw values this does not increase the reference count */
in = gegl_operation_context_get_object (context, "input");
aux = gegl_operation_context_get_object (context, "aux");
- if (in && !aux && GEGL_PROPERTIES (operation)->value == 1.0)
+ if (in && !aux && fabsf (value - 1.0f) <= EPSILON)
{
gegl_operation_context_take_object (context, "output",
g_object_ref (G_OBJECT (in)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]