[gimp] app: implement GimpColorManaged in GimpDrawable
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: implement GimpColorManaged in GimpDrawable
- Date: Sat, 30 Apr 2016 21:42:44 +0000 (UTC)
commit 8c107963e6fa036c9b61819cc235975cb3be73d9
Author: Michael Natterer <mitch gimp org>
Date: Sat Apr 30 23:41:32 2016 +0200
app: implement GimpColorManaged in GimpDrawable
so now all drawables have a profile. Default to the babl format's
bultin profile and override to use the image's format in GimpLayer.
app/core/gimpdrawable.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
app/core/gimplayer.c | 21 ---------------------
2 files changed, 44 insertions(+), 24 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 3753eae..570330f 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -72,7 +72,8 @@ enum
/* local function prototypes */
-static void gimp_drawable_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_drawable_dispose (GObject *object);
static void gimp_drawable_finalize (GObject *object);
@@ -130,6 +131,13 @@ static void gimp_drawable_transform (GimpItem *item,
GimpTransformResize clip_result,
GimpProgress *progress);
+static const guint8 *
+ gimp_drawable_get_icc_profile (GimpColorManaged *managed,
+ gsize *len);
+static GimpColorProfile *
+ gimp_drawable_get_color_profile (GimpColorManaged *managed);
+static void gimp_drawable_profile_changed (GimpColorManaged *managed);
+
static gboolean gimp_drawable_get_pixel_at (GimpPickable *pickable,
gint x,
gint y,
@@ -196,8 +204,10 @@ static void gimp_drawable_fs_update (GimpLayer *fs,
G_DEFINE_TYPE_WITH_CODE (GimpDrawable, gimp_drawable, GIMP_TYPE_ITEM,
+ G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
+ gimp_color_managed_iface_init)
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
- gimp_drawable_pickable_iface_init))
+ gimp_pickable_iface_init))
#define parent_class gimp_drawable_parent_class
@@ -289,7 +299,15 @@ gimp_drawable_init (GimpDrawable *drawable)
/* sorry for the evil casts */
static void
-gimp_drawable_pickable_iface_init (GimpPickableInterface *iface)
+gimp_color_managed_iface_init (GimpColorManagedInterface *iface)
+{
+ iface->get_icc_profile = gimp_drawable_get_icc_profile;
+ iface->get_color_profile = gimp_drawable_get_color_profile;
+ iface->profile_changed = gimp_drawable_profile_changed;
+}
+
+static void
+gimp_pickable_iface_init (GimpPickableInterface *iface)
{
iface->get_image = (GimpImage * (*) (GimpPickable *pickable)) gimp_item_get_image;
iface->get_format = (const Babl * (*) (GimpPickable *pickable)) gimp_drawable_get_format;
@@ -714,6 +732,29 @@ gimp_drawable_transform (GimpItem *item,
}
}
+static const guint8 *
+gimp_drawable_get_icc_profile (GimpColorManaged *managed,
+ gsize *len)
+{
+ GimpColorProfile *profile = gimp_color_managed_get_color_profile (managed);
+
+ return gimp_color_profile_get_icc_profile (profile, len);
+}
+
+static GimpColorProfile *
+gimp_drawable_get_color_profile (GimpColorManaged *managed)
+{
+ const Babl *format = gimp_drawable_get_format (GIMP_DRAWABLE (managed));
+
+ return gimp_babl_format_get_color_profile (format);
+}
+
+static void
+gimp_drawable_profile_changed (GimpColorManaged *managed)
+{
+ gimp_viewable_invalidate_preview (GIMP_VIEWABLE (managed));
+}
+
static gboolean
gimp_drawable_get_pixel_at (GimpPickable *pickable,
gint x,
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 6c62f4a..5895917 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -188,12 +188,8 @@ 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,
@@ -407,9 +403,7 @@ gimp_layer_init (GimpLayer *layer)
static void
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
@@ -1217,15 +1211,6 @@ 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)
{
@@ -1234,12 +1219,6 @@ gimp_layer_get_color_profile (GimpColorManaged *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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]