Commit a6ebbfe3 authored by Ell's avatar Ell

app: avoid updating image bounding box multiple times when reordering layer

Add internal gimp_image_{freeze,thaw}_bounding_box() functions, and
use them in gimp_image_reorder_item() to avoid updating the
bounding box multiple times while moving a layer across group
boundary, to prevent flickering.
parent 2a753170
Pipeline #118916 failed with stages
in 9 minutes and 45 seconds
......@@ -264,6 +264,8 @@ static void gimp_image_active_vectors_notify (GimpItemTree *tree,
const GParamSpec *pspec,
GimpImage *image);
static void gimp_image_freeze_bounding_box (GimpImage *image);
static void gimp_image_thaw_bounding_box (GimpImage *image);
static void gimp_image_update_bounding_box (GimpImage *image);
......@@ -1767,12 +1769,43 @@ gimp_image_active_vectors_notify (GimpItemTree *tree,
g_signal_emit (image, gimp_image_signals[ACTIVE_VECTORS_CHANGED], 0);
}
static void
gimp_image_freeze_bounding_box (GimpImage *image)
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
private->bounding_box_freeze_count++;
}
static void
gimp_image_thaw_bounding_box (GimpImage *image)
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
private->bounding_box_freeze_count--;
if (private->bounding_box_freeze_count == 0 &&
private->bounding_box_update_pending)
{
private->bounding_box_update_pending = FALSE;
gimp_image_update_bounding_box (image);
}
}
static void
gimp_image_update_bounding_box (GimpImage *image)
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
GeglRectangle bounding_box;
if (private->bounding_box_freeze_count > 0)
{
private->bounding_box_update_pending = TRUE;
return;
}
bounding_box.x = 0;
bounding_box.y = 0;
bounding_box.width = gimp_image_get_width (image);
......@@ -4433,6 +4466,8 @@ gimp_image_reorder_item (GimpImage *image,
undo_desc);
}
gimp_image_freeze_bounding_box (image);
gimp_item_start_move (item, push_undo);
/* item and new_parent are type-checked in GimpItemTree
......@@ -4443,6 +4478,8 @@ gimp_image_reorder_item (GimpImage *image,
gimp_item_end_move (item, push_undo);
gimp_image_thaw_bounding_box (image);
if (push_undo)
gimp_image_undo_group_end (image);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment