} // For diagnostics really public void Construct() { // The default allocs refer to four startup pages to be allocated as below from the atlas // once the atlas is used for the first time. The page coordinates correspond to the atlas's // internal algorithm's results. If that algorithm changes, the new results must be put here to match m_OpacityAllocator = m_ColorAllocator = m_ClipRectAllocator = m_TransformAllocator = m_TextSettingsAllocator = new BitmapAllocator32(); m_TransformAllocator.Construct(pageHeight, 1, 3); m_TransformAllocator.ForceFirstAlloc((ushort)identityTransformTexel.x, (ushort)identityTransformTexel.y); m_ClipRectAllocator.Construct(pageHeight); m_ClipRectAllocator.ForceFirstAlloc((ushort)infiniteClipRectTexel.x, (ushort)infiniteClipRectTexel.y); m_OpacityAllocator.Construct(pageHeight); m_OpacityAllocator.ForceFirstAlloc((ushort)fullOpacityTexel.x, (ushort)fullOpacityTexel.y); m_ColorAllocator.Construct(pageHeight); m_ColorAllocator.ForceFirstAlloc((ushort)clearColorTexel.x, (ushort)clearColorTexel.y); m_TextSettingsAllocator.Construct(pageHeight, 1, 4); m_TextSettingsAllocator.ForceFirstAlloc((ushort)defaultTextCoreSettingsTexel.x, (ushort)defaultTextCoreSettingsTexel.y); m_VertexTexturingEnabled = UIRenderDevice.vertexTexturingIsAvailable; if (!m_VertexTexturingEnabled) { int constantCount = 20; // Once custom materials are exposed, this number must be parameterized // Note that we can't do a lazy late allocation on the constants array size here (e.g. allocate only the default entry) // because once the material receives an array parameter value for the first time, it clings to its size and never // allows size changes afterwards without recreating the material, so we need to get the size right pessimistically m_Transforms = new NativeArray <Transform3x4>(constantCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_ClipRects = new NativeArray <Vector4>(constantCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_Transforms[0] = new Transform3x4() { v0 = identityTransformRow0Value, v1 = identityTransformRow1Value, v2 = identityTransformRow2Value }; m_ClipRects[0] = infiniteClipRectValue; } }
public void Construct() { this.m_OpacityAllocator = (this.m_ClipRectAllocator = (this.m_TransformAllocator = default(BitmapAllocator32))); this.m_TransformAllocator.Construct(UIRVEShaderInfoAllocator.pageHeight, 1, 3); this.m_TransformAllocator.ForceFirstAlloc((ushort)UIRVEShaderInfoAllocator.identityTransformTexel.x, (ushort)UIRVEShaderInfoAllocator.identityTransformTexel.y); this.m_ClipRectAllocator.Construct(UIRVEShaderInfoAllocator.pageHeight, 1, 1); this.m_ClipRectAllocator.ForceFirstAlloc((ushort)UIRVEShaderInfoAllocator.infiniteClipRectTexel.x, (ushort)UIRVEShaderInfoAllocator.infiniteClipRectTexel.y); this.m_OpacityAllocator.Construct(UIRVEShaderInfoAllocator.pageHeight, 1, 1); this.m_OpacityAllocator.ForceFirstAlloc((ushort)UIRVEShaderInfoAllocator.fullOpacityTexel.x, (ushort)UIRVEShaderInfoAllocator.fullOpacityTexel.y); this.m_VertexTexturingEnabled = UIRenderDevice.vertexTexturingIsAvailable; bool flag = !this.m_VertexTexturingEnabled; if (flag) { int length = 20; this.m_Transforms = new NativeArray <Transform3x4>(length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); this.m_ClipRects = new NativeArray <Vector4>(length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); this.m_Transforms[0] = new Transform3x4 { v0 = UIRVEShaderInfoAllocator.identityTransformRow0Value, v1 = UIRVEShaderInfoAllocator.identityTransformRow1Value, v2 = UIRVEShaderInfoAllocator.identityTransformRow2Value }; this.m_ClipRects[0] = UIRVEShaderInfoAllocator.infiniteClipRectValue; } }
private static bool AtlasRectMatchesPage(ref BitmapAllocator32 allocator, BMPAlloc defAlloc, RectInt atlasRect) { ushort num; ushort num2; allocator.GetAllocPageAtlasLocation(defAlloc.page, out num, out num2); return((int)num == atlasRect.xMin && (int)num2 == atlasRect.yMin && allocator.entryWidth * UIRVEShaderInfoAllocator.pageWidth == atlasRect.width && allocator.entryHeight * UIRVEShaderInfoAllocator.pageHeight == atlasRect.height); }
private static Vector2Int AllocToTexelCoord(ref BitmapAllocator32 allocator, BMPAlloc alloc) { ushort num; ushort num2; allocator.GetAllocPageAtlasLocation(alloc.page, out num, out num2); return(new Vector2Int((int)alloc.bitIndex * allocator.entryWidth + (int)num, (int)alloc.pageLine * allocator.entryHeight + (int)num2)); }
static bool AtlasRectMatchesPage(ref BitmapAllocator32 allocator, BMPAlloc defAlloc, RectInt atlasRect) { UInt16 x, y; allocator.GetAllocPageAtlasLocation(defAlloc.page, out x, out y); return((x == atlasRect.xMin) && (y == atlasRect.yMin) && (allocator.entryWidth * pageWidth == atlasRect.width) && (allocator.entryHeight * pageHeight == atlasRect.height)); }
#pragma warning restore 649 static Vector2Int AllocToTexelCoord(ref BitmapAllocator32 allocator, BMPAlloc alloc) { UInt16 x, y; allocator.GetAllocPageAtlasLocation(alloc.page, out x, out y); return(new Vector2Int( alloc.bitIndex * allocator.entryWidth + x, alloc.pageLine * allocator.entryHeight + y)); }
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); }