-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintenance 2024 #172
Draft
samizdatco
wants to merge
161
commits into
main
Choose a base branch
from
maintenance-2024
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Maintenance 2024 #172
Conversation
This file contains 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
samizdatco
force-pushed
the
maintenance-2024
branch
from
October 24, 2024 17:15
9319b5a
to
d6189d6
Compare
- use vendored version of skulpin
- upgrade ash to match version vulkano is using
- the error message/device info is accessible through the status() accessor
- ported to use the deprecated `run_on_demand` event loop - should refactor to use `run_app_on_demand`
- in order to let the App make callback connections to the js runtime, the `roundtrip` function is passed in as a closure after capturing the `cx` from the initial launch() call - removed a bunch of UserEvent wrapping; now just passing CanvasEvents to the windows as-is
- moved `App` & `Cadence` into their own module and separated `Window` and `WIndowManager`
- use the instance passed as args to lifecycle methods
- remove the unsafe Send impl from VulkanRenderer (which gets created on the main thread before being sent to the window thread)
- a thread wakes up every 2 seconds and drops any contexts that haven't rendered in that time
- only performs the supported() check once and discards the test context when done
it became unnecessary for Metal setup at some point
- switch `get_surface` to `with_surface` closure to include cleanup
- also drop the old `get_surface`→`surface` RenderingEngine→Engine methods
- the supported sampling rates are reported in the `canvas.engine.samples` array - both engines' `with_surface` handlers now take a custom msaa arg to override the default (4x)
- parsing and passing them individually was getting ungainly
- now runs once per second rather than after every surface
- omitting the option defaults to 4x MSAA if available - setting it to a positive power of 2 (that's supported by the GPU) will choose 2x, 4x, 8x, etc. MSAA when rasterizing - setting it to 0 or `false` will use shader-based antialiasing techniques (typically with higher quality results than when MSAA is enabled but can get *very* slow for more complex images) - note that the gpu drivers tend to list "1x" as a valid option but it's unclear how/whether that differs from `0` in practice
- otherwise it will mean the (rayon) thread count reported in canvas.engine is off by one
- e.g., `brightness(2)` and `brightness(200%)` are now equivalent
* Added functionality to load images from decoded pixel buffers * sync up with maintenance-2024 changes * add settings arg to ImageData constructor - colorType can be 'rgba' (the default), 'rgb', 'bgra', or 'argb' - colorSpace can currently only be 'srgb' but 'display-p3' support is on the todo list * add `loadImageData` helper - uses a common implementation with the Image.src loader (thus the weird callback design of `fetchData` to fulfill Image's expectations of sync loads for local files) * Added functionality to export canvas as raw pixel data, skipping encoding step. Adds support for "raw" format to existing export options and adds specific `Canvas#toRaw()` method. * sync up with maintenance-2024 * support `colorType` arg in get/put/createImageData methods - dropped the alias from 'argb' to the odd-seeming 16 bit color type (is it actually commonly used though?) * support `colorType` arg in saveAs/toBuffer * allow ImageData to be passed to drawImage * test ImageData initialization * consolidate ImageData typedefs * test the `this` mapping in Image.onload * only perform null-check once * allow ImageData to be passed to `createPattern` * add `.bytesPerPixel` property to ImageData * note that BMP is not being used as an encoding - it's just so we can use the common parts of the encoded-image path * make Image into a proper EventEmitter - the `.onload` and `.onerror` properties are still supported, but `on`, `once`, and `off` now work too - moved the fetchData routine back into Image as a static method so it can still be used by loadImageData * use async i/o for loading local image files - previously img.src='./local/file/path' would synchronously load the data and the image would immediately be ready for use - now, even local files should wait for img.decode() or img.on('load') to resolve first * set `complete` even if load failed - the real way to judge success is complete==true *and* non-zero width/height * genericize return type for with_surface - it now just uses the closure's Result type * use cpu renderer for filter test - since the output differs, use the version that will be stable across CI runs * nudge the test point to avoid cpu/gpu antialiasing differences * use gpu for `getImageData` and cache bitmap between calls - significantly faster for single `get`s and absurdly fast for subsequent gets of the same canvas content (since it's using a cached bitmap that's invalidated on the next drawing command) - required adding a reference to the ctx's Canvas to the call so it can access the current gpu::RenderingEngine mode (and initialize it if needed) * drop unnecessary imports & muts * update `with_surface` signatures for Vulkan and dummy engine * fix ImageData constructor's arg parsing * update changelog * include `colorType` arg when passing export opts * allow ImageData to be initialized from Image * update Image & ImageData docs * update changelog * update class ToC * add `colorType` layout test --------- Co-authored-by: ggolda <[email protected]> Co-authored-by: Christian Swinehart <[email protected]> Co-authored-by: Max Paperno <[email protected]>
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.
New Features
Website
Imagery
drawImage()
(thanks to @mpaperno Support SVG image rendering #180). Note that Images loaded from SVG files that don't have awidth
andheight
set on their root<svg>
element have some quirks as of this release:width
andheight
will both (misleadingly) report to be150
.drawImage()
without size arguments, the SVG will be scaled to a size that fits within the Canvas's current bounds (using an approach akin to CSS'sobject-fit: contain
).drawImage()
, the ‘crop’ arguments (sx
,sy
,sWidth
, &sHeight
) will correspond to this scaled-to-fit size, not the Image's reportedwidth
&height
.toBuffer()
andsaveAs()
methods now support"raw"
as a format name and/or file extension, causing them to return non-encoded pixel data (by default in an"rgba"
layout like a standard ImageData buffer)colorType
argument to specify alternative pixel data layouts (e.g.,"rgb"
or"bgra"
)new ImageData()
constructor, the optional settings arg now allows you to select thecolorType
for the buffer's pixels.Typography
outlineText()
method now takes an optionalwidth
argument and supports all the context's typographic settings (e.g.,.font
,.fontVariant
,.textWrap
,.textTracking
, etc.).fontStretch
property. Note that stretch values included in the.font
string will overwrite the current.fontStretch
setting (or will reset it tonormal
if omitted).serif
,sans-serif
,monospace
, andsystem-ui
families are currently supported..textDecoration
property..letterSpacing
and.wordSpacing
properties.GUI
resizable
property which can be set tofalse
to prevent the window from being manually resized or maximized (contributed by @nornagon add window.resizable property #124).input
event now reports the composed character, not the individual keystrokes.Rendering
engine
property which describes whether the CPU or GPU is being used, which graphics device was selected, and what (if any) error prevented it from being initialized..transform
and.setTransform
methods on Context, Path2D, and CanvasPattern objects can now take their arguments in additional formats. They can now be passed a DOMMatrix object or a string with a list of transformation operations compatible with the CSStransform
property. The DOMMatrix constructor also supports these strings as well as plain, matrix-like objects with numeric attributes nameda
,b
,c
,d
,e
, &f
(contributed by @mpaperno Allow.transform()
to take DOMMatrix or CSStransform
strings as arguments #178).SKIA_CANVAS_THREADS
environment variableBreaking Changes
src
property has been set to a local path. As a result, it's now necessary toawait img.decode()
or set up an.on("load", …)
handler before drawing it—even when thesrc
is non-remote.keyup
/keydown
andinput
event listeners now has fields and values consistent with browser behavior. In particular,code
is now a name (e.g.,ShiftLeft
orKeyS
) rather than a numeric scancode,key
is a straightforward label for the key (e.g.,Shift
ors
) and the newlocation
field provides a numeric description of which variant of a key was pressed..async
property has been removed. See the v0.9.28 release notes for details..textTracking
property has been removed in favor of the new.letterSpacing
propertyBugfixes
vulkano
crate and makes better selections among devices present (previously it was just using the first result, which is not always optimal).this
to point to the new image (contributed by @mpaperno & @ForkKILLET).fullscreen
set totrue
now takes effect immediately (previously it was failing silently)canvas::draw_path()
when trying to draw a path with an invalid transform matrix. #175).on("draw")
handlers no longer become unresponsive on macOS 14+ after being fully occluded by other windowsPath2D::add_ellipse()
where trying to draw a complete circle from certain angle combinations produced nothing. #176)drawCanvas()
method now clips to the specified crop size (contributed by @mpaperno Fix clipping not being applied to the source indrawCanvas()
9-argument version #179)isPointInPath
andisPointInStroke
now works correctly when called with a Path2D object as the first argumentMisc. Improvements
roundRect
method (contributed by @sandy85625 & @santilema)winit
and replaced the end-of-life’d skulpin-based Vulkan renderer with a new implementation using Vulkano for window-drawing on Windows and Linux..gpu
property tofalse
immediately after creation will prevent any GPU-related resource acquisition from occurring (though rendering speed will be predictably slower).msaa
export argument. If omitted, defaults to 4x MSAA.import {Image} from "skia-canvs"
) when used as an ES Module.