Пример #1
0
        public bool TryGetScriptParagraph(int paragraphIndex, out ScriptParagraph *scriptParagraph)
        {
            // Handle wrap-around at 32bits by thrashing all tokens.
            LruEntry *firstEntry = (LruEntry *)buffer.GetPointer();
            LruEntry *endEntry   = firstEntry + buffer.Count;

            if (nextToken == int.MaxValue)
            {
                nextToken = 0;
                for (LruEntry *currentEntry = firstEntry; currentEntry != endEntry; currentEntry++)
                {
                    currentEntry->Token = nextToken++;
                }
            }

            // Search for a matching paragraph and return it if found.
            // Make note of least recently used entry just in case.
            LruEntry *lruEntry = null;
            int       lruToken = int.MaxValue;

            for (LruEntry *currentEntry = firstEntry; currentEntry != endEntry; currentEntry++)
            {
                if (currentEntry->ParagraphIndex == paragraphIndex)
                {
                    currentEntry->Token = nextToken++;
                    scriptParagraph     = &currentEntry->Paragraph;
                    return(true);
                }

                int token = currentEntry->Token;
                if (token < lruToken)
                {
                    lruToken = token;
                    lruEntry = currentEntry;
                }
            }

            // Decide whether to allocate a new entry from remaining capacity or replace the least-recently used one.
            LruEntry *entryToReplace;

            if (buffer.Count != buffer.Capacity)
            {
                entryToReplace = endEntry;
                entryToReplace->Paragraph.Initialize();
                buffer.Count += 1;
            }
            else
            {
                entryToReplace = lruEntry;
            }

            // Return the entry.
            entryToReplace->Token          = nextToken++;
            entryToReplace->ParagraphIndex = paragraphIndex;
            scriptParagraph = &entryToReplace->Paragraph;
            return(false);
        }
Пример #2
0
 public GOFFSET *GlyphOffsets(ScriptParagraph *scriptParagraph)
 {
     return(scriptParagraph->GlyphOffsets + GlyphIndexInParagraph);
 }
Пример #3
0
 public int *GlyphAdvanceWidths(ScriptParagraph *scriptParagraph)
 {
     return(scriptParagraph->GlyphAdvanceWidths + GlyphIndexInParagraph);
 }
Пример #4
0
 public SCRIPT_VISATTR *GlyphVisualAttributes(ScriptParagraph *scriptParagraph)
 {
     return(scriptParagraph->GlyphVisualAttributes + GlyphIndexInParagraph);
 }
Пример #5
0
 public ushort *Glyphs(ScriptParagraph *scriptParagraph)
 {
     return(scriptParagraph->Glyphs + GlyphIndexInParagraph);
 }
Пример #6
0
 public SCRIPT_LOGATTR *CharLogicalAttributes(ScriptParagraph *scriptParagraph)
 {
     return(scriptParagraph->CharLogicalAttributes + CharIndexInParagraph);
 }
Пример #7
0
 public ushort *CharLogicalClusters(ScriptParagraph *scriptParagraph)
 {
     return(scriptParagraph->CharLogicalClusters + CharIndexInParagraph);
 }
Пример #8
0
 public char *Chars(ScriptParagraph *scriptParagraph, char *charZero)
 {
     return(scriptParagraph->Chars(charZero) + CharIndexInParagraph);
 }