Commit 525a4052 authored by Michael Natterer's avatar Michael Natterer 😴

app: port the entire transform API from TileManager to GeglBuffer

parent 7b88ab6a
This diff is collapsed.
......@@ -19,10 +19,9 @@
#define __GIMP_DRAWABLE_TRANSFORM_H__
TileManager * gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
GeglBuffer * gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
GimpContext *context,
TileManager *orig_tiles,
const Babl *orig_format,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
const GimpMatrix3 *matrix,
......@@ -33,10 +32,9 @@ TileManager * gimp_drawable_transform_tiles_affine (GimpDrawable *dra
gint *new_offset_x,
gint *new_offset_y,
GimpProgress *progress);
TileManager * gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
GeglBuffer * gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
GimpContext *context,
TileManager *orig_tiles,
const Babl *orig_format,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpOrientationType flip_type,
......@@ -45,10 +43,9 @@ TileManager * gimp_drawable_transform_tiles_flip (GimpDrawable *dra
gint *new_offset_x,
gint *new_offset_y);
TileManager * gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
GeglBuffer * gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
GimpContext *context,
TileManager *orig_tiles,
const Babl *orig_format,
GeglBuffer *buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpRotationType rotate_type,
......@@ -80,15 +77,13 @@ GimpDrawable * gimp_drawable_transform_rotate (GimpDrawable *dra
gdouble center_y,
gboolean clip_result);
TileManager * gimp_drawable_transform_cut (GimpDrawable *drawable,
GeglBuffer * gimp_drawable_transform_cut (GimpDrawable *drawable,
GimpContext *context,
const Babl **format,
gint *offset_x,
gint *offset_y,
gboolean *new_layer);
GimpDrawable * gimp_drawable_transform_paste (GimpDrawable *drawable,
TileManager *tiles,
const Babl *format,
GeglBuffer *buffer,
gint offset_x,
gint offset_y,
gboolean new_layer);
......
......@@ -621,26 +621,24 @@ gimp_drawable_flip (GimpItem *item,
gboolean clip_result)
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
TileManager *tiles;
GeglBuffer *buffer;
gint off_x, off_y;
gint new_off_x, new_off_y;
gimp_item_get_offset (item, &off_x, &off_y);
tiles = gimp_drawable_transform_tiles_flip (drawable, context,
gimp_drawable_get_tiles (drawable),
gimp_drawable_get_format (drawable),
off_x, off_y,
flip_type, axis,
clip_result,
&new_off_x, &new_off_y);
buffer = gimp_drawable_transform_buffer_flip (drawable, context,
gimp_drawable_get_buffer (drawable),
off_x, off_y,
flip_type, axis,
clip_result,
&new_off_x, &new_off_y);
if (tiles)
if (buffer)
{
gimp_drawable_transform_paste (drawable, tiles,
gimp_drawable_get_format (drawable),
gimp_drawable_transform_paste (drawable, buffer,
new_off_x, new_off_y, FALSE);
tile_manager_unref (tiles);
g_object_unref (buffer);
}
}
......@@ -653,26 +651,24 @@ gimp_drawable_rotate (GimpItem *item,
gboolean clip_result)
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
TileManager *tiles;
GeglBuffer *buffer;
gint off_x, off_y;
gint new_off_x, new_off_y;
gimp_item_get_offset (item, &off_x, &off_y);
tiles = gimp_drawable_transform_tiles_rotate (drawable, context,
gimp_drawable_get_tiles (drawable),
gimp_drawable_get_format (drawable),
off_x, off_y,
rotate_type, center_x, center_y,
clip_result,
&new_off_x, &new_off_y);
buffer = gimp_drawable_transform_buffer_rotate (drawable, context,
gimp_drawable_get_buffer (drawable),
off_x, off_y,
rotate_type, center_x, center_y,
clip_result,
&new_off_x, &new_off_y);
if (tiles)
if (buffer)
{
gimp_drawable_transform_paste (drawable, tiles,
gimp_drawable_get_format (drawable),
gimp_drawable_transform_paste (drawable, buffer,
new_off_x, new_off_y, FALSE);
tile_manager_unref (tiles);
g_object_unref (buffer);
}
}
......@@ -687,29 +683,27 @@ gimp_drawable_transform (GimpItem *item,
GimpProgress *progress)
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
TileManager *tiles;
GeglBuffer *buffer;
gint off_x, off_y;
gint new_off_x, new_off_y;
gimp_item_get_offset (item, &off_x, &off_y);
tiles = gimp_drawable_transform_tiles_affine (drawable, context,
gimp_drawable_get_tiles (drawable),
gimp_drawable_get_format (drawable),
off_x, off_y,
matrix, direction,
interpolation_type,
recursion_level,
clip_result,
&new_off_x, &new_off_y,
progress);
if (tiles)
buffer = gimp_drawable_transform_buffer_affine (drawable, context,
gimp_drawable_get_buffer (drawable),
off_x, off_y,
matrix, direction,
interpolation_type,
recursion_level,
clip_result,
&new_off_x, &new_off_y,
progress);
if (buffer)
{
gimp_drawable_transform_paste (drawable, tiles,
gimp_drawable_get_format (drawable),
gimp_drawable_transform_paste (drawable, buffer,
new_off_x, new_off_y, FALSE);
tile_manager_unref (tiles);
g_object_unref (buffer);
}
}
......
......@@ -47,25 +47,24 @@
/* local function prototypes */
static void gimp_flip_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_flip_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static gchar * gimp_flip_tool_get_undo_desc (GimpTransformTool *tool);
static TileManager * gimp_flip_tool_transform (GimpTransformTool *tool,
GimpItem *item,
TileManager *orig_tiles,
const Babl *orig_format,
gint orig_offset_x,
gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y);
static void gimp_flip_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_flip_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static gchar * gimp_flip_tool_get_undo_desc (GimpTransformTool *tool);
static GeglBuffer * gimp_flip_tool_transform (GimpTransformTool *tool,
GimpItem *item,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y);
G_DEFINE_TYPE (GimpFlipTool, gimp_flip_tool, GIMP_TYPE_TRANSFORM_TOOL)
......@@ -198,11 +197,10 @@ gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool)
}
}
static TileManager *
static GeglBuffer *
gimp_flip_tool_transform (GimpTransformTool *trans_tool,
GimpItem *active_item,
TileManager *orig_tiles,
const Babl *orig_format,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
gint *new_offset_x,
......@@ -211,7 +209,7 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (trans_tool);
GimpContext *context = GIMP_CONTEXT (options);
gdouble axis = 0.0;
TileManager *ret = NULL;
GeglBuffer *ret = NULL;
switch (options->flip_type)
{
......@@ -233,22 +231,21 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
gimp_item_linked_flip (active_item, context, options->flip_type, axis,
FALSE);
if (orig_tiles)
if (orig_buffer)
{
/* this happens when transforming a selection cut out of a
* normal drawable, or the selection
*/
ret = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (active_item),
context,
orig_tiles,
orig_format,
orig_offset_x,
orig_offset_y,
options->flip_type, axis,
FALSE,
new_offset_x,
new_offset_y);
ret = gimp_drawable_transform_buffer_flip (GIMP_DRAWABLE (active_item),
context,
orig_buffer,
orig_offset_x,
orig_offset_y,
options->flip_type, axis,
FALSE,
new_offset_x,
new_offset_y);
}
else
{
......
......@@ -29,8 +29,6 @@
#include "tools-types.h"
#include "base/tile-manager.h"
#include "core/gimp.h"
#include "core/gimpboundary.h"
#include "core/gimpcontext.h"
......@@ -122,11 +120,10 @@ static void gimp_transform_tool_draw (GimpDrawTool
static void gimp_transform_tool_dialog_update (GimpTransformTool *tr_tool);
static TileManager *
static GeglBuffer *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *item,
TileManager *orig_tiles,
const Babl *orig_format,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
gint *new_offset_x,
......@@ -960,11 +957,10 @@ gimp_transform_tool_dialog_update (GimpTransformTool *tr_tool)
}
}
static TileManager *
static GeglBuffer *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *active_item,
TileManager *orig_tiles,
const Babl *orig_format,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
gint *new_offset_x,
......@@ -973,9 +969,9 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpTool *tool = GIMP_TOOL (tr_tool);
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
GimpContext *context = GIMP_CONTEXT (options);
GimpProgress *progress;
TileManager *ret = NULL;
GeglBuffer *ret = NULL;
GimpTransformResize clip = options->clip;
GimpProgress *progress;
progress = gimp_progress_start (GIMP_PROGRESS (tool),
tr_tool->progress_text, FALSE);
......@@ -989,7 +985,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
clip,
progress);
if (orig_tiles)
if (orig_buffer)
{
/* this happens when transforming a selection cut out of a
* normal drawable, or the selection
......@@ -999,23 +995,22 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
* so they keep their size
*/
if (GIMP_IS_CHANNEL (active_item) &&
tile_manager_bpp (orig_tiles) == 1)
gegl_buffer_get_format (orig_buffer) == babl_format ("Y u8"))
clip = GIMP_TRANSFORM_RESIZE_CLIP;
ret = gimp_drawable_transform_tiles_affine (GIMP_DRAWABLE (active_item),
context,
orig_tiles,
orig_format,
orig_offset_x,
orig_offset_y,
&tr_tool->transform,
options->direction,
options->interpolation,
options->recursion_level,
clip,
new_offset_x,
new_offset_y,
progress);
ret = gimp_drawable_transform_buffer_affine (GIMP_DRAWABLE (active_item),
context,
orig_buffer,
orig_offset_x,
orig_offset_y,
&tr_tool->transform,
options->direction,
options->interpolation,
options->recursion_level,
clip,
new_offset_x,
new_offset_y,
progress);
}
else
{
......@@ -1050,11 +1045,10 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
GimpContext *context = GIMP_CONTEXT (options);
GimpImage *image = gimp_display_get_image (display);
GimpItem *active_item = NULL;
TileManager *orig_tiles = NULL;
const Babl *orig_format = NULL;
GeglBuffer *orig_buffer = NULL;
gint orig_offset_x;
gint orig_offset_y;
TileManager *new_tiles;
GeglBuffer *new_buffer;
gint new_offset_x;
gint new_offset_y;
const gchar *null_message = NULL;
......@@ -1119,17 +1113,16 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
if (! gimp_viewable_get_children (GIMP_VIEWABLE (tool->drawable)) &&
! gimp_channel_is_empty (gimp_image_get_mask (image)))
{
orig_tiles = gimp_drawable_transform_cut (tool->drawable,
context,
&orig_format,
&orig_offset_x,
&orig_offset_y,
&new_layer);
orig_buffer = gimp_drawable_transform_cut (tool->drawable,
context,
&orig_offset_x,
&orig_offset_y,
&new_layer);
}
break;
case GIMP_TRANSFORM_TYPE_SELECTION:
orig_tiles = tile_manager_ref (gimp_drawable_get_tiles (GIMP_DRAWABLE (active_item)));
orig_buffer = g_object_ref (gimp_drawable_get_buffer (GIMP_DRAWABLE (active_item)));
orig_offset_x = 0;
orig_offset_y = 0;
break;
......@@ -1140,43 +1133,41 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
/* Send the request for the transformation to the tool...
*/
new_tiles = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->transform (tr_tool,
active_item,
orig_tiles,
orig_format,
orig_offset_x,
orig_offset_y,
&new_offset_x,
&new_offset_y);
if (orig_tiles)
tile_manager_unref (orig_tiles);
new_buffer = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->transform (tr_tool,
active_item,
orig_buffer,
orig_offset_x,
orig_offset_y,
&new_offset_x,
&new_offset_y);
if (orig_buffer)
g_object_unref (orig_buffer);
switch (options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
if (new_tiles)
if (new_buffer)
{
/* paste the new transformed image to the image...also implement
* undo...
*/
gimp_drawable_transform_paste (tool->drawable,
new_tiles, orig_format,
gimp_drawable_transform_paste (tool->drawable, new_buffer,
new_offset_x, new_offset_y,
new_layer);
tile_manager_unref (new_tiles);
g_object_unref (new_buffer);
}
break;
case GIMP_TRANSFORM_TYPE_SELECTION:
if (new_tiles)
if (new_buffer)
{
gimp_channel_push_undo (GIMP_CHANNEL (active_item), NULL);
gimp_drawable_set_tiles (GIMP_DRAWABLE (active_item),
FALSE, NULL, new_tiles,
gimp_drawable_type (GIMP_DRAWABLE (active_item)));
tile_manager_unref (new_tiles);
gimp_drawable_set_buffer (GIMP_DRAWABLE (active_item),
FALSE, NULL, new_buffer,
gimp_drawable_type (GIMP_DRAWABLE (active_item)));
g_object_unref (new_buffer);
}
break;
......
......@@ -99,20 +99,19 @@ struct _GimpTransformToolClass
GimpDrawToolClass parent_class;
/* virtual functions */
void (* dialog) (GimpTransformTool *tool);
void (* dialog_update) (GimpTransformTool *tool);
void (* prepare) (GimpTransformTool *tool);
void (* motion) (GimpTransformTool *tool);
void (* recalc_matrix) (GimpTransformTool *tool);
gchar * (* get_undo_desc) (GimpTransformTool *tool);
TileManager * (* transform) (GimpTransformTool *tool,
GimpItem *item,
TileManager *orig_tiles,
const Babl *orig_format,
gint orig_offset_x,
gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y);
void (* dialog) (GimpTransformTool *tool);
void (* dialog_update) (GimpTransformTool *tool);
void (* prepare) (GimpTransformTool *tool);
void (* motion) (GimpTransformTool *tool);
void (* recalc_matrix) (GimpTransformTool *tool);
gchar * (* get_undo_desc) (GimpTransformTool *tool);
GeglBuffer * (* transform) (GimpTransformTool *tool,
GimpItem *item,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
gint *new_offset_x,
gint *new_offset_y);
};
......
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