[gimp] app: add ::get_color_profile() to GimpPickable and GimpProjectable
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add ::get_color_profile() to GimpPickable and GimpProjectable
- Date: Tue, 1 Sep 2015 20:36:15 +0000 (UTC)
commit 5c8ffdf6c5ae3f2f1b678bb8822ba1177b939faf
Author: Michael Natterer <mitch gimp org>
Date: Fri Aug 28 14:32:41 2015 +0200
app: add ::get_color_profile() to GimpPickable and GimpProjectable
which currently all end in a call to gimp_color_managed_get_color_profile()
except for channels and masks. This is currently unused infrastructure but
will be used for things like layer previews, and return NULL if called
on a mask or channel, or if color management is disabled, or whatever.
app/core/gimpgrouplayer.c | 9 +++++
app/core/gimpimage.c | 20 +++++++++++
app/core/gimplayer.c | 13 +++++++-
app/core/gimppickable.c | 15 ++++++++
app/core/gimppickable.h | 78 ++++++++++++++++++++++---------------------
app/core/gimpprojectable.c | 17 +++++++++-
app/core/gimpprojectable.h | 39 ++++++++++++----------
app/core/gimpprojection.c | 11 ++++++
8 files changed, 144 insertions(+), 58 deletions(-)
---
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 8ddb4b9..cf9016a 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -147,6 +147,8 @@ static void gimp_group_layer_convert_type (GimpDrawable *drawabl
gboolean push_undo);
static const Babl * gimp_group_layer_get_format (GimpProjectable *projectable);
+static GimpColorProfile
+ * gimp_group_layer_get_color_profile (GimpProjectable *projectable);
static GeglNode * gimp_group_layer_get_graph (GimpProjectable *projectable);
static gdouble gimp_group_layer_get_opacity_at (GimpPickable *pickable,
gint x,
@@ -244,6 +246,7 @@ gimp_projectable_iface_init (GimpProjectableInterface *iface)
{
iface->get_image = (GimpImage * (*) (GimpProjectable *)) gimp_item_get_image;
iface->get_format = gimp_group_layer_get_format;
+ iface->get_color_profile = gimp_group_layer_get_color_profile;
iface->get_offset = (void (*) (GimpProjectable*, gint*, gint*)) gimp_item_get_offset;
iface->get_size = (void (*) (GimpProjectable*, gint*, gint*)) gimp_viewable_get_size;
iface->get_graph = gimp_group_layer_get_graph;
@@ -947,6 +950,12 @@ gimp_group_layer_get_format (GimpProjectable *projectable)
return get_projection_format (projectable, base_type, precision);
}
+static GimpColorProfile *
+gimp_group_layer_get_color_profile (GimpProjectable *projectable)
+{
+ return gimp_pickable_get_color_profile (GIMP_PICKABLE (projectable));
+}
+
static GeglNode *
gimp_group_layer_get_graph (GimpProjectable *projectable)
{
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 921bd64..833a5d4 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -188,8 +188,12 @@ static void gimp_image_projectable_flush (GimpProjectable *projectable
static GeglNode * gimp_image_get_graph (GimpProjectable *projectable);
static GimpImage * gimp_image_get_image (GimpProjectable *projectable);
static const Babl * gimp_image_get_proj_format (GimpProjectable *projectable);
+static GimpColorProfile
+ * gimp_image_get_proj_color_profile (GimpProjectable *projectable);
static void gimp_image_pickable_flush (GimpPickable *pickable);
+static GimpColorProfile
+ * gimp_image_pickable_get_color_profile (GimpPickable *pickable);
static GeglBuffer * gimp_image_get_buffer (GimpPickable *pickable);
static gboolean gimp_image_get_pixel_at (GimpPickable *pickable,
gint x,
@@ -639,6 +643,7 @@ gimp_projectable_iface_init (GimpProjectableInterface *iface)
iface->flush = gimp_image_projectable_flush;
iface->get_image = gimp_image_get_image;
iface->get_format = gimp_image_get_proj_format;
+ iface->get_color_profile = gimp_image_get_proj_color_profile;
iface->get_size = (void (*) (GimpProjectable*, gint*, gint*)) gimp_image_get_size;
iface->get_graph = gimp_image_get_graph;
iface->invalidate_preview = (void (*) (GimpProjectable*)) gimp_viewable_invalidate_preview;
@@ -651,6 +656,7 @@ gimp_pickable_iface_init (GimpPickableInterface *iface)
iface->get_image = (GimpImage * (*) (GimpPickable *pickable)) gimp_image_get_image;
iface->get_format = (const Babl * (*) (GimpPickable *pickable)) gimp_image_get_proj_format;
iface->get_format_with_alpha = (const Babl * (*) (GimpPickable *pickable)) gimp_image_get_proj_format;
+ iface->get_color_profile = gimp_image_pickable_get_color_profile;
iface->get_buffer = gimp_image_get_buffer;
iface->get_pixel_at = gimp_image_get_pixel_at;
iface->get_opacity_at = gimp_image_get_opacity_at;
@@ -1452,6 +1458,12 @@ gimp_image_get_proj_format (GimpProjectable *projectable)
return NULL;
}
+static GimpColorProfile *
+gimp_image_get_proj_color_profile (GimpProjectable *projectable)
+{
+ return gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (projectable));
+}
+
static void
gimp_image_pickable_flush (GimpPickable *pickable)
{
@@ -1460,6 +1472,14 @@ gimp_image_pickable_flush (GimpPickable *pickable)
return gimp_pickable_flush (GIMP_PICKABLE (private->projection));
}
+static GimpColorProfile *
+gimp_image_pickable_get_color_profile (GimpPickable *pickable)
+{
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (pickable);
+
+ return gimp_pickable_get_color_profile (GIMP_PICKABLE (private->projection));
+}
+
static GeglBuffer *
gimp_image_get_buffer (GimpPickable *pickable)
{
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index d60441c..e7dafef 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -183,6 +183,8 @@ static void gimp_layer_set_buffer (GimpDrawable *drawable,
gint offset_x,
gint offset_y);
+static GimpColorProfile *
+ gimp_layer_get_color_profile (GimpPickable *pickable);
static gdouble gimp_layer_get_opacity_at (GimpPickable *pickable,
gint x,
gint y);
@@ -392,7 +394,8 @@ gimp_layer_init (GimpLayer *layer)
static void
gimp_layer_pickable_iface_init (GimpPickableInterface *iface)
{
- iface->get_opacity_at = gimp_layer_get_opacity_at;
+ iface->get_color_profile = gimp_layer_get_color_profile;
+ iface->get_opacity_at = gimp_layer_get_opacity_at;
}
static void
@@ -1186,6 +1189,14 @@ gimp_layer_set_buffer (GimpDrawable *drawable,
}
}
+static GimpColorProfile *
+gimp_layer_get_color_profile (GimpPickable *pickable)
+{
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (pickable));
+
+ return gimp_pickable_get_color_profile (GIMP_PICKABLE (image));
+}
+
static gdouble
gimp_layer_get_opacity_at (GimpPickable *pickable,
gint x,
diff --git a/app/core/gimppickable.c b/app/core/gimppickable.c
index d264116..461875c 100644
--- a/app/core/gimppickable.c
+++ b/app/core/gimppickable.c
@@ -144,6 +144,21 @@ gimp_pickable_get_format_with_alpha (GimpPickable *pickable)
return NULL;
}
+GimpColorProfile *
+gimp_pickable_get_color_profile (GimpPickable *pickable)
+{
+ GimpPickableInterface *pickable_iface;
+
+ g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
+
+ pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
+
+ if (pickable_iface->get_color_profile)
+ return pickable_iface->get_color_profile (pickable);
+
+ return NULL;
+}
+
GeglBuffer *
gimp_pickable_get_buffer (GimpPickable *pickable)
{
diff --git a/app/core/gimppickable.h b/app/core/gimppickable.h
index 7308127..89865d3 100644
--- a/app/core/gimppickable.h
+++ b/app/core/gimppickable.h
@@ -35,49 +35,51 @@ struct _GimpPickableInterface
GTypeInterface base_iface;
/* virtual functions */
- void (* flush) (GimpPickable *pickable);
- GimpImage * (* get_image) (GimpPickable *pickable);
- const Babl * (* get_format) (GimpPickable *pickable);
- const Babl * (* get_format_with_alpha) (GimpPickable *pickable);
- GeglBuffer * (* get_buffer) (GimpPickable *pickable);
- gboolean (* get_pixel_at) (GimpPickable *pickable,
- gint x,
- gint y,
- const Babl *format,
- gpointer pixel);
- gdouble (* get_opacity_at) (GimpPickable *pickable,
- gint x,
- gint y);
+ void (* flush) (GimpPickable *pickable);
+ GimpImage * (* get_image) (GimpPickable *pickable);
+ const Babl * (* get_format) (GimpPickable *pickable);
+ const Babl * (* get_format_with_alpha) (GimpPickable *pickable);
+ GimpColorProfile * (* get_color_profile) (GimpPickable *pickable);
+ GeglBuffer * (* get_buffer) (GimpPickable *pickable);
+ gboolean (* get_pixel_at) (GimpPickable *pickable,
+ gint x,
+ gint y,
+ const Babl *format,
+ gpointer pixel);
+ gdouble (* get_opacity_at) (GimpPickable *pickable,
+ gint x,
+ gint y);
};
-GType gimp_pickable_interface_get_type (void) G_GNUC_CONST;
+GType gimp_pickable_interface_get_type (void) G_GNUC_CONST;
-void gimp_pickable_flush (GimpPickable *pickable);
-GimpImage * gimp_pickable_get_image (GimpPickable *pickable);
-const Babl * gimp_pickable_get_format (GimpPickable *pickable);
-const Babl * gimp_pickable_get_format_with_alpha (GimpPickable *pickable);
-GeglBuffer * gimp_pickable_get_buffer (GimpPickable *pickable);
-gboolean gimp_pickable_get_pixel_at (GimpPickable *pickable,
- gint x,
- gint y,
- const Babl *format,
- gpointer pixel);
-gboolean gimp_pickable_get_color_at (GimpPickable *pickable,
- gint x,
- gint y,
- GimpRGB *color);
-gdouble gimp_pickable_get_opacity_at (GimpPickable *pickable,
- gint x,
- gint y);
+void gimp_pickable_flush (GimpPickable *pickable);
+GimpImage * gimp_pickable_get_image (GimpPickable *pickable);
+const Babl * gimp_pickable_get_format (GimpPickable *pickable);
+const Babl * gimp_pickable_get_format_with_alpha (GimpPickable *pickable);
+GimpColorProfile * gimp_pickable_get_color_profile (GimpPickable *pickable);
+GeglBuffer * gimp_pickable_get_buffer (GimpPickable *pickable);
+gboolean gimp_pickable_get_pixel_at (GimpPickable *pickable,
+ gint x,
+ gint y,
+ const Babl *format,
+ gpointer pixel);
+gboolean gimp_pickable_get_color_at (GimpPickable *pickable,
+ gint x,
+ gint y,
+ GimpRGB *color);
+gdouble gimp_pickable_get_opacity_at (GimpPickable *pickable,
+ gint x,
+ gint y);
-gboolean gimp_pickable_pick_color (GimpPickable *pickable,
- gint x,
- gint y,
- gboolean sample_average,
- gdouble average_radius,
- gpointer pixel,
- GimpRGB *color);
+gboolean gimp_pickable_pick_color (GimpPickable *pickable,
+ gint x,
+ gint y,
+ gboolean sample_average,
+ gdouble average_radius,
+ gpointer pixel,
+ GimpRGB *color);
#endif /* __GIMP_PICKABLE_H__ */
diff --git a/app/core/gimpprojectable.c b/app/core/gimpprojectable.c
index c5ae3ef..0c97418 100644
--- a/app/core/gimpprojectable.c
+++ b/app/core/gimpprojectable.c
@@ -177,7 +177,22 @@ gimp_projectable_get_format (GimpProjectable *projectable)
if (iface->get_format)
return iface->get_format (projectable);
- return 0;
+ return NULL;
+}
+
+GimpColorProfile *
+gimp_projectable_get_color_profile (GimpProjectable *projectable)
+{
+ GimpProjectableInterface *iface;
+
+ g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
+
+ iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
+
+ if (iface->get_color_profile)
+ return iface->get_color_profile (projectable);
+
+ return NULL;
}
void
diff --git a/app/core/gimpprojectable.h b/app/core/gimpprojectable.h
index 09bcc29..ea77f3b 100644
--- a/app/core/gimpprojectable.h
+++ b/app/core/gimpprojectable.h
@@ -35,26 +35,27 @@ struct _GimpProjectableInterface
GTypeInterface base_iface;
/* signals */
- void (* invalidate) (GimpProjectable *projectable,
- gint x,
- gint y,
- gint width,
- gint height);
- void (* flush) (GimpProjectable *projectable,
- gboolean invalidate_preview);
- void (* structure_changed) (GimpProjectable *projectable);
+ void (* invalidate) (GimpProjectable *projectable,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+ void (* flush) (GimpProjectable *projectable,
+ gboolean invalidate_preview);
+ void (* structure_changed) (GimpProjectable *projectable);
/* virtual functions */
- GimpImage * (* get_image) (GimpProjectable *projectable);
- const Babl * (* get_format) (GimpProjectable *projectable);
- void (* get_offset) (GimpProjectable *projectable,
- gint *x,
- gint *y);
- void (* get_size) (GimpProjectable *projectable,
- gint *width,
- gint *height);
- GeglNode * (* get_graph) (GimpProjectable *projectable);
- void (* invalidate_preview) (GimpProjectable *projectable);
+ GimpImage * (* get_image) (GimpProjectable *projectable);
+ const Babl * (* get_format) (GimpProjectable *projectable);
+ GimpColorProfile * (* get_color_profile) (GimpProjectable *projectable);
+ void (* get_offset) (GimpProjectable *projectable,
+ gint *x,
+ gint *y);
+ void (* get_size) (GimpProjectable *projectable,
+ gint *width,
+ gint *height);
+ GeglNode * (* get_graph) (GimpProjectable *projectable);
+ void (* invalidate_preview) (GimpProjectable *projectable);
};
@@ -71,6 +72,8 @@ void gimp_projectable_structure_changed (GimpProjectable *projectable);
GimpImage * gimp_projectable_get_image (GimpProjectable *projectable);
const Babl * gimp_projectable_get_format (GimpProjectable *projectable);
+GimpColorProfile
+ * gimp_projectable_get_color_profile (GimpProjectable *projectable);
void gimp_projectable_get_offset (GimpProjectable *projectable,
gint *x,
gint *y);
diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c
index 733c4e3..024b395 100644
--- a/app/core/gimpprojection.c
+++ b/app/core/gimpprojection.c
@@ -119,6 +119,8 @@ static gint64 gimp_projection_get_memsize (GimpObject *objec
static void gimp_projection_pickable_flush (GimpPickable *pickable);
static GimpImage * gimp_projection_get_image (GimpPickable *pickable);
static const Babl * gimp_projection_get_format (GimpPickable *pickable);
+static GimpColorProfile
+ * gimp_projection_get_color_profile (GimpPickable *pickable);
static GeglBuffer * gimp_projection_get_buffer (GimpPickable *pickable);
static gboolean gimp_projection_get_pixel_at (GimpPickable *pickable,
gint x,
@@ -237,6 +239,7 @@ gimp_projection_pickable_iface_init (GimpPickableInterface *iface)
iface->get_image = gimp_projection_get_image;
iface->get_format = gimp_projection_get_format;
iface->get_format_with_alpha = gimp_projection_get_format; /* sic */
+ iface->get_color_profile = gimp_projection_get_color_profile;
iface->get_buffer = gimp_projection_get_buffer;
iface->get_pixel_at = gimp_projection_get_pixel_at;
iface->get_opacity_at = gimp_projection_get_opacity_at;
@@ -372,6 +375,14 @@ gimp_projection_get_format (GimpPickable *pickable)
return gimp_projectable_get_format (proj->priv->projectable);
}
+static GimpColorProfile *
+gimp_projection_get_color_profile (GimpPickable *pickable)
+{
+ GimpProjection *proj = GIMP_PROJECTION (pickable);
+
+ return gimp_projectable_get_color_profile (proj->priv->projectable);
+}
+
static GeglBuffer *
gimp_projection_get_buffer (GimpPickable *pickable)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]