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

libgimp: make GimpTileBackendPlugin properly private, and some cleanup

parent d1ced114
...@@ -176,6 +176,8 @@ EXPORTS ...@@ -176,6 +176,8 @@ EXPORTS
gimp_drawable_foreground_extract gimp_drawable_foreground_extract
gimp_drawable_free_shadow gimp_drawable_free_shadow
gimp_drawable_get gimp_drawable_get
gimp_drawable_get_buffer
gimp_drawable_get_shadow_buffer
gimp_drawable_get_color_uchar gimp_drawable_get_color_uchar
gimp_drawable_get_image gimp_drawable_get_image
gimp_drawable_get_linked gimp_drawable_get_linked
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "gimptilebackendplugin.h" #include "gimptilebackendplugin.h"
#define TILE_WIDTH gimp_tile_width() #define TILE_WIDTH gimp_tile_width()
#define TILE_HEIGHT gimp_tile_height() #define TILE_HEIGHT gimp_tile_height()
...@@ -647,30 +648,76 @@ gimp_drawable_attach_new_parasite (gint32 drawable_ID, ...@@ -647,30 +648,76 @@ gimp_drawable_attach_new_parasite (gint32 drawable_ID,
return success; return success;
} }
/**
* gimp_drawable_get_buffer:
* @drawable_ID: the ID of the #GimpDrawableto get the buffer for.
*
* Returns a #GeglBuffer of a specified drawable. The buffer can be used
* like any other GEGL buffer. Its data will we synced back with the core
* drawable when the buffer gets destroyed, or when gegl_buffer_flush()
* is called.
*
* Return value: The #GeglBuffer.
*
* See Also: gimp_drawable_get_shadow_buffer()
*
* Since: GIMP 2.10
*/
GeglBuffer * GeglBuffer *
gimp_drawable_get_buffer (gint32 drawable_ID) gimp_drawable_get_buffer (gint32 drawable_ID)
{ {
GeglBuffer *buffer; GimpDrawable *drawable;
GimpDrawable *drawable;
GeglTileBackend *backend;
drawable = gimp_drawable_get (drawable_ID); drawable = gimp_drawable_get (drawable_ID);
backend = gimp_tile_backend_plugin_new (drawable, FALSE);
buffer = gegl_buffer_new_for_backend (NULL, backend);
g_object_unref (backend);
return buffer;
}
if (drawable)
{
GeglTileBackend *backend;
GeglBuffer *buffer;
backend = _gimp_tile_backend_plugin_new (drawable, FALSE);
buffer = gegl_buffer_new_for_backend (NULL, backend);
g_object_unref (backend);
return buffer;
}
return NULL;
}
/**
* gimp_drawable_get_shadow_buffer:
* @drawable_ID: the ID of the #GimpDrawableto get the buffer for.
*
* Returns a #GeglBuffer of a specified drawable's shadow tiles. The
* buffer can be used like any other GEGL buffer. Its data will we
* synced back with the core drawable's shadow tiles when the buffer
* gets destroyed, or when gegl_buffer_flush() is called.
*
* Return value: The #GeglBuffer.
*
* See Also: gimp_drawable_get_shadow_buffer()
*
* Since: GIMP 2.10
*/
GeglBuffer * GeglBuffer *
gimp_drawable_get_shadow_buffer (gint32 drawable_ID) gimp_drawable_get_shadow_buffer (gint32 drawable_ID)
{ {
GeglBuffer *buffer; GimpDrawable *drawable;
GimpDrawable *drawable;
GeglTileBackend *backend;
drawable = gimp_drawable_get (drawable_ID); drawable = gimp_drawable_get (drawable_ID);
backend = gimp_tile_backend_plugin_new (drawable, TRUE);
buffer = gegl_buffer_new_for_backend (NULL, backend); if (drawable)
g_object_unref (backend); {
return buffer; GeglTileBackend *backend;
GeglBuffer *buffer;
backend = _gimp_tile_backend_plugin_new (drawable, TRUE);
buffer = gegl_buffer_new_for_backend (NULL, backend);
g_object_unref (backend);
return buffer;
}
return NULL;
} }
...@@ -45,7 +45,6 @@ struct _GimpDrawable ...@@ -45,7 +45,6 @@ struct _GimpDrawable
GeglBuffer * gimp_drawable_get_buffer (gint32 drawable_ID); GeglBuffer * gimp_drawable_get_buffer (gint32 drawable_ID);
GeglBuffer * gimp_drawable_get_shadow_buffer (gint32 drawable_ID); GeglBuffer * gimp_drawable_get_shadow_buffer (gint32 drawable_ID);
GimpDrawable * gimp_drawable_get (gint32 drawable_ID); GimpDrawable * gimp_drawable_get (gint32 drawable_ID);
void gimp_drawable_detach (GimpDrawable *drawable); void gimp_drawable_detach (GimpDrawable *drawable);
void gimp_drawable_flush (GimpDrawable *drawable); void gimp_drawable_flush (GimpDrawable *drawable);
......
...@@ -48,7 +48,6 @@ static int gimp_gegl_tile_mul (void) ...@@ -48,7 +48,6 @@ static int gimp_gegl_tile_mul (void)
static const Babl *get_format (gint32 drawable_ID); static const Babl *get_format (gint32 drawable_ID);
static const Babl *get_format (gint32 drawable_ID) static const Babl *get_format (gint32 drawable_ID)
{ {
gint32 image_ID = gimp_item_get_image (drawable_ID);
switch (gimp_drawable_type (drawable_ID)) switch (gimp_drawable_type (drawable_ID))
{ {
case GIMP_RGB_IMAGE: return babl_format ("RGB u8"); case GIMP_RGB_IMAGE: return babl_format ("RGB u8");
...@@ -58,6 +57,7 @@ static const Babl *get_format (gint32 drawable_ID) ...@@ -58,6 +57,7 @@ static const Babl *get_format (gint32 drawable_ID)
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE: case GIMP_INDEXEDA_IMAGE:
{ {
gint32 image_ID = gimp_item_get_image (drawable_ID);
const Babl *pala, *pal; const Babl *pala, *pal;
gint ncols; gint ncols;
guchar *cmap = gimp_image_get_colormap (image_ID, &ncols); guchar *cmap = gimp_image_get_colormap (image_ID, &ncols);
...@@ -82,22 +82,23 @@ static gpointer gimp_tile_backend_plugin_command (GeglTileSource *tile_store, ...@@ -82,22 +82,23 @@ static gpointer gimp_tile_backend_plugin_command (GeglTileSource *tile_store,
gpointer data); gpointer data);
static void gimp_tile_write_mul (GimpTileBackendPlugin *backend_plugin, static void gimp_tile_write_mul (GimpTileBackendPlugin *backend_plugin,
gint x, gint x,
gint y, gint y,
guchar *source); guchar *source);
static GeglTile * gimp_tile_read_mul (GimpTileBackendPlugin *backend_plugin, static GeglTile * gimp_tile_read_mul (GimpTileBackendPlugin *backend_plugin,
gint x, gint x,
gint y); gint y);
G_DEFINE_TYPE (GimpTileBackendPlugin, gimp_tile_backend_plugin,
G_DEFINE_TYPE (GimpTileBackendPlugin, _gimp_tile_backend_plugin,
GEGL_TYPE_TILE_BACKEND) GEGL_TYPE_TILE_BACKEND)
#define parent_class gimp_tile_backend_plugin_parent_class #define parent_class _gimp_tile_backend_plugin_parent_class
static void static void
gimp_tile_backend_plugin_class_init (GimpTileBackendPluginClass *klass) _gimp_tile_backend_plugin_class_init (GimpTileBackendPluginClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
...@@ -108,7 +109,7 @@ gimp_tile_backend_plugin_class_init (GimpTileBackendPluginClass *klass) ...@@ -108,7 +109,7 @@ gimp_tile_backend_plugin_class_init (GimpTileBackendPluginClass *klass)
} }
static void static void
gimp_tile_backend_plugin_init (GimpTileBackendPlugin *backend) _gimp_tile_backend_plugin_init (GimpTileBackendPlugin *backend)
{ {
GeglTileSource *source = GEGL_TILE_SOURCE (backend); GeglTileSource *source = GEGL_TILE_SOURCE (backend);
...@@ -125,18 +126,18 @@ gimp_tile_backend_plugin_finalize (GObject *object) ...@@ -125,18 +126,18 @@ gimp_tile_backend_plugin_finalize (GObject *object)
GimpTileBackendPlugin *backend = GIMP_TILE_BACKEND_PLUGIN (object); GimpTileBackendPlugin *backend = GIMP_TILE_BACKEND_PLUGIN (object);
if (backend->priv->drawable) /* This also causes a flush */ if (backend->priv->drawable) /* This also causes a flush */
gimp_drawable_detach (backend->priv->drawable); gimp_drawable_detach (backend->priv->drawable);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static gpointer static gpointer
gimp_tile_backend_plugin_command (GeglTileSource *tile_store, gimp_tile_backend_plugin_command (GeglTileSource *tile_store,
GeglTileCommand command, GeglTileCommand command,
gint x, gint x,
gint y, gint y,
gint z, gint z,
gpointer data) gpointer data)
{ {
GimpTileBackendPlugin *backend_plugin; GimpTileBackendPlugin *backend_plugin;
...@@ -159,8 +160,8 @@ gimp_tile_backend_plugin_command (GeglTileSource *tile_store, ...@@ -159,8 +160,8 @@ gimp_tile_backend_plugin_command (GeglTileSource *tile_store,
static GeglTile * static GeglTile *
gimp_tile_read_mul (GimpTileBackendPlugin *backend_plugin, gimp_tile_read_mul (GimpTileBackendPlugin *backend_plugin,
gint x, gint x,
gint y) gint y)
{ {
GimpTileBackendPluginPrivate *priv = backend_plugin->priv; GimpTileBackendPluginPrivate *priv = backend_plugin->priv;
GeglTileBackend *backend; GeglTileBackend *backend;
...@@ -186,7 +187,7 @@ gimp_tile_read_mul (GimpTileBackendPlugin *backend_plugin, ...@@ -186,7 +187,7 @@ gimp_tile_read_mul (GimpTileBackendPlugin *backend_plugin,
if (x + u >= priv->drawable->ntile_cols || if (x + u >= priv->drawable->ntile_cols ||
y + v >= priv->drawable->ntile_rows) y + v >= priv->drawable->ntile_rows)
continue; continue;
gimp_tile = gimp_drawable_get_tile (priv->drawable, gimp_tile = gimp_drawable_get_tile (priv->drawable,
priv->shadow, priv->shadow,
y+v, x+u); y+v, x+u);
...@@ -261,8 +262,8 @@ gimp_tile_write_mul (GimpTileBackendPlugin *backend_plugin, ...@@ -261,8 +262,8 @@ gimp_tile_write_mul (GimpTileBackendPlugin *backend_plugin,
} }
GeglTileBackend * GeglTileBackend *
gimp_tile_backend_plugin_new (GimpDrawable *drawable, _gimp_tile_backend_plugin_new (GimpDrawable *drawable,
gint shadow) gint shadow)
{ {
const Babl *format; const Babl *format;
GeglTileBackend *ret; GeglTileBackend *ret;
...@@ -289,5 +290,6 @@ gimp_tile_backend_plugin_new (GimpDrawable *drawable, ...@@ -289,5 +290,6 @@ gimp_tile_backend_plugin_new (GimpDrawable *drawable,
priv->shadow = shadow; priv->shadow = shadow;
gegl_tile_backend_set_extent (ret, &rect); gegl_tile_backend_set_extent (ret, &rect);
return ret; return ret;
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_TILE_BACKEND_PLUGIN (gimp_tile_backend_plugin_get_type ()) #define GIMP_TYPE_TILE_BACKEND_PLUGIN (_gimp_tile_backend_plugin_get_type ())
#define GIMP_TILE_BACKEND_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TILE_BACKEND_PLUGIN, GimpTileBackendPlugin)) #define GIMP_TILE_BACKEND_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TILE_BACKEND_PLUGIN, GimpTileBackendPlugin))
#define GIMP_TILE_BACKEND_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TILE_BACKEND_PLUGIN, GimpTileBackendPluginClass)) #define GIMP_TILE_BACKEND_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TILE_BACKEND_PLUGIN, GimpTileBackendPluginClass))
#define GIMP_IS_TILE_BACKEND_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TILE_BACKEND_PLUGIN)) #define GIMP_IS_TILE_BACKEND_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TILE_BACKEND_PLUGIN))
...@@ -33,6 +33,7 @@ G_BEGIN_DECLS ...@@ -33,6 +33,7 @@ G_BEGIN_DECLS
#define GIMP_TILE_BACKEND_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TILE_BACKEND_PLUGIN, GimpTileBackendPluginClass)) #define GIMP_TILE_BACKEND_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TILE_BACKEND_PLUGIN, GimpTileBackendPluginClass))
typedef struct _GimpTileBackendPlugin GimpTileBackendPlugin;
typedef struct _GimpTileBackendPluginClass GimpTileBackendPluginClass; typedef struct _GimpTileBackendPluginClass GimpTileBackendPluginClass;
typedef struct _GimpTileBackendPluginPrivate GimpTileBackendPluginPrivate; typedef struct _GimpTileBackendPluginPrivate GimpTileBackendPluginPrivate;
...@@ -48,10 +49,10 @@ struct _GimpTileBackendPluginClass ...@@ -48,10 +49,10 @@ struct _GimpTileBackendPluginClass
GeglTileBackendClass parent_class; GeglTileBackendClass parent_class;
}; };
GType gimp_tile_backend_plugin_get_type (void) G_GNUC_CONST; GType _gimp_tile_backend_plugin_get_type (void) G_GNUC_CONST;
GeglTileBackend * gimp_tile_backend_plugin_new (GimpDrawable *drawable, GeglTileBackend * _gimp_tile_backend_plugin_new (GimpDrawable *drawable,
gint shadow); gint shadow);
G_END_DECLS G_END_DECLS
......
...@@ -28,15 +28,14 @@ G_BEGIN_DECLS ...@@ -28,15 +28,14 @@ G_BEGIN_DECLS
/* For information look into the html documentation */ /* For information look into the html documentation */
typedef struct _GimpPlugInInfo GimpPlugInInfo; typedef struct _GimpPlugInInfo GimpPlugInInfo;
typedef struct _GimpTile GimpTile; typedef struct _GimpTile GimpTile;
typedef struct _GimpDrawable GimpDrawable; typedef struct _GimpDrawable GimpDrawable;
typedef struct _GimpPixelRgn GimpPixelRgn; typedef struct _GimpPixelRgn GimpPixelRgn;
typedef struct _GimpParamDef GimpParamDef; typedef struct _GimpParamDef GimpParamDef;
typedef struct _GimpParamRegion GimpParamRegion; typedef struct _GimpParamRegion GimpParamRegion;
typedef union _GimpParamData GimpParamData; typedef union _GimpParamData GimpParamData;
typedef struct _GimpParam GimpParam; typedef struct _GimpParam GimpParam;
typedef struct _GimpTileBackendPlugin GimpTileBackendPlugin;
G_END_DECLS G_END_DECLS
......
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