Example #1
0
        public void Free(BMPAlloc alloc)
        {
            Debug.Assert(alloc.ownedState == OwnedState.Owned);
            int index = alloc.page * this.m_PageHeight + (int)alloc.pageLine;

            this.m_AllocMap[index] = (this.m_AllocMap[index] | 1u << (int)alloc.bitIndex);
            BitmapAllocator32.Page value = this.m_Pages[alloc.page];
            value.freeSlots++;
            this.m_Pages[alloc.page] = value;
        }
Example #2
0
        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);
        }
Example #3
0
 internal void GetAllocPageAtlasLocation(int page, out ushort x, out ushort y)
 {
     BitmapAllocator32.Page page2 = this.m_Pages[page];
     x = page2.x;
     y = page2.y;
 }