Skip to content
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

CanvasVirtualControl does not cover whole VisibleRegion #983

Open
ghord opened this issue Jan 19, 2025 · 0 comments
Open

CanvasVirtualControl does not cover whole VisibleRegion #983

ghord opened this issue Jan 19, 2025 · 0 comments

Comments

@ghord
Copy link

ghord commented Jan 19, 2025

I've been trying to use CanvasVirtualControl to implement infinite canvas for my application.

Unfortunately, it doesn't seem to render correctly when i resize my window to larger size than initial size.

When CanvasVritualControl size is more than 2504 in width on my machine, it no longer reports whole visible region. Somehow, visible region width is clamped to 2504 width. This is exact value of initially opened window in my Application.

This causes the RegionsInvalidated event to be reported with too small VisibleRegion and InvalidatedRegions which breaks rendering of the surface when i try to render grid:

Image

I'm using 1.6.3 version of winui3.

I've tracked source of the issue to winui3 code under debugger, connected to IVirtualSurfaceImageSource handling:

In CCoreServices::NWDrawTree method, called per frame, windowBounds under debugger has always width 2504, even when my window is resized. It does not seem to ever be updated from initial creation of window (both snippets are taken from winui3 sources)

    // TODO: This is redundant. It should be replaced with the value from GetWindowSize.
    XRECTF_RB windowBounds =
    {
        0.0f,
        0.0f,
        static_cast<XFLOAT>(pRenderTarget->GetWidth()),
        static_cast<XFLOAT>(pRenderTarget->GetHeight())
    };

This is passed later in this method to VirtualSurfaceImageSources to compute visible region, which get clamped by this incorrect window bounds:

     // Now call any VirtualSurfaceImageSources (that are in the tree) so they re-compute visible bounds
     // and fire update events if needed
     IFC(VirtualSurfaceImageSourcePerFrameWork(&windowBounds));

Now, win2d does use IVirtualSurfaceImageSource->GetVisibleBounds later for reporting visible regions, and this value is clamped.

Any ideas if this is Win2d issue or Winui3? Some possible workaround? My current thinking is that I will have to move from CanvasVirtualControl to virtual composition surface with win2d drawing, and handle all of invalidation and trimming manually. I would prefer to stay on CanvasVirtualControl.

I've tried overdrawing in RegionsInvalidated event (increasing the width of update rects), but it predictably causes artifacts when scrolling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant