diff --git a/dev-helper/src/painter_backend_eq_image_test.rs b/dev-helper/src/painter_backend_eq_image_test.rs index 06622d073..495321fed 100644 --- a/dev-helper/src/painter_backend_eq_image_test.rs +++ b/dev-helper/src/painter_backend_eq_image_test.rs @@ -86,7 +86,7 @@ pub fn assert_texture_eq_png(img: PixelImage, file_path: &std::path::Path) { ) .unwrap(); - const TOLERANCE: f64 = 0.0000025; + const TOLERANCE: f64 = 0.000008; let (v, _) = dssim.compare(&expected, dissim_mig); let v: f64 = v.into(); diff --git a/gpu/src/gpu_backend/textures_mgr.rs b/gpu/src/gpu_backend/textures_mgr.rs index 7b7e45b40..3e1e95137 100644 --- a/gpu/src/gpu_backend/textures_mgr.rs +++ b/gpu/src/gpu_backend/textures_mgr.rs @@ -123,13 +123,14 @@ where .filter(|h| h.attr >= prefer_scale) .copied() { - let slice = alpha_tex_slice(&self.alpha_atlas, &h).cut_blank_edge(); - let matrix = cache_to_view_matrix(key.path(), transform, slice.rect.origin, h.attr); - (slice, matrix) + let mask_slice = alpha_tex_slice(&self.alpha_atlas, &h).cut_blank_edge(); + let matrix = cache_to_view_matrix(key.path(), transform, mask_slice.rect.origin, h.attr); + (mask_slice.expand_for_paste(), matrix) } else { let path = key.path().clone(); let scale_bounds = path.bounds().scale(prefer_scale, prefer_scale); let prefer_cache_size = path_add_edges(scale_bounds.round_out().size.to_i32().cast_unit()); + let h = self .alpha_atlas .allocate(key, prefer_scale, prefer_cache_size, gpu_impl); @@ -146,7 +147,7 @@ where .fill_task .push(FillTask { slice, path, ts, clip_rect: None }); - (mask_slice, matrix) + (mask_slice.expand_for_paste(), matrix) } } @@ -179,7 +180,10 @@ where }; let offset = (clip_view.origin - slice.rect.origin).to_f32(); - (slice, Transform::translation(offset.x, offset.y)) + ( + slice.expand_for_paste(), + Transform::translation(offset.x, offset.y), + ) } pub(super) fn store_image( @@ -395,6 +399,13 @@ impl TextureSlice { self.rect = self.rect.inner_rect(blank_side); self } + + pub fn expand_for_paste(mut self) -> TextureSlice { + const EXPANDED_EDGE: i32 = 1; + let blank_side = SideOffsets2D::new_all_same(EXPANDED_EDGE); + self.rect = self.rect.outer_rect(blank_side); + self + } } #[derive(Debug, Clone)] @@ -638,7 +649,7 @@ pub mod tests { let (slice2, ts2) = mgr.store_clipped_path(clip_view, path, &mut wgpu); assert_eq!(slice1, slice2); assert_eq!(ts1, ts2); - assert_eq!(slice1.rect, ribir_geom::rect(2, 2, 100, 100)); + assert_eq!(slice1.rect, ribir_geom::rect(1, 1, 102, 102)); assert_eq!(ts1, Transform::new(1., 0., 0., 1., 8., 8.)); } diff --git a/test_cases/counter/counter_with_default_by_wgpu.png b/test_cases/counter/counter_with_default_by_wgpu.png index 20a7e2d3e..30c8f9ad4 100644 Binary files a/test_cases/counter/counter_with_default_by_wgpu.png and b/test_cases/counter/counter_with_default_by_wgpu.png differ diff --git a/test_cases/counter/counter_with_material_by_wgpu.png b/test_cases/counter/counter_with_material_by_wgpu.png index 6479606dd..8476bfb0d 100644 Binary files a/test_cases/counter/counter_with_material_by_wgpu.png and b/test_cases/counter/counter_with_material_by_wgpu.png differ diff --git a/test_cases/messages/messages_with_default_by_wgpu.png b/test_cases/messages/messages_with_default_by_wgpu.png index 6e329c37f..a44fb667b 100644 Binary files a/test_cases/messages/messages_with_default_by_wgpu.png and b/test_cases/messages/messages_with_default_by_wgpu.png differ diff --git a/test_cases/messages/messages_with_material_by_wgpu.png b/test_cases/messages/messages_with_material_by_wgpu.png index d5d9a660c..55db4d544 100644 Binary files a/test_cases/messages/messages_with_material_by_wgpu.png and b/test_cases/messages/messages_with_material_by_wgpu.png differ diff --git a/test_cases/ribir_gpu/gpu_backend/tests/draw_svg_gradient_wgpu.png b/test_cases/ribir_gpu/gpu_backend/tests/draw_svg_gradient_wgpu.png index 4be63f2fb..9bb1dc953 100644 Binary files a/test_cases/ribir_gpu/gpu_backend/tests/draw_svg_gradient_wgpu.png and b/test_cases/ribir_gpu/gpu_backend/tests/draw_svg_gradient_wgpu.png differ diff --git a/test_cases/ribir_gpu/gpu_backend/tests/transform_img_brush_wgpu.png b/test_cases/ribir_gpu/gpu_backend/tests/transform_img_brush_wgpu.png index a86f6bdc7..4608176a8 100644 Binary files a/test_cases/ribir_gpu/gpu_backend/tests/transform_img_brush_wgpu.png and b/test_cases/ribir_gpu/gpu_backend/tests/transform_img_brush_wgpu.png differ diff --git a/test_cases/ribir_widgets/checkbox/tests/checked_with_default_by_wgpu.png b/test_cases/ribir_widgets/checkbox/tests/checked_with_default_by_wgpu.png index a7b3d041a..17c19c631 100644 Binary files a/test_cases/ribir_widgets/checkbox/tests/checked_with_default_by_wgpu.png and b/test_cases/ribir_widgets/checkbox/tests/checked_with_default_by_wgpu.png differ diff --git a/test_cases/ribir_widgets/checkbox/tests/indeterminate_with_default_by_wgpu.png b/test_cases/ribir_widgets/checkbox/tests/indeterminate_with_default_by_wgpu.png index cbf092282..f52ebd311 100644 Binary files a/test_cases/ribir_widgets/checkbox/tests/indeterminate_with_default_by_wgpu.png and b/test_cases/ribir_widgets/checkbox/tests/indeterminate_with_default_by_wgpu.png differ diff --git a/test_cases/ribir_widgets/checkbox/tests/unchecked_with_default_by_wgpu.png b/test_cases/ribir_widgets/checkbox/tests/unchecked_with_default_by_wgpu.png index ed05a369d..d5ad9403f 100644 Binary files a/test_cases/ribir_widgets/checkbox/tests/unchecked_with_default_by_wgpu.png and b/test_cases/ribir_widgets/checkbox/tests/unchecked_with_default_by_wgpu.png differ diff --git a/test_cases/storybook/storybook_with_default_by_wgpu.png b/test_cases/storybook/storybook_with_default_by_wgpu.png index 8286c8048..cf6ac28b6 100644 Binary files a/test_cases/storybook/storybook_with_default_by_wgpu.png and b/test_cases/storybook/storybook_with_default_by_wgpu.png differ diff --git a/test_cases/storybook/storybook_with_material_by_wgpu.png b/test_cases/storybook/storybook_with_material_by_wgpu.png index 98c52840b..70e31a7e7 100644 Binary files a/test_cases/storybook/storybook_with_material_by_wgpu.png and b/test_cases/storybook/storybook_with_material_by_wgpu.png differ diff --git a/test_cases/todos/todos_with_default_by_wgpu.png b/test_cases/todos/todos_with_default_by_wgpu.png index 0c8a017de..7808708a2 100644 Binary files a/test_cases/todos/todos_with_default_by_wgpu.png and b/test_cases/todos/todos_with_default_by_wgpu.png differ diff --git a/test_cases/todos/todos_with_material_by_wgpu.png b/test_cases/todos/todos_with_material_by_wgpu.png index fce70df59..314cad524 100644 Binary files a/test_cases/todos/todos_with_material_by_wgpu.png and b/test_cases/todos/todos_with_material_by_wgpu.png differ