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 = ¤tEntry->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); }
public GOFFSET *GlyphOffsets(ScriptParagraph *scriptParagraph) { return(scriptParagraph->GlyphOffsets + GlyphIndexInParagraph); }
public int *GlyphAdvanceWidths(ScriptParagraph *scriptParagraph) { return(scriptParagraph->GlyphAdvanceWidths + GlyphIndexInParagraph); }
public SCRIPT_VISATTR *GlyphVisualAttributes(ScriptParagraph *scriptParagraph) { return(scriptParagraph->GlyphVisualAttributes + GlyphIndexInParagraph); }
public ushort *Glyphs(ScriptParagraph *scriptParagraph) { return(scriptParagraph->Glyphs + GlyphIndexInParagraph); }
public SCRIPT_LOGATTR *CharLogicalAttributes(ScriptParagraph *scriptParagraph) { return(scriptParagraph->CharLogicalAttributes + CharIndexInParagraph); }
public ushort *CharLogicalClusters(ScriptParagraph *scriptParagraph) { return(scriptParagraph->CharLogicalClusters + CharIndexInParagraph); }
public char *Chars(ScriptParagraph *scriptParagraph, char *charZero) { return(scriptParagraph->Chars(charZero) + CharIndexInParagraph); }