[gimp] app: add gimp_drawable_merge_filter() which applies a filter to a drawable
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_drawable_merge_filter() which applies a filter to a drawable
- Date: Fri, 12 Apr 2013 12:33:03 +0000 (UTC)
commit dc964956e715fc42e1e9806f69058dad49829832
Author: Michael Natterer <mitch gimp org>
Date: Fri Apr 12 14:31:50 2013 +0200
app: add gimp_drawable_merge_filter() which applies a filter to a drawable
permanently, with undo and progress.
app/core/gimpdrawable-filter.c | 36 ++++++++++++++++++++++++++++++++++++
app/core/gimpdrawable-filter.h | 5 +++++
2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpdrawable-filter.c b/app/core/gimpdrawable-filter.c
index 3cc7570..39fd1bb 100644
--- a/app/core/gimpdrawable-filter.c
+++ b/app/core/gimpdrawable-filter.c
@@ -23,11 +23,14 @@
#include "core-types.h"
+#include "gegl/gimp-gegl-apply-operation.h"
+
#include "gimpdrawable.h"
#include "gimpdrawable-filter.h"
#include "gimpdrawable-private.h"
#include "gimpfilter.h"
#include "gimpfilterstack.h"
+#include "gimpprogress.h"
void
@@ -36,6 +39,7 @@ gimp_drawable_add_filter (GimpDrawable *drawable,
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_FILTER (filter));
+ g_return_if_fail (gimp_drawable_has_filter (drawable, filter) == FALSE);
gimp_container_add (drawable->private->filter_stack,
GIMP_OBJECT (filter));
@@ -47,6 +51,7 @@ gimp_drawable_remove_filter (GimpDrawable *drawable,
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_FILTER (filter));
+ g_return_if_fail (gimp_drawable_has_filter (drawable, filter) == TRUE);
gimp_container_remove (drawable->private->filter_stack,
GIMP_OBJECT (filter));
@@ -63,3 +68,34 @@ gimp_drawable_has_filter (GimpDrawable *drawable,
GIMP_OBJECT (filter));
}
+void
+gimp_drawable_merge_filter (GimpDrawable *drawable,
+ GimpFilter *filter,
+ GimpProgress *progress,
+ const gchar *undo_desc)
+{
+ GeglRectangle rect;
+
+ g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
+ g_return_if_fail (GIMP_IS_FILTER (filter));
+ g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
+
+ if (gimp_item_mask_intersect (GIMP_ITEM (drawable),
+ &rect.x, &rect.y,
+ &rect.width, &rect.height))
+ {
+ gimp_drawable_push_undo (drawable, undo_desc, NULL,
+ rect.x, rect.y,
+ rect.width, rect.height);
+
+ gimp_gegl_apply_operation (gimp_drawable_get_buffer (drawable),
+ progress, undo_desc,
+ gimp_filter_get_node (filter),
+ gimp_drawable_get_buffer (drawable),
+ &rect);
+
+ gimp_drawable_update (drawable,
+ rect.x, rect.y,
+ rect.width, rect.height);
+ }
+}
diff --git a/app/core/gimpdrawable-filter.h b/app/core/gimpdrawable-filter.h
index 65237e1..8401c07 100644
--- a/app/core/gimpdrawable-filter.h
+++ b/app/core/gimpdrawable-filter.h
@@ -29,5 +29,10 @@ void gimp_drawable_remove_filter (GimpDrawable *drawable,
gboolean gimp_drawable_has_filter (GimpDrawable *drawable,
GimpFilter *filter);
+void gimp_drawable_merge_filter (GimpDrawable *drawable,
+ GimpFilter *filter,
+ GimpProgress *progress,
+ const gchar *undo_desc);
+
#endif /* __GIMP_DRAWABLE_FILTER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]