public VectorImageManager(UIRAtlasManager atlasManager) { this.m_AtlasManager = atlasManager; this.m_Registered = new Dictionary <VectorImage, VectorImageRenderInfo>(32); this.m_RenderInfoPool = new VectorImageRenderInfoPool(); this.m_GradientRemapPool = new GradientRemapPool(); this.m_GradientSettingsAtlas = new GradientSettingsAtlas(4096); }
public void IssuePendingAtlasBlits() { UIRAtlasManager expr_07 = this.m_Atlas; if (expr_07 != null) { expr_07.Commit(); } }
public BMPAlloc Allocate(UIRAtlasManager atlasManager) { int pageCount = m_Pages.Count; for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { var pageInfo = m_Pages[pageIndex]; if (pageInfo.freeSlots == 0) { continue; } int line = pageIndex * m_PageHeight; int endLine = line + m_PageHeight; for (; line < endLine; line++) { var allocBits = m_AllocMap[line]; if (allocBits == 0) { continue; } byte allocIndex = CountTrailingZeroes(allocBits); m_AllocMap[line] = allocBits & (~(1U << allocIndex)); pageInfo.freeSlots--; m_Pages[pageIndex] = pageInfo; return(new BMPAlloc() { page = pageIndex, pageLine = (ushort)(line - pageIndex * m_PageHeight), bitIndex = allocIndex, owned = 1 }); } // For each line } // For each page RectInt uvRect; if ((atlasManager == null) || !atlasManager.AllocateRect(kPageWidth * m_EntryWidth, m_PageHeight * m_EntryHeight, out uvRect)) { return(BMPAlloc.Invalid); } m_AllocMap.Capacity += m_PageHeight; m_AllocMap.Add(0xFFFFFFFE); // Reserve first slot for (int i = 1; i < m_PageHeight; i++) { m_AllocMap.Add(0xFFFFFFFF); } m_Pages.Add(new Page() { x = (UInt16)uvRect.xMin, y = (UInt16)uvRect.yMin, freeSlots = kPageWidth * m_PageHeight - 1 }); return(new BMPAlloc() { page = m_Pages.Count - 1, owned = 1 }); }
static EditorAtlasMonitor() { s_Monitors = new Dictionary <UIRAtlasManager, EditorAtlasMonitor>(); var createdAtlasManagerInstances = UIRAtlasManager.Instances(); for (int i = 0; i != createdAtlasManagerInstances.Count; ++i) { OnAtlasManagerCreated(createdAtlasManagerInstances[i]); } UIRAtlasManager.atlasManagerCreated += OnAtlasManagerCreated; UIRAtlasManager.atlasManagerDisposed += OnAtlasManagerDisposed; }
protected RenderChain(IPanel panel, UIRenderDevice device, UIRAtlasManager atlasManager, VectorImageManager vectorImageManager) { if (disposed) { DisposeHelper.NotifyDisposedUsed(this); } this.panel = panel; this.device = device; this.atlasManager = atlasManager; this.vectorImageManager = vectorImageManager; painter = new Implementation.UIRStylePainter(this); Font.textureRebuilt += OnFontReset; }
void ReallyCreateAtlas() { m_Atlas = new UIRAtlasManager( m_VertexTexturingEnabled ? RenderTextureFormat.ARGBFloat : RenderTextureFormat.ARGB32, // If no vertex texturing, only store opacity in ARGB32 FilterMode.Point, // Filtering is never needed for this texture Math.Max(pageWidth, pageHeight * 3), // Each transform row is stored vertically 64); // Because we want predictable placement of first pages, 64 will fit all three default allocs // The order of allocation from the atlas below is important. See the comment at the beginning of Construct(). RectInt rcTransform, rcClipRect, rcOpacity; m_Atlas.AllocateRect(pageWidth * m_TransformAllocator.entryWidth, pageHeight * m_TransformAllocator.entryHeight, out rcTransform); m_Atlas.AllocateRect(pageWidth * m_ClipRectAllocator.entryWidth, pageHeight * m_ClipRectAllocator.entryHeight, out rcClipRect); m_Atlas.AllocateRect(pageWidth * m_OpacityAllocator.entryWidth, pageHeight * m_OpacityAllocator.entryHeight, out rcOpacity); if (!AtlasRectMatchesPage(ref m_TransformAllocator, identityTransform, rcTransform)) { throw new Exception("Atlas identity transform allocation failed unexpectedly"); } if (!AtlasRectMatchesPage(ref m_ClipRectAllocator, infiniteClipRect, rcClipRect)) { throw new Exception("Atlas infinite clip rect allocation failed unexpectedly"); } if (!AtlasRectMatchesPage(ref m_OpacityAllocator, fullOpacity, rcOpacity)) { throw new Exception("Atlas full opacity allocation failed unexpectedly"); } var whiteTexel = UIRenderDevice.whiteTexel; if (m_VertexTexturingEnabled) { var allocXY = AllocToTexelCoord(ref m_TransformAllocator, identityTransform); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y + 0, false, identityTransformRow0Value); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y + 1, false, identityTransformRow1Value); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y + 2, false, identityTransformRow2Value); allocXY = AllocToTexelCoord(ref m_ClipRectAllocator, infiniteClipRect); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y, false, infiniteClipRectValue); } { var allocXY = AllocToTexelCoord(ref m_OpacityAllocator, fullOpacity); m_Atlas.EnqueueBlit(whiteTexel, allocXY.x, allocXY.y, false, fullOpacityValue); } m_AtlasReallyCreated = true; }
public static void OnPreRender() { bool colorSpaceChanged = CheckForColorSpaceChange(); bool importedTextureChanged = CheckForImportedTextures(); bool importedVectorImageChanged = CheckForImportedVectorImages(); if (colorSpaceChanged || importedTextureChanged) { UIRAtlasManager.MarkAllForReset(); VectorImageManager.MarkAllForReset(); } else if (colorSpaceChanged || importedVectorImageChanged) { VectorImageManager.MarkAllForReset(); } }
public void Dispose() { if (m_Atlas != null) { m_Atlas.Dispose(); } m_Atlas = null; if (m_ClipRects.IsCreated) { m_ClipRects.Dispose(); } if (m_Transforms.IsCreated) { m_Transforms.Dispose(); } }
public RenderChain(IPanel panel, Shader standardShader) { if (disposed) { DisposeHelper.NotifyDisposedUsed(this); } this.panel = panel; device = new UIRenderDevice(Implementation.RenderEvents.ResolveShader(standardShader)); atlasManager = new UIRAtlasManager(); vectorImageManager = new VectorImageManager(atlasManager); painter = new Implementation.UIRStylePainter(this); Font.textureRebuilt += OnFontReset; }
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; }
public UIRStylePainter(RenderChain renderChain) { this.m_Owner = renderChain; this.< meshGenerationContext > k__BackingField = new MeshGenerationContext(this); this.< device > k__BackingField = renderChain.device; this.m_AtlasManager = renderChain.atlasManager; this.m_VectorImageManager = renderChain.vectorImageManager; this.m_AllocRawVertsIndicesDelegate = new MeshBuilder.AllocMeshData.Allocator(this.AllocRawVertsIndices); this.m_AllocThroughDrawMeshDelegate = new MeshBuilder.AllocMeshData.Allocator(this.AllocThroughDrawMesh); int num = 32; this.m_MeshWriteDataPool = new List <MeshWriteData>(num); for (int i = 0; i < num; i++) { this.m_MeshWriteDataPool.Add(new MeshWriteData()); } }
protected RenderChain(IPanel panel, UIRenderDevice device, UIRAtlasManager atlasManager) { if (disposed) { DisposeHelper.NotifyDisposedUsed(this); } this.panel = panel; this.device = device; this.atlasManager = atlasManager; if (atlasManager != null) { atlasManager.ResetPerformed += OnAtlasReset; } painter = new Implementation.UIRStylePainter(this); Font.textureRebuilt += OnFontReset; }
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.Reset(); this.panel = panelObj; this.device = deviceObj; this.atlasManager = atlasMan; this.vectorImageManager = vectorImageMan; painter = new Implementation.UIRStylePainter(this); Font.textureRebuilt += OnFontReset; }
public static void OnPreRender() { bool flag = PackageEditorAtlasMonitor.CheckForColorSpaceChange(); bool flag2 = PackageEditorAtlasMonitor.CheckForImportedTextures(); bool flag3 = PackageEditorAtlasMonitor.CheckForImportedVectorImages(); bool flag4 = flag | flag2; if (flag4) { UIRAtlasManager.MarkAllForReset(); VectorImageManager.MarkAllForReset(); } else { bool flag5 = flag | flag3; if (flag5) { VectorImageManager.MarkAllForReset(); } } }
public void Dispose() { bool flag = this.m_Atlas != null; if (flag) { this.m_Atlas.Dispose(); } this.m_Atlas = null; bool isCreated = this.m_ClipRects.IsCreated; if (isCreated) { this.m_ClipRects.Dispose(); } bool isCreated2 = this.m_Transforms.IsCreated; if (isCreated2) { this.m_Transforms.Dispose(); } this.m_AtlasReallyCreated = false; }
public BMPAlloc Allocate(UIRAtlasManager atlasManager) { int count = this.m_Pages.Count; BMPAlloc result; for (int i = 0; i < count; i++) { BitmapAllocator32.Page page = this.m_Pages[i]; bool flag = page.freeSlots == 0; if (!flag) { int j = i * this.m_PageHeight; int num = j + this.m_PageHeight; while (j < num) { uint num2 = this.m_AllocMap[j]; bool flag2 = num2 == 0u; if (!flag2) { byte b = BitmapAllocator32.CountTrailingZeroes(num2); this.m_AllocMap[j] = (num2 & ~(1u << (int)b)); page.freeSlots--; this.m_Pages[i] = page; result = new BMPAlloc { page = i, pageLine = (ushort)(j - i * this.m_PageHeight), bitIndex = b, ownedState = OwnedState.Owned }; return(result); } j++; } } } RectInt rectInt; bool flag3 = atlasManager == null || !atlasManager.AllocateRect(32 * this.m_EntryWidth, this.m_PageHeight * this.m_EntryHeight, out rectInt); if (flag3) { result = BMPAlloc.Invalid; return(result); } this.m_AllocMap.Capacity += this.m_PageHeight; this.m_AllocMap.Add(4294967294u); for (int k = 1; k < this.m_PageHeight; k++) { this.m_AllocMap.Add(4294967295u); } this.m_Pages.Add(new BitmapAllocator32.Page { x = (ushort)rectInt.xMin, y = (ushort)rectInt.yMin, freeSlots = 32 * this.m_PageHeight - 1 }); result = new BMPAlloc { page = this.m_Pages.Count - 1, ownedState = OwnedState.Owned }; return(result); }
protected RenderChain(IPanel panel, UIRenderDevice device, UIRAtlasManager atlasManager, VectorImageManager vectorImageManager) { Constructor(panel, device, atlasManager, vectorImageManager); }
public EditorAtlasMonitor(UIRAtlasManager atlasManager) { atlasManager.AddMonitor(this); }
private static void OnAtlasManagerDisposed(UIRAtlasManager atlasManager) { bool removedMonitor = s_Monitors.Remove(atlasManager); Assert.IsTrue(removedMonitor); }
private static void OnAtlasManagerCreated(UIRAtlasManager atlasManager) { Assert.IsFalse(s_Monitors.ContainsKey(atlasManager)); s_Monitors.Add(atlasManager, new EditorAtlasMonitor(atlasManager)); }