Add some framework support for caching the last accessed run.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15980 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-02-17 01:19:34 +00:00
parent d6239b2d59
commit 1ba6d8c940
3 changed files with 42 additions and 1 deletions

View file

@ -1,4 +1,9 @@
2003-02-16 02:08 Alexander Malmberg <alexander@malmberg.org>
2003-02-17 02:16 Alexander Malmberg <alexander@malmberg.org>
* Headers/gnustep/gui/GSLayoutManager.h, Source/GSLayoutManager.m:
Add some framework support for caching the last accessed run.
2003-02-17 02:08 Alexander Malmberg <alexander@malmberg.org>
* Source/NSLayoutManager.m (-rectArrayForGlyphRange:
withinSelectedGlyphRange:inTextContainer:rectCount:,

View file

@ -84,6 +84,15 @@ how it's supposed to work. It's functional and correct, but it isn't fast. */
/* For -rectArrayForGlyphRange:... */
NSRect *rect_array;
int rect_array_size;
/*
Cached run. GSHorizontalTypesetter (and other typesetters, presumably)
often walk linearly through the glyphs. Thus, for many methods, we cache
the last run so we can quickly get more information for the next glyph.
*/
struct GSLayoutManager_glyph_run_s *cached_run;
int cached_pos, cached_cpos;
}

View file

@ -191,6 +191,21 @@ glyph_run_t *GSLayoutManager_run_for_glyph_index(unsigned int glyphIndex,
if (glyphs->glyph_length <= glyphIndex)
return NULL;
#if 0
if (cached_run)
{
if (glyphIndex >= cached_pos &&
glyphIndex < cached_pos + cached_run->head.glyph_length)
{
if (glyph_pos)
*glyph_pos = cached_pos;
if (char_pos)
*char_pos = cached_cpos;
return cached_run;
}
}
#endif
pos = cpos = 0;
level = SKIP_LIST_DEPTH;
h = glyphs;
@ -223,6 +238,13 @@ glyph_run_t *GSLayoutManager_run_for_glyph_index(unsigned int glyphIndex,
*glyph_pos = pos;
if (char_pos)
*char_pos = cpos;
#if 0
cached_run = (glyph_run_t *)h;
cached_pos = pos;
cached_cpos = cpos;
#endif
return (glyph_run_t *)h;
}
}
@ -900,6 +922,11 @@ it should still be safe. might lose opportunities to merge runs, though.
NSRange rng;
/*
We always clear out the cached run information to be safe.
*/
cached_run = NULL;
/* [self _glyphDumpRuns];
printf("range=(%i+%i) lengthChange=%i\n", range.location, range.length, lengthChange);*/
range.length -= lengthChange;