[gimp/gimp-2-10] app: add gimp_drawable_transform_get_effective_clip()
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add gimp_drawable_transform_get_effective_clip()
- Date: Tue, 25 Sep 2018 08:32:18 +0000 (UTC)
commit 9ad52a222068dc163ea024c3998f429e5746d4f5
Author: Ell <ell_se yahoo com>
Date: Sun Sep 23 12:23:33 2018 -0400
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.
(cherry picked from commit 2ae823ba2b852c8f6d36a462db6b71662ffe61f0)
app/core/gimpdrawable-transform.c | 45 ++++++++++---
app/core/gimpdrawable-transform.h | 134 ++++++++++++++++++++------------------
2 files changed, 106 insertions(+), 73 deletions(-)
---
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index 037da10a3f..ea21da426c 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -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) &&
diff --git a/app/core/gimpdrawable-transform.h b/app/core/gimpdrawable-transform.h
index b60233a531..fec177b42d 100644
--- a/app/core/gimpdrawable-transform.h
+++ b/app/core/gimpdrawable-transform.h
@@ -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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]