Skip to content

Conversation

@nical
Copy link
Contributor

@nical nical commented Dec 27, 2025

This PR moves the corresponding type from WebRender and adapts it to euclid's convention.

Scale-offset transformations are common enough for a browser engine or UI toolkit that it is worth having a special case for. In addition to requiring fewer operations than Transform2D, ScaleOffset2D fits in only 4 scalars, and is guaranteed to be able to transform boxes and rectangles exactly (Transform2D can only produce conservative outer boxes).

@mrobinson
Copy link
Member

Nice to see this! In Servo we also reuse WebRender's FastTransform, which might also be a useful abstraction for euclid as well: https://github.com/servo/webrender/blob/e1c924ebad9ffdfe8c8c606aba77eb3f888c396a/webrender/src/util.rs#L1007

@nical
Copy link
Contributor Author

nical commented Jan 8, 2026

Added #547 to workaround the CI failure that comes from upstream.

In Servo we also reuse WebRender's FastTransform, which might also be a useful abstraction for euclid as well

I really want to keep euclid super-duper API-stable because of how much churn breaking changes create downstream. I feel like ScaleOffsetTransform2D is pretty safe to put in the API, but it's less clear for FastTransform in my opinion (there is a fair amount of nuance about how it could be implemented). Maybe we could add a separate "euclid_extras" crate where we put code that we would like to share or experiment with, but without the stability guarantees of the main crate?

@mrobinson
Copy link
Member

Exposing a new crate seems fine, or perhaps we can just add this type to the webrender API upstream. Both are fine for the purposes of Servo.

@nical nical enabled auto-merge January 8, 2026 13:54
@nical nical added this pull request to the merge queue Jan 8, 2026
Merged via the queue into servo:main with commit 2836bea Jan 8, 2026
20 checks passed
@nical nical deleted the scaleoffset branch January 8, 2026 15:14
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