mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
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: https://github.com/sagudev/servo/actions/runs/14760658522 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
8c318af307
commit
be0f4470c7
5 changed files with 876 additions and 647 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
mod backend;
|
||||
mod raqote_backend;
|
||||
|
||||
pub mod canvas_data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue