public BMPAlloc AllocClipRect()
        {
            bool flag = !this.m_AtlasReallyCreated;

            if (flag)
            {
                this.ReallyCreateAtlas();
            }
            bool     vertexTexturingEnabled = this.m_VertexTexturingEnabled;
            BMPAlloc result;

            if (vertexTexturingEnabled)
            {
                result = this.m_ClipRectAllocator.Allocate(this.m_Atlas);
            }
            else
            {
                BMPAlloc bMPAlloc = this.m_ClipRectAllocator.Allocate(null);
                bool     flag2    = UIRVEShaderInfoAllocator.AllocToConstantBufferIndex(bMPAlloc) < this.m_ClipRects.Length;
                if (flag2)
                {
                    result = bMPAlloc;
                }
                else
                {
                    this.m_ClipRectAllocator.Free(bMPAlloc);
                    result = BMPAlloc.Invalid;
                }
            }
            return(result);
        }
        public void SetOpacityValue(BMPAlloc alloc, float opacity)
        {
            Debug.Assert(alloc.IsValid());
            Vector2Int vector2Int = UIRVEShaderInfoAllocator.AllocToTexelCoord(ref this.m_OpacityAllocator, alloc);

            this.m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, vector2Int.x, vector2Int.y, false, new Color(1f, 1f, 1f, opacity));
        }
Ejemplo n.º 3
0
        void Destructor()
        {
            if (m_StaticIndex >= 0)
            {
                RenderChainStaticIndexAllocator.FreeIndex(m_StaticIndex);
            }
            m_StaticIndex = -1;

            UIRUtility.Destroy(m_DefaultMat);
            UIRUtility.Destroy(m_DefaultWorldSpaceMat);
            m_DefaultMat = m_DefaultWorldSpaceMat = null;

            Font.textureRebuilt -= OnFontReset;
            painter?.Dispose();
            m_TextUpdatePainter?.Dispose();
            atlasManager?.Dispose();
            vectorImageManager?.Dispose();
            shaderInfoAllocator.Dispose();
            device?.Dispose();

            painter             = null;
            m_TextUpdatePainter = null;
            atlasManager        = null;
            shaderInfoAllocator = new UIRVEShaderInfoAllocator();
            device = null;

            m_ActiveRenderNodes = 0;
            m_RenderNodesData.Clear();
        }
Ejemplo n.º 4
0
 void ConstructShaderInfoAllocator()
 {
     m_ShaderInfoAllocator = new UIRVEShaderInfoAllocator();
     m_ShaderInfoAllocator.Construct();
     m_FullOpacityShaderInfo       = m_ShaderInfoAllocator.Allocate(atlasManager);
     m_FullOpacityShaderInfo.owned = 0; // This will be never freed and is marked specially with 0
     if (m_FullOpacityShaderInfo.IsValid())
     {
         atlasManager.EnqueueBlit(UIRenderDevice.whiteTexel, m_FullOpacityShaderInfo.x, m_FullOpacityShaderInfo.y, false, Color.white);
     }
 }
        public void SetClipRectValue(BMPAlloc alloc, Vector4 clipRect)
        {
            Debug.Assert(alloc.IsValid());
            bool vertexTexturingEnabled = this.m_VertexTexturingEnabled;

            if (vertexTexturingEnabled)
            {
                Vector2Int vector2Int = UIRVEShaderInfoAllocator.AllocToTexelCoord(ref this.m_ClipRectAllocator, alloc);
                this.m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, vector2Int.x, vector2Int.y, false, clipRect);
            }
            else
            {
                this.m_ClipRects[UIRVEShaderInfoAllocator.AllocToConstantBufferIndex(alloc)] = clipRect;
            }
        }
Ejemplo n.º 6
0
        void Destructor()
        {
            Font.textureRebuilt -= OnFontReset;
            painter?.Dispose();
            m_TextUpdatePainter?.Dispose();
            atlasManager?.Dispose();
            vectorImageManager?.Dispose();
            shaderInfoAllocator.Dispose();
            device?.Dispose();

            painter             = null;
            m_TextUpdatePainter = null;
            atlasManager        = null;
            shaderInfoAllocator = new UIRVEShaderInfoAllocator();
            device = null;
        }
        private void ReallyCreateAtlas()
        {
            this.m_Atlas = new UIRAtlasManager(this.m_VertexTexturingEnabled ? RenderTextureFormat.ARGBFloat : RenderTextureFormat.ARGB32, FilterMode.Point, Math.Max(UIRVEShaderInfoAllocator.pageWidth, UIRVEShaderInfoAllocator.pageHeight * 3), 64);
            RectInt atlasRect;

            this.m_Atlas.AllocateRect(UIRVEShaderInfoAllocator.pageWidth * this.m_TransformAllocator.entryWidth, UIRVEShaderInfoAllocator.pageHeight * this.m_TransformAllocator.entryHeight, out atlasRect);
            RectInt atlasRect2;

            this.m_Atlas.AllocateRect(UIRVEShaderInfoAllocator.pageWidth * this.m_ClipRectAllocator.entryWidth, UIRVEShaderInfoAllocator.pageHeight * this.m_ClipRectAllocator.entryHeight, out atlasRect2);
            RectInt atlasRect3;

            this.m_Atlas.AllocateRect(UIRVEShaderInfoAllocator.pageWidth * this.m_OpacityAllocator.entryWidth, UIRVEShaderInfoAllocator.pageHeight * this.m_OpacityAllocator.entryHeight, out atlasRect3);
            bool flag = !UIRVEShaderInfoAllocator.AtlasRectMatchesPage(ref this.m_TransformAllocator, UIRVEShaderInfoAllocator.identityTransform, atlasRect);

            if (flag)
            {
                throw new Exception("Atlas identity transform allocation failed unexpectedly");
            }
            bool flag2 = !UIRVEShaderInfoAllocator.AtlasRectMatchesPage(ref this.m_ClipRectAllocator, UIRVEShaderInfoAllocator.infiniteClipRect, atlasRect2);

            if (flag2)
            {
                throw new Exception("Atlas infinite clip rect allocation failed unexpectedly");
            }
            bool flag3 = !UIRVEShaderInfoAllocator.AtlasRectMatchesPage(ref this.m_OpacityAllocator, UIRVEShaderInfoAllocator.fullOpacity, atlasRect3);

            if (flag3)
            {
                throw new Exception("Atlas full opacity allocation failed unexpectedly");
            }
            Texture2D whiteTexel             = UIRenderDevice.whiteTexel;
            bool      vertexTexturingEnabled = this.m_VertexTexturingEnabled;

            if (vertexTexturingEnabled)
            {
                Vector2Int vector2Int = UIRVEShaderInfoAllocator.AllocToTexelCoord(ref this.m_TransformAllocator, UIRVEShaderInfoAllocator.identityTransform);
                this.m_Atlas.EnqueueBlit(whiteTexel, vector2Int.x, vector2Int.y, false, UIRVEShaderInfoAllocator.identityTransformRow0Value);
                this.m_Atlas.EnqueueBlit(whiteTexel, vector2Int.x, vector2Int.y + 1, false, UIRVEShaderInfoAllocator.identityTransformRow1Value);
                this.m_Atlas.EnqueueBlit(whiteTexel, vector2Int.x, vector2Int.y + 2, false, UIRVEShaderInfoAllocator.identityTransformRow2Value);
                vector2Int = UIRVEShaderInfoAllocator.AllocToTexelCoord(ref this.m_ClipRectAllocator, UIRVEShaderInfoAllocator.infiniteClipRect);
                this.m_Atlas.EnqueueBlit(whiteTexel, vector2Int.x, vector2Int.y, false, UIRVEShaderInfoAllocator.infiniteClipRectValue);
            }
            Vector2Int vector2Int2 = UIRVEShaderInfoAllocator.AllocToTexelCoord(ref this.m_OpacityAllocator, UIRVEShaderInfoAllocator.fullOpacity);

            this.m_Atlas.EnqueueBlit(whiteTexel, vector2Int2.x, vector2Int2.y, false, UIRVEShaderInfoAllocator.fullOpacityValue);
            this.m_AtlasReallyCreated = true;
        }
Ejemplo n.º 8
0
        void Destructor()
        {
            if (m_StaticIndex >= 0)
            {
                RenderChainStaticIndexAllocator.FreeIndex(m_StaticIndex);
            }
            m_StaticIndex = -1;

            var ve = GetFirstElementInPanel(m_FirstCommand?.owner);

            while (ve != null)
            {
                ResetTextures(ve);
                ve = ve.renderChainData.next;
            }

            UIRUtility.Destroy(m_DefaultMat);
            UIRUtility.Destroy(m_DefaultWorldSpaceMat);
            m_DefaultMat = m_DefaultWorldSpaceMat = null;

            vertsPool.Dispose();
            indicesPool.Dispose();
            jobManager.Dispose();
            vectorImageManager?.Dispose();
            shaderInfoAllocator.Dispose();
            device?.Dispose();
            opacityIdAccelerator?.Dispose();

            if (painter != null)
            {
                // todo: move painter2d to the render chain instead of the mgc
                if (painter.meshGenerationContext.hasPainter2D)
                {
                    painter.meshGenerationContext.painter2D.Destroy();
                }
                painter = null;
            }

            atlas = null;
            shaderInfoAllocator = new UIRVEShaderInfoAllocator();
            device = null;

            m_ActiveRenderNodes = 0;
            m_RenderNodesData.Clear();
        }
        public void SetTransformValue(BMPAlloc alloc, Matrix4x4 xform)
        {
            Debug.Assert(alloc.IsValid());
            bool vertexTexturingEnabled = this.m_VertexTexturingEnabled;

            if (vertexTexturingEnabled)
            {
                Vector2Int vector2Int = UIRVEShaderInfoAllocator.AllocToTexelCoord(ref this.m_TransformAllocator, alloc);
                this.m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, vector2Int.x, vector2Int.y, false, xform.GetRow(0));
                this.m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, vector2Int.x, vector2Int.y + 1, false, xform.GetRow(1));
                this.m_Atlas.EnqueueBlit(UIRenderDevice.whiteTexel, vector2Int.x, vector2Int.y + 2, false, xform.GetRow(2));
            }
            else
            {
                this.m_Transforms[UIRVEShaderInfoAllocator.AllocToConstantBufferIndex(alloc)] = new Transform3x4
                {
                    v0 = xform.GetRow(0),
                    v1 = xform.GetRow(1),
                    v2 = xform.GetRow(2)
                };
            }
        }