[gimp/soc-2011-warp] gimpwarptool: move the test code to the gegl op
- From: Michael Murà <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2011-warp] gimpwarptool: move the test code to the gegl op
- Date: Tue, 14 Jun 2011 21:51:32 +0000 (UTC)
commit fa723ce5c3f54da255bf3709d10df75d8ea8eceb
Author: Michael Murà <batolettre gmail com>
Date: Tue Jun 14 21:59:53 2011 +0200
gimpwarptool: move the test code to the gegl op
app/gegl/gimpoperationwarp.c | 51 +++++++++++++++++++++++++++++++++-------
app/tools/gimpwarptool.c | 52 +-----------------------------------------
2 files changed, 43 insertions(+), 60 deletions(-)
---
diff --git a/app/gegl/gimpoperationwarp.c b/app/gegl/gimpoperationwarp.c
index ed8315c..dc8a917 100644
--- a/app/gegl/gimpoperationwarp.c
+++ b/app/gegl/gimpoperationwarp.c
@@ -180,18 +180,51 @@ gimp_operation_warp_process (GeglOperation *operation,
GeglBuffer *out_buf,
const GeglRectangle *roi)
{
- GimpOperationWarp *ow = GIMP_OPERATION_WARP (operation);
+ GimpOperationWarp *ow = GIMP_OPERATION_WARP (operation);
+ GeglBuffer *buffer;
+ GeglBufferIterator *it;
+ Babl *format;
+ gint x, y;
+ GeglRectangle area = {100,
+ 100,
+ 200,
+ 200};
-/*
- if (in_buf)
- {
- out_buf = gegl_buffer_dup (in_buf);
- }
- else
+ format = babl_format_n (babl_type ("float"), 2);
+
+ buffer = gegl_buffer_dup (in_buf);
+
+ it = gegl_buffer_iterator_new (buffer, &area, format, GEGL_BUFFER_READWRITE);
+
+ while (gegl_buffer_iterator_next (it))
{
- gegl_buffer_clear (out_buf, roi);
+ /* iterate inside the roi */
+ gint n_pixels = it->length;
+ gfloat *coords = it->data[0];
+
+ x = it->roi->x; /* initial x */
+ y = it->roi->y; /* and y coordinates */
+
+ while (n_pixels--)
+ {
+ coords[0] += 2;
+ coords[1] += 2;
+
+ coords += 2;
+
+ /* update x and y coordinates */
+ x++;
+ if (x >= (it->roi->x + it->roi->width))
+ {
+ x = it->roi->x;
+ y++;
+ }
+ }
}
-*/
+
+ gegl_buffer_copy (buffer, roi, out_buf, roi);
+ gegl_buffer_set_extent (out_buf, gegl_buffer_get_extent (in_buf));
+ gegl_buffer_destroy (buffer);
return TRUE;
}
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index cf9289a..12877ab 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -104,11 +104,6 @@ static void gimp_warp_tool_image_map_flush (GimpImageMap *imag
GimpTool *tool);
static void gimp_warp_tool_image_map_update (GimpWarpTool *wt);
static void gimp_warp_tool_add_op (GimpWarpTool *wt);
-#if 0
-static void gimp_warp_tool_act_on_coords (GimpWarpTool *wt,
- gint x,
- gint y);
-#endif
G_DEFINE_TYPE (GimpWarpTool, gimp_warp_tool, GIMP_TYPE_DRAW_TOOL)
@@ -259,6 +254,7 @@ gimp_warp_tool_start (GimpWarpTool *wt,
bbox.width = ABS (x1 - x2);
bbox.height = ABS (y1 - y2);
+ printf ("Initialize coordinate buffer (%d,%d) at %d,%d\n", bbox.width, bbox.height, bbox.x, bbox.y);
wt->coords_buffer = gegl_buffer_new (&bbox, format);
gimp_warp_tool_create_image_map (wt, drawable);
@@ -563,50 +559,4 @@ gimp_warp_tool_add_op (GimpWarpTool *wt)
gegl_node_connect_to (last_op, "output", new_op, "input");
gegl_node_connect_to (new_op, "output", wt->render_node, "aux");
-
- g_object_unref (last_op);
-}
-
-#if 0
-static void
-gimp_warp_tool_act_on_coords (GimpWarpTool *wt,
- gint x,
- gint y)
-{
- GeglBufferIterator *it;
- Babl *format;
- GeglRectangle area = {x - 30,
- y - 30,
- 60,
- 60};
-
- format = babl_format_n (babl_type ("float"), 2);
- it = gegl_buffer_iterator_new (wt->coords_buffer, &area, format, GEGL_BUFFER_READWRITE);
-
- while (gegl_buffer_iterator_next (it))
- {
- /* iterate inside the roi */
- gint n_pixels = it->length;
- gfloat *coords = it->data[0];
-
- x = it->roi->x; /* initial x */
- y = it->roi->y; /* and y coordinates */
-
- while (n_pixels--)
- {
- coords[0] += 2;
- coords[1] += 2;
-
- coords += 2;
-
- /* update x and y coordinates */
- x++;
- if (x >= (it->roi->x + it->roi->width))
- {
- x = it->roi->x;
- y++;
- }
- }
- }
}
-#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]