public static dfTriangleClippingRegion Obtain(dfTriangleClippingRegion parent, dfControl control)
    {
        var clip = (pool.Count > 0) ? pool.Dequeue() : new dfTriangleClippingRegion();

        clip.planes.AddRange(control.GetClippingPlanes());

        if (parent != null)
        {
            clip.planes.AddRange(parent.planes);
        }

        return(clip);
    }
    private bool processRenderData( ref dfRenderData buffer, dfRenderData controlData, ref Bounds bounds, ref Rect screenRect, uint checksum, dfTriangleClippingRegion clipInfo, ref bool wasClipped )
    {
        wasClipped = false;

        // This shouldn't happen in practice, but need to make certain
        if( controlData == null || controlData.Material == null || !controlData.IsValid() )
            return false;

        // A new draw call is needed every time the current Material, Texture, or Shader
        // changes. If the control returned a buffer that is not empty and uses a
        // different Material, need to grab a new draw call buffer from the object pool.
        bool needNewDrawcall = false;
        if( buffer == null )
        {
            needNewDrawcall = true;
        }
        else
        {
            if( !Material.Equals( controlData.Material, buffer.Material ) )
            {
                needNewDrawcall = true;
            }
            else if( !textureEqual( controlData.Material.mainTexture, buffer.Material.mainTexture ) )
            {
                needNewDrawcall = true;
            }
            else if( !shaderEqual( buffer.Shader, controlData.Shader ) )
            {
                needNewDrawcall = true;
            }
            else if( !this.clipInfo.IsEmpty && drawCallBuffers.Count == 1 )
            {
                needNewDrawcall = true;
            }
        }

        if( needNewDrawcall )
        {
            buffer = getDrawCallBuffer( controlData.Material );
            buffer.Material = controlData.Material;
            buffer.Material.mainTexture = controlData.Material.mainTexture;
            buffer.Material.shader = controlData.Shader ?? controlData.Material.shader;
        }

        if( !Application.isPlaying || clipType == dfClippingMethod.Software )
        {

            // Ensure that the control's render data is properly clipped to the
            // current clipping region
            if( clipInfo.PerformClipping( buffer, ref bounds, checksum, controlData ) )
            {
                return true;
            }

            // If PerformClipping() returns FALSE, then the control was outside of
            // the active clipping region
            wasClipped = true;

        }
        else
        {
            if( clipRect.IsEmpty() || screenRect.Intersects( clipRect ) )
            {
                buffer.Merge( controlData );
            }
            else
            {
                // Control was not inside of the active clipping rectangle
                wasClipped = true;
            }
        }

        return false;
    }
	public static dfTriangleClippingRegion Obtain( dfTriangleClippingRegion parent, dfControl control )
	{

		var clip = ( pool.Count > 0 ) ? pool.Dequeue() : new dfTriangleClippingRegion();

		clip.planes.AddRange( control.GetClippingPlanes() );

		if( parent != null )
		{
			clip.planes.AddRange( parent.planes );
		}

		return clip;

	}
    private bool processRenderData(ref dfRenderData buffer, dfRenderData controlData, ref Bounds bounds, ref Rect screenRect, uint checksum, dfTriangleClippingRegion clipInfo, ref bool wasClipped)
    {
        wasClipped = false;

        // This shouldn't happen in practice, but need to make certain
        if (controlData == null || controlData.Material == null || !controlData.IsValid())
        {
            return(false);
        }

        // A new draw call is needed every time the current Material, Texture, or Shader
        // changes. If the control returned a buffer that is not empty and uses a
        // different Material, need to grab a new draw call buffer from the object pool.
        bool needNewDrawcall = false;

        if (buffer == null)
        {
            needNewDrawcall = true;
        }
        else
        {
            if (!Material.Equals(controlData.Material, buffer.Material))
            {
                needNewDrawcall = true;
            }
            else if (!textureEqual(controlData.Material.mainTexture, buffer.Material.mainTexture))
            {
                needNewDrawcall = true;
            }
            else if (!shaderEqual(buffer.Shader, controlData.Shader))
            {
                needNewDrawcall = true;
            }
            else if (!this.clipInfo.IsEmpty && drawCallBuffers.Count == 1)
            {
                needNewDrawcall = true;
            }
        }

        if (needNewDrawcall)
        {
            buffer                      = getDrawCallBuffer(controlData.Material);
            buffer.Material             = controlData.Material;
            buffer.Material.mainTexture = controlData.Material.mainTexture;
            buffer.Material.shader      = controlData.Shader ?? controlData.Material.shader;
        }

        if (!Application.isPlaying || clipType == dfClippingMethod.Software)
        {
            // Ensure that the control's render data is properly clipped to the
            // current clipping region
            if (clipInfo.PerformClipping(buffer, ref bounds, checksum, controlData))
            {
                return(true);
            }

            // If PerformClipping() returns FALSE, then the control was outside of
            // the active clipping region
            wasClipped = true;
        }
        else
        {
            if (clipRect.IsEmpty() || screenRect.Intersects(clipRect))
            {
                buffer.Merge(controlData);
            }
            else
            {
                // Control was not inside of the active clipping rectangle
                wasClipped = true;
            }
        }

        return(false);
    }