Repository navigation
Conversation
Parse background, its longhands and <image> lists (linear, radial and conic gradients, colour hints, interpolation methods, url) once in mason-core on cssparser and cssparser-color. Longhands are kept as lists and cycled per layer; invalid values are rejected whole. Parsed layers are flattened into a background buffer whose layout is generated from background-buffer.schema for Rust, Kotlin, Swift, C++ and TS. mason-c exposes set, get, buffer and detached image parsing.
Background, its longhands, mask-image and border-image gradients are parsed in mason-core through new JNI calls; each setter returns the background buffer, decoded once into BackgroundLayer. Gradients are typed, so shader rebuilds no longer reparse stop strings. Colour hints and currentColor stops now render. Longhands set before the shorthand are kept, as core applies the shorthand last.
background, its longhands, mask-image and border-image sources are parsed in mason-core through the C API and decoded from the background buffer into BackgroundLayer, on iOS and macOS. Gradients are typed, so redraws no longer reparse stop strings. Colour hints, currentColor stops and every CSS colour syntax now render. Axis-aligned angles use exact directions on iOS and Android.
A hint at the midpoint is a linear blend and one past either stop is a hard edge, so neither needs samples. Other hints take samples in proportion to the segment's drawn length, up to 16.
Linux sends background and its longhands to mason-core through mason_gtk_css_set_background and paints the parsed layers directly, resolving gradient geometry against the drawn rect. Colour hints, currentColor, radial lengths and size keywords now render. Fix the corner keyword angle in linear_points, which used atan(h/w) instead of atan(w/h) and skewed to <corner> gradients on non-square boxes.
Positions, sizes and repeats dispatch on one token instead of trying alternatives, and keywords and units match without allocating a lowercase copy. Parsing is 20-50% faster across the benchmark set.
Windows sends background and its longhands to mason-core through Css.SetBackground and decodes the background buffer into the CssMask layers it already paints. Colour hints, currentColor stops, radial lengths and ellipse size keywords, and pixel offsets on gradient centres now render. The TS background parsing and JSON encoding for Windows and Linux are removed. Add setAppFolder for the folder ~/ in image urls names, for hosts that move it such as the Preview app; Windows and Linux follow core's app folder by default, Android and iOS take the override natively.
Node.Style made a new Style on every read, so each JS access got a new COM identity and the runtime built a new wrapper. Reading view.Style drops from 0.4-1 us to 0.2 us.
Mason.Create* and the child getters return the live wrapper for a node when there is one, keyed by engine and node id through a weak registry, so JS gets one object per node and the runtime reuses its wrapper. mason-c gains mason_node_id for the key.
The app folder comes from setAppFolder through mason_gtk_css_set_app_folder, and url layers resolve ~/ against it.
Mask longhands encode into the background buffer layout with mode and composite per layer. clip-path gets its own buffer: shape, reference box, lengths with units, polygon points and path() as absolute commands.
SetMask takes the mask layer longhands and clip-path as written. The TS mask and clip-path encoders, the unused background layer encoders and the path command encoder are removed.
…ayer path SetBackgroundLayers and the JSON mask layer and clip-path decoding have no callers since backgrounds, masks and clip-path moved to mason-core.
This branch has not been deployed
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.
Builds on #246. Until that merges, this diff includes it; the commits from
feat(core): parse mask layers and clip-path in mason-coreonward are this PR.mask-*andclip-pathare now parsed once, in mason-core, on every platform. Each platform keeps its drawing code and its pseudo-state handling. When a resolved value changes, the platform calls the parser and decodes typed results.Core
MASK_MODEandCOMPOSITEadded to each layer andNO_CLIPadded to the box codes.clip-pathhas its own buffer (clip-path-buffer.schema): shape, reference box, fill rule, lengths with their units, polygon points, andpath()as absolute commands (arcs become cubics).mason_css_parse_mask,mason_css_parse_clip_path. JNI:Style.nativeParseMask,Style.nativeParseClipPath. Unset longhands cross as null.Platforms
Css.SetMasktakes the mask longhands andclip-pathas written. The TS mask and clip-path encoders and the path command encoder are removed. So are the unusedSetBackgroundLayersmethod and the JSON layer decoding.mask-borderandborder-imageare unchanged.Behaviour
mask-imagelist means no mask; an invalid longhand list falls back to its initial value. Previously each platform did something different.closest-cornerandfarthest-cornerradii incircle()andellipse()(CSS Shapes 2) now work everywhere. Previously only Android supported them.circle(iscircle().Performance
Release builds, microseconds per call, from the value strings to typed results.
linear-gradientmaskcircle()polygon()inset(... round ...)Css.SetMask, on a Windows x64 laptop.Tests
ClipPathParsingTest,MaskParsingTest,NineSliceTest.ClipPathTestsandMaskTestsare updated.