[gimp] app: remove public function gimp_vectors_bounds()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove public function gimp_vectors_bounds()
- Date: Fri, 3 Jul 2015 22:24:02 +0000 (UTC)
commit 658a7834fe72aea85e4731292d54ff934dfb850e
Author: Michael Natterer <mitch gimp org>
Date: Tue Jun 30 16:00:59 2015 +0200
app: remove public function gimp_vectors_bounds()
and move its code into the GimpItem::bounds() implementation.
app/vectors/gimpvectors.c | 144 +++++++++++++++++++--------------------------
app/vectors/gimpvectors.h | 8 +--
2 files changed, 62 insertions(+), 90 deletions(-)
---
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index 048afa0..d9c98e1 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -69,7 +69,7 @@ static gint64 gimp_vectors_get_memsize (GimpObject *object,
static gboolean gimp_vectors_is_attached (const GimpItem *item);
static GimpItemTree * gimp_vectors_get_tree (GimpItem *item);
-static gboolean gimp_vectors_item_bounds (GimpItem *item,
+static gboolean gimp_vectors_bounds (GimpItem *item,
gdouble *x,
gdouble *y,
gdouble *width,
@@ -199,7 +199,7 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
item_class->is_attached = gimp_vectors_is_attached;
item_class->get_tree = gimp_vectors_get_tree;
- item_class->bounds = gimp_vectors_item_bounds;
+ item_class->bounds = gimp_vectors_bounds;
item_class->duplicate = gimp_vectors_duplicate;
item_class->convert = gimp_vectors_convert;
item_class->translate = gimp_vectors_translate;
@@ -323,23 +323,69 @@ gimp_vectors_get_tree (GimpItem *item)
}
static gboolean
-gimp_vectors_item_bounds (GimpItem *item,
- gdouble *x,
- gdouble *y,
- gdouble *width,
- gdouble *height)
+gimp_vectors_bounds (GimpItem *item,
+ gdouble *x,
+ gdouble *y,
+ gdouble *width,
+ gdouble *height)
{
- gdouble x1, y1, x2, y2;
- gdouble retval;
+ GimpVectors *vectors = GIMP_VECTORS (item);
- retval = gimp_vectors_bounds (GIMP_VECTORS (item), &x1, &y1, &x2, &y2);
+ if (! vectors->bounds_valid)
+ {
+ GimpStroke *stroke;
- *x = x1;
- *y = y1;
- *width = x2 - x1;
- *height = y2 - y1;
+ vectors->bounds_empty = TRUE;
+ vectors->bounds_x1 = vectors->bounds_x2 = 0.0;
+ vectors->bounds_y1 = vectors->bounds_y2 = 0.0;
- return retval;
+ for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
+ stroke;
+ stroke = gimp_vectors_stroke_get_next (vectors, stroke))
+ {
+ GArray *stroke_coords;
+ gboolean closed;
+
+ stroke_coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
+
+ if (stroke_coords)
+ {
+ GimpCoords point;
+ gint i;
+
+ if (vectors->bounds_empty && stroke_coords->len > 0)
+ {
+ point = g_array_index (stroke_coords, GimpCoords, 0);
+
+ vectors->bounds_x1 = vectors->bounds_x2 = point.x;
+ vectors->bounds_y1 = vectors->bounds_y2 = point.y;
+
+ vectors->bounds_empty = FALSE;
+ }
+
+ for (i = 0; i < stroke_coords->len; i++)
+ {
+ point = g_array_index (stroke_coords, GimpCoords, i);
+
+ vectors->bounds_x1 = MIN (vectors->bounds_x1, point.x);
+ vectors->bounds_y1 = MIN (vectors->bounds_y1, point.y);
+ vectors->bounds_x2 = MAX (vectors->bounds_x2, point.x);
+ vectors->bounds_y2 = MAX (vectors->bounds_y2, point.y);
+ }
+
+ g_array_free (stroke_coords, TRUE);
+ }
+ }
+
+ vectors->bounds_valid = TRUE;
+ }
+
+ *x = vectors->bounds_x1;
+ *y = vectors->bounds_y1;
+ *width = vectors->bounds_x2 - vectors->bounds_x1;
+ *height = vectors->bounds_y2 - vectors->bounds_y1;
+
+ return ! vectors->bounds_empty;
}
static GimpItem *
@@ -1053,74 +1099,6 @@ gimp_vectors_real_get_distance (const GimpVectors *vectors,
return 0;
}
-gboolean
-gimp_vectors_bounds (GimpVectors *vectors,
- gdouble *x1,
- gdouble *y1,
- gdouble *x2,
- gdouble *y2)
-{
- g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
- g_return_val_if_fail (x1 != NULL && y1 != NULL &&
- x2 != NULL && y2 != NULL, FALSE);
-
- if (! vectors->bounds_valid)
- {
- GimpStroke *stroke;
-
- vectors->bounds_empty = TRUE;
- vectors->bounds_x1 = vectors->bounds_x2 = 0.0;
- vectors->bounds_y1 = vectors->bounds_y2 = 0.0;
-
- for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
- stroke;
- stroke = gimp_vectors_stroke_get_next (vectors, stroke))
- {
- GArray *stroke_coords;
- gboolean closed;
-
- stroke_coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
-
- if (stroke_coords)
- {
- GimpCoords point;
- gint i;
-
- if (vectors->bounds_empty && stroke_coords->len > 0)
- {
- point = g_array_index (stroke_coords, GimpCoords, 0);
-
- vectors->bounds_x1 = vectors->bounds_x2 = point.x;
- vectors->bounds_y1 = vectors->bounds_y2 = point.y;
-
- vectors->bounds_empty = FALSE;
- }
-
- for (i = 0; i < stroke_coords->len; i++)
- {
- point = g_array_index (stroke_coords, GimpCoords, i);
-
- vectors->bounds_x1 = MIN (vectors->bounds_x1, point.x);
- vectors->bounds_y1 = MIN (vectors->bounds_y1, point.y);
- vectors->bounds_x2 = MAX (vectors->bounds_x2, point.x);
- vectors->bounds_y2 = MAX (vectors->bounds_y2, point.y);
- }
-
- g_array_free (stroke_coords, TRUE);
- }
- }
-
- vectors->bounds_valid = TRUE;
- }
-
- *x1 = vectors->bounds_x1;
- *y1 = vectors->bounds_y1;
- *x2 = vectors->bounds_x2;
- *y2 = vectors->bounds_y2;
-
- return (! vectors->bounds_empty);
-}
-
gint
gimp_vectors_interpolate (const GimpVectors *vectors,
const GimpStroke *stroke,
diff --git a/app/vectors/gimpvectors.h b/app/vectors/gimpvectors.h
index a27d986..b5455ff 100644
--- a/app/vectors/gimpvectors.h
+++ b/app/vectors/gimpvectors.h
@@ -166,14 +166,8 @@ gdouble gimp_vectors_get_length (const GimpVectors *vectors,
gdouble gimp_vectors_get_distance (const GimpVectors *vectors,
const GimpCoords *coord);
-gboolean gimp_vectors_bounds (GimpVectors *vectors,
- gdouble *x1,
- gdouble *y1,
- gdouble *x2,
- gdouble *y2);
-
-
/* returns the number of valid coordinates */
+
gint gimp_vectors_interpolate (const GimpVectors *vectors,
const GimpStroke *stroke,
gdouble precision,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]