-
Notifications
You must be signed in to change notification settings - Fork 719
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
feat: add a SkiaVisual that allows allows external use of SkiaSharp #15212
Conversation
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-15212/index.html |
e998a91
to
23b7fb1
Compare
Invalidate(session.Surface.Canvas); | ||
} | ||
|
||
protected abstract void Invalidate(SKCanvas canvas); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramezgerges This method should be called Render
. An Invalidate
is also needed as a way for a visual to ask for a render, though there may be a Compositor
way of doing so.
By default, the visual does not have any size specified, which means that we'll need to explain how to use it as well.
Multiple things:
- Can you add runtime tests?
- Can you add a new documentation page?
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-15212/index.html |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-15212/index.html |
@ramezgerges Thank you and can I ask any update ? |
@lindexi we're still working on it at this time, there's a bit of work that's involving the reference API that we have not resolved yet. |
{ | ||
internal override void Draw(in DrawingSession session) | ||
{ | ||
Invalidate(session.Surface.Canvas); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalidate(session.Surface.Canvas); | |
Invalidate(session.Canvas); |
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-15212/index.html |
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-15212/index.html |
|
||
# SkiaVisual | ||
|
||
A `SkiaVisual` is a abstract Visual that provides Uno applications the ability to utilize SkiaSharp to draw directly on the Skia canvas that is used internally by Uno to draw the window. To use `SkiaVisual`, create a subclass of `SkiaVisual` and override the `RenderOverride` method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A `SkiaVisual` is a abstract Visual that provides Uno applications the ability to utilize SkiaSharp to draw directly on the Skia canvas that is used internally by Uno to draw the window. To use `SkiaVisual`, create a subclass of `SkiaVisual` and override the `RenderOverride` method. | |
A `SkiaVisual` is an abstract `Visual` that provides Uno applications the ability to utilize SkiaSharp to draw directly on the Skia canvas that is used internally by Uno to draw the window. To use `SkiaVisual`, create a subclass of `SkiaVisual` and override the `RenderOverride` method. |
private bool ApplyFlowDirection() | ||
{ | ||
var oldMatrix = _skiaVisual.TransformMatrix; | ||
if (FlowDirection == FlowDirection.RightToLeft && !MirroredWhenRightToLeft) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, mirroring happen when FlowDirection is the opposite of the parent, which is something we're supposed to already do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is supposed to disable this behaviour, since most likely, the user will want to keep the drawing the same regardless of RTL (like an image).
/// By default, SKCanvasElement will have the origin at the top-left of the drawing area with the normal directions increasing down and right. | ||
/// If MirroredWhenRightToLeft is true, the drawing will be horizontally reflected when <see cref="SKCanvasElement.FlowDirection"/> is <see cref="FlowDirection.RightToLeft"/>. | ||
/// </summary> | ||
public bool MirroredWhenRightToLeft |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we really need this API. I tend to avoid adding public APIs without enough motivation. We could probably postpone it unless it's clear that we need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this is something that the user can do by hand, but it might be common enough and annoying enough to get right that we should provide it ourselves. @jeromelaban thoughts?
closing in favor of #16621. |
GitHub Issue (If applicable): closes #15166
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Run
results.Other information
Internal Issue (If applicable):