app: move new get_buffer() functions around; some general cleanup

This commit is contained in:
Michael Natterer
2012-03-13 19:37:06 +01:00
parent 751eba9d23
commit 3bd8ee1a63
8 changed files with 45 additions and 37 deletions

View File

@ -28,8 +28,7 @@
#include "base/tile-manager.h" #include "base/tile-manager.h"
#include "gegl/gimptilebackendtilemanager.h" #include "gegl/gimp-gegl-utils.h"
#include "gimpdrawable.h" #include "gimpdrawable.h"
#include "gimpdrawable-operation.h" #include "gimpdrawable-operation.h"
@ -148,8 +147,9 @@ gimp_drawable_apply_operation_private (GimpDrawable *drawable,
"dont-cache", TRUE, "dont-cache", TRUE,
NULL); NULL);
inbuf = gimp_drawable_get_gegl_buffer (drawable, FALSE); inbuf = gimp_drawable_get_buffer (drawable, FALSE);
outbuf = gimp_tile_manager_get_gegl_buffer (dest_tiles, TRUE); outbuf = gimp_tile_manager_get_gegl_buffer (dest_tiles, TRUE);
input = gegl_node_new_child (gegl, input = gegl_node_new_child (gegl,
"operation", "buffer-source", "operation", "buffer-source",
"buffer", inbuf, "buffer", inbuf,

View File

@ -1456,6 +1456,16 @@ gimp_drawable_init_src_region (GimpDrawable *drawable,
*temp_tiles = NULL; *temp_tiles = NULL;
} }
GeglBuffer *
gimp_drawable_get_buffer (GimpDrawable *drawable,
gboolean write)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
return gimp_tile_manager_get_gegl_buffer (gimp_drawable_get_tiles (drawable),
write);
}
TileManager * TileManager *
gimp_drawable_get_tiles (GimpDrawable *drawable) gimp_drawable_get_tiles (GimpDrawable *drawable)
{ {

View File

@ -178,6 +178,8 @@ void gimp_drawable_init_src_region (GimpDrawable *drawable,
gint height, gint height,
TileManager **temp_tiles); TileManager **temp_tiles);
GeglBuffer * gimp_drawable_get_buffer (GimpDrawable *drawable,
gboolean write);
TileManager * gimp_drawable_get_tiles (GimpDrawable *drawable); TileManager * gimp_drawable_get_tiles (GimpDrawable *drawable);
void gimp_drawable_set_tiles (GimpDrawable *drawable, void gimp_drawable_set_tiles (GimpDrawable *drawable,
gboolean push_undo, gboolean push_undo,

View File

@ -44,7 +44,7 @@
#include "paint-funcs/paint-funcs.h" #include "paint-funcs/paint-funcs.h"
#include "gegl/gimptilebackendtilemanager.h" #include "gegl/gimp-gegl-utils.h"
#include "gimpdrawable.h" #include "gimpdrawable.h"
#include "gimpdrawable-shadow.h" #include "gimpdrawable-shadow.h"
@ -803,12 +803,13 @@ gimp_image_map_data_written (GObject *operation,
const GeglRectangle *extent, const GeglRectangle *extent,
GimpImageMap *image_map) GimpImageMap *image_map)
{ {
PixelRegion srcPR; GimpImage *image;
PixelRegion destPR; PixelRegion srcPR;
PixelRegion destPR;
if (!gimp_channel_is_empty ( image = gimp_item_get_image (GIMP_ITEM (image_map->drawable));
gimp_image_get_mask (
gimp_item_get_image (GIMP_ITEM (image_map->drawable))))) if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
{ {
/* Reset to initial drawable conditions. */ /* Reset to initial drawable conditions. */
pixel_region_init (&srcPR, image_map->undo_tiles, pixel_region_init (&srcPR, image_map->undo_tiles,

View File

@ -27,6 +27,7 @@
#include "base/tile-manager.h" #include "base/tile-manager.h"
#include "gimp-gegl-utils.h" #include "gimp-gegl-utils.h"
#include "gimptilebackendtilemanager.h"
/** /**
@ -168,3 +169,17 @@ gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation)
return "nearest"; return "nearest";
} }
GeglBuffer *
gimp_tile_manager_get_gegl_buffer (TileManager *tm,
gboolean write)
{
GeglTileBackend *backend;
GeglBuffer *buffer;
backend = gimp_tile_backend_tile_manager_new (tm, write);
buffer = gegl_buffer_new_for_backend (NULL, backend);
g_object_unref (backend);
return buffer;
}

View File

@ -30,5 +30,8 @@ TileManager * gimp_buffer_to_tiles (GeglBuffer *buffer);
const gchar * gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode) G_GNUC_CONST; const gchar * gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode) G_GNUC_CONST;
const gchar * gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation) G_GNUC_CONST; const gchar * gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation) G_GNUC_CONST;
GeglBuffer * gimp_tile_manager_get_gegl_buffer (TileManager *tm,
gboolean write);
#endif /* __GIMP_GEGL_UTILS_H__ */ #endif /* __GIMP_GEGL_UTILS_H__ */

View File

@ -258,25 +258,3 @@ gimp_tile_backend_tile_manager_new (TileManager *tm,
return ret; return ret;
} }
GeglBuffer *
gimp_tile_manager_get_gegl_buffer (TileManager *tm,
gboolean write)
{
GeglTileBackend *backend;
GeglBuffer *buffer;
backend = gimp_tile_backend_tile_manager_new (tm, write);
buffer = gegl_buffer_new_for_backend (NULL, backend);
g_object_unref (backend);
return buffer;
}
GeglBuffer *
gimp_drawable_get_gegl_buffer (GimpDrawable *drawable,
gboolean write)
{
return gimp_tile_manager_get_gegl_buffer (gimp_drawable_get_tiles (drawable), write);
}

View File

@ -25,6 +25,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GIMP_TYPE_TILE_BACKEND_TILE_MANAGER (gimp_tile_backend_tile_manager_get_type ()) #define GIMP_TYPE_TILE_BACKEND_TILE_MANAGER (gimp_tile_backend_tile_manager_get_type ())
#define GIMP_TILE_BACKEND_TILE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TILE_BACKEND_TILE_MANAGER, GimpTileBackendTileManager)) #define GIMP_TILE_BACKEND_TILE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TILE_BACKEND_TILE_MANAGER, GimpTileBackendTileManager))
#define GIMP_TILE_BACKEND_TILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TILE_BACKEND_TILE_MANAGER, GimpTileBackendTileManagerClass)) #define GIMP_TILE_BACKEND_TILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TILE_BACKEND_TILE_MANAGER, GimpTileBackendTileManagerClass))
@ -32,6 +33,7 @@ G_BEGIN_DECLS
#define GIMP_IS_TILE_BACKEND_TILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TILE_BACKEND_TILE_MANAGER)) #define GIMP_IS_TILE_BACKEND_TILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TILE_BACKEND_TILE_MANAGER))
#define GIMP_TILE_BACKEND_TILE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TILE_BACKEND_TILE_MANAGER, GimpTileBackendTileManagerClass)) #define GIMP_TILE_BACKEND_TILE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TILE_BACKEND_TILE_MANAGER, GimpTileBackendTileManagerClass))
typedef struct _GimpTileBackendTileManagerClass GimpTileBackendTileManagerClass; typedef struct _GimpTileBackendTileManagerClass GimpTileBackendTileManagerClass;
typedef struct _GimpTileBackendTileManagerPrivate GimpTileBackendTileManagerPrivate; typedef struct _GimpTileBackendTileManagerPrivate GimpTileBackendTileManagerPrivate;
@ -47,15 +49,12 @@ struct _GimpTileBackendTileManagerClass
GeglTileBackendClass parent_class; GeglTileBackendClass parent_class;
}; };
GType gimp_tile_backend_tile_manager_get_type (void) G_GNUC_CONST; GType gimp_tile_backend_tile_manager_get_type (void) G_GNUC_CONST;
GeglTileBackend * gimp_tile_backend_tile_manager_new (TileManager *tm, GeglTileBackend * gimp_tile_backend_tile_manager_new (TileManager *tm,
gboolean write); gboolean write);
GeglBuffer * gimp_tile_manager_get_gegl_buffer (TileManager *tm,
gboolean write);
GeglBuffer * gimp_drawable_get_gegl_buffer (GimpDrawable *drawable,
gboolean write);
G_END_DECLS G_END_DECLS