Commit 2ae823ba authored by Ell's avatar Ell

app: add gimp_drawable_transform_get_effective_clip()

Which returns the actual clip mode that will be used by the
drawable for a particular transformation.
parent 2c52bba0
......@@ -66,6 +66,37 @@
/* public functions */
GimpTransformResize
gimp_drawable_transform_get_effective_clip (GimpDrawable *drawable,
GeglBuffer *orig_buffer,
GimpTransformResize clip_result)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), clip_result);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)),
clip_result);
g_return_val_if_fail (orig_buffer == NULL || GEGL_IS_BUFFER (orig_buffer),
clip_result);
/* Always clip unfloated buffers since they must keep their size */
if (GIMP_IS_CHANNEL (drawable))
{
if (orig_buffer)
{
if (! babl_format_has_alpha (gegl_buffer_get_format (orig_buffer)))
clip_result = GIMP_TRANSFORM_RESIZE_CLIP;
}
else
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
if (gimp_channel_is_empty (gimp_image_get_mask (image)))
clip_result = GIMP_TRANSFORM_RESIZE_CLIP;
}
}
return clip_result;
}
GeglBuffer *
gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
GimpContext *context,
......@@ -113,10 +144,9 @@ gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
u2 = u1 + gegl_buffer_get_width (orig_buffer);
v2 = v1 + gegl_buffer_get_height (orig_buffer);
/* Always clip unfloated buffers since they must keep their size */
if (G_TYPE_FROM_INSTANCE (drawable) == GIMP_TYPE_CHANNEL &&
! babl_format_has_alpha (gegl_buffer_get_format (orig_buffer)))
clip_result = GIMP_TRANSFORM_RESIZE_CLIP;
clip_result = gimp_drawable_transform_get_effective_clip (drawable,
orig_buffer,
clip_result);
/* Find the bounding coordinates of target */
gimp_transform_resize_boundary (&m, clip_result,
......@@ -749,10 +779,9 @@ gimp_drawable_transform_affine (GimpDrawable *drawable,
gint new_offset_y;
GimpColorProfile *profile;
/* always clip unfloated buffers so they keep their size */
if (GIMP_IS_CHANNEL (drawable) &&
! babl_format_has_alpha (gegl_buffer_get_format (orig_buffer)))
clip_result = GIMP_TRANSFORM_RESIZE_CLIP;
clip_result = gimp_drawable_transform_get_effective_clip (drawable,
orig_buffer,
clip_result);
/* also transform the mask if we are transforming an entire layer */
if (GIMP_IS_LAYER (drawable) &&
......
......@@ -19,76 +19,80 @@
#define __GIMP_DRAWABLE_TRANSFORM_H__
GeglBuffer * gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
GimpContext *context,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
GimpTransformResize clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y,
GimpProgress *progress);
GeglBuffer * gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
GimpContext *context,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
GimpTransformResize gimp_drawable_transform_get_effective_clip (GimpDrawable *drawable,
GeglBuffer *orig_buffer,
GimpTransformResize clip_result);
GeglBuffer * gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
GimpContext *context,
GeglBuffer *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 * gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
GimpContext *context,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
GimpTransformResize clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y,
GimpProgress *progress);
GeglBuffer * gimp_drawable_transform_buffer_flip (GimpDrawable *drawable,
GimpContext *context,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
GimpDrawable * gimp_drawable_transform_affine (GimpDrawable *drawable,
GimpContext *context,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
GimpTransformResize clip_result,
GimpProgress *progress);
GeglBuffer * gimp_drawable_transform_buffer_rotate (GimpDrawable *drawable,
GimpContext *context,
GeglBuffer *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);
GimpDrawable * gimp_drawable_transform_flip (GimpDrawable *drawable,
GimpContext *context,
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result);
GimpDrawable * gimp_drawable_transform_affine (GimpDrawable *drawable,
GimpContext *context,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
GimpTransformResize clip_result,
GimpProgress *progress);
GimpDrawable * gimp_drawable_transform_rotate (GimpDrawable *drawable,
GimpContext *context,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y,
gboolean clip_result);
GimpDrawable * gimp_drawable_transform_flip (GimpDrawable *drawable,
GimpContext *context,
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result);
GeglBuffer * gimp_drawable_transform_cut (GimpDrawable *drawable,
GimpContext *context,
gint *offset_x,
gint *offset_y,
gboolean *new_layer);
GimpDrawable * gimp_drawable_transform_paste (GimpDrawable *drawable,
GeglBuffer *buffer,
GimpColorProfile *buffer_profile,
gint offset_x,
gint offset_y,
gboolean new_layer);
GimpDrawable * gimp_drawable_transform_rotate (GimpDrawable *drawable,
GimpContext *context,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y,
gboolean clip_result);
GeglBuffer * gimp_drawable_transform_cut (GimpDrawable *drawable,
GimpContext *context,
gint *offset_x,
gint *offset_y,
gboolean *new_layer);
GimpDrawable * gimp_drawable_transform_paste (GimpDrawable *drawable,
GeglBuffer *buffer,
GimpColorProfile *buffer_profile,
gint offset_x,
gint offset_y,
gboolean new_layer);
#endif /* __GIMP_DRAWABLE_TRANSFORM_H__ */
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