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
gimp_drawable_foreground_extract
gimp_drawable_free_shadow
gimp_drawable_get
gimp_drawable_get_buffer
gimp_drawable_get_shadow_buffer
gimp_drawable_get_color_uchar
gimp_drawable_get_image
gimp_drawable_get_linked
......
......@@ -25,6 +25,7 @@
#include "gimptilebackendplugin.h"
#define TILE_WIDTH gimp_tile_width()
#define TILE_HEIGHT gimp_tile_height()
......@@ -647,30 +648,76 @@ gimp_drawable_attach_new_parasite (gint32 drawable_ID,
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 *
gimp_drawable_get_buffer (gint32 drawable_ID)
{
GeglBuffer *buffer;
GimpDrawable *drawable;
GeglTileBackend *backend;
drawable = gimp_drawable_get (drawable_ID);
backend = gimp_tile_backend_plugin_new (drawable, FALSE);
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 *
gimp_drawable_get_shadow_buffer (gint32 drawable_ID)
{
GeglBuffer *buffer;
GimpDrawable *drawable;
GeglTileBackend *backend;
drawable = gimp_drawable_get (drawable_ID);
backend = gimp_tile_backend_plugin_new (drawable, TRUE);
if (drawable)
{
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
GeglBuffer * gimp_drawable_get_buffer (gint32 drawable_ID);
GeglBuffer * gimp_drawable_get_shadow_buffer (gint32 drawable_ID);
GimpDrawable * gimp_drawable_get (gint32 drawable_ID);
void gimp_drawable_detach (GimpDrawable *drawable);
void gimp_drawable_flush (GimpDrawable *drawable);
......
......@@ -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)
{
gint32 image_ID = gimp_item_get_image (drawable_ID);
switch (gimp_drawable_type (drawable_ID))
{
case GIMP_RGB_IMAGE: return babl_format ("RGB u8");
......@@ -58,6 +57,7 @@ static const Babl *get_format (gint32 drawable_ID)
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
{
gint32 image_ID = gimp_item_get_image (drawable_ID);
const Babl *pala, *pal;
gint ncols;
guchar *cmap = gimp_image_get_colormap (image_ID, &ncols);
......@@ -90,14 +90,15 @@ static GeglTile * gimp_tile_read_mul (GimpTileBackendPlugin *backend_plugin,
gint x,
gint y);
G_DEFINE_TYPE (GimpTileBackendPlugin, gimp_tile_backend_plugin,
G_DEFINE_TYPE (GimpTileBackendPlugin, _gimp_tile_backend_plugin,
GEGL_TYPE_TILE_BACKEND)
#define parent_class gimp_tile_backend_plugin_parent_class
#define parent_class _gimp_tile_backend_plugin_parent_class
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);
......@@ -108,7 +109,7 @@ gimp_tile_backend_plugin_class_init (GimpTileBackendPluginClass *klass)
}
static void
gimp_tile_backend_plugin_init (GimpTileBackendPlugin *backend)
_gimp_tile_backend_plugin_init (GimpTileBackendPlugin *backend)
{
GeglTileSource *source = GEGL_TILE_SOURCE (backend);
......@@ -261,7 +262,7 @@ gimp_tile_write_mul (GimpTileBackendPlugin *backend_plugin,
}
GeglTileBackend *
gimp_tile_backend_plugin_new (GimpDrawable *drawable,
_gimp_tile_backend_plugin_new (GimpDrawable *drawable,
gint shadow)
{
const Babl *format;
......@@ -289,5 +290,6 @@ gimp_tile_backend_plugin_new (GimpDrawable *drawable,
priv->shadow = shadow;
gegl_tile_backend_set_extent (ret, &rect);
return ret;
}
......@@ -25,7 +25,7 @@
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_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))
......@@ -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))
typedef struct _GimpTileBackendPlugin GimpTileBackendPlugin;
typedef struct _GimpTileBackendPluginClass GimpTileBackendPluginClass;
typedef struct _GimpTileBackendPluginPrivate GimpTileBackendPluginPrivate;
......@@ -48,9 +49,9 @@ struct _GimpTileBackendPluginClass
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);
G_END_DECLS
......
......@@ -36,7 +36,6 @@ typedef struct _GimpParamDef GimpParamDef;
typedef struct _GimpParamRegion GimpParamRegion;
typedef union _GimpParamData GimpParamData;
typedef struct _GimpParam GimpParam;
typedef struct _GimpTileBackendPlugin GimpTileBackendPlugin;
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