Files
gimp/app/core/gimpimage-fade.c
Ell 782d54a615 app: align drawable undo rectangle to tile grid
When creating a drawable undo from the drawable's buffer, align the
copied rectangle to the buffer's tile grid, so that all the copied
tiles are COWed, saving memory and gaining speed.

Add applied_x and applied_y fields to GimpDrawableUndo, specifying
the position at which to apply the applied_buffer, so that we apply
it in the right place, even if the undo rect has changed due to
alignment.

(cherry picked from commit bb9dd049fb)
2018-12-02 03:11:19 -05:00

80 lines
2.4 KiB
C

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "core-types.h"
#include "operations/layer-modes/gimp-layer-modes.h"
#include "gimpcontext.h"
#include "gimpdrawable.h"
#include "gimpdrawableundo.h"
#include "gimpimage.h"
#include "gimpimage-fade.h"
#include "gimpimage-undo.h"
/* public functions */
gboolean
gimp_image_fade (GimpImage *image,
GimpContext *context)
{
GimpDrawableUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image));
if (undo && undo->applied_buffer)
{
GimpDrawable *drawable;
GeglBuffer *buffer;
drawable = GIMP_DRAWABLE (GIMP_ITEM_UNDO (undo)->item);
g_object_ref (undo);
buffer = g_object_ref (undo->applied_buffer);
gimp_image_undo (image);
gimp_drawable_apply_buffer (drawable, buffer,
gegl_buffer_get_extent (buffer),
TRUE,
gimp_object_get_name (undo),
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context),
GIMP_LAYER_COLOR_SPACE_AUTO,
GIMP_LAYER_COLOR_SPACE_AUTO,
gimp_layer_mode_get_paint_composite_mode (
gimp_context_get_paint_mode (context)),
NULL, undo->applied_x, undo->applied_y);
g_object_unref (buffer);
g_object_unref (undo);
return TRUE;
}
return FALSE;
}