aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas
Commit message (Collapse)AuthorAgeFilesLines
* Change canvas/context/snapshot size from u64 -> u32 (#36827)Sam K3 days2-12/+12
| | | | | | | | | | | | | | | | | | | | | Replaces uses of `euclid::default::Size2D<u64>` with `euclid::default::Size2D<u32>` for the canvas/context/snapshot. This PR includes changes to the following components: - canvas - pixels - script - script_bindings - shared/canvas - shared/snapshot Testing: https://github.com/hashcatHitman/servo/actions/runs/15426115391 (as of 892edc0048dfad28342e5e2ff247c963eb91ed11) Fixes: #36706 --------- Signed-off-by: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com>
* canvas: ensure there is a subpath in `PathBuilderRef` (#37251)sagudev6 days2-1/+33
| | | | | | | | | | | | | | | | This is also required by spec: https://html.spec.whatwg.org/multipage/canvas.html#ensure-there-is-a-subpath and if we not ensure it vello will trigger debug asserts. Enforcing this at `PathBuilderRef` is the lowest possible level that avoids misuse (and avoids IPC messages if we were to do this in content process) while still keeping it from backend. Testing: There are tests in WPT Split of https://github.com/servo/servo/pull/36821 try run: https://github.com/sagudev/servo/actions/runs/15449044694 --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* canvas: Use `Cow<[u8]>` for bytes() getter (#37249)sagudev6 days3-6/+9
| | | | | | | | | | | | I fell into trap of over-generalization in https://github.com/servo/servo/pull/36793, but https://github.com/servo/servo/pull/36821 showed `Cow<[u8]>` is all we need (to reuse existing vec alloc or pass on a slice). Testing: There are WPT tests, but it's just refactor so rust keeps us safe. Split of https://github.com/servo/servo/pull/36821 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* constellation: Wait for canvas thread to shut down before shutting down ↵Martin Robinson11 days1-1/+4
| | | | | | | | | | | | | | system font service (#37182) The canvas thread might need access to the system font service before it shuts down. Ensure that it finishes shutting down before triggering the shutdown of the system font service. This should avoid issues where canvas tries to access fonts right before shutting down. Fixes: #36849. Testing: Since this fixes a flaky crash on shutdown, there isn't a good way to write a test for it. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Removing unused dependencies in crates. (#37096)Narfinger2025-05-231-1/+0
| | | | | | | | Removed unused dependencies in various crates using cargo-machete, grep and cargo-udeps. Testing: The CI tests if any dependencies were used that are removed. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
* canvas: Move generic implementations into `GenericPathBuilder` trait (#36999)sagudev2025-05-142-48/+29
| | | | | | | | | | 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>
* canvas: rename `snapshot(_data)` to `surface() -> SourceSurface`/`bytes() -> ↵sagudev2025-05-013-11/+13
| | | | | | | | | | | | | | 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>
* canvas: Move `CompositionOrBlending` and `ellipse()` from `RaqoteBackend` to ↵sagudev2025-05-013-66/+58
| | | | | | | | | | | | | | | | | | | `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>
* Use backend trait with associated types for 2d canvas backends abstraction ↵sagudev2025-05-015-644/+873
| | | | | | | | | | | | | | | | | | | | | | | | (#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>
* Split webgl into separate crate (#36718)sagudev2025-04-307-4020/+0
| | | | | | | | | | canvas crate was home for both webgl and 2dcanvas impl, but it makes more sense to separate these two, by splitting webgl into standalone crate (like we already have for webgpu). Testing: Rust for fearless refactoring (but there are WPT tests just in case) Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* canvas: Apply large size limitations (#36445)Andrei Volykhin2025-04-291-1/+8
| | | | | | | | | | | | | | | | | | | | | To prevent any potential crash/OOM issues with "canvas" element from "rogue" applications let's apply large size limitations for context canvas2d's draw target to Servo (similar approach in Firefox/Chromium - they limits width and height to 32767/65535 pixels). Fixes: #36155, #34117, #30164, #24710 -- - [x] ./mach build -d does not report any errors - [x] ./mach test-tidy does not report any errors - [x] There are tests for these changes tests/wpt/tests/html/canvas/element/canvas-host/2d.canvas.host.size.large.html tests/wpt/tests/html/canvas/offscreen/canvas-host/2d.canvas.host.size.large.html tests/wpt/tests/html/canvas/offscreen/canvas-host/2d.canvas.host.size.large.worker.js Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
* Introduce snapshot concept of canvas (#36119)sagudev2025-04-235-62/+75
| | | | | | | | | | | | | | | | | | Each canvas context returns snapshot instead of just raw bytes. This allows as to hold off conversions (BGRA <-> RGBA, (un)premultiply) to when/if they are actually needed. For example when loading snapshot into webgl we can load both RGBA and BGRA so no conversion is really needed. Currently whole thing is designed to be able to be extend on https://github.com/servo/ipc-channel/pull/356, to make less copies. Hence some commented out code. Fixes #35759 There are tests for these changes in WPT --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* `compositing`: Combine `webrender_traits` and `compositing_traits` (#36372)Martin Robinson2025-04-065-8/+8
| | | | | | | | | | | | | | | These two traits both exposed different parts of the compositing API, but now that the compositor doesn't depend directly on `script` any longer and the `script_traits` crate has been split into the `constellation_traits` crate, this can be finally be cleaned up without causing circular dependencies. In addition, some unit tests for the `IOPCompositor`'s scroll node tree are also moved into `compositing_traits` as well. Testing: This just combines two crates, so no new tests are necessary. Fixes: #35984. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* canvas: Implement line dash setters and getters (#36257)Steven Novaryo2025-04-013-0/+22
| | | | | | | | | | | Implement `setLineDash`, `getLineDash`, and `lineDashOffset` from `CanvasPathDrawingStyles` mixin, according to the spec https://html.spec.whatwg.org/multipage/canvas.html#canvaspathdrawingstyles. Testing: Existing WPT. --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
* Add `Path2D` (#35783)Lukas Lihotzki2025-03-263-69/+255
| | | Signed-off-by: Lukas Lihotzki <lukas@lihotzki.de>
* canvas: Update the image as part of update the rendering (#35996)sagudev2025-03-251-6/+4
| | | | | | | | | | | | | | | | | | | | | | | * Create `update_rendering` in `CanvasState` instead of manually updating in layout Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Mark as dirty and do flushes Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * fixup rebase Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update components/script/dom/htmlcanvaselement.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* Cleanup Stylo dependencies (#36046)Oriol Brufau2025-03-191-1/+1
| | | | | | | | | Now that Stylo considers `servo` as the default feature, Servo doesn't need to specify `features = ["servo"]`. Also use the same crate names as Stylo, rather than renaming them with `package`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Migrate to the 2024 edition (#35755)Simon Wülker2025-03-131-3/+3
| | | | | | | | | | | | | | | | | | | | | | * Migrate to 2024 edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Allow unsafe_op_in_unsafe_fn lint This lint warns by default in the 2024 edition, but is *way* too noisy for servo. We might enable it in the future, but not now. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Compile using the 2024 edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* canvas: Do not update ImageKey during canvas layout (#35719)Samson2025-03-122-22/+19
| | | Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-036-10/+10
| | | | | | | | | | | | | * Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* fonts: Remove the per-FontGroup cached fallback font (#35705)Martin Robinson2025-02-281-1/+1
| | | | | | | | | | | | | | | | | | | Instead of keeping a per-FontGroup cache of the previously used fallback font, cache this value in the caller of `FontGroup::find_by_codepoint`. The problem with caching this value in the `FontGroup` is that it can make one layout different from the next. Still, it is important to cache the value somewhere so that, for instance, Chinese character don't have to continuously walk through the entire fallback list when laying out. The heuristic here is to try to last used font first if the `Script`s match. At the very least this should make one layout consistent with the next. Fixes #35704. Fixes #35697. Fixes #35689. Fixes #35679. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Reuse same `ImageKey` for 2d canvas (#35695)Samson2025-02-271-59/+34
| | | | | this was not possible when original code was written due to wr limitations (image sizes could not be changed) Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Update to rust 1.85 (#35628)Simon Wülker2025-02-242-21/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | * Update to rust 1.85 This is needed for cargo-deny Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Upgrade crown Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Clippy fixes Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Re-upgrade cargo-deny to 0.18 Keeping it locked to 0.18 just in case they update their required rustc version again Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Use surfman with glow bindings (take II) (#35422)Samson2025-02-132-33/+21
| | | | | | | | | | | | | | | * Reapply "Use surfman with glow bindings (#34328)" (#35402) This reverts commit 0fed99590a9377d8be071e457ecb1b3284f9ef27. Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * update surfman Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Revert "Use surfman with glow bindings (#34328)" (#35402)Samson2025-02-102-21/+33
| | | | | This reverts commit 503bb10c5b1fafe01ebfb6b320902be2e8671c69. Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* deps: Upgrade to `webrender@0.66` (#35325)Martin Robinson2025-02-071-0/+1
| | | | | | | | | In addition to some small API changes, this downstream version of WebRender no longer depends on a very old version of time. This is the last step toward removing the dependency on `time0.1`. The review for this commit should also include: https://github.com/servo/webrender/commit/9f552bebab81a73e62068c42d94be2f9c0586ce4 Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* fix: bring back connection method to fix WebGL texture error (#35358)Ngo Iok Ui (Wu Yu Wei)2025-02-071-1/+3
| | | | | | | | | | | | | * Bring back connection method to fix texture error Signed-off-by: Wu Yuwei <yuweiwu@pm.me> * Print GL info in log instead Signed-off-by: Wu Yuwei <yuweiwu@pm.me> --------- Signed-off-by: Wu Yuwei <yuweiwu@pm.me>
* Update `pixels::unmultiply_inplace` to support RB swap and use it in ↵Euclid Ye2025-02-061-1/+1
| | | | | | | | | | | | | | | canvas_state (#35313) * update unmultiply_inplace to handle reversed RGB Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> * Reuse unmultiply_inplace instead of manual compute; remove unused Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com> --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* Simplify `RenderingContext` trait methods (#35251)Ngo Iok Ui (Wu Yu Wei)2025-02-051-14/+25
| | | | | | | | | | | | | | | | | | There are a few methods are still difficult to implement without the help of surfman. To simplify the trait methods, all methods that return surfman types are removed. They are either handled by embedders themselves or abstract to simpler types that servo components need. The most noticeable changes are: - Methods related to native surface are moved to servo_glue. The embedder should decide when to remove/replace the surface and it's outside of servo's scope. - Methods required by servo media now return exact media types for it. The other major change is sevevral difficult trait methods that are reuiqred by WebGL and Servo media have default implementation. So they can be optional for users to implement. Signed-off-by: Wu Wayne <yuweiwu@pm.me>
* Use surfman with glow bindings (#34328)Samson2025-02-052-33/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use glowing surfman Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Port https://github.com/servo/webxr/pull/255 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * fixups rebase Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * fmt Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update surfman Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Fix stale TODO Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Finish the integration of `webxr` into the Cargo workspace (#35229)Martin Robinson2025-01-311-1/+1
| | | | | | | | | - Run `cargo fmt` on `webxr` and `webxr-api` - Fix clippy warnings in the existing `webxr` code - Integrate the new crates into the workspace - Expose `webxr` via the libservo API rather than requiring embedders to depend on it explicitly. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* feat: Turn `RenderingContext` into a trait (#35052)DK Liao2025-01-241-23/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * feat: turn RenderingContext into a trait Signed-off-by: DK Liao <dklassic@gmail.com> Add comment and handle drop error Signed-off-by: DK Liao <dklassic@gmail.com> Add doc comment Signed-off-by: DK Liao <dklassic@gmail.com> Allow make_current to propagate Error Signed-off-by: DK Liao <dklassic@gmail.com> Fix all make_current occurances Signed-off-by: DK Liao <dklassic@gmail.com> Move back to Rc<dyn RenderingContext> Signed-off-by: DK Liao <dklassic@gmail.com> fix android/ohos Signed-off-by: DK Liao <dklassic@gmail.com> Fix build Signed-off-by: DK Liao <dklassic@gmail.com> fix android/ohos again Signed-off-by: DK Liao <dklassic@gmail.com> * Fix macOS smoke test Signed-off-by: DK Liao <dklassic@gmail.com> * Add comment for create_texture and destroy_texture Signed-off-by: DK Liao <dklassic@gmail.com> * Improve comments written Signed-off-by: DK Liao <dklassic@gmail.com> --------- Signed-off-by: DK Liao <dklassic@gmail.com>
* prefs: Move some `DebugOptions` to `Preferences` and clean up (#34998)Martin Robinson2025-01-173-31/+9
| | | | | | | | | - Move options configuring antialiasing and WebRender shader precache to the `Preferences` to group them with other related WebRender and DOM settings. - Remove the option to disable antialiasing for canvases. This was unused. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* webgl: shutdown webrender before acknowledging Exit message (#34917)Mukilan Thiyagarajan2025-01-091-9/+9
| | | | | Fixes #34847. Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* Add initial support for WebGL 2 BlitFramebuffer (#26389)Josh Matthews2025-01-061-0/+16
| | | | | | Add initial support for the WebGL2 BlitFramebuffer call. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Istvan <istvan.miklos@h-lab.eu>
* Elide lifetimes where possible after rustup (#34824)Martin Robinson2025-01-035-7/+6
| | | | | | | | | The new version of rust allows us to elide some lifetimes and clippy is now complaining about this. This change elides them where possible and removes the clippy exceptions. Fixes #34804. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Upgrade rustc to 1.83 (#34793)Nico Burns2025-01-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Upgrade rustc to 1.83 Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix crown (change copied from linked clippy function) Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix named lifetime lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Bump shell.nix Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix non-local impl warnings Signed-off-by: Nico Burns <nico@nicoburns.com> * Format with 1.83 formatting changes Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix manual non-local impl Signed-off-by: Nico Burns <nico@nicoburns.com> * More fixes for crown Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix tidy Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix needless_return lints Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix doc comment lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix missing wait lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow needless_lifetimes lint Signed-off-by: Nico Burns <nico@nicoburns.com> * more doc comments Signed-off-by: Nico Burns <nico@nicoburns.com> * More needless_returns Signed-off-by: Nico Burns <nico@nicoburns.com> * is_empty lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Fix needless_lifetime lints Signed-off-by: Nico Burns <nico@nicoburns.com> * fix div_ceil lint Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow non-minimal bool Signed-off-by: Nico Burns <nico@nicoburns.com> * Non-local impl in constellation Signed-off-by: Nico Burns <nico@nicoburns.com> * Missing wait in constellation Signed-off-by: Nico Burns <nico@nicoburns.com> * fmt Signed-off-by: Nico Burns <nico@nicoburns.com> * remove useless lints table Signed-off-by: Nico Burns <nico@nicoburns.com> * Fixup comments Signed-off-by: Nico Burns <nico@nicoburns.com> * Allow non-local definition in sandboxing code to simplify feature flagging Signed-off-by: Nico Burns <nico@nicoburns.com> * Remove wait calls and allow zombie_processes lint Signed-off-by: Nico Burns <nico@nicoburns.com> --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
* Remove some unused dependencies (#34355)Jonathan Schwender2024-11-251-3/+0
| | | | | | | | | | | | | | | * Remove unused deps This doesn't seem to remove any deps from the workspace. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * ohos: Remove gaol dependency Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> --------- Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
* Replace `sparkle` with `glow` in `components/canvas` (#33918)Samson2024-11-204-670/+903
| | | | | | | | | | | | | * Replace sparkle with glow in components/canvas Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Replace safe_gl with #34300 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* feat: `webxr` feature flag (#34241)Ngo Iok Ui (Wu Yu Wei)2024-11-135-345/+380
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add webxr feature flag Add webxr feature flag to embedder_traits Add webxr flag to constellation Add webxr flag to compositor Add webxr flag to canvas Turn registry into optional Add webxr flag to servo lib Signed-off-by: Wu Yu Wei <yuweiwu@pm.me> Co-authored-by: august kline <me@augustkline.com> * Cargo fmt Signed-off-by: Wu Yu Wei <yuweiwu@pm.me> * Add missing license Signed-off-by: Wu Yu Wei <yuweiwu@pm.me> * Cargo clippy Signed-off-by: Wu Yu Wei <yuweiwu@pm.me> --------- Signed-off-by: Wu Yu Wei <yuweiwu@pm.me> Co-authored-by: august kline <me@augustkline.com>
* remove sparkle from components/servo (#33910)Samson2024-10-192-14/+13
| | | | | | | | | | | | | * replace sparkle's GlType with canvas_traits's GlType Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * remove sparkle from components/servo Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Update to surfman&webxr without sparkle and use glow 0.15 (#33538)Samson2024-10-182-5/+19
| | | Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Use `ROUTER::add_typed_route` instead of `ROUTER::add_route` everywhere (#33866)Simon Wülker2024-10-181-2/+2
| | | | | | | | | | | | | * Use ROUTER::add_typed_route where possible Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Update webxr, media and ipc-channel Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* clippy: Add safety documentation and clean up unsafe methods (#33748)Martin Robinson2024-10-161-1/+1
| | | | | | | | | | | This change: 1. Adds safety documentation where it was missing. 2. Limits the scope of unsafe code in some cases to where it is actually unsafe. 3. Converts some free functions to associated functions and methods, thereby making them more likely to be called safely. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* fonts: Instantiate system fonts using system font loaders (#33747)Martin Robinson2024-10-102-4/+3
| | | | | | | | | | | | | | | | | | | | | System fonts used to be instantiated using the system font loader and this change restores that behavior. In addition, on macOS and FreeType platforms font data for system fonts is loaded using memory mapping. The benefit is that system font loaders typically are able to cache fonts in system memory (using memory mapping, for instance) and we'd like to load them in a the way most compatible with other applications. On my Linux system, this manages to get the overhead of loading a very large font down from 10ms to approximately 1ms. Subsequent runs show even less overhead. We've measured similar gains on macOS systems. Currently, system font data must be loaded into memory manually for canvas and this is unlikely to change even with a switch to `vello`. The use of explicit memmory mapping should help in this case -- though it probably won't be possible to use this properly on macOS and Windows if we ever want to load fonts from TTCs properly. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* compositor: Create a single cross-process compositor API (#33619) (#33660)Martin Robinson2024-10-092-30/+20
| | | | | | | | | | | | | | | | | | | | | | Instead of exposing many different kinds of messages to the compositor that are routed through the constellation, expose a single message type which can be sent across IPC channels. In addition, this IPC channel and the route to the crossbeam channel with the compositor is created along with the `CompositorProxy`, simplifying what needs to be passed around during pipeline initialization. Previously, some image updates (from video) were sent over IPC with a special serialization routine and some were sent via crossbeam channels (canvas). Now all updates go over the IPC channel `IpcSharedMemory` is used to avoid serialization penalties. This should improve performance and reduce copies for video, but add a memory copy overhead for canvas. This will improve in the future when canvas renders directly into a texture. All-in-all this is a simplification which opens the path toward having a standard compositor API and reduces the number of duplicate messages and proxying that had to happen in libservo. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Revert "compositor: Create a single cross-process compositor API (#33619)" ↵Martin Robinson2024-10-042-20/+30
| | | | | | | | | (#33645) This reverts commit f2f5614ad64927aa82aa8937ae14a6086df49d2b. This is causing intermittent crashes: https://github.com/servo/servo/actions/runs/11167043809/job/31044255019 Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* compositor: Create a single cross-process compositor API (#33619)Martin Robinson2024-10-032-30/+20
| | | | | | | | | | | | | | | | | | | | | | Instead of exposing many different kinds of messages to the compositor that are routed through the constellation, expose a single message type which can be sent across IPC channels. In addition, this IPC channel and the route to the crossbeam channel with the compositor is created along with the `CompositorProxy`, simplifying what needs to be passed around during pipeline initialization. Previously, some image updates (from video) were sent over IPC with a special serialization routine and some were sent via crossbeam channels (canvas). Now all updates go over the IPC channel `IpcSharedMemory` is used to avoid serialization penalties. This should improve performance and reduce copies for video, but add a memory copy overhead for canvas. This will improve in the future when canvas renders directly into a texture. All-in-all this is a simplification which opens the path toward having a standard compositor API and reduces the number of duplicate messages and proxying that had to happen in libservo. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Move unmultiply_inplace to pixels crate (#33553)Taym Haddadi2024-09-271-10/+1
| | | Signed-off-by: Taym <haddadi.taym@gmail.com>
* fonts: Simplify `FontContext` in two ways that affect the unit test (#33541)Martin Robinson2024-09-252-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | This is done by no longer forwarding compositor-bound messages through SystemFontService and making `FontContext` non-generic: - Messages from the `FontContext` to the `Compositor` no longer need to be forwarded through the `SystemFontService`. Instead send these messages directly through the script IPC channel to the `Compositor`. - Instead of adding a mock `SystemFontServiceProxy`, simply implement a mock `SystemFontService` on the other side of an IPC channel in the `font_context` unit test. This allows making `FontContext` non-generic, greatly simplifying the code. The extra complexity moves into the unit test. These changes necessitate adding a new kind of `FontIdentifier`, `FontIdentifier::Mock` due to the fact that local fonts have platform-specific identifiers. This avoids having to pretend like the system font service can have web fonts -- which was always a bit of a hack. These two changes are combined into one PR because they both require extensive and similar chages in the font_context unit test which dependended on the details of both of them. Signed-off-by: Martin Robinson <mrobinson@igalia.com>