Bug 51112 - Support layer masks on layer groups

Desktop / GNOME / GIMP - Ell [yahoo.com] - 5 February 2018 17:08 EST

Add layer-mask support for group layers. Group-layer masks work similarly to ordinary-layer masks, with the following considerations:

The group's mask size is the same as group's size (i.e., the bounding box of its children) at all times. When the group's size changes, the mask is cropped to the new size -- areas of the mask that fall outside of the new bounds are discarded and their data is lost (sans undo), and newly added areas are filled with black (and hence are transparent by default).

The new gimp_group_layer_{suspend,resume}_mask() functions can be used to modify this behavior. Between the outermost pair of suspend/resume calls, the old mask data is remembered, and is used to fill the newly added areas while cropping the mask when the group is resized. We override GimpItem::{start,end}_move() for GimpLayer, to call these functions (suspend() in start_move(), and resume() in end_move()) for each of the layer's ancestors.

As a result, while moving a layer, or a set of layers, atomically, such as while dragging with the move tool, or moving linked layers, the ancestors' mask data is not lost, and is only discarded at the end of the operation.

This commit also takes care of properly handling undo for group-layer mask crops, properly invalidating the image when the group layer's mask is shown, and enabling the mask actions for group layers (obviously :).

36dec4e6b0 Bug 51112 - Support layer masks on layer groups
app/actions/layers-actions.c | 6 +-
app/core/core-enums.c | 12 +-
app/core/core-enums.h | 6 +-
app/core/gimpgrouplayer.c | 274 +++++++++++++++++++++++++++++++++++++++--
app/core/gimpgrouplayer.h | 26 ++--
app/core/gimpgrouplayerundo.c | 102 ++++++++++++---
app/core/gimpgrouplayerundo.h | 3 +
app/core/gimpimage-undo-push.c | 48 ++++++--
app/core/gimpimage-undo-push.h | 14 ++-
app/core/gimplayer.c | 35 ++++++
10 files changed, 477 insertions(+), 49 deletions(-)

Upstream: git.gnome.org

  • Share