Skip to content

Conversation

LaurenzV
Copy link
Contributor

@LaurenzV LaurenzV commented Oct 1, 2025

The motivation for this is two-fold:

  1. Currently, the only way to draw an image is by drawing a rectangle with a pattern fill. If you know how to do it, you know it, but this is probably not the most intuitive way (as can be seen in [vello_cpu] How to draw pixmap on a pixmap? #1130). Because of this, I think it's a good idea to add an explicit draw_pixmap method that can be called by the user, which should be much more clear.

  2. Currently, there is the problem that we have to define an extend for images, which makes sense for patterns but not necessarily for just drawing a single image. For example, I encountered the situation where when drawing a very small bitmap glyph using bilinear/biubic interpolation, it will basically look like a black block, because when sampling pixels outside we will apply an extend instead of sampling a transparent pixel, which would make more sense:

image

Because of this, when drawing an image we add a new mode that applies no extend at all and samples transparent pixels when going oob. This makes the letter a look nicer (the V looks a bit funky for different reasons):
image

This does have some impact on performance when rendering normal patterns (left is before, right after), but nothing that I would consider very too serious. The other option would be to introduce generic parameters, but that would make our already very generics-heavy code even more heavy, so I'd like to avoid that.

image

@LaurenzV LaurenzV force-pushed the laurenz/draw_pixmap branch 4 times, most recently from 80fc8a1 to 29cae2a Compare October 2, 2025 15:29
@LaurenzV LaurenzV force-pushed the laurenz/draw_pixmap branch from 29cae2a to 08925d0 Compare October 2, 2025 15:37
@LaurenzV
Copy link
Contributor Author

LaurenzV commented Oct 2, 2025

Hmmm, I'm not actually sure now whether this is the intended way.... I will mark this as draft for now.

@LaurenzV LaurenzV marked this pull request as draft October 2, 2025 16:48
/// The advance in image coordinates for one step in the y direction.
pub y_advance: Vec2,
/// Whether the extends in `ImageSampler` should be ignored.
pub ignore_extend: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I have a similar task in my backlog 😅 In some cases like the one below, we’d prefer to render transparent pixels instead of using Extend::Pad. I think the more appropriate solution would be to add another extend Transparent here. What do you think?

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, but unfortunately we just cut a new peniko release yesterday. :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! We can include it in one of the next releases.

@LaurenzV
Copy link
Contributor Author

LaurenzV commented Oct 8, 2025

WIll split this PR into two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants