Skip to content

Commit 94c02dd

Browse files
committed
test all extend modes
Signed-off-by: sagudev <[email protected]>
1 parent 5059273 commit 94c02dd

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

vello_tests/tests/known_issues.rs

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
clippy::allow_attributes_without_reason
1313
)]
1414

15+
use scenes::ImageCache;
1516
use vello::{
16-
Scene,
17+
AaConfig, Scene,
1718
kurbo::{Affine, Rect},
18-
peniko::{ImageFormat, color::palette},
19+
peniko::{Extend, ImageFormat, ImageQuality, color::palette},
1920
};
20-
use vello_tests::TestParams;
21+
use vello_tests::{TestParams, smoke_snapshot_test_sync};
2122

2223
/// A reproduction of <https://github.com/linebender/vello/issues/680>
2324
fn many_bins(use_cpu: bool) {
@@ -76,3 +77,43 @@ fn many_bins_gpu() {
7677
fn many_bins_cpu() {
7778
many_bins(true);
7879
}
80+
81+
const DATA_IMAGE_PNG: &[u8] = include_bytes!("../snapshots/smoke/data_image_roundtrip.png");
82+
83+
/// Test for <https://github.com/linebender/vello/issues/972>
84+
#[test]
85+
#[should_panic]
86+
fn test_data_image_roundtrip_extend_reflect() {
87+
let mut scene = Scene::new();
88+
let mut images = ImageCache::new();
89+
let image = images
90+
.from_bytes(0, DATA_IMAGE_PNG)
91+
.unwrap()
92+
.with_quality(ImageQuality::Low)
93+
.with_extend(Extend::Reflect);
94+
scene.draw_image(&image, Affine::IDENTITY);
95+
let mut params = TestParams::new("data_image_roundtrip", image.width, image.height);
96+
params.anti_aliasing = AaConfig::Area;
97+
smoke_snapshot_test_sync(scene, &params)
98+
.unwrap()
99+
.assert_mean_less_than(0.001);
100+
}
101+
102+
/// Test for <https://github.com/linebender/vello/issues/972>
103+
#[test]
104+
#[should_panic]
105+
fn test_data_image_roundtrip_extend_repeat() {
106+
let mut scene = Scene::new();
107+
let mut images = ImageCache::new();
108+
let image = images
109+
.from_bytes(0, DATA_IMAGE_PNG)
110+
.unwrap()
111+
.with_quality(ImageQuality::Low)
112+
.with_extend(Extend::Repeat);
113+
scene.draw_image(&image, Affine::IDENTITY);
114+
let mut params = TestParams::new("data_image_roundtrip", image.width, image.height);
115+
params.anti_aliasing = AaConfig::Area;
116+
smoke_snapshot_test_sync(scene, &params)
117+
.unwrap()
118+
.assert_mean_less_than(0.001);
119+
}

vello_tests/tests/regression.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use scenes::ImageCache;
77
use vello::{
88
AaConfig, Scene,
99
kurbo::{Affine, RoundedRect, Stroke},
10-
peniko::{ImageQuality, color::palette},
10+
peniko::{Extend, ImageQuality, color::palette},
1111
};
1212
use vello_tests::{TestParams, smoke_snapshot_test_sync, snapshot_test_sync};
1313

@@ -30,13 +30,14 @@ const DATA_IMAGE_PNG: &[u8] = include_bytes!("../snapshots/smoke/data_image_roun
3030

3131
/// Test for <https://github.com/linebender/vello/issues/972>
3232
#[test]
33-
fn test_data_image_roundtrip() {
33+
fn test_data_image_roundtrip_extend_pad() {
3434
let mut scene = Scene::new();
3535
let mut images = ImageCache::new();
3636
let image = images
3737
.from_bytes(0, DATA_IMAGE_PNG)
3838
.unwrap()
39-
.with_quality(ImageQuality::Low);
39+
.with_quality(ImageQuality::Low)
40+
.with_extend(Extend::Pad);
4041
scene.draw_image(&image, Affine::IDENTITY);
4142
let mut params = TestParams::new("data_image_roundtrip", image.width, image.height);
4243
params.anti_aliasing = AaConfig::Area;

0 commit comments

Comments
 (0)