コード例 #1
0
        /// <summary>
        /// Try to pack the given glyph into the given texture width and height.
        /// </summary>
        /// <param name="glyph">The glyph to try to pack.</param>
        /// <param name="padding">The padding between this glyph and other glyphs.</param>
        /// <param name="packingMode">The packing algorithm used to pack the glyphs.</param>
        /// <param name="renderMode">The glyph rendering mode.</param>
        /// <param name="width">The width of the target atlas texture.</param>
        /// <param name="height">The height of the target atlas texture.</param>
        /// <param name="freeGlyphRects">List of GlyphRects representing the available space in the atlas.</param>
        /// <param name="usedGlyphRects">List of GlyphRects representing the occupied space in the atlas.</param>
        /// <returns></returns>
        internal static bool TryPackGlyphInAtlas(Glyph glyph, int padding, GlyphPackingMode packingMode, GlyphRenderMode renderMode, int width, int height, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects)
        {
            GlyphMarshallingStruct glyphStruct = new GlyphMarshallingStruct(glyph);

            int freeGlyphRectCount = freeGlyphRects.Count;
            int usedGlyphRectCount = usedGlyphRects.Count;
            int totalGlyphRects    = freeGlyphRectCount + usedGlyphRectCount;

            // Make sure marshalling arrays allocations are appropriate.
            if (s_FreeGlyphRects.Length < totalGlyphRects || s_UsedGlyphRects.Length < totalGlyphRects)
            {
                int newSize = Mathf.NextPowerOfTwo(totalGlyphRects + 1);
                s_FreeGlyphRects = new GlyphRect[newSize];
                s_UsedGlyphRects = new GlyphRect[newSize];
            }

            // Copy glyph rect data to marshalling arrays.
            int glyphRectCount = Mathf.Max(freeGlyphRectCount, usedGlyphRectCount);

            for (int i = 0; i < glyphRectCount; i++)
            {
                if (i < freeGlyphRectCount)
                {
                    s_FreeGlyphRects[i] = freeGlyphRects[i];
                }

                if (i < usedGlyphRectCount)
                {
                    s_UsedGlyphRects[i] = usedGlyphRects[i];
                }
            }

            if (TryPackGlyphInAtlas_Internal(ref glyphStruct, padding, packingMode, renderMode, width, height, s_FreeGlyphRects, ref freeGlyphRectCount, s_UsedGlyphRects, ref usedGlyphRectCount))
            {
                // Copy new glyph position to source glyph.
                glyph.glyphRect = glyphStruct.glyphRect;

                freeGlyphRects.Clear();
                usedGlyphRects.Clear();

                // Copy marshalled glyph rect data
                glyphRectCount = Mathf.Max(freeGlyphRectCount, usedGlyphRectCount);
                for (int i = 0; i < glyphRectCount; i++)
                {
                    if (i < freeGlyphRectCount)
                    {
                        freeGlyphRects.Add(s_FreeGlyphRects[i]);
                    }

                    if (i < usedGlyphRectCount)
                    {
                        usedGlyphRects.Add(s_UsedGlyphRects[i]);
                    }
                }

                return(true);
            }

            return(false);
        }
コード例 #2
0
        internal static bool TryAddGlyphToTexture(uint glyphIndex, int padding, GlyphPackingMode packingMode, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects, GlyphRenderMode renderMode, Texture2D texture, out Glyph glyph)
        {
            int  count  = freeGlyphRects.Count;
            int  count2 = usedGlyphRects.Count;
            int  num    = count + count2;
            bool flag   = FontEngine.s_FreeGlyphRects.Length < num || FontEngine.s_UsedGlyphRects.Length < num;

            if (flag)
            {
                int num2 = Mathf.NextPowerOfTwo(num + 1);
                FontEngine.s_FreeGlyphRects = new GlyphRect[num2];
                FontEngine.s_UsedGlyphRects = new GlyphRect[num2];
            }
            int num3 = Mathf.Max(count, count2);

            for (int i = 0; i < num3; i++)
            {
                bool flag2 = i < count;
                if (flag2)
                {
                    FontEngine.s_FreeGlyphRects[i] = freeGlyphRects[i];
                }
                bool flag3 = i < count2;
                if (flag3)
                {
                    FontEngine.s_UsedGlyphRects[i] = usedGlyphRects[i];
                }
            }
            GlyphMarshallingStruct glyphStruct;
            bool flag4 = FontEngine.TryAddGlyphToTexture_Internal(glyphIndex, padding, packingMode, FontEngine.s_FreeGlyphRects, ref count, FontEngine.s_UsedGlyphRects, ref count2, renderMode, texture, out glyphStruct);
            bool result;

            if (flag4)
            {
                glyph = new Glyph(glyphStruct);
                freeGlyphRects.Clear();
                usedGlyphRects.Clear();
                num3 = Mathf.Max(count, count2);
                for (int j = 0; j < num3; j++)
                {
                    bool flag5 = j < count;
                    if (flag5)
                    {
                        freeGlyphRects.Add(FontEngine.s_FreeGlyphRects[j]);
                    }
                    bool flag6 = j < count2;
                    if (flag6)
                    {
                        usedGlyphRects.Add(FontEngine.s_UsedGlyphRects[j]);
                    }
                }
                result = true;
            }
            else
            {
                glyph  = null;
                result = false;
            }
            return(result);
        }
コード例 #3
0
        internal static bool TryPackGlyphInAtlas(Glyph glyph, int padding, GlyphPackingMode packingMode, GlyphRenderMode renderMode, int width, int height, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects)
        {
            GlyphMarshallingStruct glyphMarshallingStruct = new GlyphMarshallingStruct(glyph);
            int  count  = freeGlyphRects.Count;
            int  count2 = usedGlyphRects.Count;
            int  num    = count + count2;
            bool flag   = FontEngine.s_FreeGlyphRects.Length < num || FontEngine.s_UsedGlyphRects.Length < num;

            if (flag)
            {
                int num2 = Mathf.NextPowerOfTwo(num + 1);
                FontEngine.s_FreeGlyphRects = new GlyphRect[num2];
                FontEngine.s_UsedGlyphRects = new GlyphRect[num2];
            }
            int num3 = Mathf.Max(count, count2);

            for (int i = 0; i < num3; i++)
            {
                bool flag2 = i < count;
                if (flag2)
                {
                    FontEngine.s_FreeGlyphRects[i] = freeGlyphRects[i];
                }
                bool flag3 = i < count2;
                if (flag3)
                {
                    FontEngine.s_UsedGlyphRects[i] = usedGlyphRects[i];
                }
            }
            bool flag4 = FontEngine.TryPackGlyphInAtlas_Internal(ref glyphMarshallingStruct, padding, packingMode, renderMode, width, height, FontEngine.s_FreeGlyphRects, ref count, FontEngine.s_UsedGlyphRects, ref count2);
            bool result;

            if (flag4)
            {
                glyph.glyphRect = glyphMarshallingStruct.glyphRect;
                freeGlyphRects.Clear();
                usedGlyphRects.Clear();
                num3 = Mathf.Max(count, count2);
                for (int j = 0; j < num3; j++)
                {
                    bool flag5 = j < count;
                    if (flag5)
                    {
                        freeGlyphRects.Add(FontEngine.s_FreeGlyphRects[j]);
                    }
                    bool flag6 = j < count2;
                    if (flag6)
                    {
                        usedGlyphRects.Add(FontEngine.s_UsedGlyphRects[j]);
                    }
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
コード例 #4
0
 extern static bool TryAddGlyphsToTexture_Internal(uint[] glyphIndex, int padding,
                                                   GlyphPackingMode packingMode, [Out] GlyphRect[] freeGlyphRects, ref int freeGlyphRectCount, [Out] GlyphRect[] usedGlyphRects, ref int usedGlyphRectCount,
                                                   GlyphRenderMode renderMode, Texture2D texture, [Out] GlyphMarshallingStruct[] glyphs, ref int glyphCount);
コード例 #5
0
        /// <summary>
        /// Internal function used to add multiple glyphs to atlas texture.
        /// </summary>
        internal static bool TryAddGlyphsToTexture(List <uint> glyphIndexes, int padding, GlyphPackingMode packingMode, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects, GlyphRenderMode renderMode, Texture2D texture, out Glyph[] glyphs)
        {
            glyphs = null;

            if (glyphIndexes == null || glyphIndexes.Count == 0)
            {
                return(false);
            }

            int glyphCount = glyphIndexes.Count;

            // Make sure marshalling glyph index array allocations are appropriate.
            if (s_GlyphIndexesToMarshall == null || s_GlyphIndexesToMarshall.Length < glyphCount)
            {
                if (s_GlyphIndexesToMarshall == null)
                {
                    s_GlyphIndexesToMarshall = new uint[glyphCount];
                }
                else
                {
                    int newSize = Mathf.NextPowerOfTwo(glyphCount + 1);
                    s_GlyphIndexesToMarshall = new uint[newSize];
                }
            }

            // Determine potential total allocations required for glyphs and glyph rectangles.
            int freeGlyphRectCount = freeGlyphRects.Count;
            int usedGlyphRectCount = usedGlyphRects.Count;
            int totalGlyphRects    = freeGlyphRectCount + usedGlyphRectCount + glyphCount;

            // Make sure marshalling array(s) allocations are appropriate.
            if (s_FreeGlyphRects.Length < totalGlyphRects || s_UsedGlyphRects.Length < totalGlyphRects)
            {
                int newSize = Mathf.NextPowerOfTwo(totalGlyphRects + 1);
                s_FreeGlyphRects = new GlyphRect[newSize];
                s_UsedGlyphRects = new GlyphRect[newSize];
            }

            // Make sure marshaling array allocations are appropriate.
            if (s_GlyphMarshallingStruct_OUT.Length < glyphCount)
            {
                int newSize = Mathf.NextPowerOfTwo(glyphCount + 1);
                s_GlyphMarshallingStruct_OUT = new GlyphMarshallingStruct[newSize];
            }

            // Copy glyph indexes and glyph rect data to marshalling arrays.
            int glyphRectCount = Mathf.Max(freeGlyphRectCount, usedGlyphRectCount, glyphCount);

            for (int i = 0; i < glyphRectCount; i++)
            {
                if (i < glyphCount)
                {
                    s_GlyphIndexesToMarshall[i] = glyphIndexes[i];
                }

                if (i < freeGlyphRectCount)
                {
                    s_FreeGlyphRects[i] = freeGlyphRects[i];
                }

                if (i < usedGlyphRectCount)
                {
                    s_UsedGlyphRects[i] = usedGlyphRects[i];
                }
            }

            // Marshall data over to the native side.
            bool allGlyphsAdded = TryAddGlyphsToTexture_Internal(s_GlyphIndexesToMarshall, padding, packingMode, s_FreeGlyphRects, ref freeGlyphRectCount, s_UsedGlyphRects, ref usedGlyphRectCount, renderMode, texture, s_GlyphMarshallingStruct_OUT, ref glyphCount);

            // Allocate array of glyphs
            glyphs = new Glyph[glyphCount];

            freeGlyphRects.Clear();
            usedGlyphRects.Clear();

            // Copy marshalled free and used GlyphRect data over.
            glyphRectCount = Mathf.Max(freeGlyphRectCount, usedGlyphRectCount, glyphCount);
            for (int i = 0; i < glyphRectCount; i++)
            {
                if (i < glyphCount)
                {
                    glyphs[i] = new Glyph(s_GlyphMarshallingStruct_OUT[i]);
                }

                if (i < freeGlyphRectCount)
                {
                    freeGlyphRects.Add(s_FreeGlyphRects[i]);
                }

                if (i < usedGlyphRectCount)
                {
                    usedGlyphRects.Add(s_UsedGlyphRects[i]);
                }
            }

            return(allGlyphsAdded);
        }
コード例 #6
0
        /// <summary>
        /// Internal function used to add glyph to atlas texture.
        /// </summary>
        internal static bool TryAddGlyphToTexture(uint glyphIndex, int padding, GlyphPackingMode packingMode, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects, GlyphRenderMode renderMode, Texture2D texture, out Glyph glyph)
        {
            // Determine potential total allocations required for glyphs and glyph rectangles.
            int freeGlyphRectCount = freeGlyphRects.Count;
            int usedGlyphRectCount = usedGlyphRects.Count;
            int totalGlyphRects    = freeGlyphRectCount + usedGlyphRectCount;

            // Make sure marshalling arrays allocations are appropriate.
            if (s_FreeGlyphRects.Length < totalGlyphRects || s_UsedGlyphRects.Length < totalGlyphRects)
            {
                int newSize = Mathf.NextPowerOfTwo(totalGlyphRects + 1);
                s_FreeGlyphRects = new GlyphRect[newSize];
                s_UsedGlyphRects = new GlyphRect[newSize];
            }

            // Copy glyph rect data to marshalling arrays.
            int glyphRectCount = Mathf.Max(freeGlyphRectCount, usedGlyphRectCount);

            for (int i = 0; i < glyphRectCount; i++)
            {
                if (i < freeGlyphRectCount)
                {
                    s_FreeGlyphRects[i] = freeGlyphRects[i];
                }

                if (i < usedGlyphRectCount)
                {
                    s_UsedGlyphRects[i] = usedGlyphRects[i];
                }
            }

            GlyphMarshallingStruct glyphStruct;

            // Marshall data over to the native side.
            if (TryAddGlyphToTexture_Internal(glyphIndex, padding, packingMode, s_FreeGlyphRects, ref freeGlyphRectCount, s_UsedGlyphRects, ref usedGlyphRectCount, renderMode, texture, out glyphStruct))
            {
                // Copy marshalled data over to new glyph.
                glyph = new Glyph(glyphStruct);

                freeGlyphRects.Clear();
                usedGlyphRects.Clear();

                // Copy marshalled free and used GlyphRect data over.
                glyphRectCount = Mathf.Max(freeGlyphRectCount, usedGlyphRectCount);
                for (int i = 0; i < glyphRectCount; i++)
                {
                    if (i < freeGlyphRectCount)
                    {
                        freeGlyphRects.Add(s_FreeGlyphRects[i]);
                    }

                    if (i < usedGlyphRectCount)
                    {
                        usedGlyphRects.Add(s_UsedGlyphRects[i]);
                    }
                }

                return(true);
            }

            glyph = null;

            return(false);
        }
コード例 #7
0
 extern static bool TryPackGlyphsInAtlas_Internal([Out] GlyphMarshallingStruct[] glyphsToAdd, ref int glyphsToAddCount, [Out] GlyphMarshallingStruct[] glyphsAdded, ref int glyphsAddedCount,
                                                  int padding, GlyphPackingMode packingMode, GlyphRenderMode renderMode, int width, int height,
                                                  [Out] GlyphRect[] freeGlyphRects, ref int freeGlyphRectCount, [Out] GlyphRect[] usedGlyphRects, ref int usedGlyphRectCount);
コード例 #8
0
        /// <summary>
        /// Pack glyphs in the given atlas size.
        /// </summary>
        /// <param name="glyphsToAdd">Glyphs to pack in atlas.</param>
        /// <param name="glyphsAdded">Glyphs packed in atlas.</param>
        /// <param name="padding">The padding between glyphs.</param>
        /// <param name="packingMode">The packing algorithm used to pack the glyphs.</param>
        /// <param name="renderMode">The glyph rendering mode.</param>
        /// <param name="width">The width of the target atlas texture.</param>
        /// <param name="height">The height of the target atlas texture.</param>
        /// <param name="freeGlyphRects">List of GlyphRects representing the available space in the atlas.</param>
        /// <param name="usedGlyphRects">List of GlyphRects representing the occupied space in the atlas.</param>
        /// <returns></returns>
        internal static bool TryPackGlyphsInAtlas(List <Glyph> glyphsToAdd, List <Glyph> glyphsAdded, int padding, GlyphPackingMode packingMode, GlyphRenderMode renderMode, int width, int height, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects)
        {
            // Determine potential total allocations required for glyphs and glyph rectangles.
            int glyphsToAddCount   = glyphsToAdd.Count;
            int glyphsAddedCount   = glyphsAdded.Count;
            int freeGlyphRectCount = freeGlyphRects.Count;
            int usedGlyphRectCount = usedGlyphRects.Count;
            int totalCount         = glyphsToAddCount + glyphsAddedCount + freeGlyphRectCount + usedGlyphRectCount;

            // Make sure marshaling arrays allocations are appropriate.
            if (s_GlyphMarshallingStruct_IN.Length < totalCount || s_GlyphMarshallingStruct_OUT.Length < totalCount || s_FreeGlyphRects.Length < totalCount || s_UsedGlyphRects.Length < totalCount)
            {
                int newSize = Mathf.NextPowerOfTwo(totalCount + 1);
                s_GlyphMarshallingStruct_IN  = new GlyphMarshallingStruct[newSize];
                s_GlyphMarshallingStruct_OUT = new GlyphMarshallingStruct[newSize];
                s_FreeGlyphRects             = new GlyphRect[newSize];
                s_UsedGlyphRects             = new GlyphRect[newSize];
            }

            s_GlyphLookupDictionary.Clear();

            // Copy glyph data into appropriate marshaling array.
            for (int i = 0; i < totalCount; i++)
            {
                if (i < glyphsToAddCount)
                {
                    GlyphMarshallingStruct glyphStruct = new GlyphMarshallingStruct(glyphsToAdd[i]);

                    s_GlyphMarshallingStruct_IN[i] = glyphStruct;

                    // Add reference to glyph in lookup dictionary
                    if (s_GlyphLookupDictionary.ContainsKey(glyphStruct.index) == false)
                    {
                        s_GlyphLookupDictionary.Add(glyphStruct.index, glyphsToAdd[i]);
                    }
                }

                if (i < glyphsAddedCount)
                {
                    GlyphMarshallingStruct glyphStruct = new GlyphMarshallingStruct(glyphsAdded[i]);

                    s_GlyphMarshallingStruct_OUT[i] = glyphStruct;

                    // Add reference to glyph in lookup dictionary
                    if (s_GlyphLookupDictionary.ContainsKey(glyphStruct.index) == false)
                    {
                        s_GlyphLookupDictionary.Add(glyphStruct.index, glyphsAdded[i]);
                    }
                }

                if (i < freeGlyphRectCount)
                {
                    s_FreeGlyphRects[i] = freeGlyphRects[i];
                }

                if (i < usedGlyphRectCount)
                {
                    s_UsedGlyphRects[i] = usedGlyphRects[i];
                }
            }

            bool allGlyphsIncluded = TryPackGlyphsInAtlas_Internal(s_GlyphMarshallingStruct_IN, ref glyphsToAddCount, s_GlyphMarshallingStruct_OUT, ref glyphsAddedCount,
                                                                   padding, packingMode, renderMode, width, height,
                                                                   s_FreeGlyphRects, ref freeGlyphRectCount, s_UsedGlyphRects, ref usedGlyphRectCount);

            // Clear lists and / or re-allocate arrays.
            glyphsToAdd.Clear();
            glyphsAdded.Clear();
            freeGlyphRects.Clear();
            usedGlyphRects.Clear();

            // Copy marshaled glyph data back into the appropriate lists.
            for (int i = 0; i < totalCount; i++)
            {
                if (i < glyphsToAddCount)
                {
                    GlyphMarshallingStruct glyphStruct = s_GlyphMarshallingStruct_IN[i];
                    Glyph glyph = s_GlyphLookupDictionary[glyphStruct.index];

                    // Note: In theory, only new glyphRect x and y need to be copied.
                    glyph.metrics    = glyphStruct.metrics;
                    glyph.glyphRect  = glyphStruct.glyphRect;
                    glyph.scale      = glyphStruct.scale;
                    glyph.atlasIndex = glyphStruct.atlasIndex;

                    glyphsToAdd.Add(glyph);
                }

                if (i < glyphsAddedCount)
                {
                    GlyphMarshallingStruct glyphStruct = s_GlyphMarshallingStruct_OUT[i];
                    Glyph glyph = s_GlyphLookupDictionary[glyphStruct.index];

                    glyph.metrics    = glyphStruct.metrics;
                    glyph.glyphRect  = glyphStruct.glyphRect;
                    glyph.scale      = glyphStruct.scale;
                    glyph.atlasIndex = glyphStruct.atlasIndex;

                    glyphsAdded.Add(glyph);
                }

                if (i < freeGlyphRectCount)
                {
                    freeGlyphRects.Add(s_FreeGlyphRects[i]);
                }

                if (i < usedGlyphRectCount)
                {
                    usedGlyphRects.Add(s_UsedGlyphRects[i]);
                }
            }

            return(allGlyphsIncluded);
        }
コード例 #9
0
        internal static bool TryAddGlyphsToTexture(List <uint> glyphIndexes, int padding, GlyphPackingMode packingMode, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects, GlyphRenderMode renderMode, Texture2D texture, out Glyph[] glyphs)
        {
            Profiler.BeginSample("FontEngine.TryAddGlyphsToTexture");
            glyphs = null;
            bool flag = glyphIndexes == null || glyphIndexes.Count == 0;
            bool result;

            if (flag)
            {
                Profiler.EndSample();
                result = false;
            }
            else
            {
                int  count = glyphIndexes.Count;
                bool flag2 = FontEngine.s_GlyphIndexes_MarshallingArray_A == null || FontEngine.s_GlyphIndexes_MarshallingArray_A.Length < count;
                if (flag2)
                {
                    bool flag3 = FontEngine.s_GlyphIndexes_MarshallingArray_A == null;
                    if (flag3)
                    {
                        FontEngine.s_GlyphIndexes_MarshallingArray_A = new uint[count];
                    }
                    else
                    {
                        int num = Mathf.NextPowerOfTwo(count + 1);
                        FontEngine.s_GlyphIndexes_MarshallingArray_A = new uint[num];
                    }
                }
                int  count2 = freeGlyphRects.Count;
                int  count3 = usedGlyphRects.Count;
                int  num2   = count2 + count3 + count;
                bool flag4  = FontEngine.s_FreeGlyphRects.Length < num2 || FontEngine.s_UsedGlyphRects.Length < num2;
                if (flag4)
                {
                    int num3 = Mathf.NextPowerOfTwo(num2 + 1);
                    FontEngine.s_FreeGlyphRects = new GlyphRect[num3];
                    FontEngine.s_UsedGlyphRects = new GlyphRect[num3];
                }
                bool flag5 = FontEngine.s_GlyphMarshallingStruct_OUT.Length < count;
                if (flag5)
                {
                    int num4 = Mathf.NextPowerOfTwo(count + 1);
                    FontEngine.s_GlyphMarshallingStruct_OUT = new GlyphMarshallingStruct[num4];
                }
                int num5 = FontEngineUtilities.MaxValue(count2, count3, count);
                for (int i = 0; i < num5; i++)
                {
                    bool flag6 = i < count;
                    if (flag6)
                    {
                        FontEngine.s_GlyphIndexes_MarshallingArray_A[i] = glyphIndexes[i];
                    }
                    bool flag7 = i < count2;
                    if (flag7)
                    {
                        FontEngine.s_FreeGlyphRects[i] = freeGlyphRects[i];
                    }
                    bool flag8 = i < count3;
                    if (flag8)
                    {
                        FontEngine.s_UsedGlyphRects[i] = usedGlyphRects[i];
                    }
                }
                bool flag9  = FontEngine.TryAddGlyphsToTexture_Internal(FontEngine.s_GlyphIndexes_MarshallingArray_A, padding, packingMode, FontEngine.s_FreeGlyphRects, ref count2, FontEngine.s_UsedGlyphRects, ref count3, renderMode, texture, FontEngine.s_GlyphMarshallingStruct_OUT, ref count);
                bool flag10 = FontEngine.s_Glyphs == null || FontEngine.s_Glyphs.Length <= count;
                if (flag10)
                {
                    FontEngine.s_Glyphs = new Glyph[Mathf.NextPowerOfTwo(count + 1)];
                }
                FontEngine.s_Glyphs[count] = null;
                freeGlyphRects.Clear();
                usedGlyphRects.Clear();
                num5 = FontEngineUtilities.MaxValue(count2, count3, count);
                for (int j = 0; j < num5; j++)
                {
                    bool flag11 = j < count;
                    if (flag11)
                    {
                        FontEngine.s_Glyphs[j] = new Glyph(FontEngine.s_GlyphMarshallingStruct_OUT[j]);
                    }
                    bool flag12 = j < count2;
                    if (flag12)
                    {
                        freeGlyphRects.Add(FontEngine.s_FreeGlyphRects[j]);
                    }
                    bool flag13 = j < count3;
                    if (flag13)
                    {
                        usedGlyphRects.Add(FontEngine.s_UsedGlyphRects[j]);
                    }
                }
                glyphs = FontEngine.s_Glyphs;
                Profiler.EndSample();
                result = flag9;
            }
            return(result);
        }
コード例 #10
0
 private static extern bool TryAddGlyphsToTexture_Internal_MultiThread([Out] GlyphMarshallingStruct[] glyphsToAdd, ref int glyphsToAddCount, [Out] GlyphMarshallingStruct[] glyphsAdded, ref int glyphsAddedCount, int padding, GlyphPackingMode packingMode, [Out] GlyphRect[] freeGlyphRects, ref int freeGlyphRectCount, [Out] GlyphRect[] usedGlyphRects, ref int usedGlyphRectCount, GlyphRenderMode renderMode, Texture2D texture);
コード例 #11
0
        internal static bool TryAddGlyphsToTexture(List <Glyph> glyphsToAdd, List <Glyph> glyphsAdded, int padding, GlyphPackingMode packingMode, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects, GlyphRenderMode renderMode, Texture2D texture)
        {
            Profiler.BeginSample("FontEngine.TryAddGlyphsToTexture");
            int  count = glyphsToAdd.Count;
            int  num   = 0;
            bool flag  = FontEngine.s_GlyphMarshallingStruct_IN.Length < count || FontEngine.s_GlyphMarshallingStruct_OUT.Length < count;

            if (flag)
            {
                int  newSize = Mathf.NextPowerOfTwo(count + 1);
                bool flag2   = FontEngine.s_GlyphMarshallingStruct_IN.Length < count;
                if (flag2)
                {
                    Array.Resize <GlyphMarshallingStruct>(ref FontEngine.s_GlyphMarshallingStruct_IN, newSize);
                }
                bool flag3 = FontEngine.s_GlyphMarshallingStruct_OUT.Length < count;
                if (flag3)
                {
                    Array.Resize <GlyphMarshallingStruct>(ref FontEngine.s_GlyphMarshallingStruct_OUT, newSize);
                }
            }
            int  count2 = freeGlyphRects.Count;
            int  count3 = usedGlyphRects.Count;
            int  num2   = count2 + count3 + count;
            bool flag4  = FontEngine.s_FreeGlyphRects.Length < num2 || FontEngine.s_UsedGlyphRects.Length < num2;

            if (flag4)
            {
                int  newSize2 = Mathf.NextPowerOfTwo(num2 + 1);
                bool flag5    = FontEngine.s_FreeGlyphRects.Length < num2;
                if (flag5)
                {
                    Array.Resize <GlyphRect>(ref FontEngine.s_FreeGlyphRects, newSize2);
                }
                bool flag6 = FontEngine.s_UsedGlyphRects.Length < num2;
                if (flag6)
                {
                    Array.Resize <GlyphRect>(ref FontEngine.s_UsedGlyphRects, newSize2);
                }
            }
            FontEngine.s_GlyphLookupDictionary.Clear();
            int  num3  = 0;
            bool flag7 = true;

            while (flag7)
            {
                flag7 = false;
                bool flag8 = num3 < count;
                if (flag8)
                {
                    Glyph glyph = glyphsToAdd[num3];
                    FontEngine.s_GlyphMarshallingStruct_IN[num3] = new GlyphMarshallingStruct(glyph);
                    FontEngine.s_GlyphLookupDictionary.Add(glyph.index, glyph);
                    flag7 = true;
                }
                bool flag9 = num3 < count2;
                if (flag9)
                {
                    FontEngine.s_FreeGlyphRects[num3] = freeGlyphRects[num3];
                    flag7 = true;
                }
                bool flag10 = num3 < count3;
                if (flag10)
                {
                    FontEngine.s_UsedGlyphRects[num3] = usedGlyphRects[num3];
                    flag7 = true;
                }
                num3++;
            }
            bool result = FontEngine.TryAddGlyphsToTexture_Internal_MultiThread(FontEngine.s_GlyphMarshallingStruct_IN, ref count, FontEngine.s_GlyphMarshallingStruct_OUT, ref num, padding, packingMode, FontEngine.s_FreeGlyphRects, ref count2, FontEngine.s_UsedGlyphRects, ref count3, renderMode, texture);

            glyphsToAdd.Clear();
            glyphsAdded.Clear();
            freeGlyphRects.Clear();
            usedGlyphRects.Clear();
            num3  = 0;
            flag7 = true;
            while (flag7)
            {
                flag7 = false;
                bool flag11 = num3 < count;
                if (flag11)
                {
                    uint index = FontEngine.s_GlyphMarshallingStruct_IN[num3].index;
                    glyphsToAdd.Add(FontEngine.s_GlyphLookupDictionary[index]);
                    flag7 = true;
                }
                bool flag12 = num3 < num;
                if (flag12)
                {
                    uint  index2 = FontEngine.s_GlyphMarshallingStruct_OUT[num3].index;
                    Glyph glyph2 = FontEngine.s_GlyphLookupDictionary[index2];
                    glyph2.atlasIndex = FontEngine.s_GlyphMarshallingStruct_OUT[num3].atlasIndex;
                    glyph2.scale      = FontEngine.s_GlyphMarshallingStruct_OUT[num3].scale;
                    glyph2.glyphRect  = FontEngine.s_GlyphMarshallingStruct_OUT[num3].glyphRect;
                    glyph2.metrics    = FontEngine.s_GlyphMarshallingStruct_OUT[num3].metrics;
                    glyphsAdded.Add(glyph2);
                    flag7 = true;
                }
                bool flag13 = num3 < count2;
                if (flag13)
                {
                    freeGlyphRects.Add(FontEngine.s_FreeGlyphRects[num3]);
                    flag7 = true;
                }
                bool flag14 = num3 < count3;
                if (flag14)
                {
                    usedGlyphRects.Add(FontEngine.s_UsedGlyphRects[num3]);
                    flag7 = true;
                }
                num3++;
            }
            Profiler.EndSample();
            return(result);
        }
コード例 #12
0
        internal static bool TryPackGlyphsInAtlas(List <Glyph> glyphsToAdd, List <Glyph> glyphsAdded, int padding, GlyphPackingMode packingMode, GlyphRenderMode renderMode, int width, int height, List <GlyphRect> freeGlyphRects, List <GlyphRect> usedGlyphRects)
        {
            int  count  = glyphsToAdd.Count;
            int  count2 = glyphsAdded.Count;
            int  count3 = freeGlyphRects.Count;
            int  count4 = usedGlyphRects.Count;
            int  num    = count + count2 + count3 + count4;
            bool flag   = FontEngine.s_GlyphMarshallingStruct_IN.Length < num || FontEngine.s_GlyphMarshallingStruct_OUT.Length < num || FontEngine.s_FreeGlyphRects.Length < num || FontEngine.s_UsedGlyphRects.Length < num;

            if (flag)
            {
                int num2 = Mathf.NextPowerOfTwo(num + 1);
                FontEngine.s_GlyphMarshallingStruct_IN  = new GlyphMarshallingStruct[num2];
                FontEngine.s_GlyphMarshallingStruct_OUT = new GlyphMarshallingStruct[num2];
                FontEngine.s_FreeGlyphRects             = new GlyphRect[num2];
                FontEngine.s_UsedGlyphRects             = new GlyphRect[num2];
            }
            FontEngine.s_GlyphLookupDictionary.Clear();
            for (int i = 0; i < num; i++)
            {
                bool flag2 = i < count;
                if (flag2)
                {
                    GlyphMarshallingStruct glyphMarshallingStruct = new GlyphMarshallingStruct(glyphsToAdd[i]);
                    FontEngine.s_GlyphMarshallingStruct_IN[i] = glyphMarshallingStruct;
                    bool flag3 = !FontEngine.s_GlyphLookupDictionary.ContainsKey(glyphMarshallingStruct.index);
                    if (flag3)
                    {
                        FontEngine.s_GlyphLookupDictionary.Add(glyphMarshallingStruct.index, glyphsToAdd[i]);
                    }
                }
                bool flag4 = i < count2;
                if (flag4)
                {
                    GlyphMarshallingStruct glyphMarshallingStruct2 = new GlyphMarshallingStruct(glyphsAdded[i]);
                    FontEngine.s_GlyphMarshallingStruct_OUT[i] = glyphMarshallingStruct2;
                    bool flag5 = !FontEngine.s_GlyphLookupDictionary.ContainsKey(glyphMarshallingStruct2.index);
                    if (flag5)
                    {
                        FontEngine.s_GlyphLookupDictionary.Add(glyphMarshallingStruct2.index, glyphsAdded[i]);
                    }
                }
                bool flag6 = i < count3;
                if (flag6)
                {
                    FontEngine.s_FreeGlyphRects[i] = freeGlyphRects[i];
                }
                bool flag7 = i < count4;
                if (flag7)
                {
                    FontEngine.s_UsedGlyphRects[i] = usedGlyphRects[i];
                }
            }
            bool result = FontEngine.TryPackGlyphsInAtlas_Internal(FontEngine.s_GlyphMarshallingStruct_IN, ref count, FontEngine.s_GlyphMarshallingStruct_OUT, ref count2, padding, packingMode, renderMode, width, height, FontEngine.s_FreeGlyphRects, ref count3, FontEngine.s_UsedGlyphRects, ref count4);

            glyphsToAdd.Clear();
            glyphsAdded.Clear();
            freeGlyphRects.Clear();
            usedGlyphRects.Clear();
            for (int j = 0; j < num; j++)
            {
                bool flag8 = j < count;
                if (flag8)
                {
                    GlyphMarshallingStruct glyphMarshallingStruct3 = FontEngine.s_GlyphMarshallingStruct_IN[j];
                    Glyph glyph = FontEngine.s_GlyphLookupDictionary[glyphMarshallingStruct3.index];
                    glyph.metrics    = glyphMarshallingStruct3.metrics;
                    glyph.glyphRect  = glyphMarshallingStruct3.glyphRect;
                    glyph.scale      = glyphMarshallingStruct3.scale;
                    glyph.atlasIndex = glyphMarshallingStruct3.atlasIndex;
                    glyphsToAdd.Add(glyph);
                }
                bool flag9 = j < count2;
                if (flag9)
                {
                    GlyphMarshallingStruct glyphMarshallingStruct4 = FontEngine.s_GlyphMarshallingStruct_OUT[j];
                    Glyph glyph2 = FontEngine.s_GlyphLookupDictionary[glyphMarshallingStruct4.index];
                    glyph2.metrics    = glyphMarshallingStruct4.metrics;
                    glyph2.glyphRect  = glyphMarshallingStruct4.glyphRect;
                    glyph2.scale      = glyphMarshallingStruct4.scale;
                    glyph2.atlasIndex = glyphMarshallingStruct4.atlasIndex;
                    glyphsAdded.Add(glyph2);
                }
                bool flag10 = j < count3;
                if (flag10)
                {
                    freeGlyphRects.Add(FontEngine.s_FreeGlyphRects[j]);
                }
                bool flag11 = j < count4;
                if (flag11)
                {
                    usedGlyphRects.Add(FontEngine.s_UsedGlyphRects[j]);
                }
            }
            return(result);
        }
コード例 #13
0
 private static extern bool TryPackGlyphInAtlas_Internal(ref GlyphMarshallingStruct glyph, int padding, GlyphPackingMode packingMode, GlyphRenderMode renderMode, int width, int height, [Out] GlyphRect[] freeGlyphRects, ref int freeGlyphRectCount, [Out] GlyphRect[] usedGlyphRects, ref int usedGlyphRectCount);