Jelajahi Sumber

LibGfx: Skip horizontal edges in path rasterizer

Only the vertical parts of edges are plotted (then accumulated
horizontally). Fully horizontal edges won't be plotted (and just result
in NaNs).
MacDue 1 tahun lalu
induk
melakukan
2fa488cfa9
1 mengubah file dengan 7 tambahan dan 4 penghapusan
  1. 7 4
      Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp

+ 7 - 4
Userland/Libraries/LibGfx/EdgeFlagPathRasterizer.cpp

@@ -70,16 +70,19 @@ static Vector<Detail::Edge> prepare_edges(ReadonlySpan<FloatLine> lines, unsigne
         if (max_y < top_clip)
         if (max_y < top_clip)
             continue;
             continue;
 
 
-        float start_x = p0.x();
-        float end_x = p1.x();
-
+        auto start_x = p0.x();
+        auto end_x = p1.x();
         auto dx = end_x - start_x;
         auto dx = end_x - start_x;
         auto dy = max_y - min_y;
         auto dy = max_y - min_y;
+
+        if (dy == 0)
+            continue;
+
         auto dxdy = dx / dy;
         auto dxdy = dx / dy;
 
 
         // Trim off the non-visible portions of the edge.
         // Trim off the non-visible portions of the edge.
         if (min_y < top_clip) {
         if (min_y < top_clip) {
-            start_x += (top_clip - min_y) * dxdy;
+            start_x += dxdy * (top_clip - min_y);
             min_y = top_clip;
             min_y = top_clip;
         }
         }
         if (max_y > bottom_clip) {
         if (max_y > bottom_clip) {