Commit graph

4 commits

Author SHA1 Message Date
sagudev
fdb9c0af12
canvas: Move generic implementations into GenericPathBuilder trait (#36999)
There is no reason to require this impls, because we already have
written them in generic way.

Testing: Just refactoring, but there are WPT tests

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-05-14 03:51:56 +00:00
sagudev
5cdb0865ba
canvas: rename snapshot(_data) to surface() -> SourceSurface/bytes() -> AsRef<[u8]> (#36793)
`surface()` returns `SourceSurface` which is/was meant as optimization
when passing from canvas to canvas (in vello that would be wgpu texture;
but raquote does not really have this) while bytes returns something
that must impl AsRef<[u8]> (this is more generic then `&[u8]` as it
allows us to have type with drop impl - wgpu's BufferView).

Testing: This is just refactoring (protected by rust), but there are WPT
tests.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-05-01 14:18:56 +00:00
sagudev
d1f7a90619
canvas: Move CompositionOrBlending and ellipse() from RaqoteBackend to Backend (#36790)
Small fixes of abstraction.

We do not need to generalize `CompositionOrBlending`, because it's from
canvas_traits.
Ellipse impl that uses arc is not backend specific, so it serves as good
trait default.

Reviewable per commit.


Testing: Only refactoring, but there are WPT tests

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-05-01 09:57:20 +00:00
sagudev
be0f4470c7
Use backend trait with associated types for 2d canvas backends abstraction (#36783)
Current abstraction was leaky and very hard to understand/impl because
it was so intervened with actual implementation.

Now we generalize both `CanvasState` and `CanvasData` over `B: Beckend`,
meaning that every type/method must be part of trait interface (that
lives in `beckend.rs`). Using associated trait types instead of `Box<dyn
>` allows us too remove the need for wrapper types (and `to_raquote()`
methods) as we can implement helper traits on (foreign) raquote types.
The only time we actually do dispatch (by enum) is at `Canvas` methods.

Implementation now only need to implement all backend traits and
helpers. I tried to restrain myself from actually cleaning abstraction
(where possible), to keep this change as much mechanical as possible,
but we should absolutely do that as a follow up.

Testing: Rust as we only do refactor, but there are also WPT tests

try run: 1476065852

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-05-01 04:16:23 +00:00