Repository navigation
fix(background): rasterize the heropattern tile at its target scale - #282
Closed
LeadcodeDev wants to merge 1 commit into
Closed
LeadcodeDev wants to merge 1 commit into
LeadcodeDev wants to merge 1 commit into
Conversation
tile_w = def.width * cfg.scale is computed at line 581 and used only for the overscan margin; the pixmap at 605-606 is sized from the unscaled def.width/def.height and resvg renders with Transform::default() (identity). The magnification then happens on the raster, via the shader matrix, with SamplingOptions::default() — which I read in skia- safe-0.99.0/src/core/sampling_options.rs:70-80: filter: FilterMode::Nearest, mipmap: MipmapMode::None. So heropattern with scale: 4 on a 1080p frame draws hard 4x4 pixel blocks from a 20x20 source raster, when the source is vector art that resvg could have rendered crisply at any size. The whole point of shipping 87 SVG patterns is lost above scale 1. It is also wasteful below 1: a scale: 0.25 pattern is rasterized at full size and then point- sampled down, aliasing badly. Fix: Size the pixmap at the scaled tile ((def.width * cfg.scale).ceil() x (def.height * cfg.scale).ceil(), clamped to a sane maximum) and pass tiny_skia::Transform::from_scale(cfg.scale, cfg.scale) to resvg::render, then drop the shader matrix so the tile is used 1:1. At minimum, pass SamplingOptions::new(FilterMode::Linear, MipmapMode::Linear) instead of the nearest-neighbour default. Refs #220
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Severity Medium, category quality. Location:
crates/rustmotion/src/engine/render/background.rs:605Impact
tile_w = def.width * cfg.scaleis computed at line 581 and used only for the overscan margin; the pixmap at 605-606 is sized from the unscaleddef.width/def.heightand resvg renders withTransform::default()(identity). The magnification then happens on the raster, via the shader matrix, withSamplingOptions::default()— which I read in skia-safe-0.99.0/src/core/sampling_options.rs:70-80:filter: FilterMode::Nearest, mipmap: MipmapMode::None. Soheropatternwithscale: 4on a 1080p frame draws hard 4x4 pixel blocks from a 20x20 source raster, when the source is vector art that resvg could have rendered crisply at any size. The whole point of shipping 87 SVG patterns is lost above scale 1. It is also wasteful below 1: ascale: 0.25pattern is rasterized at full size and then point-sampled down, aliasing badly.Fix
Size the pixmap at the scaled tile (
(def.width * cfg.scale).ceil()x(def.height * cfg.scale).ceil(), clamped to a sane maximum) and passtiny_skia::Transform::from_scale(cfg.scale, cfg.scale)toresvg::render, then drop the shader matrix so the tile is used 1:1. At minimum, passSamplingOptions::new(FilterMode::Linear, MipmapMode::Linear)instead of the nearest-neighbour default.Evidence the audit read
Part of the September 2026 audit remediation chantier. Refs #220 (RM-22).