mirror of https://github.com/GNOME/gimp.git
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.
This commit is contained in:
parent
0103fe2c19
commit
5e1eba68e2
|
@ -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,
|
||||
|
@ -302,6 +305,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;
|
||||
|
@ -838,6 +842,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.
|
||||
|
@ -1232,6 +1242,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,
|
||||
|
|
|
@ -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,
|
||||
|
@ -136,6 +137,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,
|
||||
|
|
|
@ -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,
|
||||
|
@ -447,6 +448,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;
|
||||
|
@ -1356,6 +1358,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,
|
||||
|
|
Loading…
Reference in New Issue