Beispiel #1
0
        // Purge all caches, useful in low memory conditions
        public void purgeCaches()
        {
            std::lock_guard <std::recursive_mutex> _l = new std::lock_guard <std::recursive_mutex>(gMinikinLock);
            LayoutCache layoutCache = LayoutEngine.getInstance().layoutCache.functorMethod;

            layoutCache.clear();
            purgeHbFontCacheLocked();
        }
Beispiel #2
0
        // Lay out a single word
        public float doLayoutWord(UInt16[] buf, int start, int count, int bufSize, bool isRtl, LayoutContext ctx, int bufStart, FontCollection collection, Layout layout, float[] advances)
        {
            LayoutCache    cache = LayoutEngine.getInstance().layoutCache.functorMethod;
            LayoutCacheKey key   = new LayoutCacheKey(collection, ctx.paint, new FontStyle(ctx.style), new UInt16(buf), start, count, bufSize, isRtl);

            float wordSpacing = count == 1 && isWordSpace(buf[start]) ? ctx.paint.wordSpacing : 0F;

            float advance;

            if (ctx.paint.skipCache())
            {
                Layout layoutForWord = new Layout();
                key.doLayout(layoutForWord, ctx, collection);
                if (layout != null)
                {
                    layout.appendLayout(layoutForWord, bufStart, wordSpacing);
                }
                if (advances != 0F)
                {
                    layoutForWord.getAdvances(advances);
                }
                advance = layoutForWord.getAdvance();
            }
            else
            {
                Layout layoutForWord = cache.get(key, ctx, collection);
                if (layout != null)
                {
                    layout.appendLayout(layoutForWord, bufStart, wordSpacing);
                }
                if (advances != 0F)
                {
                    layoutForWord.getAdvances(advances);
                }
                advance = layoutForWord.getAdvance();
            }

            if (wordSpacing != 0F)
            {
                advance += wordSpacing;
                if (advances != 0F)
                {
                    advances[0] += wordSpacing;
                }
            }
            return(advance);
        }