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.
This commit is contained in:
Michael Natterer 2015-08-28 14:32:41 +02:00
parent cf4e9967a2
commit 5c8ffdf6c5
8 changed files with 144 additions and 58 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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