Esempio n. 1
0
        protected virtual void Dispose(bool disposing)
        {
            UIRAtlasManager.s_Instances.Remove(this);
            bool disposed = this.disposed;

            if (!disposed)
            {
                if (disposing)
                {
                    UIRUtility.Destroy(this.atlas);
                    this.atlas = null;
                    bool flag = this.m_Allocator != null;
                    if (flag)
                    {
                        this.m_Allocator.Dispose();
                        this.m_Allocator = null;
                    }
                    bool flag2 = this.m_Blitter != null;
                    if (flag2)
                    {
                        this.m_Blitter.Dispose();
                        this.m_Blitter = null;
                    }
                    bool flag3 = UIRAtlasManager.atlasManagerDisposed != null;
                    if (flag3)
                    {
                        UIRAtlasManager.atlasManagerDisposed(this);
                    }
                }
                this.disposed = true;
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                UIRUtility.Destroy(atlas);
                atlas = null;

                if (m_Allocator != null)
                {
                    m_Allocator.Dispose();
                    m_Allocator = null;
                }

                if (m_Blitter != null)
                {
                    m_Blitter.Dispose();
                    m_Blitter = null;
                }
            }
            else
            {
                UnityEngine.UIElements.DisposeHelper.NotifyMissingDispose(this);
            }

            disposed = true;
        }
Esempio n. 3
0
        private void BlitRightEye(CommandList cl, TextureBlitter blitter, float viewportAspect)
        {
            GetSampleRatio(_context.RightEyeFramebuffer, viewportAspect, out Vector2 minUV, out Vector2 maxUV);
            ResourceSet rightEyeSet = GetRightEyeSet(blitter.ResourceLayout);

            blitter.Render(cl, rightEyeSet, minUV, maxUV);
        }
Esempio n. 4
0
        public UIRAtlasManager(RenderTextureFormat format = RenderTextureFormat.ARGB32, FilterMode filterMode = FilterMode.Bilinear, int maxImageSize = 64, int initialSize = 64)
        {
            bool flag = filterMode != FilterMode.Bilinear && filterMode > FilterMode.Point;

            if (flag)
            {
                throw new NotSupportedException("The only supported atlas filter modes are point or bilinear");
            }
            this.< format > k__BackingField       = format;
            this.< maxImageSize > k__BackingField = maxImageSize;
            this.m_FloatFormat  = (format == RenderTextureFormat.ARGBFloat);
            this.m_FilterMode   = filterMode;
            this.m_UVs          = new Dictionary <Texture2D, RectInt>(64);
            this.m_Blitter      = new TextureBlitter(64);
            this.m_InitialSize  = initialSize;
            this.m_2SidePadding = ((filterMode == FilterMode.Point) ? 0 : 2);
            this.m_1SidePadding = ((filterMode == FilterMode.Point) ? 0 : 1);
            this.Reset();
            UIRAtlasManager.s_Instances.Add(this);
            bool flag2 = UIRAtlasManager.atlasManagerCreated != null;

            if (flag2)
            {
                UIRAtlasManager.atlasManagerCreated(this);
            }
        }
Esempio n. 5
0
        public void Render(CommandList cl, Framebuffer fb, MirrorTextureEyeSource source)
        {
            cl.SetFramebuffer(fb);
            TextureBlitter blitter = GetBlitter(fb.OutputDescription);

            switch (source)
            {
            case MirrorTextureEyeSource.BothEyes:
                float width = fb.Width * 0.5f;
                cl.SetViewport(0, new Viewport(0, 0, width, fb.Height, 0, 1));
                BlitLeftEye(cl, blitter, width / fb.Height);
                cl.SetViewport(0, new Viewport(width, 0, width, fb.Height, 0, 1));
                BlitRightEye(cl, blitter, width / fb.Height);
                break;

            case MirrorTextureEyeSource.LeftEye:
                BlitLeftEye(cl, blitter, (float)fb.Width / fb.Height);
                break;

            case MirrorTextureEyeSource.RightEye:
                BlitRightEye(cl, blitter, (float)fb.Width / fb.Height);
                break;
            }

            cl.SetFullViewports();
        }
        public DynamicAtlasPage(RenderTextureFormat format, FilterMode filterMode, Vector2Int minSize, Vector2Int maxSize)
        {
            textureId       = TextureRegistry.instance.AllocAndAcquireDynamic();
            this.format     = format;
            this.filterMode = filterMode;
            this.minSize    = minSize;
            this.maxSize    = maxSize;

            m_Allocator = new Allocator2D(minSize, maxSize, m_2Padding);
            m_Blitter   = new TextureBlitter(64);
        }
Esempio n. 7
0
        public UIRAtlasManager(int maxImageSize = 64)
        {
            this.maxImageSize = maxImageSize;
            m_UVs             = new Dictionary <Texture2D, RectInt>(64);
            m_Blitter         = new TextureBlitter(64);
            Reset();

            s_Instances.Add(this);
            if (atlasManagerCreated != null)
            {
                atlasManagerCreated(this);
            }
        }
Esempio n. 8
0
        private TextureBlitter GetBlitter(OutputDescription outputDescription)
        {
            if (!_blitters.TryGetValue(outputDescription, out TextureBlitter ret))
            {
                ret = new TextureBlitter(
                    _context.GraphicsDevice,
                    _context.GraphicsDevice.ResourceFactory,
                    outputDescription,
                    srgbOutput: false);

                _blitters.Add(outputDescription, ret);
            }

            return(ret);
        }
        public DynamicAtlasCore(RenderTextureFormat format = RenderTextureFormat.ARGB32, FilterMode filterMode = FilterMode.Bilinear, int maxImageSize = 64, int initialSize = 64, int maxAtlasSize = 4096)
        {
            Debug.Assert(filterMode == FilterMode.Bilinear || filterMode == FilterMode.Point);
            Debug.Assert(maxAtlasSize <= SystemInfo.maxRenderTextureSize);
            Debug.Assert(initialSize <= maxAtlasSize);
            Debug.Assert(Mathf.IsPowerOfTwo(maxImageSize));
            Debug.Assert(Mathf.IsPowerOfTwo(initialSize));
            Debug.Assert(Mathf.IsPowerOfTwo(maxAtlasSize));

            m_MaxAtlasSize    = maxAtlasSize;
            this.format       = format;
            this.maxImageSize = maxImageSize;
            m_FilterMode      = filterMode;
            m_UVs             = new Dictionary <Texture2D, RectInt>(64);
            m_Blitter         = new TextureBlitter(64);
            m_InitialSize     = initialSize;
            m_2SidePadding    = filterMode == FilterMode.Point ? 0 : 2;
            m_1SidePadding    = filterMode == FilterMode.Point ? 0 : 1;
            m_Allocator       = new UIRAtlasAllocator(m_InitialSize, m_MaxAtlasSize, m_1SidePadding);
            m_ColorSpace      = QualitySettings.activeColorSpace;
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                if (atlas != null)
                {
                    UIRUtility.Destroy(atlas);
                    atlas = null;
                }

                if (m_Allocator != null)
                {
                    // m_Allocator.Dispose(); TODO once we pool content
                    m_Allocator = null;
                }

                if (m_Blitter != null)
                {
                    m_Blitter.Dispose();
                    m_Blitter = null;
                }

                if (textureId != TextureId.invalid)
                {
                    TextureRegistry.instance.Release(textureId);
                    textureId = TextureId.invalid;
                }
            }
            else
            {
                UnityEngine.UIElements.DisposeHelper.NotifyMissingDispose(this);
            }

            disposed = true;
        }
Esempio n. 11
0
        public UIRAtlasManager(RenderTextureFormat format = RenderTextureFormat.ARGB32, FilterMode filterMode = FilterMode.Bilinear, int maxImageSize = 64, int initialSize = 64)
        {
            if (filterMode != FilterMode.Bilinear && filterMode != FilterMode.Point)
            {
                throw new NotSupportedException("The only supported atlas filter modes are point or bilinear");
            }

            this.format       = format;
            this.maxImageSize = maxImageSize;
            m_FloatFormat     = (format == RenderTextureFormat.ARGBFloat); // Identify any other formats to be used as float here
            m_FilterMode      = filterMode;
            m_UVs             = new Dictionary <Texture2D, RectInt>(64);
            m_Blitter         = new TextureBlitter(64);
            m_InitialSize     = initialSize;
            m_2SidePadding    = filterMode == FilterMode.Point ? 0 : 2;
            m_1SidePadding    = filterMode == FilterMode.Point ? 0 : 1;
            Reset();

            s_Instances.Add(this);
            if (atlasManagerCreated != null)
            {
                atlasManagerCreated(this);
            }
        }