[gimp/goat-invasion: 33/412] app: completely port GimpBuffer to using GeglBuffer not TileManager
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 33/412] app: completely port GimpBuffer to using GeglBuffer not TileManager
- Date: Tue, 3 Apr 2012 09:35:53 +0000 (UTC)
commit 226a9dd690d784b04bae68717c48f2c883e5b01a
Author: Michael Natterer <mitch gimp org>
Date: Wed Mar 14 23:09:36 2012 +0100
app: completely port GimpBuffer to using GeglBuffer not TileManager
app/actions/edit-commands.c | 10 ++--
app/core/gimp-edit.c | 19 ++++--
app/core/gimpbrushclipboard.c | 10 +++-
app/core/gimpbuffer.c | 129 ++++++++++++++++++++-------------------
app/core/gimpbuffer.h | 14 +++--
app/core/gimpimage-new.c | 18 ++----
app/core/gimppatternclipboard.c | 33 +++++-----
app/widgets/gimpclipboard.c | 1 +
8 files changed, 123 insertions(+), 111 deletions(-)
---
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index c1244be..b7c05cb 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -342,11 +342,11 @@ edit_paste_as_new_layer_cmd_callback (GtkAction *action,
{
GimpLayer *layer;
- layer = gimp_layer_new_from_tiles (gimp_buffer_get_tiles (buffer),
- image,
- gimp_image_base_type_with_alpha (image),
- _("Clipboard"),
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+ layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (buffer),
+ image,
+ gimp_image_base_type_with_alpha (image),
+ _("Clipboard"),
+ GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
g_object_unref (buffer);
gimp_image_add_layer (image, layer,
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index adf7a76..1ba12db 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -31,6 +31,8 @@
#include "paint-funcs/paint-funcs.h"
+#include "gegl/gimp-gegl-utils.h"
+
#include "gimp.h"
#include "gimp-edit.h"
#include "gimpbuffer.h"
@@ -185,9 +187,10 @@ gimp_edit_paste (GimpImage *image,
else
type = gimp_image_base_type_with_alpha (image);
- layer = gimp_layer_new_from_tiles (paste->tiles, image, type,
- _("Pasted Layer"),
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+ layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (paste),
+ image, type,
+ _("Pasted Layer"),
+ GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer)
return NULL;
@@ -512,11 +515,17 @@ gimp_edit_extract (GimpImage *image,
if (tiles)
{
- GimpBuffer *buffer = gimp_buffer_new (tiles, _("Global Buffer"),
- offset_x, offset_y, FALSE);
+ GeglBuffer *temp;
+ GimpBuffer *buffer;
+ temp = gimp_tile_manager_get_gegl_buffer (tiles, TRUE);
tile_manager_unref (tiles);
+ buffer = gimp_buffer_new (temp, _("Global Buffer"),
+ GIMP_IMAGE_TYPE_FROM_BYTES (tile_manager_bpp (tiles)),
+ offset_x, offset_y, FALSE);
+ g_object_unref (temp);
+
return buffer;
}
diff --git a/app/core/gimpbrushclipboard.c b/app/core/gimpbrushclipboard.c
index 4e5d24e..8eb2ad3 100644
--- a/app/core/gimpbrushclipboard.c
+++ b/app/core/gimpbrushclipboard.c
@@ -26,9 +26,12 @@
#include "base/temp-buf.h"
#include "base/pixel-region.h"
+#include "base/tile-manager.h"
#include "paint-funcs/paint-funcs.h"
+#include "gegl/gimp-gegl-utils.h"
+
#include "gimp.h"
#include "gimpbuffer.h"
#include "gimpbrushclipboard.h"
@@ -198,8 +201,9 @@ gimp_brush_clipboard_buffer_changed (Gimp *gimp,
if (gimp->global_buffer)
{
- TileManager *tiles = gimp_buffer_get_tiles (gimp->global_buffer);
- GimpImageType type = gimp_buffer_get_image_type (gimp->global_buffer);
+ GeglBuffer *buffer = gimp_buffer_get_buffer (gimp->global_buffer);
+ TileManager *tiles = gimp_buffer_to_tiles (buffer);
+ GimpImageType type = gimp_buffer_get_image_type (gimp->global_buffer);
width = MIN (gimp_buffer_get_width (gimp->global_buffer), 512);
height = MIN (gimp_buffer_get_height (gimp->global_buffer), 512);
@@ -265,6 +269,8 @@ gimp_brush_clipboard_buffer_changed (Gimp *gimp,
temp_buf_copy (temp, brush->pixmap);
temp_buf_free (temp);
}
+
+ tile_manager_unref (tiles);
}
else
{
diff --git a/app/core/gimpbuffer.c b/app/core/gimpbuffer.c
index 7988634..4672114 100644
--- a/app/core/gimpbuffer.c
+++ b/app/core/gimpbuffer.c
@@ -17,18 +17,17 @@
#include "config.h"
+#include <gegl.h>
#include <glib-object.h>
-#include "libgimpmath/gimpmath.h"
-
#include "core-types.h"
-#include "base/pixel-region.h"
-#include "base/tile-manager.h"
-#include "base/tile-manager-preview.h"
#include "base/temp-buf.h"
+#include "gegl/gimp-gegl-utils.h"
+
#include "gimpbuffer.h"
+#include "gimpimage.h"
static void gimp_buffer_finalize (GObject *object);
@@ -86,7 +85,6 @@ gimp_buffer_class_init (GimpBufferClass *klass)
static void
gimp_buffer_init (GimpBuffer *buffer)
{
- buffer->tiles = NULL;
}
static void
@@ -94,10 +92,10 @@ gimp_buffer_finalize (GObject *object)
{
GimpBuffer *buffer = GIMP_BUFFER (object);
- if (buffer->tiles)
+ if (buffer->buffer)
{
- tile_manager_unref (buffer->tiles);
- buffer->tiles = NULL;
+ g_object_unref (buffer->buffer);
+ buffer->buffer = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -110,7 +108,7 @@ gimp_buffer_get_memsize (GimpObject *object,
GimpBuffer *buffer = GIMP_BUFFER (object);
gint64 memsize = 0;
- memsize += tile_manager_get_memsize (buffer->tiles, FALSE);
+ /* FIXME memsize += tile_manager_get_memsize (buffer->tiles, FALSE); */
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
@@ -197,8 +195,21 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
gint height)
{
GimpBuffer *buffer = GIMP_BUFFER (viewable);
+ TempBuf *preview;
+
+ preview = temp_buf_new (width, height, gimp_buffer_get_bytes (buffer),
+ 0, 0, NULL);
- return tile_manager_get_preview (buffer->tiles, width, height);
+ gegl_buffer_get (buffer->buffer,
+ MIN ((gdouble) width / (gdouble) gimp_buffer_get_width (buffer),
+ (gdouble) height / (gdouble) gimp_buffer_get_height (buffer)),
+ NULL,
+ gimp_bpp_to_babl_format (gimp_buffer_get_bytes (buffer),
+ TRUE),
+ temp_buf_get_data (preview),
+ width * gimp_buffer_get_bytes (buffer));
+
+ return preview;
}
static gchar *
@@ -214,30 +225,32 @@ gimp_buffer_get_description (GimpViewable *viewable,
}
GimpBuffer *
-gimp_buffer_new (TileManager *tiles,
- const gchar *name,
- gint offset_x,
- gint offset_y,
- gboolean copy_pixels)
+gimp_buffer_new (GeglBuffer *buffer,
+ const gchar *name,
+ GimpImageType image_type,
+ gint offset_x,
+ gint offset_y,
+ gboolean copy_pixels)
{
- GimpBuffer *buffer;
+ GimpBuffer *gimp_buffer;
- g_return_val_if_fail (tiles != NULL, NULL);
+ g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
g_return_val_if_fail (name != NULL, NULL);
- buffer = g_object_new (GIMP_TYPE_BUFFER,
- "name", name,
- NULL);
+ gimp_buffer = g_object_new (GIMP_TYPE_BUFFER,
+ "name", name,
+ NULL);
- if (copy_pixels)
- buffer->tiles = tile_manager_duplicate (tiles);
+ if (TRUE /* FIXME copy_pixels */)
+ gimp_buffer->buffer = gegl_buffer_dup (buffer);
else
- buffer->tiles = tile_manager_ref (tiles);
+ gimp_buffer->buffer = g_object_ref (buffer);
- buffer->offset_x = offset_x;
- buffer->offset_y = offset_y;
+ gimp_buffer->image_type = image_type;
+ gimp_buffer->offset_x = offset_x;
+ gimp_buffer->offset_y = offset_y;
- return buffer;
+ return gimp_buffer;
}
GimpBuffer *
@@ -246,15 +259,13 @@ gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf,
gint offset_x,
gint offset_y)
{
- GimpBuffer *buffer;
- TileManager *tiles;
- guchar *pixels;
- PixelRegion destPR;
- gint width;
- gint height;
- gint rowstride;
- gint channels;
- gint y;
+ GimpBuffer *gimp_buffer;
+ GeglBuffer *buffer;
+ gint width;
+ gint height;
+ gint rowstride;
+ gint channels;
+ GeglRectangle rect = { 0, };
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (name != NULL, NULL);
@@ -264,22 +275,22 @@ gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf,
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
channels = gdk_pixbuf_get_n_channels (pixbuf);
- tiles = tile_manager_new (width, height, channels);
+ rect.width = width;
+ rect.height = height;
- pixel_region_init (&destPR, tiles, 0, 0, width, height, TRUE);
+ buffer = gegl_buffer_linear_new_from_data (gdk_pixbuf_get_pixels (pixbuf),
+ gimp_bpp_to_babl_format (channels,
+ TRUE),
+ &rect, rowstride,
+ NULL, NULL);
- for (y = 0, pixels = gdk_pixbuf_get_pixels (pixbuf);
- y < height;
- y++, pixels += rowstride)
- {
- pixel_region_set_row (&destPR, 0, y, width, pixels);
- }
-
- buffer = gimp_buffer_new (tiles, name, offset_x, offset_y, FALSE);
+ gimp_buffer = gimp_buffer_new (buffer, name,
+ GIMP_IMAGE_TYPE_FROM_BYTES (channels),
+ offset_x, offset_y, FALSE);
- tile_manager_unref (tiles);
+ g_object_unref (buffer);
- return buffer;
+ return gimp_buffer;
}
gint
@@ -287,7 +298,7 @@ gimp_buffer_get_width (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
- return tile_manager_width (buffer->tiles);
+ return gegl_buffer_get_width (buffer->buffer);
}
gint
@@ -295,7 +306,7 @@ gimp_buffer_get_height (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
- return tile_manager_height (buffer->tiles);
+ return gegl_buffer_get_height (buffer->buffer);
}
gint
@@ -303,7 +314,7 @@ gimp_buffer_get_bytes (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
- return tile_manager_bpp (buffer->tiles);
+ return GIMP_IMAGE_TYPE_BYTES (buffer->image_type);
}
GimpImageType
@@ -311,21 +322,13 @@ gimp_buffer_get_image_type (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
- switch (tile_manager_bpp (buffer->tiles))
- {
- case 1: return GIMP_GRAY_IMAGE;
- case 2: return GIMP_GRAYA_IMAGE;
- case 3: return GIMP_RGB_IMAGE;
- case 4: return GIMP_RGBA_IMAGE;
- }
-
- return 0;
+ return buffer->image_type;
}
-TileManager *
-gimp_buffer_get_tiles (const GimpBuffer *buffer)
+GeglBuffer *
+gimp_buffer_get_buffer (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), NULL);
- return buffer->tiles;
+ return buffer->buffer;
}
diff --git a/app/core/gimpbuffer.h b/app/core/gimpbuffer.h
index 72cd2eb..ee10a5e 100644
--- a/app/core/gimpbuffer.h
+++ b/app/core/gimpbuffer.h
@@ -34,11 +34,12 @@ typedef struct _GimpBufferClass GimpBufferClass;
struct _GimpBuffer
{
- GimpViewable parent_instance;
+ GimpViewable parent_instance;
- TileManager *tiles;
- gint offset_x;
- gint offset_y;
+ GeglBuffer *buffer;
+ GimpImageType image_type;
+ gint offset_x;
+ gint offset_y;
};
struct _GimpBufferClass
@@ -49,8 +50,9 @@ struct _GimpBufferClass
GType gimp_buffer_get_type (void) G_GNUC_CONST;
-GimpBuffer * gimp_buffer_new (TileManager *tiles,
+GimpBuffer * gimp_buffer_new (GeglBuffer *buffer,
const gchar *name,
+ GimpImageType image_type,
gint offset_x,
gint offset_y,
gboolean copy_pixels);
@@ -64,7 +66,7 @@ gint gimp_buffer_get_height (const GimpBuffer *buffer);
gint gimp_buffer_get_bytes (const GimpBuffer *buffer);
GimpImageType gimp_buffer_get_image_type (const GimpBuffer *buffer);
-TileManager * gimp_buffer_get_tiles (const GimpBuffer *buffer);
+GeglBuffer * gimp_buffer_get_buffer (const GimpBuffer *buffer);
#endif /* __GIMP_BUFFER_H__ */
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index 2a83816..48fd5ec 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -276,16 +276,7 @@ gimp_image_new_from_buffer (Gimp *gimp,
g_return_val_if_fail (invoke == NULL || GIMP_IS_IMAGE (invoke), NULL);
g_return_val_if_fail (GIMP_IS_BUFFER (paste), NULL);
- switch (tile_manager_bpp (paste->tiles))
- {
- case 1: type = GIMP_GRAY_IMAGE; break;
- case 2: type = GIMP_GRAYA_IMAGE; break;
- case 3: type = GIMP_RGB_IMAGE; break;
- case 4: type = GIMP_RGBA_IMAGE; break;
- default:
- g_return_val_if_reached (NULL);
- break;
- }
+ type = gimp_buffer_get_image_type (paste);
/* create a new image (always of type GIMP_RGB) */
image = gimp_create_image (gimp,
@@ -305,9 +296,10 @@ gimp_image_new_from_buffer (Gimp *gimp,
gimp_image_set_unit (image, gimp_image_get_unit (invoke));
}
- layer = gimp_layer_new_from_tiles (paste->tiles, image, type,
- _("Pasted Layer"),
- GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+ layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (paste),
+ image, type,
+ _("Pasted Layer"),
+ GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
gimp_image_add_layer (image, layer, NULL, 0, TRUE);
diff --git a/app/core/gimppatternclipboard.c b/app/core/gimppatternclipboard.c
index 990a50d..b9e4620 100644
--- a/app/core/gimppatternclipboard.c
+++ b/app/core/gimppatternclipboard.c
@@ -25,9 +25,8 @@
#include "core-types.h"
#include "base/temp-buf.h"
-#include "base/pixel-region.h"
-#include "paint-funcs/paint-funcs.h"
+#include "gegl/gimp-gegl-utils.h"
#include "gimp.h"
#include "gimpbuffer.h"
@@ -189,25 +188,25 @@ gimp_pattern_clipboard_buffer_changed (Gimp *gimp,
if (gimp->global_buffer)
{
- gint width;
- gint height;
- gint bytes;
- PixelRegion bufferPR;
- PixelRegion maskPR;
+ GimpBuffer *buffer = gimp->global_buffer;
+ GeglRectangle rect = { 0, };
+ gint width;
+ gint height;
+ gint bytes;
- width = MIN (gimp_buffer_get_width (gimp->global_buffer), 512);
- height = MIN (gimp_buffer_get_height (gimp->global_buffer), 512);
- bytes = gimp_buffer_get_bytes (gimp->global_buffer);
+ width = MIN (gimp_buffer_get_width (buffer), 512);
+ height = MIN (gimp_buffer_get_height (buffer), 512);
+ bytes = gimp_buffer_get_bytes (buffer);
- pattern->mask = temp_buf_new (width, height, bytes, 0, 0, NULL);
+ rect.width = width;
+ rect.height = height;
- pixel_region_init (&bufferPR,
- gimp_buffer_get_tiles (gimp->global_buffer),
- 0, 0, width, height, FALSE);
- pixel_region_init_temp_buf (&maskPR, pattern->mask,
- 0, 0, width, height);
+ pattern->mask = temp_buf_new (width, height, bytes, 0, 0, NULL);
- copy_region (&bufferPR, &maskPR);
+ gegl_buffer_get (gimp_buffer_get_buffer (buffer), 1.0, &rect,
+ gimp_bpp_to_babl_format (bytes, TRUE),
+ temp_buf_get_data (pattern->mask),
+ width * gimp_buffer_get_bytes (buffer));
}
else
{
diff --git a/app/widgets/gimpclipboard.c b/app/widgets/gimpclipboard.c
index 9367c74..5c5af23 100644
--- a/app/widgets/gimpclipboard.c
+++ b/app/widgets/gimpclipboard.c
@@ -19,6 +19,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "widgets-types.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]