private bool IsTextureValid(Texture2D image) { bool isReadable = image.isReadable; bool result; if (isReadable) { result = false; } else { bool flag = image.width > this.maxImageSize || image.height > this.maxImageSize; if (flag) { result = false; } else { bool flag2 = !UIRAtlasManager.IsTextureFormatSupported(image.format); if (flag2) { result = false; } else { bool flag3 = !this.m_FloatFormat && this.m_ColorSpace == ColorSpace.Linear && image.activeTextureColorSpace > ColorSpace.Gamma; if (flag3) { result = false; } else { bool flag4 = SystemInfo.graphicsShaderLevel >= 35; if (flag4) { bool flag5 = image.filterMode != FilterMode.Bilinear && image.filterMode > FilterMode.Point; if (flag5) { result = false; return(result); } } else { bool flag6 = this.m_FilterMode != image.filterMode; if (flag6) { result = false; return(result); } } bool flag7 = image.wrapMode != TextureWrapMode.Clamp; result = !flag7; } } } } return(result); }
public bool TryGetLocation(Texture2D image, out RectInt uvs) { uvs = default(RectInt); bool disposed = this.disposed; bool result; if (disposed) { UIRAtlasManager.LogDisposeError(); result = false; } else { bool flag = image == null; if (flag) { result = false; } else { bool flag2 = this.m_UVs.TryGetValue(image, out uvs); if (flag2) { result = true; } else { bool flag3 = !this.IsTextureValid(image); if (flag3) { result = false; } else { bool flag4 = !this.AllocateRect(image.width, image.height, out uvs); if (flag4) { result = false; } else { this.m_UVs[image] = uvs; this.m_Blitter.QueueBlit(image, new RectInt(0, 0, image.width, image.height), new Vector2Int(uvs.x, uvs.y), true, Color.white); result = true; } } } } } return(result); }
public void Reset() { bool disposed = this.disposed; if (disposed) { UIRAtlasManager.LogDisposeError(); } else { UIRAtlasManager.s_MarkerReset.Begin(); this.m_Blitter.Reset(); this.m_UVs.Clear(); this.m_Allocator = new UIRAtlasAllocator(this.m_InitialSize, 4096, this.m_1SidePadding); this.m_ForceReblitAll = false; this.m_ColorSpace = QualitySettings.activeColorSpace; UIRUtility.Destroy(this.atlas); this.atlas = null; UIRAtlasManager.s_MarkerReset.End(); this.m_ResetVersion = UIRAtlasManager.s_GlobalResetVersion; } }
public void Commit() { bool disposed = this.disposed; if (disposed) { UIRAtlasManager.LogDisposeError(); } else { this.UpdateAtlasTexture(); bool forceReblitAll = this.m_ForceReblitAll; if (forceReblitAll) { this.m_ForceReblitAll = false; this.m_Blitter.Reset(); foreach (KeyValuePair <Texture2D, RectInt> current in this.m_UVs) { this.m_Blitter.QueueBlit(current.Key, new RectInt(0, 0, current.Key.width, current.Key.height), new Vector2Int(current.Value.x, current.Value.y), true, Color.white); } } this.m_Blitter.Commit(this.atlas); } }
public Allocation Allocate(UIRAtlasManager atlasManager) { if (atlasManager == null) { return new Allocation() { line = -1 } } ; // Not possible int linesAvailable = m_AllocMap.Count; for (int i = 0; i < linesAvailable; i++) { var allocBits = m_AllocMap[i]; if (allocBits == 0) { continue; } byte allocIndex = CountTrailingZeroes(allocBits); m_AllocMap[i] = allocBits & (~(1U << allocIndex)); int pageIndex = i / kPageHeight; var pageInfo = m_Pages[pageIndex]; return(new Allocation() { line = i, bitIndex = allocIndex, x = (UInt16)(allocIndex + pageInfo.x), y = (UInt16)(i - pageIndex * kPageHeight + pageInfo.y), owned = 1 }); } RectInt uvRect; if (!atlasManager.AllocateRect(kPageWidth, kPageHeight, out uvRect)) { return new Allocation() { line = -1 } } ; // Failed var alloc = new Allocation() { line = m_AllocMap.Count, bitIndex = 0, x = 0, y = 0, owned = 1 }; m_AllocMap.Capacity += kPageHeight; m_AllocMap.Add(0xFFFFFFFE); // Reserve first slot for (int i = 1; i < kPageHeight; i++) { m_AllocMap.Add(0xFFFFFFFF); } var newPage = new Page(); newPage.x = (UInt16)uvRect.xMin; newPage.y = (UInt16)uvRect.yMin; m_Pages.Add(newPage); alloc.x += newPage.x; alloc.y += newPage.y; return(alloc); }