File 0010-Do-Not-Merge-d2d1-Extra-debug-output.patch of Package wine

From da70f177590b3e77d8464c0cc4272089b443e280 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Fri, 7 Jan 2022 20:53:58 +0100
Subject: [PATCH 10/10] Do-Not-Merge: d2d1: Extra debug output

---
 dlls/d2d1/geometry.c   | 53 +++++++++++++++++++++++++++++++++++++++++-
 dlls/d2d1/tests/d2d1.c |  7 ++++++
 2 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/dlls/d2d1/geometry.c b/dlls/d2d1/geometry.c
index c2a7db7a045..38c548c38ca 100644
--- a/dlls/d2d1/geometry.c
+++ b/dlls/d2d1/geometry.c
@@ -1958,6 +1958,7 @@ static BOOL d2d_geometry_intersect_line_line(struct d2d_geometry *geometry,
 
     intersection.x = p[0]->x + v_p.x * s;
     intersection.y = p[0]->y + v_p.y * s;
+    TRACE("intersection %s s=%.8f -> t=%.8f\n", debug_d2d_point_2f(&intersection), s, t);
 
     if (s > 0.0f && s < 1.0f && !d2d_geometry_intersections_add(intersections, idx_p, s, intersection))
         return FALSE;
@@ -1968,6 +1969,27 @@ static BOOL d2d_geometry_intersect_line_line(struct d2d_geometry *geometry,
     return TRUE;
 }
 
+static void _d2d_debug_bezier(struct d2d_geometry *geometry, const struct d2d_segment_idx *idx)
+{
+    const struct d2d_figure *figure = &geometry->u.path.figures[idx->figure_idx];
+    size_t next = idx->vertex_idx + 1;
+    enum d2d_vertex_type type = figure->vertex_types[idx->vertex_idx];
+
+    if (next == figure->vertex_count)
+        next = 0;
+
+    if (d2d_vertex_type_is_bezier(type)) {
+        TRACE("bezier[%d:%d]: %d %s %s %s\n", idx->figure_idx, idx->vertex_idx, type,
+            debug_d2d_point_2f(&figure->vertices[idx->vertex_idx]),
+            debug_d2d_point_2f(&figure->bezier_controls[idx->control_idx]),
+            debug_d2d_point_2f(&figure->vertices[next]));
+    } else {
+        TRACE("line[%d:%d]: %d %s %s\n", idx->figure_idx, idx->vertex_idx, type,
+            debug_d2d_point_2f(&figure->vertices[idx->vertex_idx]),
+            debug_d2d_point_2f(&figure->vertices[next]));
+    }
+}
+
 static BOOL d2d_geometry_add_bezier_line_intersections(struct d2d_geometry *geometry,
         struct d2d_geometry_intersections *intersections, const struct d2d_segment_idx *idx_p,
         const D2D1_POINT_2F **p, const struct d2d_segment_idx *idx_q, const D2D1_POINT_2F **q, float s)
@@ -1980,6 +2002,10 @@ static BOOL d2d_geometry_add_bezier_line_intersections(struct d2d_geometry *geom
         t = (intersection.x - q[0]->x) / (q[1]->x - q[0]->x);
     else
         t = (intersection.y - q[0]->y) / (q[1]->y - q[0]->y);
+    TRACE("intersection %s s=%.8f -> t=%.8f\n", debug_d2d_point_2f(&intersection), s, t);
+    _d2d_debug_bezier(geometry, idx_p);
+    _d2d_debug_bezier(geometry, idx_q);
+
     if (t < 0.0f || t > 1.0f)
         return TRUE;
 
@@ -2604,6 +2630,8 @@ static BOOL d2d_geometry_add_figure_outline(struct d2d_geometry *geometry,
     size_t bezier_idx, i, vertex_count;
 
     vertex_count = figure->vertex_count;
+    TRACE("Outline %d vertices, closed: %d, type[vc-1]: %d\n", vertex_count,
+      (figure_end == D2D1_FIGURE_END_CLOSED), figure->vertex_types[vertex_count - 1]);
     /* An OPEN path needs at least 2 vertices, a CLOSED one
      * needs at least 1 vertex */
     if (vertex_count < 2
@@ -2641,6 +2669,8 @@ static BOOL d2d_geometry_add_figure_outline(struct d2d_geometry *geometry,
             /* type BEZIER implies i + 1 < figure->vertex_count */
             p1 = &figure->vertices[i + 1];
 
+            TRACE("Draw bezier %d/%d (%d) %s, %s\n", i, vertex_count, figure->vertex_count,
+                debug_d2d_point_2f(p0), debug_d2d_point_2f(p1));
             if (!d2d_geometry_outline_add_bezier_segment(geometry, p0, next, p1))
             {
                 ERR("Failed to add bezier segment.\n");
@@ -2655,6 +2685,8 @@ static BOOL d2d_geometry_add_figure_outline(struct d2d_geometry *geometry,
                 next = p1 = &figure->vertices[i + 1];
             next_prev = p0;
 
+            TRACE("Draw line %d/%d (%d) %s, %s\n", i, vertex_count, figure->vertex_count,
+                debug_d2d_point_2f(p0), debug_d2d_point_2f(p1));
             if (!d2d_geometry_outline_add_line_segment(geometry, p0, p1))
             {
                 ERR("Failed to add line segment.\n");
@@ -2669,9 +2701,13 @@ static BOOL d2d_geometry_add_figure_outline(struct d2d_geometry *geometry,
             d2d_point_subtract(&q_prev, prev, p0);
             d2d_point_subtract(&q_next, next, p0);
 
+            /* FIXME ||q_prev|| == 0; dito q_next */
             d2d_point_normalise(&q_prev);
             d2d_point_normalise(&q_next);
 
+            TRACE("Draw join: Closed: %d %d/%d (%d) %s\n", (figure_end == D2D1_FIGURE_END_CLOSED), i, vertex_count,
+                figure->vertex_count, debug_d2d_point_2f(p0));
+
             if (!d2d_geometry_outline_add_join(geometry, &q_prev, p0, &q_next))
             {
                 ERR("Failed to add join.\n");
@@ -3135,13 +3171,21 @@ static HRESULT d2d_geometry_resolve_beziers(struct d2d_geometry *geometry)
     /* Split overlapping bezier control triangles. */
     while (d2d_geometry_get_next_bezier_segment_idx(geometry, &idx_p))
     {
+        figure = &geometry->u.path.figures[idx_p.figure_idx];
+        TRACE("o p=%d:%d / %d\n", idx_p.figure_idx, idx_p.vertex_idx, figure->vertex_count);
+        _d2d_debug_bezier(geometry, &idx_p);
+
         d2d_geometry_get_first_bezier_segment_idx(geometry, &idx_q);
         while (idx_q.figure_idx < idx_p.figure_idx || idx_q.vertex_idx < idx_p.vertex_idx)
         {
+            TRACE("check_bezier_overlap p=%d:%d <> q=%d:%d\n", idx_p.figure_idx, idx_p.vertex_idx, idx_q.figure_idx, idx_q.vertex_idx);
+            _d2d_debug_bezier(geometry, &idx_q);
+
             while (d2d_geometry_check_bezier_overlap(geometry, &idx_p, &idx_q))
             {
                 if (fabsf(d2d_geometry_bezier_ccw(geometry, &idx_q)) > fabsf(d2d_geometry_bezier_ccw(geometry, &idx_p)))
                 {
+                    TRACE("check_bezier_overlap split q: %d\n", idx_q.figure_idx);
                     if (!d2d_geometry_split_bezier(geometry, &idx_q))
                         return E_OUTOFMEMORY;
                     if (idx_p.figure_idx == idx_q.figure_idx)
@@ -3152,9 +3196,12 @@ static HRESULT d2d_geometry_resolve_beziers(struct d2d_geometry *geometry)
                 }
                 else
                 {
+                    TRACE("check_bezier_overlap split p: %d\n", idx_p.figure_idx);
                     if (!d2d_geometry_split_bezier(geometry, &idx_p))
                         return E_OUTOFMEMORY;
                 }
+                TRACE("i p=%d:%d / %d\n", idx_p.figure_idx, idx_p.vertex_idx, figure->vertex_count);
+                _d2d_debug_bezier(geometry, &idx_p);
             }
             d2d_geometry_get_next_bezier_segment_idx(geometry, &idx_q);
         }
@@ -3229,14 +3276,18 @@ static HRESULT STDMETHODCALLTYPE d2d_geometry_sink_Close(ID2D1GeometrySink *ifac
 
     if (!d2d_geometry_intersect_self(geometry))
         goto done;
+    TRACE("iface %p intersect_self done.\n", iface);
     if (FAILED(hr = d2d_geometry_resolve_beziers(geometry)))
         goto done;
+    TRACE("iface %p resolve_beziers done.\n", iface);
     if (FAILED(hr = d2d_path_geometry_triangulate(geometry)))
         goto done;
+    TRACE("iface %p triangulate done.\n", iface);
 
 done:
     if (FAILED(hr))
     {
+        TRACE("iface %p failed.\n", iface);
         heap_free(geometry->fill.bezier_vertices);
         geometry->fill.bezier_vertex_count = 0;
         d2d_path_geometry_free_figures(geometry);
@@ -3262,7 +3313,7 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_AddBezier(ID2D1GeometrySink *ifa
 static void STDMETHODCALLTYPE d2d_geometry_sink_AddQuadraticBezier(ID2D1GeometrySink *iface,
         const D2D1_QUADRATIC_BEZIER_SEGMENT *bezier)
 {
-    TRACE("iface %p, bezier %p.\n", iface, bezier);
+    TRACE("iface %p, bezier %p %s,%s.\n", iface, bezier, debug_d2d_point_2f(&bezier->point1), debug_d2d_point_2f(&bezier->point2));
 
     ID2D1GeometrySink_AddQuadraticBeziers(iface, bezier, 1);
 }
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 5efa87bd89c..f3ced9894a0 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -1141,6 +1141,8 @@ static void STDMETHODCALLTYPE geometry_sink_BeginFigure(ID2D1SimplifiedGeometryS
     figure->segments_size = 4;
     figure->segments = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
             figure->segments_size * sizeof(*figure->segments));
+
+    trace("mock BeginFigure -> {%.8e %.8e}\n", start_point.x, start_point.y);
 }
 
 static struct geometry_segment *geometry_figure_add_segment(struct geometry_figure *figure)
@@ -1164,6 +1166,8 @@ static void STDMETHODCALLTYPE geometry_sink_AddLines(ID2D1SimplifiedGeometrySink
 
     for (i = 0; i < count; ++i)
     {
+        trace("mock AddLines[%d/%d] -> {%.8e %.8e}\n", i, count,
+	    points[i].x, points[i].y);
         segment = geometry_figure_add_segment(figure);
         segment->type = SEGMENT_LINE;
         segment->u.line = points[i];
@@ -1195,6 +1199,7 @@ static void STDMETHODCALLTYPE geometry_sink_EndFigure(ID2D1SimplifiedGeometrySin
     struct geometry_figure *figure = &sink->figures[sink->figure_count - 1];
 
     figure->end = figure_end;
+    trace("mock EndFigure %d, %d segments\n", figure_end, figure->segment_count);
 }
 
 static HRESULT STDMETHODCALLTYPE geometry_sink_Close(ID2D1SimplifiedGeometrySink *iface)
@@ -1202,6 +1207,7 @@ static HRESULT STDMETHODCALLTYPE geometry_sink_Close(ID2D1SimplifiedGeometrySink
     struct geometry_sink *sink = impl_from_ID2D1SimplifiedGeometrySink(iface);
 
     sink->closed = TRUE;
+    trace("mock close, %d figures\n", sink->figure_count);
 
     return S_OK;
 }
@@ -3937,6 +3943,7 @@ static void test_path_geometry(BOOL d3d11)
     hr = ID2D1PathGeometry_Simplify(geometry, D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES,
             NULL, 0.0f, &simplify_sink.ID2D1SimplifiedGeometrySink_iface);
     ok(SUCCEEDED(hr), "Failed to simplify geometry, hr %#x.\n", hr);
+    trace("SIMPLIFY done\n");
     geometry_sink_check(&simplify_sink, D2D1_FILL_MODE_ALTERNATE, 4, &expected_figures[29], 1);
     geometry_sink_cleanup(&simplify_sink);
 
-- 
2.34.1

openSUSE Build Service is sponsored by