-
Notifications
You must be signed in to change notification settings - Fork 143
Canvas test #1468
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
Draft
CedricGuillemet
wants to merge
48
commits into
master
Choose a base branch
from
CanvasTest
base: master
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
Canvas test #1468
Conversation
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
Adds implementation for canvas `transform` function https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform
Add `fontBoundingBoxAscent` and `fontBoundingBoxDescent` to textMetrics
- Adds bindings for setting and getting `letterSpacing` https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/letterSpacing - Adds implementation for setter and getter
…nto CanvasTest
Co-authored-by: Ryan Tremblay <[email protected]>
- `lineCap` https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap - `lineJoin` https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin - `miterLimit` https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit --------- Co-authored-by: Cedric Guillemet <[email protected]>
Gradient / color stop glue code and small example. 
… into CanvasTest # Conflicts: # Polyfills/Canvas/Source/Context.cpp
- https://developer.mozilla.org/en-US/docs/Web/API/Path2D Adds nanosvg.h for SVG path parsing. Known missing functionality: 1. `addPath` doesn't accept DOMMatrix transform 2. `roundRect` doesn't accept CSS-style radii array 3. `ellipse` doesn't handle clockwise Called from BabylonJS/Babylon.js#16221
…nto CanvasTest
- https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getTransform - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform - https://developer.mozilla.org/en-US/docs/Web/API/Path2D/addPath#transform usage: ``` // Path 2D let path = new _native.Path2D(); let path2 = new _native.Path2D("M 10,30 A 20, 20 0, 0, 1 50, 30 A 20, 20 0, 0, 1 90, 30 Q 90, 60 50, 90 Q 10, 60 10, 30 z"); path.addPath(path2, { a: 1, b: 0, c: 0, d: 1, e: 400, f: 0 }); // shift right 400 context.stroke(path); ```
…nto CanvasTest
… into CanvasTest
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect Known Issues: - clipping round rect does not have rounded corners Co-authored-by: Cedric Guillemet <[email protected]>
Small PR just so later PRs that require modifying nanovg have proper diffs
- allow NVGPaint to have 2 images (onlye used when text is mixed with gradient) - shader update 
I'll need someone to generate the HSSL shader for me since I'm on Mac. Currently doesn't support blurred text but can add that in a future PR. --------- Co-authored-by: Cedric Guillemet <[email protected]>
- Adds example Path2D usage in experience.js. - Makes Path2D work with .fill as well  --------- Co-authored-by: Cedric Guillemet <[email protected]>
Replaces #1488 - Fix wrongly named `CreateInstance` with `Initialize` - Canvas/Context unit test - Implement `GetCanvas` - Fix parameters and objectReference between Canvas and Context - Keep and return the object reference created with `getContext` - Install specified CMake version for Windows platform (see #1492 ) - Update to Babylon.js 8.0 --------- Co-authored-by: Sergio R. Z. Masson <[email protected]>
…nto CanvasTest # Conflicts: # Polyfills/Canvas/Source/Canvas.cpp
- Supports passing Path2D to Path2D constructor - Handles >1 args for context.fill - As [matanui159](https://github.com/BabylonJS/BabylonNative/issues?q=is%3Apr%20is%3Aopen%20author%3Amatanui159), as pointed out, `SetHeight`, `SetWidth` clears canvas on browser even if width/height doesn't change. We re-use framebuffer but clear it in this scenario.
This improves the handling of the "font" field on the context to properly parse out weight/style/size. Currently weight and style are unused since the font map only takes the family name into consideration.
- Adds basic framebuffer manager `FrameBufferPool`, enabling multi-pass composition in `nanovg_filterstack` - Wires up `context.filter` https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter - Incomplete implementation of `blur()` https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/blur This PR takes over @CedricGuillemet's #1477 Comments from CedricGuillemet#9 addressed before opening this for review. Added comments for the ones which I haven't addressed. RenderDoc shows filterstack correctly swapping between render targets for a 3-iterations (6 pass) blur.:  Will need to do abit of digging on weights to match how it looks on browser. Applying filter blur to couple of items in experience.js:  Also, on Babylon.js side, have raised a PR adding `filter` to context. BabylonJS/Babylon.js#16424 --------- Co-authored-by: Cedric Guillemet <[email protected]>
Fixes: - Depth stencil missing. Not optional in nanovg - Unnecessary texture creation. This was caused by a bad merge resolution ([link](50697ff)) - Missing `m_available` increment when framebuffer released caused infinite framebuffer creation The various warnings about missing stencil bugger and failed to allocate framebuffer are now gone.
MDN: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect Implements CSS-style radius array argument 
MDN: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/direction MDN: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getTransform - Context direction is incomplete. Further investigation is needed on a solution to deal with ligatures (eg. stb_freetype + harfbuzz?) - Context getTransform() now returns missing DOMMatrix properties
…nto CanvasTest # Conflicts: # Polyfills/Canvas/Source/Canvas.cpp # Polyfills/Canvas/Source/Canvas.h # Polyfills/Canvas/Source/Context.cpp # Polyfills/Canvas/Source/Context.h
W3: https://www.w3.org/TR/SVG11/filters.html#feGaussianBlurElement - 13-tap gaussian blur for s < 2 - 3-pass box blur for s >= 2 Notes: - gaussian weights no longer hardcoded. we can optimize by caching weights. - box blur handles even vs odd kernel as per W3. sanity limit of 1000px. - edge sampling set to mirror. this avoids artifacts when blurring close to edge. Testing with even-case box blur d=8: `ctx.filter='blur(4px)'` 
MDN: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect Adds support for single DOMPoint argument in roundRect (Context, Path2D) Looks like `nvgRoundedRectVarying` already implemented seperate x/y radius, so just needed to add extra args 
@ryantrem found that when we load in a replacement font buffer.. the old buffer passed to nvgCreateFontMem is freed and can get corrupted To solve this, we've made LoadTTFAsync effectively synchronous and don't allow loading in a duplicate font. We can consider future work to support safely updating existing fonts
small followup to #1516
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.
Draft PR for build/testing validation