-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Reworked the way we are clipping dirty rects with CompositionTarget #14806
Conversation
38da7ff
to
7643bbf
Compare
4e06b06
to
54f0757
Compare
You can test this PR using the following package version. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
@@ -172,7 +172,8 @@ private void UpdateCore() | |||
v.SynchronizeCompositionChildVisuals(); | |||
_dirty.Clear(); | |||
_recalculateChildren.Clear(); | |||
CompositionTarget.Size = _root.ClientSize; | |||
|
|||
CompositionTarget.PixelSize = PixelSize.FromSizeRounded(_root.ClientSize, _root.RenderScaling); |
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.
In some backends, like Browser, we can get this pixel size without doing roundtrip of scaling conversion. See https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/devicePixelContentBoxSize
Possibly, toplevel itself should report its pixel size?
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, but I've decided against touching every single backend including ones I can't really test (especially since that we want this PR in 11.1 for SE needs).
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 meant more moving PixelSize.FromSizeRounded to the TopLevel level, instead of updating each backend at once. It can be done gradually, once main API is there.
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.
Will devicePixelContentBoxSize
match the ClientSize that we are using for layout purposes?
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.
devicePixelContentBoxSize
itself returns pixel size that can be used to set render size of the html canvas.
Since our ClientSize is scaled, right now we divide devicePixelContentBoxSize by scaling factor.
https://github.com/AvaloniaUI/Avalonia/blob/master/src/Browser/Avalonia.Browser/AvaloniaView.cs#L473
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.
Can be done in separated PR
@@ -95,6 +100,11 @@ public static Rect ToAvaloniaRect(this SKRect r) | |||
{ | |||
return new Rect(r.Left, r.Top, r.Right - r.Left, r.Bottom - r.Top); | |||
} | |||
|
|||
public static PixelRect ToAvaloniaPixelRect(this SKRectI r) |
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.
Note: all of these extensions are public for some reason. But it's too late to change that.
Does it affect current drawing context API consumers? I.e. custom drawn controls. |
f2cc4fb
to
a86317b
Compare
Drawing API always uses the control-local coordinate space. The current change moves TopLevel-wide DPI scaling from DrawingContext to CompositionTarget itself. Right now it doesn't affect built-in scaling for user-created drawing contexts like one returned from RenderTargetBitmap. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
7fde2a5
to
6cebe2b
Compare
You can test this PR using the following package version. |
Tested on latest Avalonia source vs. 11.0.9. Seems the problem is solved on latest source. Great! |
CompositionCustomVisualHandler
to access the current clip rect (transformed to visual coordinate space)CompositionOptions
class to be used withAppBuilder.With