app: pass profiles around along with the buffers in the transform code

"transform" as in flip, rotate, affine. Same reasoning as in the
gimp_selection_float() commit below.
This commit is contained in:
Michael Natterer 2016-05-08 18:35:40 +02:00
parent 2739c34573
commit 8eb6cdf488
6 changed files with 95 additions and 58 deletions

View File

@ -74,6 +74,7 @@ gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
GimpTransformResize clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y,
GimpProgress *progress)
@ -130,6 +131,9 @@ gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
interpolation_type,
&gegl_matrix);
*buffer_profile =
gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (drawable));
*new_offset_x = x1;
*new_offset_y = y1;
@ -145,6 +149,7 @@ gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y)
{
@ -287,6 +292,9 @@ gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
break;
}
*buffer_profile =
gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (drawable));
return new_buffer;
}
@ -325,17 +333,18 @@ gimp_drawable_transform_rotate_point (gint x,
}
GeglBuffer *
gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
GimpContext *context,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y,
gboolean clip_result,
gint *new_offset_x,
gint *new_offset_y)
gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
GimpContext *context,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y,
gboolean clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y)
{
GeglBuffer *new_buffer;
GeglRectangle src_rect;
@ -604,6 +613,9 @@ gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
break;
}
*buffer_profile =
gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (drawable));
return new_buffer;
}
@ -643,9 +655,10 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
if (orig_buffer)
{
GeglBuffer *new_buffer;
gint new_offset_x;
gint new_offset_y;
GeglBuffer *new_buffer;
gint new_offset_x;
gint new_offset_y;
GimpColorProfile *profile;
/* always clip unfloated buffers so they keep their size */
if (GIMP_IS_CHANNEL (drawable) &&
@ -676,6 +689,7 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
direction,
interpolation_type,
clip_result,
&profile,
&new_offset_x,
&new_offset_y,
progress);
@ -685,7 +699,7 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
if (new_buffer)
{
result = gimp_drawable_transform_paste (drawable, new_buffer,
result = gimp_drawable_transform_paste (drawable, new_buffer, profile,
new_offset_x, new_offset_y,
new_layer);
g_object_unref (new_buffer);
@ -730,9 +744,10 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
if (orig_buffer)
{
GeglBuffer *new_buffer = NULL;
gint new_offset_x;
gint new_offset_y;
GeglBuffer *new_buffer;
gint new_offset_x;
gint new_offset_y;
GimpColorProfile *profile;
/* always clip unfloated buffers so they keep their size */
if (GIMP_IS_CHANNEL (drawable) &&
@ -753,24 +768,22 @@ gimp_drawable_transform_flip (GimpDrawable *drawable,
}
/* transform the buffer */
if (orig_buffer)
{
new_buffer = gimp_drawable_transform_buffer_flip (drawable, context,
orig_buffer,
orig_offset_x,
orig_offset_y,
flip_type, axis,
clip_result,
&new_offset_x,
&new_offset_y);
new_buffer = gimp_drawable_transform_buffer_flip (drawable, context,
orig_buffer,
orig_offset_x,
orig_offset_y,
flip_type, axis,
clip_result,
&profile,
&new_offset_x,
&new_offset_y);
/* Free the cut/copied buffer */
g_object_unref (orig_buffer);
}
/* Free the cut/copied buffer */
g_object_unref (orig_buffer);
if (new_buffer)
{
result = gimp_drawable_transform_paste (drawable, new_buffer,
result = gimp_drawable_transform_paste (drawable, new_buffer, profile,
new_offset_x, new_offset_y,
new_layer);
g_object_unref (new_buffer);
@ -816,9 +829,10 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
if (orig_buffer)
{
GeglBuffer *new_buffer;
gint new_offset_x;
gint new_offset_y;
GeglBuffer *new_buffer;
gint new_offset_x;
gint new_offset_y;
GimpColorProfile *profile;
/* always clip unfloated buffers so they keep their size */
if (GIMP_IS_CHANNEL (drawable) &&
@ -847,6 +861,7 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
rotate_type,
center_x, center_y,
clip_result,
&profile,
&new_offset_x,
&new_offset_y);
@ -855,7 +870,7 @@ gimp_drawable_transform_rotate (GimpDrawable *drawable,
if (new_buffer)
{
result = gimp_drawable_transform_paste (drawable, new_buffer,
result = gimp_drawable_transform_paste (drawable, new_buffer, profile,
new_offset_x, new_offset_y,
new_layer);
g_object_unref (new_buffer);
@ -931,11 +946,12 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
}
GimpDrawable *
gimp_drawable_transform_paste (GimpDrawable *drawable,
GeglBuffer *buffer,
gint offset_x,
gint offset_y,
gboolean new_layer)
gimp_drawable_transform_paste (GimpDrawable *drawable,
GeglBuffer *buffer,
GimpColorProfile *buffer_profile,
gint offset_x,
gint offset_y,
gboolean new_layer)
{
GimpImage *image;
GimpLayer *layer = NULL;
@ -944,6 +960,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (buffer_profile), NULL);
image = gimp_item_get_image (GIMP_ITEM (drawable));
@ -963,7 +980,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
gimp_drawable_get_format_with_alpha (drawable),
_("Transformation"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
NULL /* same image */);
buffer_profile);
gimp_item_set_offset (GIMP_ITEM (layer), offset_x, offset_y);

View File

@ -28,6 +28,7 @@ GeglBuffer * gimp_drawable_transform_buffer_affine (GimpDrawable *dra
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
GimpTransformResize clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y,
GimpProgress *progress);
@ -39,6 +40,7 @@ GeglBuffer * gimp_drawable_transform_buffer_flip (GimpDrawable *dra
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
@ -51,6 +53,7 @@ GeglBuffer * gimp_drawable_transform_buffer_rotate (GimpDrawable *dra
gdouble center_x,
gdouble center_y,
gboolean clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
@ -82,6 +85,7 @@ GeglBuffer * gimp_drawable_transform_cut (GimpDrawable *dra
gboolean *new_layer);
GimpDrawable * gimp_drawable_transform_paste (GimpDrawable *drawable,
GeglBuffer *buffer,
GimpColorProfile *buffer_profile,
gint offset_x,
gint offset_y,
gboolean new_layer);

View File

@ -642,10 +642,11 @@ gimp_drawable_flip (GimpItem *item,
gdouble axis,
gboolean clip_result)
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GeglBuffer *buffer;
gint off_x, off_y;
gint new_off_x, new_off_y;
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GeglBuffer *buffer;
GimpColorProfile *buffer_profile;
gint off_x, off_y;
gint new_off_x, new_off_y;
gimp_item_get_offset (item, &off_x, &off_y);
@ -654,11 +655,12 @@ gimp_drawable_flip (GimpItem *item,
off_x, off_y,
flip_type, axis,
clip_result,
&buffer_profile,
&new_off_x, &new_off_y);
if (buffer)
{
gimp_drawable_transform_paste (drawable, buffer,
gimp_drawable_transform_paste (drawable, buffer, buffer_profile,
new_off_x, new_off_y, FALSE);
g_object_unref (buffer);
}
@ -672,10 +674,11 @@ gimp_drawable_rotate (GimpItem *item,
gdouble center_y,
gboolean clip_result)
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GeglBuffer *buffer;
gint off_x, off_y;
gint new_off_x, new_off_y;
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GeglBuffer *buffer;
GimpColorProfile *buffer_profile;
gint off_x, off_y;
gint new_off_x, new_off_y;
gimp_item_get_offset (item, &off_x, &off_y);
@ -684,11 +687,12 @@ gimp_drawable_rotate (GimpItem *item,
off_x, off_y,
rotate_type, center_x, center_y,
clip_result,
&buffer_profile,
&new_off_x, &new_off_y);
if (buffer)
{
gimp_drawable_transform_paste (drawable, buffer,
gimp_drawable_transform_paste (drawable, buffer, buffer_profile,
new_off_x, new_off_y, FALSE);
g_object_unref (buffer);
}
@ -703,10 +707,11 @@ gimp_drawable_transform (GimpItem *item,
GimpTransformResize clip_result,
GimpProgress *progress)
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GeglBuffer *buffer;
gint off_x, off_y;
gint new_off_x, new_off_y;
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GeglBuffer *buffer;
GimpColorProfile *buffer_profile;
gint off_x, off_y;
gint new_off_x, new_off_y;
gimp_item_get_offset (item, &off_x, &off_y);
@ -716,12 +721,13 @@ gimp_drawable_transform (GimpItem *item,
matrix, direction,
interpolation_type,
clip_result,
&buffer_profile,
&new_off_x, &new_off_y,
progress);
if (buffer)
{
gimp_drawable_transform_paste (drawable, buffer,
gimp_drawable_transform_paste (drawable, buffer, buffer_profile,
new_off_x, new_off_y, FALSE);
g_object_unref (buffer);
}

View File

@ -63,6 +63,7 @@ static GeglBuffer * gimp_flip_tool_transform (GimpTransformTool *tool,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
@ -203,6 +204,7 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y)
{
@ -240,6 +242,7 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
orig_offset_y,
options->flip_type, axis,
FALSE,
buffer_profile,
new_offset_x,
new_offset_y);
}

View File

@ -134,6 +134,7 @@ static GeglBuffer *
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
static void gimp_transform_tool_real_draw_gui (GimpTransformTool *tr_tool,
@ -1256,6 +1257,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y)
{
@ -1291,6 +1293,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
options->direction,
options->interpolation,
clip,
buffer_profile,
new_offset_x,
new_offset_y,
progress);
@ -1345,6 +1348,7 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
GeglBuffer *new_buffer;
gint new_offset_x;
gint new_offset_y;
GimpColorProfile *buffer_profile;
gchar *undo_desc = NULL;
gboolean new_layer = FALSE;
GError *error = NULL;
@ -1403,6 +1407,7 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
orig_buffer,
orig_offset_x,
orig_offset_y,
&buffer_profile,
&new_offset_x,
&new_offset_y);
@ -1417,7 +1422,8 @@ gimp_transform_tool_transform (GimpTransformTool *tr_tool,
/* paste the new transformed image to the image...also implement
* undo...
*/
gimp_drawable_transform_paste (tool->drawable, new_buffer,
gimp_drawable_transform_paste (tool->drawable,
new_buffer, buffer_profile,
new_offset_x, new_offset_y,
new_layer);
g_object_unref (new_buffer);

View File

@ -154,6 +154,7 @@ struct _GimpTransformToolClass
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
};