[gimp] app: add gimp_drawable_apply_operation_to_tiles()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_drawable_apply_operation_to_tiles()
- Date: Sun, 6 Jun 2010 17:53:46 +0000 (UTC)
commit 301b990a4682fd8881f896805cbabca96da5b0ac
Author: Michael Natterer <mitch gimp org>
Date: Sun Jun 6 19:52:39 2010 +0200
app: add gimp_drawable_apply_operation_to_tiles()
which uses a passed-in tile manager instead of
the drawable's shadow tiles as sink.
app/core/gimpdrawable-operation.c | 115 +++++++++++++++++++++++++++++++------
app/core/gimpdrawable-operation.h | 17 ++++--
2 files changed, 110 insertions(+), 22 deletions(-)
---
diff --git a/app/core/gimpdrawable-operation.c b/app/core/gimpdrawable-operation.c
index 8bbfabc..a1bed3d 100644
--- a/app/core/gimpdrawable-operation.c
+++ b/app/core/gimpdrawable-operation.c
@@ -26,12 +26,27 @@
#include "core-types.h"
+#include "base/tile-manager.h"
+
#include "gimpdrawable.h"
#include "gimpdrawable-operation.h"
#include "gimpdrawable-shadow.h"
#include "gimpprogress.h"
+/* local function prototypes */
+
+static void gimp_drawable_apply_operation_private (GimpDrawable *drawable,
+ GimpProgress *progress,
+ const gchar *undo_desc,
+ GeglNode *operation,
+ gboolean linear,
+ TileManager *dest_tiles,
+ const GeglRectangle *rect);
+
+
+/* public functions */
+
void
gimp_drawable_apply_operation (GimpDrawable *drawable,
GimpProgress *progress,
@@ -39,12 +54,7 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
GeglNode *operation,
gboolean linear)
{
- GeglNode *gegl;
- GeglNode *input;
- GeglNode *output;
- GeglProcessor *processor;
- GeglRectangle rect;
- gdouble value;
+ GeglRectangle rect;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
@@ -57,6 +67,75 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
&rect.width, &rect.height))
return;
+ gimp_drawable_apply_operation_private (drawable,
+ progress,
+ undo_desc,
+ operation,
+ linear,
+ gimp_drawable_get_shadow_tiles (drawable),
+ &rect);
+
+ gimp_drawable_merge_shadow_tiles (drawable, TRUE, undo_desc);
+ gimp_drawable_free_shadow_tiles (drawable);
+
+ gimp_drawable_update (drawable, rect.x, rect.y, rect.width, rect.height);
+
+ if (progress)
+ gimp_progress_end (progress);
+}
+
+void
+gimp_drawable_apply_operation_to_tiles (GimpDrawable *drawable,
+ GimpProgress *progress,
+ const gchar *undo_desc,
+ GeglNode *operation,
+ gboolean linear,
+ TileManager *new_tiles)
+{
+ GeglRectangle rect;
+
+ g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
+ g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
+ g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
+ g_return_if_fail (undo_desc != NULL);
+ g_return_if_fail (GEGL_IS_NODE (operation));
+ g_return_if_fail (new_tiles != NULL);
+
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = tile_manager_width (new_tiles);
+ rect.height = tile_manager_height (new_tiles);
+
+ gimp_drawable_apply_operation_private (drawable,
+ progress,
+ undo_desc,
+ operation,
+ linear,
+ new_tiles,
+ &rect);
+
+ if (progress)
+ gimp_progress_end (progress);
+}
+
+
+/* private functions */
+
+static void
+gimp_drawable_apply_operation_private (GimpDrawable *drawable,
+ GimpProgress *progress,
+ const gchar *undo_desc,
+ GeglNode *operation,
+ gboolean linear,
+ TileManager *dest_tiles,
+ const GeglRectangle *rect)
+{
+ GeglNode *gegl;
+ GeglNode *input;
+ GeglNode *output;
+ GeglProcessor *processor;
+ gdouble value;
+
gegl = gegl_node_new ();
/* Disable caching on all children of the node unless explicitly re-enabled.
@@ -72,7 +151,7 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
NULL);
output = gegl_node_new_child (gegl,
"operation", "gimp:tilemanager-sink",
- "tile-manager", gimp_drawable_get_shadow_tiles (drawable),
+ "tile-manager", dest_tiles,
"linear", linear,
NULL);
@@ -80,24 +159,26 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
gegl_node_link_many (input, operation, output, NULL);
- processor = gegl_node_new_processor (output, &rect);
+ processor = gegl_node_new_processor (output, rect);
if (progress)
gimp_progress_start (progress, undo_desc, FALSE);
while (gegl_processor_work (processor, &value))
if (progress)
- gimp_progress_set_value (progress, value);
+ {
+ gimp_progress_set_value (progress, value);
+
+ /* FIXME: this needs to move to GimpProgress, it seems the
+ * introduction of client-side windows has somehow changed
+ * things, so calling gdk_window_process_updates() is not
+ * enough any longer.
+ */
+ while (g_main_context_pending (NULL))
+ g_main_context_iteration (NULL, TRUE);
+ }
g_object_unref (processor);
- gimp_drawable_merge_shadow_tiles (drawable, TRUE, undo_desc);
- gimp_drawable_free_shadow_tiles (drawable);
-
- gimp_drawable_update (drawable, rect.x, rect.y, rect.width, rect.height);
-
- if (progress)
- gimp_progress_end (progress);
-
g_object_unref (gegl);
}
diff --git a/app/core/gimpdrawable-operation.h b/app/core/gimpdrawable-operation.h
index 6e205a8..798680b 100644
--- a/app/core/gimpdrawable-operation.h
+++ b/app/core/gimpdrawable-operation.h
@@ -24,11 +24,18 @@
#define __GIMP_DRAWABLE_OPERATION_H__
-void gimp_drawable_apply_operation (GimpDrawable *drawable,
- GimpProgress *progress,
- const gchar *undo_desc,
- GeglNode *operation,
- gboolean linear);
+void gimp_drawable_apply_operation (GimpDrawable *drawable,
+ GimpProgress *progress,
+ const gchar *undo_desc,
+ GeglNode *operation,
+ gboolean linear);
+
+void gimp_drawable_apply_operation_to_tiles (GimpDrawable *drawable,
+ GimpProgress *progress,
+ const gchar *undo_desc,
+ GeglNode *operation,
+ gboolean linear,
+ TileManager *new_tiles);
#endif /* __GIMP_DRAWABLE_OPERATION_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]