gimp r27552 - in trunk: . app/core
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27552 - in trunk: . app/core
- Date: Tue, 4 Nov 2008 18:06:36 +0000 (UTC)
Author: mitch
Date: Tue Nov 4 18:06:36 2008
New Revision: 27552
URL: http://svn.gnome.org/viewvc/gimp?rev=27552&view=rev
Log:
2008-11-04 Michael Natterer <mitch gimp org>
Unfinished first step to make the projection independent of
GimpImage, also one step closer to layer grouping.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpprojectable.[ch]: add new interface which abstracts
something that can have a projection attached to it. Has "update"
and "flush" signals and get_graph() and get_image()
vfuncs. get_image() is temporary until the hack is finishes.
* app/core/gimpimage.[ch]: implement GimpProjectableInterface,
remove "update" and "flush" signals and made get_graph() a private
implementation of the interface method. Moved interface method
implementations after virtual function implementations.
* app/core/gimpprojection.[ch]: change member "image" to
"projectable" and use the projectable API as often as
possible. Still some implicit dependencies on the projectable
being an image left but it's getting close.
* app/core/gimpprojection-construct.c: same here.
Added:
trunk/app/core/gimpprojectable.c
trunk/app/core/gimpprojectable.h
Modified:
trunk/ChangeLog
trunk/app/core/Makefile.am
trunk/app/core/core-types.h
trunk/app/core/gimpimage.c
trunk/app/core/gimpimage.h
trunk/app/core/gimpprojection-construct.c
trunk/app/core/gimpprojection.c
trunk/app/core/gimpprojection.h
Modified: trunk/app/core/Makefile.am
==============================================================================
--- trunk/app/core/Makefile.am (original)
+++ trunk/app/core/Makefile.am Tue Nov 4 18:06:36 2008
@@ -297,6 +297,8 @@
gimppreviewcache.h \
gimpprogress.c \
gimpprogress.h \
+ gimpprojectable.c \
+ gimpprojectable.h \
gimpprojection.c \
gimpprojection.h \
gimpprojection-construct.c \
Modified: trunk/app/core/core-types.h
==============================================================================
--- trunk/app/core/core-types.h (original)
+++ trunk/app/core/core-types.h Tue Nov 4 18:06:36 2008
@@ -153,9 +153,10 @@
/* interfaces */
-typedef struct _GimpPickable GimpPickable; /* dummy typedef */
-typedef struct _GimpProgress GimpProgress; /* dummy typedef */
-typedef struct _GimpTagged GimpTagged; /* dummy typedef */
+typedef struct _GimpPickable GimpPickable; /* dummy typedef */
+typedef struct _GimpProgress GimpProgress; /* dummy typedef */
+typedef struct _GimpProjectable GimpProjectable; /* dummy typedef */
+typedef struct _GimpTagged GimpTagged; /* dummy typedef */
/* non-object types */
Modified: trunk/app/core/gimpimage.c
==============================================================================
--- trunk/app/core/gimpimage.c (original)
+++ trunk/app/core/gimpimage.c Tue Nov 4 18:06:36 2008
@@ -57,6 +57,7 @@
#include "gimpmarshal.h"
#include "gimpparasitelist.h"
#include "gimppickable.h"
+#include "gimpprojectable.h"
#include "gimpprojection.h"
#include "gimpsamplepoint.h"
#include "gimpselection.h"
@@ -96,7 +97,6 @@
CLEAN,
DIRTY,
SAVED,
- UPDATE,
UPDATE_GUIDE,
UPDATE_SAMPLE_POINT,
SAMPLE_POINT_ADDED,
@@ -105,7 +105,6 @@
PARASITE_DETACHED,
COLORMAP_CHANGED,
UNDO_EVENT,
- FLUSH,
LAST_SIGNAL
};
@@ -130,6 +129,7 @@
/* local function prototypes */
static void gimp_color_managed_iface_init (GimpColorManagedInterface *iface);
+static void gimp_projectable_iface_init (GimpProjectableInterface *iface);
static GObject *gimp_image_constructor (GType type,
guint n_params,
@@ -164,8 +164,14 @@
gint previous_height);
static void gimp_image_real_colormap_changed (GimpImage *image,
gint color_index);
-static void gimp_image_real_flush (GimpImage *image,
+
+static const guint8 * gimp_image_get_icc_profile (GimpColorManaged *managed,
+ gsize *len);
+
+static void gimp_image_projectable_flush (GimpProjectable *projectable,
gboolean invalidate_preview);
+static GimpImage * gimp_image_get_image (GimpProjectable *projectable);
+static GeglNode * gimp_image_get_graph (GimpProjectable *projectable);
static void gimp_image_mask_update (GimpDrawable *drawable,
gint x,
@@ -186,9 +192,6 @@
static void gimp_image_channel_color_changed (GimpChannel *channel,
GimpImage *image);
-static const guint8 * gimp_image_get_icc_profile (GimpColorManaged *managed,
- gsize *len);
-
static const gint valid_combinations[][MAX_CHANNELS + 1] =
{
@@ -209,7 +212,9 @@
G_DEFINE_TYPE_WITH_CODE (GimpImage, gimp_image, GIMP_TYPE_VIEWABLE,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
- gimp_color_managed_iface_init))
+ gimp_color_managed_iface_init)
+ G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROJECTABLE,
+ gimp_projectable_iface_init))
#define parent_class gimp_image_parent_class
@@ -386,19 +391,6 @@
G_TYPE_NONE, 1,
G_TYPE_STRING);
- gimp_image_signals[UPDATE] =
- g_signal_new ("update",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GimpImageClass, update),
- NULL, NULL,
- gimp_marshal_VOID__INT_INT_INT_INT,
- G_TYPE_NONE, 4,
- G_TYPE_INT,
- G_TYPE_INT,
- G_TYPE_INT,
- G_TYPE_INT);
-
gimp_image_signals[UPDATE_GUIDE] =
g_signal_new ("update-guide",
G_TYPE_FROM_CLASS (klass),
@@ -480,16 +472,6 @@
GIMP_TYPE_UNDO_EVENT,
GIMP_TYPE_UNDO);
- gimp_image_signals[FLUSH] =
- g_signal_new ("flush",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GimpImageClass, flush),
- NULL, NULL,
- gimp_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-
object_class->constructor = gimp_image_constructor;
object_class->set_property = gimp_image_set_property;
object_class->get_property = gimp_image_get_property;
@@ -527,7 +509,6 @@
klass->clean = NULL;
klass->dirty = NULL;
klass->saved = NULL;
- klass->update = NULL;
klass->update_guide = NULL;
klass->update_sample_point = NULL;
klass->sample_point_added = NULL;
@@ -536,7 +517,6 @@
klass->parasite_detached = NULL;
klass->colormap_changed = gimp_image_real_colormap_changed;
klass->undo_event = NULL;
- klass->flush = gimp_image_real_flush;
g_object_class_install_property (object_class, PROP_GIMP,
g_param_spec_object ("gimp", NULL, NULL,
@@ -578,6 +558,14 @@
}
static void
+gimp_projectable_iface_init (GimpProjectableInterface *iface)
+{
+ iface->flush = gimp_image_projectable_flush;
+ iface->get_image = gimp_image_get_image;
+ iface->get_graph = gimp_image_get_graph;
+}
+
+static void
gimp_image_init (GimpImage *image)
{
gint i;
@@ -606,7 +594,7 @@
image->tattoo_state = 0;
- image->projection = gimp_projection_new (image);
+ image->projection = gimp_projection_new (GIMP_PROJECTABLE (image));
image->guides = NULL;
image->grid = NULL;
@@ -1135,10 +1123,35 @@
}
}
+static const guint8 *
+gimp_image_get_icc_profile (GimpColorManaged *managed,
+ gsize *len)
+{
+ const GimpParasite *parasite;
+
+ parasite = gimp_image_parasite_find (GIMP_IMAGE (managed), "icc-profile");
+
+ if (parasite)
+ {
+ gsize data_size = gimp_parasite_data_size (parasite);
+
+ if (data_size > 0)
+ {
+ *len = data_size;
+
+ return gimp_parasite_data (parasite);
+ }
+ }
+
+ return NULL;
+}
+
static void
-gimp_image_real_flush (GimpImage *image,
- gboolean invalidate_preview)
+gimp_image_projectable_flush (GimpProjectable *projectable,
+ gboolean invalidate_preview)
{
+ GimpImage *image = GIMP_IMAGE (projectable);
+
if (image->flush_accum.alpha_changed)
{
gimp_image_alpha_changed (image);
@@ -1160,6 +1173,53 @@
}
}
+static GimpImage *
+gimp_image_get_image (GimpProjectable *projectable)
+{
+ return GIMP_IMAGE (projectable);
+}
+
+static GeglNode *
+gimp_image_get_graph (GimpProjectable *projectable)
+{
+ GimpImage *image = GIMP_IMAGE (projectable);
+ GeglNode *layers_node;
+ GeglNode *channels_node;
+ GeglNode *blend_node;
+ GeglNode *output;
+
+ if (image->graph)
+ return image->graph;
+
+ image->graph = gegl_node_new ();
+
+ layers_node =
+ gimp_drawable_stack_get_graph (GIMP_DRAWABLE_STACK (image->layers));
+
+ gegl_node_add_child (image->graph, layers_node);
+
+ channels_node =
+ gimp_drawable_stack_get_graph (GIMP_DRAWABLE_STACK (image->channels));
+
+ gegl_node_add_child (image->graph, channels_node);
+
+ blend_node = gegl_node_new_child (image->graph,
+ "operation", "gegl:normal",
+ NULL);
+
+ gegl_node_connect_to (layers_node, "output",
+ blend_node, "input");
+ gegl_node_connect_to (channels_node, "output",
+ blend_node, "aux");
+
+ output = gegl_node_get_output_proxy (image->graph, "output");
+
+ gegl_node_connect_to (blend_node, "output",
+ output, "input");
+
+ return image->graph;
+}
+
static void
gimp_image_mask_update (GimpDrawable *drawable,
gint x,
@@ -1699,8 +1759,8 @@
{
g_return_if_fail (GIMP_IS_IMAGE (image));
- g_signal_emit (image, gimp_image_signals[UPDATE], 0,
- x, y, width, height);
+ gimp_projectable_update (GIMP_PROJECTABLE (image),
+ x, y, width, height);
image->flush_accum.preview_invalidated = TRUE;
}
@@ -1975,8 +2035,8 @@
{
g_return_if_fail (GIMP_IS_IMAGE (image));
- g_signal_emit (image, gimp_image_signals[FLUSH], 0,
- image->flush_accum.preview_invalidated);
+ gimp_projectable_flush (GIMP_PROJECTABLE (image),
+ image->flush_accum.preview_invalidated);
}
@@ -2443,48 +2503,6 @@
return image->projection;
}
-GeglNode *
-gimp_image_get_graph (GimpImage *image)
-{
- GeglNode *layers_node;
- GeglNode *channels_node;
- GeglNode *blend_node;
- GeglNode *output;
-
- g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
-
- if (image->graph)
- return image->graph;
-
- image->graph = gegl_node_new ();
-
- layers_node =
- gimp_drawable_stack_get_graph (GIMP_DRAWABLE_STACK (image->layers));
-
- gegl_node_add_child (image->graph, layers_node);
-
- channels_node =
- gimp_drawable_stack_get_graph (GIMP_DRAWABLE_STACK (image->channels));
-
- gegl_node_add_child (image->graph, channels_node);
-
- blend_node = gegl_node_new_child (image->graph,
- "operation", "gegl:normal",
- NULL);
-
- gegl_node_connect_to (layers_node, "output",
- blend_node, "input");
- gegl_node_connect_to (channels_node, "output",
- blend_node, "aux");
-
- output = gegl_node_get_output_proxy (image->graph, "output");
-
- gegl_node_connect_to (blend_node, "output",
- output, "input");
-
- return image->graph;
-}
-
/* layers / channels / vectors */
@@ -3774,26 +3792,3 @@
(GFunc) gimp_viewable_invalidate_preview,
NULL);
}
-
-static const guint8 *
-gimp_image_get_icc_profile (GimpColorManaged *managed,
- gsize *len)
-{
- const GimpParasite *parasite;
-
- parasite = gimp_image_parasite_find (GIMP_IMAGE (managed), "icc-profile");
-
- if (parasite)
- {
- gsize data_size = gimp_parasite_data_size (parasite);
-
- if (data_size > 0)
- {
- *len = data_size;
-
- return gimp_parasite_data (parasite);
- }
- }
-
- return NULL;
-}
Modified: trunk/app/core/gimpimage.h
==============================================================================
--- trunk/app/core/gimpimage.h (original)
+++ trunk/app/core/gimpimage.h Tue Nov 4 18:06:36 2008
@@ -205,11 +205,6 @@
void (* saved) (GimpImage *image,
const gchar *uri);
- void (* update) (GimpImage *image,
- gint x,
- gint y,
- gint width,
- gint height);
void (* update_guide) (GimpImage *image,
GimpGuide *guide);
void (* update_sample_point) (GimpImage *image,
@@ -227,9 +222,6 @@
void (* undo_event) (GimpImage *image,
GimpUndoEvent event,
GimpUndo *undo);
-
- void (* flush) (GimpImage *image,
- gboolean invalidate_preview);
};
@@ -407,7 +399,6 @@
/* projection */
GimpProjection * gimp_image_get_projection (const GimpImage *image);
-GeglNode * gimp_image_get_graph (GimpImage *image);
/* layers / channels / vectors */
Added: trunk/app/core/gimpprojectable.c
==============================================================================
--- (empty file)
+++ trunk/app/core/gimpprojectable.c Tue Nov 4 18:06:36 2008
@@ -0,0 +1,163 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpprojectable.c
+ * Copyright (C) 2008 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "core-types.h"
+
+#include "gimpmarshal.h"
+#include "gimpprojectable.h"
+#include "gimpviewable.h"
+
+
+enum
+{
+ UPDATE,
+ FLUSH,
+ LAST_SIGNAL
+};
+
+
+/* local function prototypes */
+
+static void gimp_projectable_iface_base_init (GimpProjectableInterface *iface);
+
+
+static guint projectable_signals[LAST_SIGNAL] = { 0 };
+
+
+GType
+gimp_projectable_interface_get_type (void)
+{
+ static GType projectable_iface_type = 0;
+
+ if (! projectable_iface_type)
+ {
+ const GTypeInfo projectable_iface_info =
+ {
+ sizeof (GimpProjectableInterface),
+ (GBaseInitFunc) gimp_projectable_iface_base_init,
+ (GBaseFinalizeFunc) NULL,
+ };
+
+ projectable_iface_type = g_type_register_static (G_TYPE_INTERFACE,
+ "GimpProjectableInterface",
+ &projectable_iface_info,
+ 0);
+
+ g_type_interface_add_prerequisite (projectable_iface_type,
+ GIMP_TYPE_VIEWABLE);
+ }
+
+ return projectable_iface_type;
+}
+
+static void
+gimp_projectable_iface_base_init (GimpProjectableInterface *iface)
+{
+ static gboolean initialized = FALSE;
+
+ if (! initialized)
+ {
+ projectable_signals[UPDATE] =
+ g_signal_new ("update",
+ G_TYPE_FROM_CLASS (iface),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GimpProjectableInterface, update),
+ NULL, NULL,
+ gimp_marshal_VOID__INT_INT_INT_INT,
+ G_TYPE_NONE, 4,
+ G_TYPE_INT,
+ G_TYPE_INT,
+ G_TYPE_INT,
+ G_TYPE_INT);
+
+ projectable_signals[FLUSH] =
+ g_signal_new ("flush",
+ G_TYPE_FROM_CLASS (iface),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GimpProjectableInterface, flush),
+ NULL, NULL,
+ gimp_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1,
+ G_TYPE_BOOLEAN);
+
+ initialized = TRUE;
+ }
+}
+
+
+/* public functions */
+
+void
+gimp_projectable_update (GimpProjectable *projectable,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ g_return_if_fail (GIMP_IS_PROJECTABLE (projectable));
+
+ g_signal_emit (projectable, projectable_signals[UPDATE], 0,
+ x, y, width, height);
+}
+
+void
+gimp_projectable_flush (GimpProjectable *projectable,
+ gboolean preview_invalidated)
+{
+ g_return_if_fail (GIMP_IS_PROJECTABLE (projectable));
+
+ g_signal_emit (projectable, projectable_signals[FLUSH], 0,
+ preview_invalidated);
+}
+
+GimpImage *
+gimp_projectable_get_image (GimpProjectable *projectable)
+{
+ GimpProjectableInterface *iface;
+
+ g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
+
+ iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
+
+ if (iface->get_image)
+ return iface->get_image (projectable);
+
+ return NULL;
+}
+
+GeglNode *
+gimp_projectable_get_graph (GimpProjectable *projectable)
+{
+ GimpProjectableInterface *iface;
+
+ g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
+
+ iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
+
+ if (iface->get_graph)
+ return iface->get_graph (projectable);
+
+ return NULL;
+}
Added: trunk/app/core/gimpprojectable.h
==============================================================================
--- (empty file)
+++ trunk/app/core/gimpprojectable.h Tue Nov 4 18:06:36 2008
@@ -0,0 +1,67 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
+ *
+ * gimpprojectable.h
+ * Copyright (C) 2008 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GIMP_PROJECTABLE_H__
+#define __GIMP_PROJECTABLE_H__
+
+
+#define GIMP_TYPE_PROJECTABLE (gimp_projectable_interface_get_type ())
+#define GIMP_IS_PROJECTABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PROJECTABLE))
+#define GIMP_PROJECTABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PROJECTABLE, GimpProjectable))
+#define GIMP_PROJECTABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_PROJECTABLE, GimpProjectableInterface))
+
+
+typedef struct _GimpProjectableInterface GimpProjectableInterface;
+
+struct _GimpProjectableInterface
+{
+ GTypeInterface base_iface;
+
+ /* signals */
+ void (* update) (GimpProjectable *projectable,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+ void (* flush) (GimpProjectable *projectable,
+ gboolean invalidate_preview);
+
+ /* virtual functions */
+ GimpImage * (* get_image) (GimpProjectable *projectable);
+ GeglNode * (* get_graph) (GimpProjectable *projectable);
+};
+
+
+GType gimp_projectable_interface_get_type (void) G_GNUC_CONST;
+
+void gimp_projectable_update (GimpProjectable *projectable,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+void gimp_projectable_flush (GimpProjectable *projectable,
+ gboolean preview_invalidated);
+
+GimpImage * gimp_projectable_get_image (GimpProjectable *projectable);
+GeglNode * gimp_projectable_get_graph (GimpProjectable *projectable);
+
+
+#endif /* __GIMP_PROJECTABLE_H__ */
Modified: trunk/app/core/gimpprojection-construct.c
==============================================================================
--- trunk/app/core/gimpprojection-construct.c (original)
+++ trunk/app/core/gimpprojection-construct.c Tue Nov 4 18:06:36 2008
@@ -35,6 +35,7 @@
#include "gimplayer-floating-sel.h"
#include "gimplayermask.h"
#include "gimppickable.h"
+#include "gimpprojectable.h"
#include "gimpprojection.h"
#include "gimpprojection-construct.h"
@@ -100,7 +101,7 @@
g_return_if_fail (GIMP_IS_PROJECTION (proj));
#if 0
- GimpImage *image = proj->image;
+ GimpImage *image = gimp_projectable_get_image (proj->projectable);
if ((gimp_container_num_children (image->layers) == 1)) /* a single layer */
{
@@ -203,6 +204,7 @@
gint w,
gint h)
{
+ GimpImage *image = gimp_projectable_get_image (proj->projectable);
GimpLayer *layer;
GList *list;
GList *reverse_list;
@@ -211,12 +213,12 @@
gint off_y;
/* composite the floating selection if it exists */
- if ((layer = gimp_image_floating_sel (proj->image)))
+ if ((layer = gimp_image_floating_sel (image)))
floating_sel_composite (layer, x, y, w, h, FALSE);
reverse_list = NULL;
- for (list = gimp_image_get_layer_iter (proj->image);
+ for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
@@ -328,11 +330,12 @@
gint w,
gint h)
{
- GList *list;
- GList *reverse_list = NULL;
+ GimpImage *image = gimp_projectable_get_image (proj->projectable);
+ GList *list;
+ GList *reverse_list = NULL;
/* reverse the channel list */
- for (list = gimp_image_get_channel_iter (proj->image);
+ for (list = gimp_image_get_channel_iter (image);
list;
list = g_list_next (list))
{
@@ -386,11 +389,11 @@
gint w,
gint h)
{
+ GimpImage *image = gimp_projectable_get_image (proj->projectable);
+ GList *list;
+ gboolean coverage = FALSE;
- GList *list;
- gboolean coverage = FALSE;
-
- for (list = gimp_image_get_layer_iter (proj->image);
+ for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
@@ -432,12 +435,14 @@
PixelRegion *dest,
PixelRegion *mask)
{
+ GimpImage *image = gimp_projectable_get_image (proj->projectable);
+
if (proj->construct_flag)
{
combine_regions (dest, src, dest, mask, NULL,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- proj->image->visible,
+ image->visible,
COMBINE_INTEN_A_INTEN);
}
else
@@ -445,7 +450,7 @@
initial_region (src, dest, mask, NULL,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- proj->image->visible,
+ image->visible,
INITIAL_INTENSITY);
}
}
@@ -457,12 +462,14 @@
PixelRegion *dest,
PixelRegion *mask)
{
+ GimpImage *image = gimp_projectable_get_image (proj->projectable);
+
if (proj->construct_flag)
{
combine_regions (dest, src, dest, mask, NULL,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- proj->image->visible,
+ image->visible,
COMBINE_INTEN_A_INTEN_A);
}
else
@@ -470,7 +477,7 @@
initial_region (src, dest, mask, NULL,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- proj->image->visible,
+ image->visible,
INITIAL_INTENSITY_ALPHA);
}
}
@@ -482,7 +489,8 @@
PixelRegion *dest,
PixelRegion *mask)
{
- const guchar *colormap = gimp_image_get_colormap (proj->image);
+ GimpImage *image = gimp_projectable_get_image (proj->projectable);
+ const guchar *colormap = gimp_image_get_colormap (image);
g_return_if_fail (colormap != NULL);
@@ -491,7 +499,7 @@
combine_regions (dest, src, dest, mask, colormap,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- proj->image->visible,
+ image->visible,
COMBINE_INTEN_A_INDEXED);
}
else
@@ -499,7 +507,7 @@
initial_region (src, dest, mask, colormap,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- proj->image->visible,
+ image->visible,
INITIAL_INDEXED);
}
}
@@ -511,7 +519,8 @@
PixelRegion *dest,
PixelRegion *mask)
{
- const guchar *colormap = gimp_image_get_colormap (proj->image);
+ GimpImage *image = gimp_projectable_get_image (proj->projectable);
+ const guchar *colormap = gimp_image_get_colormap (image);
g_return_if_fail (colormap != NULL);
@@ -520,7 +529,7 @@
combine_regions (dest, src, dest, mask, colormap,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- proj->image->visible,
+ image->visible,
COMBINE_INTEN_A_INDEXED_A);
}
else
@@ -528,7 +537,7 @@
initial_region (src, dest, mask, colormap,
gimp_layer_get_opacity (layer) * 255.999,
gimp_layer_get_mode (layer),
- proj->image->visible,
+ image->visible,
INITIAL_INDEXED_ALPHA);
}
}
Modified: trunk/app/core/gimpprojection.c
==============================================================================
--- trunk/app/core/gimpprojection.c (original)
+++ trunk/app/core/gimpprojection.c Tue Nov 4 18:06:36 2008
@@ -31,6 +31,7 @@
#include "gimpimage.h"
#include "gimpmarshal.h"
#include "gimppickable.h"
+#include "gimpprojectable.h"
#include "gimpprojection.h"
#include "gimpprojection-construct.h"
@@ -99,19 +100,18 @@
static void gimp_projection_validate_tile (TileManager *tm,
Tile *tile,
GimpProjection *proj);
-static void gimp_projection_image_update (GimpImage *image,
+
+static void gimp_projection_projectable_update (GimpProjectable *projectable,
gint x,
gint y,
gint w,
gint h,
GimpProjection *proj);
-static void gimp_projection_image_size_changed (GimpImage *image,
- GimpProjection *proj);
-static void gimp_projection_image_mode_changed (GimpImage *image,
- GimpProjection *proj);
-static void gimp_projection_image_flush (GimpImage *image,
+static void gimp_projection_projectable_flush (GimpProjectable *projectable,
gboolean invalidate_preview,
GimpProjection *proj);
+static void gimp_projection_image_changed (GimpImage *image,
+ GimpProjection *proj);
G_DEFINE_TYPE_WITH_CODE (GimpProjection, gimp_projection, GIMP_TYPE_OBJECT,
@@ -151,7 +151,7 @@
static void
gimp_projection_init (GimpProjection *proj)
{
- proj->image = NULL;
+ proj->projectable = NULL;
proj->pyramid = NULL;
proj->update_areas = NULL;
proj->idle_render.idle_id = 0;
@@ -223,8 +223,8 @@
/**
* gimp_projection_estimate_memsize:
* @type: the image base type
- * @width: image width
- * @height: image height
+ * @width: projection width
+ * @height: projection height
*
* Calculates a rough estimate of the memory that is required for the
* projection of an image with the given @width and @height.
@@ -270,7 +270,7 @@
*/
proj->invalidate_preview = FALSE;
- gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->image));
+ gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->projectable));
}
}
@@ -279,7 +279,7 @@
{
GimpProjection *proj = GIMP_PROJECTION (pickable);
- return proj->image;
+ return gimp_projectable_get_image (proj->projectable);
}
static GimpImageType
@@ -320,15 +320,15 @@
gint y,
guchar *pixel)
{
- GimpProjection *proj = GIMP_PROJECTION (pickable);
+ TileManager *tiles = gimp_projection_get_tiles (pickable);
- if (x < 0 ||
- y < 0 ||
- x >= gimp_image_get_width (proj->image) ||
- y >= gimp_image_get_height (proj->image))
+ if (x < 0 ||
+ y < 0 ||
+ x >= tile_manager_width (tiles) ||
+ y >= tile_manager_height (tiles))
return FALSE;
- read_pixel_data_1 (gimp_projection_get_tiles (pickable), x, y, pixel);
+ read_pixel_data_1 (tiles, x, y, pixel);
return TRUE;
}
@@ -342,27 +342,31 @@
}
GimpProjection *
-gimp_projection_new (GimpImage *image)
+gimp_projection_new (GimpProjectable *projectable)
{
GimpProjection *proj;
+ GimpImage *image;
- g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+ g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
proj = g_object_new (GIMP_TYPE_PROJECTION, NULL);
- proj->image = image;
+ proj->projectable = projectable;
- g_signal_connect_object (image, "update",
- G_CALLBACK (gimp_projection_image_update),
+ g_signal_connect_object (projectable, "update",
+ G_CALLBACK (gimp_projection_projectable_update),
+ proj, 0);
+ g_signal_connect_object (projectable, "flush",
+ G_CALLBACK (gimp_projection_projectable_flush),
proj, 0);
+
+ image = gimp_projectable_get_image (projectable);
+
g_signal_connect_object (image, "size-changed",
- G_CALLBACK (gimp_projection_image_size_changed),
+ G_CALLBACK (gimp_projection_image_changed),
proj, 0);
g_signal_connect_object (image, "mode-changed",
- G_CALLBACK (gimp_projection_image_mode_changed),
- proj, 0);
- g_signal_connect_object (image, "flush",
- G_CALLBACK (gimp_projection_image_flush),
+ G_CALLBACK (gimp_projection_image_changed),
proj, 0);
return proj;
@@ -371,7 +375,7 @@
GeglNode *
gimp_projection_get_sink_node (GimpProjection *proj)
{
- GeglNode *image_graph;
+ GeglNode *graph;
g_return_val_if_fail (GIMP_IS_PROJECTION (proj), NULL);
@@ -384,8 +388,8 @@
"dont-cache", TRUE,
NULL);
- image_graph = gimp_image_get_graph (proj->image);
- gegl_node_add_child (proj->graph, image_graph);
+ graph = gimp_projectable_get_graph (proj->projectable);
+ gegl_node_add_child (proj->graph, graph);
proj->sink_node =
gegl_node_new_child (proj->graph,
@@ -394,7 +398,7 @@
"linear", TRUE,
NULL);
- gegl_node_connect_to (image_graph, "output",
+ gegl_node_connect_to (graph, "output",
proj->sink_node, "input");
return proj->sink_node;
@@ -409,9 +413,13 @@
if (! proj->pyramid)
{
+ gint width, height;
+
+ gimp_viewable_get_size (GIMP_VIEWABLE (proj->projectable),
+ &width, &height);
+
proj->pyramid = tile_pyramid_new (gimp_projection_get_image_type (GIMP_PICKABLE (proj)),
- gimp_image_get_width (proj->image),
- gimp_image_get_height (proj->image));
+ width, height);
tile_pyramid_set_validate_proc (proj->pyramid,
(TileValidateProc) gimp_projection_validate_tile,
@@ -445,9 +453,11 @@
gdouble scale_x,
gdouble scale_y)
{
- return tile_pyramid_get_level (gimp_image_get_width (proj->image),
- gimp_image_get_height (proj->image),
- MAX (scale_x, scale_y));
+ gint width, height;
+
+ gimp_viewable_get_size (GIMP_VIEWABLE (proj->projectable), &width, &height);
+
+ return tile_pyramid_get_level (width, height, MAX (scale_x, scale_y));
}
void
@@ -497,13 +507,14 @@
gint h)
{
GimpArea *area;
+ gint width, height;
- g_return_if_fail (GIMP_IS_PROJECTION (proj));
+ gimp_viewable_get_size (GIMP_VIEWABLE (proj->projectable), &width, &height);
- area = gimp_area_new (CLAMP (x, 0, gimp_image_get_width (proj->image)),
- CLAMP (y, 0, gimp_image_get_height (proj->image)),
- CLAMP (x + w, 0, gimp_image_get_width (proj->image)),
- CLAMP (y + h, 0, gimp_image_get_height (proj->image)));
+ area = gimp_area_new (CLAMP (x, 0, width),
+ CLAMP (y, 0, height),
+ CLAMP (x + w, 0, width),
+ CLAMP (y + h, 0, height));
proj->update_areas = gimp_area_list_process (proj->update_areas, area);
}
@@ -550,7 +561,7 @@
*/
proj->invalidate_preview = FALSE;
- gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->image));
+ gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->projectable));
}
}
@@ -667,7 +678,7 @@
*/
proj->invalidate_preview = FALSE;
- gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->image));
+ gimp_viewable_invalidate_preview (GIMP_VIEWABLE (proj->projectable));
}
return FALSE;
@@ -710,14 +721,16 @@
gint w,
gint h)
{
- const gint width = gimp_image_get_width (proj->image);
- const gint height = gimp_image_get_height (proj->image);
+ gint width, height;
+ gint x1, y1, x2, y2;
+
+ gimp_viewable_get_size (GIMP_VIEWABLE (proj->projectable), &width, &height);
/* Bounds check */
- gint x1 = CLAMP (x, 0, width);
- gint y1 = CLAMP (y, 0, height);
- gint x2 = CLAMP (x + w, 0, width);
- gint y2 = CLAMP (y + h, 0, height);
+ x1 = CLAMP (x, 0, width);
+ y1 = CLAMP (y, 0, height);
+ x2 = CLAMP (x + w, 0, width);
+ y2 = CLAMP (y + h, 0, height);
gimp_projection_invalidate (proj, x1, y1, x2 - x1, y2 - y1);
@@ -754,55 +767,40 @@
/* image callbacks */
static void
-gimp_projection_image_update (GimpImage *image,
- gint x,
- gint y,
- gint w,
- gint h,
- GimpProjection *proj)
+gimp_projection_projectable_update (GimpProjectable *projectable,
+ gint x,
+ gint y,
+ gint w,
+ gint h,
+ GimpProjection *proj)
{
gimp_projection_add_update_area (proj, x, y, w, h);
}
static void
-gimp_projection_image_size_changed (GimpImage *image,
- GimpProjection *proj)
+gimp_projection_projectable_flush (GimpProjectable *projectable,
+ gboolean invalidate_preview,
+ GimpProjection *proj)
{
- if (proj->pyramid)
- {
- tile_pyramid_destroy (proj->pyramid);
- proj->pyramid = NULL;
- }
+ if (invalidate_preview)
+ proj->invalidate_preview = TRUE;
- gimp_projection_add_update_area (proj,
- 0, 0,
- gimp_image_get_width (image),
- gimp_image_get_height (image));
+ gimp_projection_flush (proj);
}
static void
-gimp_projection_image_mode_changed (GimpImage *image,
- GimpProjection *proj)
+gimp_projection_image_changed (GimpImage *image,
+ GimpProjection *proj)
{
+ gint width, height;
+
if (proj->pyramid)
{
tile_pyramid_destroy (proj->pyramid);
proj->pyramid = NULL;
}
- gimp_projection_add_update_area (proj,
- 0, 0,
- gimp_image_get_width (image),
- gimp_image_get_height (image));
-}
-
-static void
-gimp_projection_image_flush (GimpImage *image,
- gboolean invalidate_preview,
- GimpProjection *proj)
-{
- if (invalidate_preview)
- proj->invalidate_preview = TRUE;
+ gimp_viewable_get_size (GIMP_VIEWABLE (image), &width, &height);
- gimp_projection_flush (proj);
+ gimp_projection_add_update_area (proj, 0, 0, width, height);
}
Modified: trunk/app/core/gimpprojection.h
==============================================================================
--- trunk/app/core/gimpprojection.h (original)
+++ trunk/app/core/gimpprojection.h Tue Nov 4 18:06:36 2008
@@ -53,7 +53,7 @@
{
GimpObject parent_instance;
- GimpImage *image;
+ GimpProjectable *projectable;
TilePyramid *pyramid;
GeglNode *graph;
@@ -72,7 +72,7 @@
{
GimpObjectClass parent_class;
- void (* update) (GimpProjection *image,
+ void (* update) (GimpProjection *proj,
gboolean now,
gint x,
gint y,
@@ -83,7 +83,7 @@
GType gimp_projection_get_type (void) G_GNUC_CONST;
-GimpProjection * gimp_projection_new (GimpImage *image);
+GimpProjection * gimp_projection_new (GimpProjectable *projectable);
GeglNode * gimp_projection_get_sink_node (GimpProjection *proj);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]