[gtk/curve-ops: 6/10] Add gsk_curve_get_bounds
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/curve-ops: 6/10] Add gsk_curve_get_bounds
- Date: Mon, 7 Dec 2020 23:46:26 +0000 (UTC)
commit 807d68ca5b9668540d80948741dc8f22837bd229
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Dec 7 01:22:39 2020 -0500
Add gsk_curve_get_bounds
A cheaper bounding box.
gsk/gskcurve.c | 37 +++++++++++++++++++++++++++++++++++++
gsk/gskcurveprivate.h | 3 ++-
2 files changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/gsk/gskcurve.c b/gsk/gskcurve.c
index 3d5f3e2397..1523f07362 100644
--- a/gsk/gskcurve.c
+++ b/gsk/gskcurve.c
@@ -48,6 +48,8 @@ struct _GskCurveClass
graphene_vec2_t *tangent);
void (* get_end_tangent) (const GskCurve *curve,
graphene_vec2_t *tangent);
+ void (* get_bounds) (const GskCurve *curve,
+ graphene_rect_t *bounds);
void (* get_tight_bounds) (const GskCurve *curve,
graphene_rect_t *bounds);
};
@@ -183,6 +185,7 @@ static const GskCurveClass GSK_LINE_CURVE_CLASS = {
gsk_line_curve_get_end_point,
gsk_line_curve_get_tangent,
gsk_line_curve_get_tangent,
+ gsk_line_curve_get_bounds,
gsk_line_curve_get_bounds
};
@@ -366,6 +369,19 @@ gsk_curve_curve_get_end_tangent (const GskCurve *curve,
return get_tangent (&self->points[2], &self->points[3], tangent);
}
+static void
+gsk_curve_curve_get_bounds (const GskCurve *curve,
+ graphene_rect_t *bounds)
+{
+ const GskCurveCurve *self = &curve->curve;
+ const graphene_point_t *pts = self->points;
+
+ graphene_rect_init (bounds, pts[0].x, pts[0].y, 0, 0);
+ graphene_rect_expand (bounds, &pts[1], bounds);
+ graphene_rect_expand (bounds, &pts[2], bounds);
+ graphene_rect_expand (bounds, &pts[3], bounds);
+}
+
static inline gboolean
acceptable (float t)
{
@@ -450,6 +466,7 @@ static const GskCurveClass GSK_CURVE_CURVE_CLASS = {
gsk_curve_curve_get_end_point,
gsk_curve_curve_get_start_tangent,
gsk_curve_curve_get_end_tangent,
+ gsk_curve_curve_get_bounds,
gsk_curve_curve_get_tight_bounds
};
@@ -682,6 +699,18 @@ gsk_conic_curve_get_end_tangent (const GskCurve *curve,
return get_tangent (&self->points[1], &self->points[3], tangent);
}
+static void
+gsk_conic_curve_get_bounds (const GskCurve *curve,
+ graphene_rect_t *bounds)
+{
+ const GskCurveCurve *self = &curve->curve;
+ const graphene_point_t *pts = self->points;
+
+ graphene_rect_init (bounds, pts[0].x, pts[0].y, 0, 0);
+ graphene_rect_expand (bounds, &pts[1], bounds);
+ graphene_rect_expand (bounds, &pts[3], bounds);
+}
+
/* Solve N = 0 where N is the numerator of (P/Q)', with
* P = (1-t)^2*a + 2*t*(1-t)*w*b + t^2*c
* Q = (1-t)^2 + 2*t*(1-t)*w + t^2
@@ -758,6 +787,7 @@ static const GskCurveClass GSK_CONIC_CURVE_CLASS = {
gsk_conic_curve_get_end_point,
gsk_conic_curve_get_start_tangent,
gsk_conic_curve_get_end_tangent,
+ gsk_conic_curve_get_bounds,
gsk_conic_curve_get_tight_bounds
};
@@ -844,6 +874,13 @@ gsk_curve_get_end_tangent (const GskCurve *curve,
get_class (curve->op)->get_end_tangent (curve, tangent);
}
+void
+gsk_curve_get_bounds (const GskCurve *curve,
+ graphene_rect_t *bounds)
+{
+ get_class (curve->op)->get_bounds (curve, bounds);
+}
+
void
gsk_curve_get_tight_bounds (const GskCurve *curve,
graphene_rect_t *bounds)
diff --git a/gsk/gskcurveprivate.h b/gsk/gskcurveprivate.h
index a64e8ce736..838841ad68 100644
--- a/gsk/gskcurveprivate.h
+++ b/gsk/gskcurveprivate.h
@@ -102,7 +102,8 @@ void gsk_curve_get_start_tangent (const GskCurve
graphene_vec2_t *tangent);
void gsk_curve_get_end_tangent (const GskCurve *curve,
graphene_vec2_t *tangent);
-
+void gsk_curve_get_bounds (const GskCurve *curve,
+ graphene_rect_t *bounds);
void gsk_curve_get_tight_bounds (const GskCurve *curve,
graphene_rect_t *bounds);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]