Пример #1
0
        internal void AfterRenderDeviceRelease()
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
            }

            Debug.Assert(device == null);
            device = new UIRenderDevice(Implementation.RenderEvents.ResolveShader((panel as BaseVisualElementPanel)?.standardShader));

            Debug.Assert(painter == null);
            painter = new Implementation.UIRStylePainter(this);
            var ve = GetFirstElementInPanel(m_FirstCommand?.owner);

            while (ve != null)
            {
                Implementation.RenderEvents.OnRestoreTransformIDs(ve, device);
                UIEOnVisualsChanged(ve, false); // Marking dirty will repaint and have the data regenerated
                ve = ve.renderChainData.next;
            }
        }
        public void Commit()
        {
            bool disposed = this.disposed;

            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
            }
            else
            {
                bool flag = !this.MustCommit;
                if (!flag)
                {
                    this.PrepareAtlas();
                    GradientSettingsAtlas.s_MarkerCommit.Begin();
                    this.m_Atlas.SetPixels32(this.m_RawAtlas.rgba);
                    this.m_Atlas.Apply();
                    GradientSettingsAtlas.s_MarkerCommit.End();
                    this.MustCommit = false;
                }
            }
        }
 public void BlitOneNow(RenderTexture dst, Texture src, RectInt srcRect, Vector2Int dstPos, bool addBorder, Color tint)
 {
     bool disposed = this.disposed;
     if (disposed)
     {
         DisposeHelper.NotifyDisposedUsed(this);
     }
     else
     {
         this.m_SingleBlit[0] = new TextureBlitter.BlitInfo
         {
             src = src,
             srcRect = srcRect,
             dstPos = dstPos,
             border = (addBorder ? 1 : 0),
             tint = tint
         };
         this.BeginBlit(dst);
         this.DoBlit(this.m_SingleBlit, 0);
         this.EndBlit();
     }
 }
Пример #4
0
        public void Commit()
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
                return;
            }

            if (!MustCommit)
            {
                return;
            }

            PrepareAtlas();

            s_MarkerCommit.Begin();
            // TODO: This way of transferring is costly since it is a synchronous operation that flushes the pipeline.
            m_Atlas.SetPixels32(m_RawAtlas.rgba);
            m_Atlas.Apply();
            s_MarkerCommit.End();

            MustCommit = false;
        }
Пример #5
0
        void Constructor(IPanel panelObj, UIRenderDevice deviceObj, UIRAtlasManager atlasMan, VectorImageManager vectorImageMan)
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
            }

            // A reasonable starting depth level suggested here
            m_DirtyTracker.heads     = new List <VisualElement>(8);
            m_DirtyTracker.tails     = new List <VisualElement>(8);
            m_DirtyTracker.minDepths = new int[(int)RenderDataDirtyTypeClasses.Count];
            m_DirtyTracker.maxDepths = new int[(int)RenderDataDirtyTypeClasses.Count];
            m_DirtyTracker.Reset();

            this.panel              = panelObj;
            this.device             = deviceObj;
            this.atlasManager       = atlasMan;
            this.vectorImageManager = vectorImageMan;
            this.shaderInfoAllocator.Construct();

            painter              = new Implementation.UIRStylePainter(this);
            Font.textureRebuilt += OnFontReset;
        }
Пример #6
0
        public void RemoveUser(VectorImage vi)
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
                return;
            }

            if (vi == null)
            {
                return;
            }

            VectorImageRenderInfo renderInfo;

            if (m_Registered.TryGetValue(vi, out renderInfo))
            {
                --renderInfo.useCount;
                if (renderInfo.useCount == 0)
                {
                    Unregister(vi, renderInfo);
                }
            }
        }
Пример #7
0
        public void Commit(RenderTexture dst)
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
                return;
            }

            if (m_PendingBlits.Count == 0)
            {
                return;
            }

            s_CommitSampler.Begin();
            BeginBlit(dst);
            for (int i = 0; i < m_PendingBlits.Count; i += k_TextureSlotCount)
            {
                DoBlit(m_PendingBlits, i);
            }
            EndBlit();
            s_CommitSampler.End();

            m_PendingBlits.Clear();
        }
Пример #8
0
        internal void AfterRenderDeviceRelease()
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
            }

            Debug.Assert(device == null);

            var panelObj          = m_RenderDeviceRestoreInfo.panel;
            var root              = m_RenderDeviceRestoreInfo.root;
            var deviceObj         = new UIRenderDevice();
            var atlasManObj       = m_RenderDeviceRestoreInfo.hasAtlasMan ? new UIRAtlasManager() : null;
            var vectorImageManObj = m_RenderDeviceRestoreInfo.hasVectorImageMan ? new VectorImageManager(atlasManObj) : null;

            m_RenderDeviceRestoreInfo = new RenderDeviceRestoreInfo();

            Constructor(panelObj, deviceObj, atlasManObj, vectorImageManObj);
            if (root != null)
            {
                Debug.Assert(root.panel == panelObj);
                UIEOnChildAdded(root.parent, root, root.hierarchy.parent == null ? 0 : root.hierarchy.parent.IndexOf(panel.visualTree));
            }
        }
 public void Commit(RenderTexture dst)
 {
     bool disposed = this.disposed;
     if (disposed)
     {
         DisposeHelper.NotifyDisposedUsed(this);
     }
     else
     {
         bool flag = this.m_PendingBlits.Count == 0;
         if (!flag)
         {
             TextureBlitter.s_CommitSampler.Begin();
             this.BeginBlit(dst);
             for (int i = 0; i < this.m_PendingBlits.Count; i += 8)
             {
                 this.DoBlit(this.m_PendingBlits, i);
             }
             this.EndBlit();
             TextureBlitter.s_CommitSampler.End();
             this.m_PendingBlits.Clear();
         }
     }
 }
Пример #10
0
        public void Write(Alloc alloc, GradientSettings[] settings, GradientRemap remap)
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
                return;
            }

            if (m_RawAtlas.rgba == null)
            {
                m_RawAtlas = new RawTexture
                {
                    rgba   = new Color32[m_ElemWidth * m_Length],
                    width  = m_ElemWidth,
                    height = m_Length
                };

                int size = m_ElemWidth * m_Length;
                for (int i = 0; i < size; ++i)
                {
                    m_RawAtlas.rgba[i] = Color.black;
                }
            }

            s_MarkerWrite.Begin();

            int destY = (int)alloc.start;

            for (int i = 0, settingsCount = settings.Length; i < settingsCount; ++i)
            {
                int destX = 0;
                GradientSettings entry = settings[i];
                Debug.Assert(remap == null || destY == remap.destIndex);
                if (entry.gradientType == GradientType.Radial)
                {
                    var focus = entry.radialFocus;
                    focus  += Vector2.one;
                    focus  /= 2.0f;
                    focus.y = 1.0f - focus.y;
                    m_RawAtlas.WriteRawFloat4Packed((float)GradientType.Radial / 255, (float)entry.addressMode / 255, focus.x, focus.y, destX++, destY);
                }
                else if (entry.gradientType == GradientType.Linear)
                {
                    m_RawAtlas.WriteRawFloat4Packed(0.0f, (float)entry.addressMode / 255, 0.0f, 0.0f, destX++, destY);
                }

                Vector2Int pos  = new Vector2Int(entry.location.x, entry.location.y);
                var        size = new Vector2(entry.location.width - 1, entry.location.height - 1);
                if (remap != null)
                {
                    pos  = new Vector2Int(remap.location.x, remap.location.y);
                    size = new Vector2(remap.location.width - 1, remap.location.height - 1);
                }
                m_RawAtlas.WriteRawInt2Packed(pos.x, pos.y, destX++, destY);
                m_RawAtlas.WriteRawInt2Packed((int)size.x, (int)size.y, destX++, destY);

                remap = remap?.next;
                ++destY;
            }

            MustCommit = true;

            s_MarkerWrite.End();
        }
        public void Write(Alloc alloc, GradientSettings[] settings, GradientRemap remap)
        {
            bool disposed = this.disposed;

            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
            }
            else
            {
                bool flag = this.m_RawAtlas.rgba == null;
                if (flag)
                {
                    this.m_RawAtlas = new GradientSettingsAtlas.RawTexture
                    {
                        rgba   = new Color32[this.m_ElemWidth * this.m_Length],
                        width  = this.m_ElemWidth,
                        height = this.m_Length
                    };
                    int num = this.m_ElemWidth * this.m_Length;
                    for (int i = 0; i < num; i++)
                    {
                        this.m_RawAtlas.rgba[i] = Color.black;
                    }
                }
                GradientSettingsAtlas.s_MarkerWrite.Begin();
                int num2 = (int)alloc.start;
                int j    = 0;
                int num3 = settings.Length;
                while (j < num3)
                {
                    int num4 = 0;
                    GradientSettings gradientSettings = settings[j];
                    Debug.Assert(remap == null || num2 == remap.destIndex);
                    bool flag2 = gradientSettings.gradientType == GradientType.Radial;
                    if (flag2)
                    {
                        Vector2 vector = gradientSettings.radialFocus;
                        vector  += Vector2.one;
                        vector  /= 2f;
                        vector.y = 1f - vector.y;
                        this.m_RawAtlas.WriteRawFloat4Packed(0.003921569f, (float)gradientSettings.addressMode / 255f, vector.x, vector.y, num4++, num2);
                    }
                    else
                    {
                        bool flag3 = gradientSettings.gradientType == GradientType.Linear;
                        if (flag3)
                        {
                            this.m_RawAtlas.WriteRawFloat4Packed(0f, (float)gradientSettings.addressMode / 255f, 0f, 0f, num4++, num2);
                        }
                    }
                    Vector2Int vector2Int = new Vector2Int(gradientSettings.location.x, gradientSettings.location.y);
                    Vector2    vector2    = new Vector2((float)(gradientSettings.location.width - 1), (float)(gradientSettings.location.height - 1));
                    bool       flag4      = remap != null;
                    if (flag4)
                    {
                        vector2Int = new Vector2Int(remap.location.x, remap.location.y);
                        vector2    = new Vector2((float)(remap.location.width - 1), (float)(remap.location.height - 1));
                    }
                    this.m_RawAtlas.WriteRawInt2Packed(vector2Int.x, vector2Int.y, num4++, num2);
                    this.m_RawAtlas.WriteRawInt2Packed((int)vector2.x, (int)vector2.y, num4++, num2);
                    remap = ((remap != null) ? remap.next : null);
                    num2++;
                    j++;
                }
                this.MustCommit = true;
                GradientSettingsAtlas.s_MarkerWrite.End();
            }
        }