[gegl] operations: make the motion blurs use angles from -180 to 180
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operations: make the motion blurs use angles from -180 to 180
- Date: Sun, 18 May 2014 20:33:18 +0000 (UTC)
commit 210f9345a94d9a59c856ab75fc46805ce30339ae
Author: Michael Natterer <mitch gimp org>
Date: Sun May 18 22:31:05 2014 +0200
operations: make the motion blurs use angles from -180 to 180
operations/common/motion-blur-circular.c | 9 ++-
operations/common/motion-blur-linear.c | 101 ++++++++++++++++++------------
2 files changed, 67 insertions(+), 43 deletions(-)
---
diff --git a/operations/common/motion-blur-circular.c b/operations/common/motion-blur-circular.c
index 2f36b93..71dab69 100644
--- a/operations/common/motion-blur-circular.c
+++ b/operations/common/motion-blur-circular.c
@@ -55,8 +55,7 @@ gegl_property_double (center_y, _("Center Y"),
/* FIXME: With a large angle, we lose AreaFilter's flavours */
gegl_property_double (angle, _("Angle"),
"description", _("Rotation blur angle. A large angle may take some time to render"),
- "default", 5.0, "min", 0.0, "max", 360.0,
- "ui-min", 0.0, "ui-max", 90.0, "ui-gamma", 2.0,
+ "default", 5.0, "min", -180.0, "max", 180.0,
"unit", "degree",
NULL)
@@ -80,6 +79,9 @@ prepare (GeglOperation *operation)
GeglRectangle *whole_region;
gdouble angle = o->angle * G_PI / 180.0;
+ while (angle < 0.0)
+ angle += 2 * G_PI;
+
whole_region = gegl_operation_source_get_bounding_box (operation, "input");
if (whole_region != NULL)
@@ -181,6 +183,9 @@ process (GeglOperation *operation,
angle = o->angle * G_PI / 180.0;
+ while (angle < 0.0)
+ angle += 2 * G_PI;
+
for (y = roi->y; y < roi->height + roi->y; ++y)
{
for (x = roi->x; x < roi->width + roi->x; ++x)
diff --git a/operations/common/motion-blur-linear.c b/operations/common/motion-blur-linear.c
index ff75645..e8e8b51 100644
--- a/operations/common/motion-blur-linear.c
+++ b/operations/common/motion-blur-linear.c
@@ -32,8 +32,7 @@ gegl_property_double (length, _("Length"),
gegl_property_double (angle, _("Angle"),
"description", _("Angle of blur in degrees"),
- "default", 0.0, "min", -360.0, "max", 360.0,
- "ui-min", -180.0, "ui-max", 180.0,
+ "default", 0.0, "min", -180.0, "max", 180.0,
"unit", "degrees",
NULL)
@@ -49,10 +48,15 @@ prepare (GeglOperation *operation)
{
GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation);
GeglProperties *o = GEGL_PROPERTIES (operation);
+ gdouble theta = o->angle * G_PI / 180.0;
+ gdouble offset_x;
+ gdouble offset_y;
- gdouble theta = o->angle * G_PI / 180.0;
- gdouble offset_x = fabs (o->length * cos (theta));
- gdouble offset_y = fabs (o->length * sin (theta));
+ while (theta < 0.0)
+ theta += 2 * G_PI;
+
+ offset_x = fabs (o->length * cos (theta));
+ offset_y = fabs (o->length * sin (theta));
op_area->left =
op_area->right = (gint) ceil (0.5 * offset_x);
@@ -140,45 +144,54 @@ cl_process (GeglOperation *operation,
GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation);
GeglProperties *o = GEGL_PROPERTIES (operation);
+ GeglBufferClIterator *i;
const Babl *in_format = gegl_operation_get_format (operation, "input");
const Babl *out_format = gegl_operation_get_format (operation, "output");
- gint err;
-
- gdouble theta = o->angle * G_PI / 180.0;
- gfloat offset_x = (gfloat)(o->length * cos(theta));
- gfloat offset_y = (gfloat)(o->length * sin(theta));
- gint num_steps = (gint)ceil(o->length) + 1;
-
- GeglBufferClIterator *i = gegl_buffer_cl_iterator_new (output,
- result,
- out_format,
- GEGL_CL_BUFFER_WRITE);
-
- gint read = gegl_buffer_cl_iterator_add_2 (i,
- input,
- result,
- in_format,
- GEGL_CL_BUFFER_READ,
- op_area->left,
- op_area->right,
- op_area->top,
- op_area->bottom,
- GEGL_ABYSS_NONE);
+ gint err;
+ gdouble theta = o->angle * G_PI / 180.0;
+ gint num_steps = (gint)ceil(o->length) + 1;
+ gfloat offset_x;
+ gfloat offset_y;
+ gint read;
+
+ while (theta < 0.0)
+ theta += 2 * G_PI;
+
+ offset_x = (gfloat) (o->length * cos (theta));
+ offset_y = (gfloat) (o->length * sin (theta));
+
+ i = gegl_buffer_cl_iterator_new (output,
+ result,
+ out_format,
+ GEGL_CL_BUFFER_WRITE);
+
+ read = gegl_buffer_cl_iterator_add_2 (i,
+ input,
+ result,
+ in_format,
+ GEGL_CL_BUFFER_READ,
+ op_area->left,
+ op_area->right,
+ op_area->top,
+ op_area->bottom,
+ GEGL_ABYSS_NONE);
while (gegl_buffer_cl_iterator_next (i, &err))
{
- if (err) return FALSE;
-
- err = cl_motion_blur_linear(i->tex[read],
- i->tex[0],
- i->size[0],
- &i->roi[0],
- &i->roi[read],
- num_steps,
- offset_x,
- offset_y);
-
- if (err) return FALSE;
+ if (err)
+ return FALSE;
+
+ err = cl_motion_blur_linear (i->tex[read],
+ i->tex[0],
+ i->size[0],
+ &i->roi[0],
+ &i->roi[read],
+ num_steps,
+ offset_x,
+ offset_y);
+
+ if (err)
+ return FALSE;
}
return TRUE;
@@ -215,10 +228,16 @@ process (GeglOperation *operation,
gint x, y;
gdouble theta = o->angle * G_PI / 180.0;
- gdouble offset_x = o->length * cos (theta);
- gdouble offset_y = o->length * sin (theta);
gint num_steps = (gint) ceil (o->length) + 1;
gfloat inv_num_steps = 1.0f / num_steps;
+ gdouble offset_x;
+ gdouble offset_y;
+
+ while (theta < 0.0)
+ theta += 2 * G_PI;
+
+ offset_x = o->length * cos (theta);
+ offset_y = o->length * sin (theta);
src_rect = *roi;
src_rect.x -= op_area->left;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]