static ClipMethod DetermineSelfClipMethod(RenderChain renderChain, VisualElement ve) { if (!ve.ShouldClip()) { return(ClipMethod.NotClipped); } // Even though GroupTransform does not formally imply the use of scissors, we prefer to use them because // this way, we can avoid updating nested clipping rects. bool preferScissors = (ve.renderHints & (RenderHints.GroupTransform | RenderHints.ClipWithScissors)) != 0; ClipMethod rectClipMethod = preferScissors ? ClipMethod.Scissor : ClipMethod.ShaderDiscard; if (!UIRUtility.IsRoundRect(ve) && !UIRUtility.IsVectorImageBackground(ve)) { return(rectClipMethod); } int inheritedMaskDepth = 0; VisualElement parent = ve.hierarchy.parent; if (parent != null) { inheritedMaskDepth = parent.renderChainData.childrenMaskDepth; } // We're already at the deepest level, we can't go any deeper. if (inheritedMaskDepth == UIRUtility.k_MaxMaskDepth) { return(rectClipMethod); } // Stencil clipping is not yet supported in world-space rendering, fallback to a coarse shader discard for now return(renderChain.drawInCameras ? rectClipMethod : ClipMethod.Stencil); }