[gimp] app: implement the GimpColorManaged interface in GimpLayer
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: implement the GimpColorManaged interface in GimpLayer
- Date: Wed, 2 Sep 2015 22:34:55 +0000 (UTC)
commit 7c95676f88217bedf16eca846943600cf4347bcb
Author: Michael Natterer <mitch gimp org>
Date: Thu Sep 3 00:19:05 2015 +0200
app: implement the GimpColorManaged interface in GimpLayer
and change GimpImage and GimpItemStack to emit the "profile-changed"
signal when the image's profile changed. Also connect GimpViewRenderer
to "profile-changed" if the viewable is a GimpColorManaged and
invalidate the preview.
app/core/gimpimage.c | 2 +-
app/core/gimpitemstack.c | 29 +++++++++++++++++++++++-
app/core/gimpitemstack.h | 1 +
app/core/gimplayer.c | 47 +++++++++++++++++++++++++++++++++++++--
app/widgets/gimpviewrenderer.c | 22 ++++++++++++++++++
5 files changed, 95 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 4677062..d46de3d 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -1403,7 +1403,7 @@ gimp_image_color_managed_profile_changed (GimpColorManaged *managed)
GimpItemStack *layers = GIMP_ITEM_STACK (gimp_image_get_layers (image));
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (image));
- gimp_item_stack_invalidate_previews (layers);
+ gimp_item_stack_profile_changed (layers);
}
static void
diff --git a/app/core/gimpitemstack.c b/app/core/gimpitemstack.c
index 1de9c1e..0045bf3 100644
--- a/app/core/gimpitemstack.c
+++ b/app/core/gimpitemstack.c
@@ -22,9 +22,12 @@
#include <string.h>
+#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
+#include "libgimpcolor/gimpcolor.h"
+
#include "core-types.h"
#include "gimpitem.h"
@@ -302,7 +305,7 @@ gimp_item_stack_get_parent_by_path (GimpItemStack *stack,
}
static void
-gimp_item_stack_invalidate_preview (GimpViewable *viewable)
+gimp_item_stack_viewable_invalidate_previews (GimpViewable *viewable)
{
GimpContainer *children = gimp_viewable_get_children (viewable);
@@ -318,6 +321,28 @@ gimp_item_stack_invalidate_previews (GimpItemStack *stack)
g_return_if_fail (GIMP_IS_ITEM_STACK (stack));
gimp_container_foreach (GIMP_CONTAINER (stack),
- (GFunc) gimp_item_stack_invalidate_preview,
+ (GFunc) gimp_item_stack_viewable_invalidate_previews,
+ NULL);
+}
+
+static void
+gimp_item_stack_viewable_profile_changed (GimpViewable *viewable)
+{
+ GimpContainer *children = gimp_viewable_get_children (viewable);
+
+ if (children)
+ gimp_item_stack_profile_changed (GIMP_ITEM_STACK (children));
+
+ if (GIMP_IS_COLOR_MANAGED (viewable))
+ gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (viewable));
+}
+
+void
+gimp_item_stack_profile_changed (GimpItemStack *stack)
+{
+ g_return_if_fail (GIMP_IS_ITEM_STACK (stack));
+
+ gimp_container_foreach (GIMP_CONTAINER (stack),
+ (GFunc) gimp_item_stack_viewable_profile_changed,
NULL);
}
diff --git a/app/core/gimpitemstack.h b/app/core/gimpitemstack.h
index 09dd92e..c2d143c 100644
--- a/app/core/gimpitemstack.h
+++ b/app/core/gimpitemstack.h
@@ -60,6 +60,7 @@ GimpItem * gimp_item_stack_get_parent_by_path (GimpItemStack *stack,
gint *index);
void gimp_item_stack_invalidate_previews (GimpItemStack *stack);
+void gimp_item_stack_profile_changed (GimpItemStack *stack);
#endif /* __GIMP_ITEM_STACK_H__ */
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index d60441c..aa30741 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -78,7 +78,8 @@ enum
};
-static void gimp_layer_pickable_iface_init (GimpPickableInterface *iface);
+static void gimp_color_managed_iface_init (GimpColorManagedInterface *iface);
+static void gimp_pickable_iface_init (GimpPickableInterface *iface);
static void gimp_layer_set_property (GObject *object,
guint property_id,
@@ -183,6 +184,13 @@ static void gimp_layer_set_buffer (GimpDrawable *drawable,
gint offset_x,
gint offset_y);
+static const guint8 *
+ gimp_layer_get_icc_profile (GimpColorManaged *managed,
+ gsize *len);
+static GimpColorProfile *
+ gimp_layer_get_color_profile (GimpColorManaged *managed);
+static void gimp_layer_profile_changed (GimpColorManaged *managed);
+
static gdouble gimp_layer_get_opacity_at (GimpPickable *pickable,
gint x,
gint y);
@@ -196,8 +204,10 @@ static void gimp_layer_layer_mask_update (GimpDrawable *layer_mask,
G_DEFINE_TYPE_WITH_CODE (GimpLayer, gimp_layer, GIMP_TYPE_DRAWABLE,
+ G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
+ gimp_color_managed_iface_init)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
- gimp_layer_pickable_iface_init))
+ gimp_pickable_iface_init))
#define parent_class gimp_layer_parent_class
@@ -390,7 +400,15 @@ gimp_layer_init (GimpLayer *layer)
}
static void
-gimp_layer_pickable_iface_init (GimpPickableInterface *iface)
+gimp_color_managed_iface_init (GimpColorManagedInterface *iface)
+{
+ iface->get_icc_profile = gimp_layer_get_icc_profile;
+ iface->get_color_profile = gimp_layer_get_color_profile;
+ iface->profile_changed = gimp_layer_profile_changed;
+}
+
+static void
+gimp_pickable_iface_init (GimpPickableInterface *iface)
{
iface->get_opacity_at = gimp_layer_get_opacity_at;
}
@@ -1186,6 +1204,29 @@ gimp_layer_set_buffer (GimpDrawable *drawable,
}
}
+static const guint8 *
+gimp_layer_get_icc_profile (GimpColorManaged *managed,
+ gsize *len)
+{
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (managed));
+
+ return gimp_color_managed_get_icc_profile (GIMP_COLOR_MANAGED (image), len);
+}
+
+static GimpColorProfile *
+gimp_layer_get_color_profile (GimpColorManaged *managed)
+{
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (managed));
+
+ return gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
+}
+
+static void
+gimp_layer_profile_changed (GimpColorManaged *managed)
+{
+ gimp_viewable_invalidate_preview (GIMP_VIEWABLE (managed));
+}
+
static gdouble
gimp_layer_get_opacity_at (GimpPickable *pickable,
gint x,
diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c
index 22c4e45..603b0aa 100644
--- a/app/widgets/gimpviewrenderer.c
+++ b/app/widgets/gimpviewrenderer.c
@@ -70,6 +70,8 @@ static void gimp_view_renderer_real_render (GimpViewRenderer *rende
static void gimp_view_renderer_size_changed (GimpViewRenderer *renderer,
GimpViewable *viewable);
+static void gimp_view_renderer_profile_changed (GimpViewRenderer *renderer,
+ GimpViewable *viewable);
static void gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
GtkWidget *widget,
@@ -351,6 +353,11 @@ gimp_view_renderer_set_viewable (GimpViewRenderer *renderer,
g_signal_handlers_disconnect_by_func (renderer->viewable,
G_CALLBACK (gimp_view_renderer_size_changed),
renderer);
+
+ if (GIMP_IS_COLOR_MANAGED (renderer->viewable))
+ g_signal_handlers_disconnect_by_func (renderer->viewable,
+ G_CALLBACK (gimp_view_renderer_profile_changed),
+ renderer);
}
renderer->viewable = viewable;
@@ -371,6 +378,12 @@ gimp_view_renderer_set_viewable (GimpViewRenderer *renderer,
G_CALLBACK (gimp_view_renderer_size_changed),
renderer);
+ if (GIMP_IS_COLOR_MANAGED (renderer->viewable))
+ g_signal_connect_swapped (renderer->viewable,
+ "profile-changed",
+ G_CALLBACK (gimp_view_renderer_profile_changed),
+ renderer);
+
if (renderer->size != -1)
gimp_view_renderer_set_size (renderer, renderer->size,
renderer->border_width);
@@ -791,6 +804,15 @@ gimp_view_renderer_size_changed (GimpViewRenderer *renderer,
gimp_view_renderer_invalidate (renderer);
}
+static void
+gimp_view_renderer_profile_changed (GimpViewRenderer *renderer,
+ GimpViewable *viewable)
+{
+ /* FIXME: kill cached color transform */
+
+ gimp_view_renderer_invalidate (renderer);
+}
+
/* protected functions */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]