summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src/backend.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-27 03:02:13 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-27 03:02:13 +0100
commit8750d83337041f1d0fac8c2c0f4c40fd3a051a2c (patch)
treebcc1b5d3c15dbca54d528c4cc629a5465499efe2 /tiny_skia/src/backend.rs
parent37ce30f360ce7cba9ad05654e1faf26276a1dc17 (diff)
downloadiced-8750d83337041f1d0fac8c2c0f4c40fd3a051a2c.tar.gz
iced-8750d83337041f1d0fac8c2c0f4c40fd3a051a2c.tar.bz2
iced-8750d83337041f1d0fac8c2c0f4c40fd3a051a2c.zip
Short-circuit rectangle path building in `iced_tiny_skia`
Diffstat (limited to 'tiny_skia/src/backend.rs')
-rw-r--r--tiny_skia/src/backend.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index 38a6c51d..d0977462 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -221,6 +221,22 @@ fn rounded_rectangle(
) -> tiny_skia::Path {
let [top_left, top_right, bottom_right, bottom_left] = border_radius;
+ if top_left == 0.0
+ && top_right == 0.0
+ && bottom_right == 0.0
+ && bottom_left == 0.0
+ {
+ return tiny_skia::PathBuilder::from_rect(
+ tiny_skia::Rect::from_xywh(
+ bounds.x,
+ bounds.y,
+ bounds.width,
+ bounds.height,
+ )
+ .expect("Build quad rectangle"),
+ );
+ }
+
if top_left == top_right
&& top_left == bottom_right
&& top_left == bottom_left