[gimp/goat-invasion: 315/412] app: replace GimpProjectable::get_image_type() by ::get_format()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 315/412] app: replace GimpProjectable::get_image_type() by ::get_format()
- Date: Tue, 3 Apr 2012 09:59:35 +0000 (UTC)
commit cfb96ad02c265f6502c530a7592b387735572cc4
Author: Michael Natterer <mitch gimp org>
Date: Thu Mar 29 21:09:37 2012 +0200
app: replace GimpProjectable::get_image_type() by ::get_format()
and change semantics to returning the format it wants to be projected
in, not its actual format.
app/core/gimpgrouplayer.c | 23 ++++++++++++++++++++++-
app/core/gimpimage.c | 27 ++++++++++++++++++---------
app/core/gimpprojectable.c | 10 +++++-----
app/core/gimpprojectable.h | 4 ++--
app/core/gimpprojection.c | 17 +----------------
5 files changed, 48 insertions(+), 33 deletions(-)
---
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 9ee5718..ce977f4 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -140,6 +140,7 @@ static void gimp_group_layer_convert_type (GimpDrawable *drawabl
GimpImageBaseType new_base_type,
gboolean push_undo);
+static const Babl * gimp_group_layer_get_format (GimpProjectable *projectable);
static GeglNode * gimp_group_layer_get_graph (GimpProjectable *projectable);
static GList * gimp_group_layer_get_layers (GimpProjectable *projectable);
static gint gimp_group_layer_get_opacity_at
@@ -237,7 +238,7 @@ static void
gimp_projectable_iface_init (GimpProjectableInterface *iface)
{
iface->get_image = (GimpImage * (*) (GimpProjectable *)) gimp_item_get_image;
- iface->get_image_type = (GimpImageType (*) (GimpProjectable *)) gimp_drawable_type;
+ iface->get_format = gimp_group_layer_get_format;
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;
@@ -871,6 +872,26 @@ gimp_group_layer_convert_type (GimpDrawable *drawable,
g_object_unref (buffer);
}
+static const Babl *
+gimp_group_layer_get_format (GimpProjectable *projectable)
+{
+ GimpDrawable *drawable = GIMP_DRAWABLE (projectable);
+
+ switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)))
+ {
+ case GIMP_RGB:
+ case GIMP_INDEXED:
+ return babl_format ("R'G'B'A u8");
+
+ case GIMP_GRAY:
+ return babl_format ("Y'A u8");
+ }
+
+ g_assert_not_reached ();
+
+ return NULL;
+}
+
static GeglNode *
gimp_group_layer_get_graph (GimpProjectable *projectable)
{
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index c90ee3c..6a51e06 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -175,9 +175,9 @@ static const guint8 * gimp_image_get_icc_profile (GimpColorManaged *managed,
static void gimp_image_projectable_flush (GimpProjectable *projectable,
gboolean invalidate_preview);
-static GeglNode * gimp_image_get_graph (GimpProjectable *projectable);
-static GimpImage * gimp_image_get_image (GimpProjectable *projectable);
-static GimpImageType gimp_image_get_image_type (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 void gimp_image_mask_update (GimpDrawable *drawable,
gint x,
@@ -609,7 +609,7 @@ gimp_projectable_iface_init (GimpProjectableInterface *iface)
{
iface->flush = gimp_image_projectable_flush;
iface->get_image = gimp_image_get_image;
- iface->get_image_type = gimp_image_get_image_type;
+ iface->get_format = gimp_image_get_proj_format;
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;
@@ -1265,15 +1265,24 @@ gimp_image_get_image (GimpProjectable *projectable)
return GIMP_IMAGE (projectable);
}
-static GimpImageType
-gimp_image_get_image_type (GimpProjectable *projectable)
+static const Babl *
+gimp_image_get_proj_format (GimpProjectable *projectable)
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (projectable);
- GimpImageType type;
- type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (private->base_type);
+ switch (private->base_type)
+ {
+ case GIMP_RGB:
+ case GIMP_INDEXED:
+ return babl_format ("R'G'B'A u8");
+
+ case GIMP_GRAY:
+ return babl_format ("Y'A u8");
+ }
- return GIMP_IMAGE_TYPE_WITH_ALPHA (type);
+ g_assert_not_reached ();
+
+ return NULL;
}
static GeglNode *
diff --git a/app/core/gimpprojectable.c b/app/core/gimpprojectable.c
index b9a05ff..05f979b 100644
--- a/app/core/gimpprojectable.c
+++ b/app/core/gimpprojectable.c
@@ -164,17 +164,17 @@ gimp_projectable_get_image (GimpProjectable *projectable)
return NULL;
}
-GimpImageType
-gimp_projectable_get_image_type (GimpProjectable *projectable)
+const Babl *
+gimp_projectable_get_format (GimpProjectable *projectable)
{
GimpProjectableInterface *iface;
- g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), 0);
+ g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
iface = GIMP_PROJECTABLE_GET_INTERFACE (projectable);
- if (iface->get_image_type)
- return iface->get_image_type (projectable);
+ if (iface->get_format)
+ return iface->get_format (projectable);
return 0;
}
diff --git a/app/core/gimpprojectable.h b/app/core/gimpprojectable.h
index 5c3ec70..11f70c1 100644
--- a/app/core/gimpprojectable.h
+++ b/app/core/gimpprojectable.h
@@ -46,7 +46,7 @@ struct _GimpProjectableInterface
/* virtual functions */
GimpImage * (* get_image) (GimpProjectable *projectable);
- GimpImageType (* get_image_type) (GimpProjectable *projectable);
+ const Babl * (* get_format) (GimpProjectable *projectable);
void (* get_offset) (GimpProjectable *projectable,
gint *x,
gint *y);
@@ -74,7 +74,7 @@ void gimp_projectable_flush (GimpProjectable *projectable
void gimp_projectable_structure_changed (GimpProjectable *projectable);
GimpImage * gimp_projectable_get_image (GimpProjectable *projectable);
-GimpImageType gimp_projectable_get_image_type (GimpProjectable *projectable);
+const Babl * gimp_projectable_get_format (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 1da3223..3b718f6 100644
--- a/app/core/gimpprojection.c
+++ b/app/core/gimpprojection.c
@@ -295,23 +295,8 @@ static const Babl *
gimp_projection_get_format (GimpPickable *pickable)
{
GimpProjection *proj = GIMP_PROJECTION (pickable);
- GimpImageType type;
- type = gimp_projectable_get_image_type (proj->projectable);
-
- switch (GIMP_IMAGE_TYPE_BASE_TYPE (type))
- {
- case GIMP_RGB:
- case GIMP_INDEXED:
- return babl_format ("R'G'B'A u8");
-
- case GIMP_GRAY:
- return babl_format ("Y'A u8");
- }
-
- g_assert_not_reached ();
-
- return NULL;
+ return gimp_projectable_get_format (proj->projectable);
}
static GeglBuffer *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]