Commit d5795c00 authored by Michael Natterer's avatar Michael Natterer 😴

app: use a GeglBuffer instead of TileManager as storage in drawables \o/

parent 3a8248cc
......@@ -22,10 +22,8 @@ struct _GimpDrawablePrivate
{
const Babl *format; /* format of drawable */
TileManager *tiles; /* tiles for drawable data */
TileManager *shadow; /* shadow buffer tiles */
GeglBuffer *buffer;
GeglBuffer *buffer; /* buffer for drawable data */
TileManager *shadow; /* shadow buffer tiles */
GeglNode *source_node;
GeglNode *tile_source_node;
......
......@@ -293,20 +293,14 @@ gimp_drawable_finalize (GObject *object)
{
GimpDrawable *drawable = GIMP_DRAWABLE (object);
if (drawable->private->tiles)
{
tile_manager_unref (drawable->private->tiles);
drawable->private->tiles = NULL;
}
gimp_drawable_free_shadow_tiles (drawable);
if (drawable->private->buffer)
{
g_object_unref (drawable->private->buffer);
drawable->private->buffer = NULL;
}
gimp_drawable_free_shadow_tiles (drawable);
if (drawable->private->source_node)
{
g_object_unref (drawable->private->source_node);
......@@ -431,16 +425,11 @@ gimp_drawable_duplicate (GimpItem *item,
new_drawable->private->format = format;
if (new_drawable->private->tiles)
tile_manager_unref (new_drawable->private->tiles);
new_drawable->private->tiles =
tile_manager_new (gimp_item_get_width (new_item),
gimp_item_get_height (new_item),
gimp_drawable_bytes (new_drawable));
if (new_drawable->private->buffer)
g_object_unref (new_drawable->private->buffer);
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
gimp_drawable_get_buffer (new_drawable), NULL);
new_drawable->private->buffer =
gimp_gegl_buffer_dup (gimp_drawable_get_buffer (drawable));
}
return new_item;
......@@ -788,7 +777,7 @@ gimp_drawable_real_convert_type (GimpDrawable *drawable,
static TileManager *
gimp_drawable_real_get_tiles (GimpDrawable *drawable)
{
return drawable->private->tiles;
return gimp_gegl_buffer_get_tiles (drawable->private->buffer);
}
static void
......@@ -818,18 +807,15 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
/* ref new before unrefing old, they might be the same */
tile_manager_ref (tiles);
if (drawable->private->tiles)
tile_manager_unref (drawable->private->tiles);
if (drawable->private->buffer)
g_object_unref (drawable->private->buffer);
drawable->private->tiles = tiles;
drawable->private->format = gimp_image_get_format (gimp_item_get_image (item),
type);
drawable->private->buffer = gimp_tile_manager_create_buffer (tiles,
drawable->private->format);
if (drawable->private->buffer)
{
g_object_unref (drawable->private->buffer);
drawable->private->buffer = NULL;
}
tile_manager_unref (tiles);
gimp_item_set_offset (item, offset_x, offset_y);
gimp_item_set_size (item,
......@@ -1202,8 +1188,9 @@ gimp_drawable_new (GType type,
width, height));
drawable->private->format = format;
drawable->private->tiles = tile_manager_new (width, height,
gimp_drawable_bytes (drawable));
drawable->private->buffer = gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
width, height),
format);
return drawable;
}
......@@ -1470,25 +1457,12 @@ gimp_drawable_init_src_region (GimpDrawable *drawable,
*temp_tiles = NULL;
}
static GeglBuffer *
gimp_drawable_create_buffer (GimpDrawable *drawable)
{
TileManager *tiles = gimp_drawable_get_tiles (drawable);
const Babl *format = gimp_drawable_get_format (drawable);
return gimp_tile_manager_create_buffer (tiles, format);
}
GeglBuffer *
gimp_drawable_get_buffer (GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
if (! drawable->private->buffer)
{
drawable->private->buffer = gimp_drawable_create_buffer (drawable);
}
else
if (drawable->private->buffer)
{
gegl_buffer_flush (drawable->private->buffer);
gimp_gegl_buffer_refetch_tiles (drawable->private->buffer);
......@@ -1541,23 +1515,6 @@ gimp_drawable_set_buffer_full (GimpDrawable *drawable,
offset_x, offset_y);
}
void
gimp_drawable_recreate_buffers (GimpDrawable *drawable)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
if (drawable->private->buffer)
{
g_object_unref (drawable->private->buffer);
drawable->private->buffer = NULL;
}
if (drawable->private->tile_source_node)
gegl_node_set (drawable->private->tile_source_node,
"buffer", gimp_drawable_get_buffer (drawable),
NULL);
}
TileManager *
gimp_drawable_get_tiles (GimpDrawable *drawable)
{
......
......@@ -191,8 +191,6 @@ void gimp_drawable_set_buffer_full (GimpDrawable *drawable,
GimpImageType type,
gint offset_x,
gint offset_y);
/* FIXME gegl migration hack */
void gimp_drawable_recreate_buffers (GimpDrawable *drawable);
TileManager * gimp_drawable_get_tiles (GimpDrawable *drawable);
void gimp_drawable_set_tiles (GimpDrawable *drawable,
......
......@@ -1155,14 +1155,6 @@ gimp_image_get_description (GimpViewable *viewable,
static void
gimp_image_real_mode_changed (GimpImage *image)
{
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
GList *layers;
/* FIXME gegl migration hack */
layers = gimp_item_stack_get_item_list (GIMP_ITEM_STACK (private->layers->container));
g_list_foreach (layers, (GFunc) gimp_drawable_recreate_buffers, NULL);
g_list_free (layers);
gimp_projectable_structure_changed (GIMP_PROJECTABLE (image));
}
......
......@@ -195,8 +195,8 @@ gimp_text_layer_from_layer (GimpLayer *layer,
drawable = GIMP_DRAWABLE (text_layer);
drawable->private->format = gimp_drawable_get_format (GIMP_DRAWABLE (layer));
drawable->private->tiles = gimp_drawable_get_tiles (GIMP_DRAWABLE (layer));
GIMP_DRAWABLE (layer)->private->tiles = NULL;
drawable->private->buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
GIMP_DRAWABLE (layer)->private->buffer = NULL;
gimp_layer_set_opacity (GIMP_LAYER (text_layer),
gimp_layer_get_opacity (layer), FALSE);
......
......@@ -945,10 +945,10 @@ xcf_load_channel_props (XcfInfo *info,
gimp_item_get_height (GIMP_ITEM (*channel)));
g_object_ref_sink (mask);
tile_manager_unref (GIMP_DRAWABLE (mask)->private->tiles);
GIMP_DRAWABLE (mask)->private->tiles =
GIMP_DRAWABLE (*channel)->private->tiles;
GIMP_DRAWABLE (*channel)->private->tiles = NULL;
g_object_unref (GIMP_DRAWABLE (mask)->private->buffer);
GIMP_DRAWABLE (mask)->private->buffer =
GIMP_DRAWABLE (*channel)->private->buffer;
GIMP_DRAWABLE (*channel)->private->buffer = NULL;
g_object_unref (*channel);
*channel = mask;
(*channel)->boundary_known = FALSE;
......
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