mirror of https://github.com/GNOME/gimp.git
app: calculate drawable bounding box according to graph by default
Change the default implementation of GimpDrawable::get_bounding_box() to return the drawable source node's bounding box, instead of the drawable's item bounds. This allows filters to affect the size of all drawables, including, in particular, layer masks. Change GimpLayer's implementation of get_bounding_box() to return the intersection of the layer's own bounding box, and the layer mask's bounding box (if it has one), and update the layer's bounding box when the mask is enabled/disabled, or when its bounding box changes.
This commit is contained in:
parent
4a4359d3da
commit
cb5a63e260
|
@ -931,15 +931,7 @@ gimp_drawable_real_set_buffer (GimpDrawable *drawable,
|
|||
static GeglRectangle
|
||||
gimp_drawable_real_get_bounding_box (GimpDrawable *drawable)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (drawable);
|
||||
GeglRectangle bounding_box;
|
||||
|
||||
bounding_box.x = 0;
|
||||
bounding_box.y = 0;
|
||||
bounding_box.width = gimp_item_get_width (item);
|
||||
bounding_box.height = gimp_item_get_height (item);
|
||||
|
||||
return bounding_box;
|
||||
return gegl_node_get_bounding_box (gimp_drawable_get_source_node (drawable));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1522,12 +1522,25 @@ gimp_layer_set_buffer (GimpDrawable *drawable,
|
|||
static GeglRectangle
|
||||
gimp_layer_get_bounding_box (GimpDrawable *drawable)
|
||||
{
|
||||
GimpLayer *layer = GIMP_LAYER (drawable);
|
||||
GimpLayer *layer = GIMP_LAYER (drawable);
|
||||
GimpLayerMask *mask = gimp_layer_get_mask (layer);
|
||||
GeglRectangle bounding_box;
|
||||
|
||||
if (gimp_layer_get_mask (layer))
|
||||
return GIMP_DRAWABLE_CLASS (parent_class)->get_bounding_box (drawable);
|
||||
bounding_box = GIMP_DRAWABLE_CLASS (parent_class)->get_bounding_box (
|
||||
drawable);
|
||||
|
||||
return gegl_node_get_bounding_box (gimp_drawable_get_source_node (drawable));
|
||||
if (mask && gimp_layer_get_apply_mask (layer))
|
||||
{
|
||||
GeglRectangle mask_bounding_box;
|
||||
|
||||
mask_bounding_box = gimp_drawable_get_bounding_box (
|
||||
GIMP_DRAWABLE (mask));
|
||||
|
||||
gegl_rectangle_intersect (&bounding_box,
|
||||
&bounding_box, &mask_bounding_box);
|
||||
}
|
||||
|
||||
return bounding_box;
|
||||
}
|
||||
|
||||
static GimpColorProfile *
|
||||
|
@ -2292,6 +2305,8 @@ gimp_layer_set_apply_mask (GimpLayer *layer,
|
|||
}
|
||||
}
|
||||
|
||||
gimp_drawable_update_bounding_box (GIMP_DRAWABLE (layer));
|
||||
|
||||
gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
|
||||
|
||||
g_signal_emit (layer, layer_signals[APPLY_MASK_CHANGED], 0);
|
||||
|
|
|
@ -32,29 +32,30 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_layer_mask_preview_freeze (GimpViewable *viewable);
|
||||
static void gimp_layer_mask_preview_thaw (GimpViewable *viewable);
|
||||
static void gimp_layer_mask_preview_freeze (GimpViewable *viewable);
|
||||
static void gimp_layer_mask_preview_thaw (GimpViewable *viewable);
|
||||
|
||||
static gboolean gimp_layer_mask_is_attached (GimpItem *item);
|
||||
static gboolean gimp_layer_mask_is_content_locked (GimpItem *item);
|
||||
static gboolean gimp_layer_mask_is_position_locked (GimpItem *item);
|
||||
static GimpItemTree * gimp_layer_mask_get_tree (GimpItem *item);
|
||||
static GimpItem * gimp_layer_mask_duplicate (GimpItem *item,
|
||||
GType new_type);
|
||||
static gboolean gimp_layer_mask_rename (GimpItem *item,
|
||||
const gchar *new_name,
|
||||
const gchar *undo_desc,
|
||||
GError **error);
|
||||
static gboolean gimp_layer_mask_is_attached (GimpItem *item);
|
||||
static gboolean gimp_layer_mask_is_content_locked (GimpItem *item);
|
||||
static gboolean gimp_layer_mask_is_position_locked (GimpItem *item);
|
||||
static GimpItemTree * gimp_layer_mask_get_tree (GimpItem *item);
|
||||
static GimpItem * gimp_layer_mask_duplicate (GimpItem *item,
|
||||
GType new_type);
|
||||
static gboolean gimp_layer_mask_rename (GimpItem *item,
|
||||
const gchar *new_name,
|
||||
const gchar *undo_desc,
|
||||
GError **error);
|
||||
|
||||
static void gimp_layer_mask_convert_type (GimpDrawable *drawable,
|
||||
GimpImage *dest_image,
|
||||
const Babl *new_format,
|
||||
GimpColorProfile *src_profile,
|
||||
GimpColorProfile *dest_profile,
|
||||
GeglDitherMethod layer_dither_type,
|
||||
GeglDitherMethod mask_dither_type,
|
||||
gboolean push_undo,
|
||||
GimpProgress *progress);
|
||||
static void gimp_layer_mask_bounding_box_changed (GimpDrawable *drawable);
|
||||
static void gimp_layer_mask_convert_type (GimpDrawable *drawable,
|
||||
GimpImage *dest_image,
|
||||
const Babl *new_format,
|
||||
GimpColorProfile *src_profile,
|
||||
GimpColorProfile *dest_profile,
|
||||
GeglDitherMethod layer_dither_type,
|
||||
GeglDitherMethod mask_dither_type,
|
||||
gboolean push_undo,
|
||||
GimpProgress *progress);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpLayerMask, gimp_layer_mask, GIMP_TYPE_CHANNEL)
|
||||
|
@ -71,19 +72,20 @@ gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
|
|||
|
||||
viewable_class->default_icon_name = "gimp-layer-mask";
|
||||
|
||||
viewable_class->preview_freeze = gimp_layer_mask_preview_freeze;
|
||||
viewable_class->preview_thaw = gimp_layer_mask_preview_thaw;
|
||||
viewable_class->preview_freeze = gimp_layer_mask_preview_freeze;
|
||||
viewable_class->preview_thaw = gimp_layer_mask_preview_thaw;
|
||||
|
||||
item_class->is_attached = gimp_layer_mask_is_attached;
|
||||
item_class->is_content_locked = gimp_layer_mask_is_content_locked;
|
||||
item_class->is_position_locked = gimp_layer_mask_is_position_locked;
|
||||
item_class->get_tree = gimp_layer_mask_get_tree;
|
||||
item_class->duplicate = gimp_layer_mask_duplicate;
|
||||
item_class->rename = gimp_layer_mask_rename;
|
||||
item_class->translate_desc = C_("undo-type", "Move Layer Mask");
|
||||
item_class->to_selection_desc = C_("undo-type", "Layer Mask to Selection");
|
||||
item_class->is_attached = gimp_layer_mask_is_attached;
|
||||
item_class->is_content_locked = gimp_layer_mask_is_content_locked;
|
||||
item_class->is_position_locked = gimp_layer_mask_is_position_locked;
|
||||
item_class->get_tree = gimp_layer_mask_get_tree;
|
||||
item_class->duplicate = gimp_layer_mask_duplicate;
|
||||
item_class->rename = gimp_layer_mask_rename;
|
||||
item_class->translate_desc = C_("undo-type", "Move Layer Mask");
|
||||
item_class->to_selection_desc = C_("undo-type", "Layer Mask to Selection");
|
||||
|
||||
drawable_class->convert_type = gimp_layer_mask_convert_type;
|
||||
drawable_class->bounding_box_changed = gimp_layer_mask_bounding_box_changed;
|
||||
drawable_class->convert_type = gimp_layer_mask_convert_type;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -197,6 +199,19 @@ gimp_layer_mask_rename (GimpItem *item,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_layer_mask_bounding_box_changed (GimpDrawable *drawable)
|
||||
{
|
||||
GimpLayerMask *mask = GIMP_LAYER_MASK (drawable);
|
||||
GimpLayer *layer = gimp_layer_mask_get_layer (mask);
|
||||
|
||||
if (GIMP_DRAWABLE_CLASS (parent_class)->bounding_box_changed)
|
||||
GIMP_DRAWABLE_CLASS (parent_class)->bounding_box_changed (drawable);
|
||||
|
||||
if (layer)
|
||||
gimp_drawable_update_bounding_box (GIMP_DRAWABLE (layer));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_layer_mask_convert_type (GimpDrawable *drawable,
|
||||
GimpImage *dest_image,
|
||||
|
|
Loading…
Reference in New Issue