예제 #1
0
        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);
        }
예제 #2
0
        public void ApplyVisualElementClipping()
        {
            bool flag = this.currentElement.renderChainData.clipMethod == ClipMethod.Scissor;

            if (flag)
            {
                RenderChainCommand renderChainCommand = this.m_Owner.AllocCommand();
                renderChainCommand.type  = CommandType.PushScissor;
                renderChainCommand.owner = this.currentElement;
                this.m_Entries.Add(new UIRStylePainter.Entry
                {
                    customCommand = renderChainCommand
                });
                this.m_ClosingInfo.needsClosing = (this.m_ClosingInfo.popScissorClip = true);
            }
            else
            {
                bool flag2 = this.currentElement.renderChainData.clipMethod == ClipMethod.Stencil;
                if (flag2)
                {
                    bool flag3 = UIRUtility.IsVectorImageBackground(this.currentElement);
                    if (flag3)
                    {
                        this.GenerateStencilClipEntryForSVGBackground();
                    }
                    else
                    {
                        this.GenerateStencilClipEntryForRoundedRectBackground();
                    }
                }
            }
            this.m_ClipRectID = this.currentElement.renderChainData.clipRectID;
        }