Compositor clips layers positioned away from the origin when no root layer spans the viewport #1747
vaidik-bajpai
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
While experimenting with the new
Layer/CompositorAPI, I came across what might be an edge case in the compositor's rendering logic, although I'm not sure whether it's actually a bug or simply the intended behavior.I noticed that if I create a single layer positioned away from the origin—for example at
(40, 0)with a width of80—and pass it directly toNewCompositor, only part of the layer is rendered. However, if I wrap that exact same layer inside another "root" layer that spans the viewport, it renders correctly without any clipping. The only difference between the two cases is the presence of the enclosing parent layer.After looking through the compositor implementation, my current understanding is that the compositor computes the canvas size using
c.bounds.Dx()andc.bounds.Dy(). For a layer whose bounds are(40,0)-(120,...), the resulting canvas width is80, which is mathematically correct, but the layer is still drawn at an absolute X position of40. Since the canvas itself begins at(0,0), the right portion of the layer appears to be clipped. Wrapping the layer in a full-screen parent causes the compositor bounds to begin at(0,0), making the canvas large enough for the translated child and avoiding the issue entirely.I've put together a small Bubble Tea example that demonstrates both behaviors. Pressing one renders the offset layer directly (which appears clipped), while pressing two wraps it in a root layer (which renders as expected). The child layer is identical in both cases.
Before opening an issue, I wanted to check whether this is an implementation bug or whether the compositor is intentionally designed around the assumption that the root layer always starts at the origin. If it's the latter, perhaps this behavior should be documented. If not, I'd be happy to open an issue with the reproduction example.
All reactions