[gtk/wip/otte/lottie: 14/17] path: Always decompose conics into at least 2 segments




commit e5174d3d958ac25c9e92f9857dce50db9d434d54
Author: Benjamin Otte <otte redhat com>
Date:   Wed Dec 9 20:02:05 2020 +0100

    path: Always decompose conics into at least 2 segments
    
    Conics are evil in that their parameter skews towards the center, and if
    it's a very flat conic (weight almost equal to 0), then we'd approximate
    it with a single segment and not subdivide, which would cause the
    parameter to be wildly off around 0.25 or 0.75.
    
    And that would cause offset calculations to fail.

 gsk/gskcurve.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/gsk/gskcurve.c b/gsk/gskcurve.c
index 6e0332ab37..9556ad098d 100644
--- a/gsk/gskcurve.c
+++ b/gsk/gskcurve.c
@@ -725,13 +725,24 @@ gsk_conic_curve_decompose (const GskCurve      *curve,
                            gpointer             user_data)
 {
   const GskConicCurve *self = &curve->conic;
+  graphene_point_t mid;
 
   gsk_conic_curve_ensure_coefficents (self);
 
+  gsk_conic_curve_eval_point (self, 0.5, &mid);
+
   return gsk_conic_curve_decompose_subdivide (self,
                                               tolerance,
                                               &self->points[0],
                                               0.0f,
+                                              &mid,
+                                              0.5f,
+                                              add_line_func,
+                                              user_data)
+      && gsk_conic_curve_decompose_subdivide (self,
+                                              tolerance,
+                                              &mid,
+                                              0.5f,
                                               &self->points[3],
                                               1.0f,
                                               add_line_func,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]