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.
This commit is contained in:
Michael Natterer 2015-09-03 00:19:05 +02:00
parent 76ff1c1584
commit 7c95676f88
5 changed files with 95 additions and 6 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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__ */

View File

@ -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,

View File

@ -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 */