From 02abf00b01eb92c8fbb1c14a0e9b8998a2dfd308 Mon Sep 17 00:00:00 2001 From: Davide Depau Date: Thu, 25 Dec 2025 22:04:09 +0100 Subject: [PATCH] Prevent unbalanced SCISSOR_END commands for culled containers --- clay.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clay.h b/clay.h index 80d8393..7f594b0 100644 --- a/clay.h +++ b/clay.h @@ -3076,10 +3076,14 @@ void Clay__CalculateFinalLayout(void) { } // This exists because the scissor needs to end _after_ borders between elements if (closeClipElement) { - Clay__AddRenderCommand(CLAY__INIT(Clay_RenderCommand) { - .id = Clay__HashNumber(currentElement->id, rootElement->childrenOrTextContent.children.length + 11).id, - .commandType = CLAY_RENDER_COMMAND_TYPE_SCISSOR_END, - }); + Clay_LayoutElementHashMapItem *currentElementData = Clay__GetHashMapItem(currentElement->id); + Clay_BoundingBox currentElementBoundingBox = currentElementData->boundingBox; + if (!Clay__ElementIsOffscreen(¤tElementBoundingBox)) { + Clay__AddRenderCommand(CLAY__INIT(Clay_RenderCommand) { + .id = Clay__HashNumber(currentElement->id, rootElement->childrenOrTextContent.children.length + 11).id, + .commandType = CLAY_RENDER_COMMAND_TYPE_SCISSOR_END, + }); + } } dfsBuffer.length--;