Repository navigation
fix(geom, render, engine): release quality sweep #1605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5ace28e
8044a52
39192f4
85e5402
42f7da3
97bf083
b4def78
a8e880f
c6d442b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -327,9 +327,14 @@ pub fn map_pdf(s: &mut Session, dpi: f64) -> Result<Vec<u8>, String> { | |
| let (w, h) = (mm(view.width), mm(view.height)); | ||
| let page = if drawing.overflowed() { | ||
|
giswqs marked this conversation as resolved.
Resolved
|
||
| // Too large for vectors: the map as one picture, as it is drawn on screen. | ||
| super::layout::pictured_notices(s, &[], &[1]); | ||
| let png = rustgis_render::render_png(s.map_mut(), &view)?; | ||
| let pm = rustgis_render::decode_png(&png).ok_or("could not draw the map")?; | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| // Said once the picture is drawn. The budget counts the drawing's pictures (rasters, | ||
| // tiles) as well as its shapes. | ||
| let (mb, items) = (rustgis_render::vector::MAX_COST >> 20, rustgis_render::vector::MAX_ITEMS / 1_000_000); | ||
| s.warn(format!( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-raising the earlier test-coverage point, because the code here has changed but the gap remains. The new overflow notice has a clean-input test ( What is new: the earlier suggestion to use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed the overflow half is untested; the options named (a doc-hidden setter behind a test-only feature on rustgis-render) add a cross-crate test hook for one notice, which is a test-infrastructure change rather than a fix. Left for the release quality pass. |
||
| "The map is drawn as one picture, not vectors: kept as vectors, it would pass the drawing limit ({mb} MB or {items} million items)" | ||
| )); | ||
|
giswqs marked this conversation as resolved.
Resolved
|
||
| rustgis_render::pdf::Page::new(&pm, w, h) | ||
| } else { | ||
| rustgis_render::pdf::Page::drawing(drawing, w, h) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,7 +241,16 @@ impl Canvas { | |
| pub fn place(&mut self, child: Canvas, transform: Transform, opacity: f32, blend: Blend, clip: Option<Clip>) { | ||
| if self.rec.is_none() || !child.is_recording() { | ||
| let paint = PixmapPaint { opacity, blend_mode: crate::blend_mode(blend), quality: tiny_skia::FilterQuality::Bilinear }; | ||
| self.pixels().draw_pixmap(0, 0, child.pm.as_ref(), &paint, transform, None); | ||
| // Cut to `clip` as the recording is: a mask the size of these pixels. | ||
| let mask = match &clip { | ||
| Some(c) => { | ||
| let Some(mut m) = Mask::new(self.pm.width(), self.pm.height()) else { return }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low confidence, quality/never-silent:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not reachable: the mask is made at the size of a pixmap that already exists, and tiny-skia's Mask::new accepts the sizes Pixmap::new does. Stating the invariant in a comment is left for the release quality pass. |
||
| m.fill_path(&c.path, c.rule, true, c.transform); | ||
| Some(m) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| None => None, | ||
| }; | ||
| self.pixels().draw_pixmap(0, 0, child.pm.as_ref(), &paint, transform, mask.as_ref()); | ||
| return; | ||
| } | ||
| let Some(drawing) = child.into_drawing() else { return }; | ||
|
|
@@ -394,6 +403,41 @@ mod tests { | |
| assert!(stroke.width == 2.0 && path.segments().filter(|s| matches!(s, tiny_skia::PathSegment::MoveTo(_))).count() == 10); | ||
| } | ||
|
|
||
| #[test] | ||
| fn placing_pixels_keeps_inside_the_clip() { | ||
| let mut c = Canvas::new(40, 20).unwrap(); | ||
| let mut child = c.sub(40, 20).unwrap(); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| child.pixels().fill(Color::from_rgba8(200, 0, 0, 255)); | ||
| let clip = Clip { | ||
| path: PathBuilder::from_rect(Rect::from_xywh(0.0, 0.0, 20.0, 20.0).unwrap()), | ||
| rule: FillRule::Winding, | ||
| transform: Transform::identity(), | ||
| }; | ||
| c.place(child, Transform::identity(), 1.0, Blend::Normal, Some(clip)); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| let pm = c.into_pixmap(); | ||
| assert_eq!(pm.pixel(5, 10).map(|p| p.alpha()), Some(255), "inside the clip"); | ||
| assert_eq!(pm.pixel(30, 10).map(|p| p.alpha()), Some(0), "outside the clip"); | ||
|
giswqs marked this conversation as resolved.
Resolved
coderabbitai[bot] marked this conversation as resolved.
Resolved
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| #[test] | ||
| fn placing_pixels_cuts_to_the_clip_where_its_own_transform_puts_it() { | ||
| let mut c = Canvas::new(40, 20).unwrap(); | ||
| let mut child = c.sub(10, 20).unwrap(); | ||
| child.pixels().fill(Color::from_rgba8(200, 0, 0, 255)); | ||
| // The clip covers x 20 to 30, the child x 15 to 25: only 20 to 25 is drawn. | ||
| let clip = Clip { | ||
| path: PathBuilder::from_rect(Rect::from_xywh(0.0, 0.0, 10.0, 20.0).unwrap()), | ||
| rule: FillRule::Winding, | ||
| transform: Transform::from_translate(20.0, 0.0), | ||
| }; | ||
| c.place(child, Transform::from_translate(15.0, 0.0), 1.0, Blend::Normal, Some(clip)); | ||
| let pm = c.into_pixmap(); | ||
| let alpha = |x| pm.pixel(x, 10).map(|p| p.alpha()); | ||
| assert_eq!(alpha(22), Some(255), "the child inside the clip"); | ||
| assert_eq!(alpha(17), Some(0), "the child outside the clip"); | ||
| assert_eq!(alpha(27), Some(0), "the clip past the child"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn a_label_keeps_its_halo_as_a_shape_and_its_text_once() { | ||
| let label = crate::PlacedLabel { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.