feat(canvas): replace Canvas 2D with a native recording-backed architecture - #414
Open
BibekPathak wants to merge 11 commits into
Open
feat(canvas): replace Canvas 2D with a native recording-backed architecture#414BibekPathak wants to merge 11 commits into
BibekPathak wants to merge 11 commits into
Conversation
Contributor
Author
|
Hey @ldm0 , look at this!! |
ldm0
self-requested a review
September 7, 2026 13:04
ldm0
reviewed
Sep 7, 2026
| apply_global_alpha(rgba, context_global_alpha(scope, context)) | ||
| } | ||
|
|
||
| fn apply_global_alpha(rgba: [u8; 4], global_alpha: f64) -> [u8; 4] { |
Member
There was a problem hiding this comment.
Apply globalAlpha only to the alpha channel of this straight-RGBA color. Scaling RGB here causes Vello to premultiply already-darkened channels. A red path with globalAlpha = 0.5 reads back as [128,0,0,128], whereas its straight RGB should remain red, approximately [255,0,0,128]. This affects fill, stroke, and strokeRect. Please add a regression that checks RGB as well as alpha.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deliver the complete Chromium-style Canvas 2D re-architecture for Moli,
replacing the scattered pixel-ownership model with a native, recording-backed
core in moli-canvas. This is the full M0–M6 migration: baseline, geometry
extraction, surface/backend, single-owner integration, ordered recording,
observation/invalidation, and removal of the old implementation.
Crate architecture
current-path geometry, ordered recording, persistent premultiplied-RGBA8
surface, region readback, and encoding/export helpers. It depends only on
AnyRender/Vello-CPU/peniko/kurbo/mol-image; it never touches V8, the DOM,
layout, or page paint.
invalidation, page-image publication, lifecycle). moli-paint responsibility
for page painting is unchanged.
Milestones
routing/ownership inventory used as the final-review checklist.
adapter reduced.
Vello CPU backend, cached straight-alpha snapshot, region readback,
reset/resize) with native surface/backend tests.
Uint8ClampedArray backing store; GC/isolation reclamation, resize, and all
115 canvas JS regressions pass.
rect fill/stroke, clear, drawImage, text, putImageData) with frozen inputs,
batching contiguous scene ops into one backend submission while preserving
order through direct-step segments for clears/blits/writes. Integrated into
the renderer; dead rasterize/composite/color helpers removed.
invalidation on every write path, and VisualResourceGeneration bumped on
every draw record (not just at flush) so screenshots/screencast see current
content and geometry-only ops neither flush nor invalidate.
four direct ops by compositing in premultiplied space (O(operation area) not
O(canvas area)); delete CanvasSurface::with_straight_pixels_mut; verify
same-size reset; declare STUBs out of scope.
Correctness hardening
replacement) instead of an accidental source-over composite, matching the
spec even for translucent ImageData over existing content.
recorded bytes (including pinned source images) exceed the limit, mirroring
Chromium's FlushIfRecordingLimitExceeded.
Checks
the moli-canvas native suite (45 tests) pass.