瀏覽代碼

LibGfx: Only attempt to paint strokes with a width > 0

MacDue 2 年之前
父節點
當前提交
a9b4e876d0
共有 2 個文件被更改,包括 6 次插入0 次删除
  1. 4 0
      Userland/Libraries/LibGfx/AntiAliasingPainter.cpp
  2. 2 0
      Userland/Libraries/LibGfx/Path.cpp

+ 4 - 0
Userland/Libraries/LibGfx/AntiAliasingPainter.cpp

@@ -194,12 +194,16 @@ void AntiAliasingPainter::draw_line(FloatPoint actual_from, FloatPoint actual_to
 
 
 void AntiAliasingPainter::stroke_path(Path const& path, Color color, float thickness)
 void AntiAliasingPainter::stroke_path(Path const& path, Color color, float thickness)
 {
 {
+    if (thickness <= 0)
+        return;
     // FIXME: Cache this? Probably at a higher level such as in LibWeb?
     // FIXME: Cache this? Probably at a higher level such as in LibWeb?
     fill_path(path.stroke_to_fill(thickness), color);
     fill_path(path.stroke_to_fill(thickness), color);
 }
 }
 
 
 void AntiAliasingPainter::stroke_path(Path const& path, Gfx::PaintStyle const& paint_style, float thickness, float opacity)
 void AntiAliasingPainter::stroke_path(Path const& path, Gfx::PaintStyle const& paint_style, float thickness, float opacity)
 {
 {
+    if (thickness <= 0)
+        return;
     // FIXME: Cache this? Probably at a higher level such as in LibWeb?
     // FIXME: Cache this? Probably at a higher level such as in LibWeb?
     fill_path(path.stroke_to_fill(thickness), paint_style, opacity);
     fill_path(path.stroke_to_fill(thickness), paint_style, opacity);
 }
 }

+ 2 - 0
Userland/Libraries/LibGfx/Path.cpp

@@ -416,6 +416,8 @@ Path Path::stroke_to_fill(float thickness) const
     // Note: This convolves a polygon with the path using the algorithm described
     // Note: This convolves a polygon with the path using the algorithm described
     // in https://keithp.com/~keithp/talks/cairo2003.pdf (3.1 Stroking Splines via Convolution)
     // in https://keithp.com/~keithp/talks/cairo2003.pdf (3.1 Stroking Splines via Convolution)
 
 
+    VERIFY(thickness > 0);
+
     auto& lines = split_lines();
     auto& lines = split_lines();
     if (lines.is_empty())
     if (lines.is_empty())
         return Path {};
         return Path {};