|
12 | 12 | clippy::allow_attributes_without_reason
|
13 | 13 | )]
|
14 | 14 |
|
| 15 | +use scenes::ImageCache; |
15 | 16 | use vello::{
|
16 |
| - Scene, |
| 17 | + AaConfig, Scene, |
17 | 18 | kurbo::{Affine, Rect},
|
18 |
| - peniko::{ImageFormat, color::palette}, |
| 19 | + peniko::{Extend, ImageFormat, ImageQuality, color::palette}, |
19 | 20 | };
|
20 |
| -use vello_tests::TestParams; |
| 21 | +use vello_tests::{TestParams, smoke_snapshot_test_sync}; |
21 | 22 |
|
22 | 23 | /// A reproduction of <https://github.com/linebender/vello/issues/680>
|
23 | 24 | fn many_bins(use_cpu: bool) {
|
@@ -76,3 +77,43 @@ fn many_bins_gpu() {
|
76 | 77 | fn many_bins_cpu() {
|
77 | 78 | many_bins(true);
|
78 | 79 | }
|
| 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, ¶ms) |
| 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, ¶ms) |
| 117 | + .unwrap() |
| 118 | + .assert_mean_less_than(0.001); |
| 119 | +} |
0 commit comments