app: add gimp_gegl_buffer_dup()
... as a drop-in replacement for gegl_buffer_dup(), which COWs all
tiles of the source buffer, including ones that aren't fully
included within buffer's extent.
(cherry picked from commit 5798cefe1b
)
This commit is contained in:
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "core/gimpprogress.h"
|
#include "core/gimpprogress.h"
|
||||||
|
|
||||||
|
#include "gimp-gegl-loops.h"
|
||||||
#include "gimp-gegl-utils.h"
|
#include "gimp-gegl-utils.h"
|
||||||
|
|
||||||
|
|
||||||
@ -230,3 +231,52 @@ gimp_gegl_param_spec_has_key (GParamSpec *pspec,
|
|||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GeglBuffer *
|
||||||
|
gimp_gegl_buffer_dup (GeglBuffer *buffer)
|
||||||
|
{
|
||||||
|
GeglBuffer *new_buffer;
|
||||||
|
const GeglRectangle *extent;
|
||||||
|
const GeglRectangle *abyss;
|
||||||
|
GeglRectangle rect;
|
||||||
|
gint shift_x;
|
||||||
|
gint shift_y;
|
||||||
|
gint tile_width;
|
||||||
|
gint tile_height;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
|
||||||
|
|
||||||
|
extent = gegl_buffer_get_extent (buffer);
|
||||||
|
abyss = gegl_buffer_get_abyss (buffer);
|
||||||
|
|
||||||
|
g_object_get (buffer,
|
||||||
|
"shift-x", &shift_x,
|
||||||
|
"shift-y", &shift_y,
|
||||||
|
"tile-width", &tile_width,
|
||||||
|
"tile-height", &tile_height,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
new_buffer = g_object_new (GEGL_TYPE_BUFFER,
|
||||||
|
"format", gegl_buffer_get_format (buffer),
|
||||||
|
"x", extent->x,
|
||||||
|
"y", extent->y,
|
||||||
|
"width", extent->width,
|
||||||
|
"height", extent->height,
|
||||||
|
"abyss-x", abyss->x,
|
||||||
|
"abyss-y", abyss->y,
|
||||||
|
"abyss-width", abyss->width,
|
||||||
|
"abyss-height", abyss->height,
|
||||||
|
"shift-x", shift_x,
|
||||||
|
"shift-y", shift_y,
|
||||||
|
"tile-width", tile_width,
|
||||||
|
"tile-height", tile_height,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gegl_rectangle_align_to_buffer (&rect, extent, buffer,
|
||||||
|
GEGL_RECTANGLE_ALIGNMENT_SUPERSET);
|
||||||
|
|
||||||
|
gimp_gegl_buffer_copy (buffer, &rect, GEGL_ABYSS_NONE,
|
||||||
|
new_buffer, &rect);
|
||||||
|
|
||||||
|
return new_buffer;
|
||||||
|
}
|
||||||
|
@ -46,5 +46,7 @@ gboolean gimp_gegl_param_spec_has_key (GParamSpec *pspec
|
|||||||
const gchar *key,
|
const gchar *key,
|
||||||
const gchar *value);
|
const gchar *value);
|
||||||
|
|
||||||
|
GeglBuffer * gimp_gegl_buffer_dup (GeglBuffer *buffer);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_GEGL_UTILS_H__ */
|
#endif /* __GIMP_GEGL_UTILS_H__ */
|
||||||
|
Reference in New Issue
Block a user