[gimp/gimp-2-10] app: add GimpDrawable::supports_alpha() vfunc
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add GimpDrawable::supports_alpha() vfunc
- Date: Fri, 17 Jan 2020 10:16:18 +0000 (UTC)
commit 29a02b29490d2baf7d4fb95484c27ba67a32c86c
Author: Ell <ell_se yahoo com>
Date: Fri Jan 17 11:24:31 2020 +0200
app: add GimpDrawable::supports_alpha() vfunc
Add a new GimpDrawable::supports_alpha() virtual function, and a
corresponding gimp_drawable_supports_alpha() function, which
determine if the drawable supports an alpha channel. The default
implementation returns FALSE, and GimpLayer overrides it to return
TRUE.
app/core/gimpdrawable.c | 18 ++++++++++++++++++
app/core/gimpdrawable.h | 3 +++
app/core/gimplayer.c | 8 ++++++++
3 files changed, 29 insertions(+)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 3ff76c6ccd..9a85eeef33 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -172,6 +172,9 @@ static void gimp_drawable_real_update_all (GimpDrawable *drawable)
static GimpComponentMask
gimp_drawable_real_get_active_mask (GimpDrawable *drawable);
+static gboolean gimp_drawable_real_supports_alpha
+ (GimpDrawable *drawable);
+
static void gimp_drawable_real_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
const Babl *new_format,
@@ -301,6 +304,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
klass->invalidate_boundary = NULL;
klass->get_active_components = NULL;
klass->get_active_mask = gimp_drawable_real_get_active_mask;
+ klass->supports_alpha = gimp_drawable_real_supports_alpha;
klass->convert_type = gimp_drawable_real_convert_type;
klass->apply_buffer = gimp_drawable_real_apply_buffer;
klass->get_buffer = gimp_drawable_real_get_buffer;
@@ -830,6 +834,12 @@ gimp_drawable_real_get_active_mask (GimpDrawable *drawable)
return GIMP_COMPONENT_MASK_ALL;
}
+static gboolean
+gimp_drawable_real_supports_alpha (GimpDrawable *drawable)
+{
+ return FALSE;
+}
+
/* FIXME: this default impl is currently unused because no subclass
* chains up. the goal is to handle the almost identical subclass code
* here again.
@@ -1222,6 +1232,14 @@ gimp_drawable_get_active_mask (GimpDrawable *drawable)
return mask;
}
+gboolean
+gimp_drawable_supports_alpha (GimpDrawable *drawable)
+{
+ g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
+
+ return GIMP_DRAWABLE_GET_CLASS (drawable)->supports_alpha (drawable);
+}
+
void
gimp_drawable_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 6d19bd25db..73c42831d7 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -64,6 +64,7 @@ struct _GimpDrawableClass
void (* get_active_components) (GimpDrawable *drawable,
gboolean *active);
GimpComponentMask (* get_active_mask) (GimpDrawable *drawable);
+ gboolean (* supports_alpha) (GimpDrawable *drawable);
void (* convert_type) (GimpDrawable *drawable,
GimpImage *dest_image,
const Babl *new_format,
@@ -135,6 +136,8 @@ void gimp_drawable_get_active_components (GimpDrawable *drawable,
gboolean *active);
GimpComponentMask gimp_drawable_get_active_mask (GimpDrawable *drawable);
+gboolean gimp_drawable_supports_alpha (GimpDrawable *drawable);
+
void gimp_drawable_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
GimpImageBaseType new_base_type,
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 2f835e4d40..5d785d21b6 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -183,6 +183,7 @@ static gint64 gimp_layer_estimate_memsize (GimpDrawable *drawable,
GimpComponentType component_type,
gint width,
gint height);
+static gboolean gimp_layer_supports_alpha (GimpDrawable *drawable);
static void gimp_layer_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
const Babl *new_format,
@@ -457,6 +458,7 @@ gimp_layer_class_init (GimpLayerClass *klass)
drawable_class->alpha_changed = gimp_layer_alpha_changed;
drawable_class->estimate_memsize = gimp_layer_estimate_memsize;
+ drawable_class->supports_alpha = gimp_layer_supports_alpha;
drawable_class->convert_type = gimp_layer_convert_type;
drawable_class->invalidate_boundary = gimp_layer_invalidate_boundary;
drawable_class->get_active_components = gimp_layer_get_active_components;
@@ -1362,6 +1364,12 @@ gimp_layer_estimate_memsize (GimpDrawable *drawable,
width, height);
}
+static gboolean
+gimp_layer_supports_alpha (GimpDrawable *drawable)
+{
+ return TRUE;
+}
+
static void
gimp_layer_convert_type (GimpDrawable *drawable,
GimpImage *dest_image,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]