Optimize reuse of soft-invalidated layout a bit in a common case.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16006 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-02-18 23:34:51 +00:00
parent 30e76ace40
commit 5faf6f6f1e
5 changed files with 55 additions and 18 deletions

View file

@ -1,3 +1,9 @@
2003-02-19 00:31 Alexander Malmberg <alexander@malmberg.org>
* Headers/gnustep/gui/GSLayoutManager.h,
Source/GSHorizontalTypesetter.m, Source/GSLayoutManager.m: Optimize
reuse of soft-invalidated layout a bit in a common case.
2003-02-19 00:10 Alexander Malmberg <alexander@malmberg.org>
* Source/GSLayoutManager.m (-invalidateGlyphsForCharacterRange:

View file

@ -1,10 +1,10 @@
/*
GSLayoutManager.h
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Author: Alexander Malmberg <alexander@malmberg.org>
Date: 2002
Date: November 2002 - February 2003
This file is part of the GNUstep GUI Library.
@ -329,6 +329,7 @@ layout information.
nextGlyph: (unsigned int *)next_glyph
inTextContainer: (NSTextContainer *)textContainer;
-(unsigned int) _softInvalidateFirstGlyphInTextContainer: (NSTextContainer *)textContainer;
-(unsigned int) _softInvalidateNumberOfLineFragsInTextContainer: (NSTextContainer *)textContainer;
@end

View file

@ -1,10 +1,10 @@
/*
GSLayoutManager_internal.h
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Author: Alexander Malmberg <alexander@malmberg.org>
Date: 2002
Date: November 2002 - February 2003
This file is part of the GNUstep GUI Library.

View file

@ -1,10 +1,10 @@
/*
GSHorizontalTypesetter.m
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Author: Alexander Malmberg <alexander@malmberg.org>
Date: 2002
Date: November 2002 - February 2003
This file is part of the GNUstep GUI Library.
@ -418,7 +418,21 @@ typedef struct GSHorizontalTypesetter_line_frag_s
*/
shift.width = 0;
shift.height = curPoint.y - r0.origin.y;
for (i = 1; 1; i++)
if (shift.height == 0)
{
/*
If we don't need to shift, we know that everything will fit,
so we just need the last rectangle so we can update the
current point and glyph.
*/
i = [curLayoutManager _softInvalidateNumberOfLineFragsInTextContainer: curTextContainer];
i--;
}
else
{
i = 1;
}
for (; 1; i++)
{
r = [curLayoutManager _softInvalidateLineFragRect: i
nextGlyph: &g2

View file

@ -1,10 +1,10 @@
/*
GSLayoutManager.m
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Author: Alexander Malmberg <alexander@malmberg.org>
Date: 2002
Date: November 2002 - February 2003
This file is part of the GNUstep GUI Library.
@ -1164,9 +1164,7 @@ places where we switch.
next->glyphs = NULL;
}
/* TODO: this creates really large runs at times */
printf("at %i, length is %i, max is %i\n",cpos,next->head.char_length,max);
next->head.char_length -= max - cpos;
printf("extend?? to %i\n",next->head.char_length);
hn = &next->head;
hn--;
@ -1213,7 +1211,7 @@ places where we switch.
adjust their heads with updated information. When we're done, we update
all the remaining heads.
*/
printf("create runs for %i+%i\n", range.location, range.length);
// printf("create runs for %i+%i\n", range.location, range.length);
{ /* OPT: this is creating more runs than it needs to */
NSDictionary *attributes;
glyph_run_t *new;
@ -2283,16 +2281,20 @@ forStartOfGlyphRange: (NSRange)glyphRange
return;
}
for (i = 0, lf = &tc->linefrags[tc->num_linefrags]; i < num; i++, lf++)
if (shift.width || shift.height)
{
lf->rect.origin.x += shift.width;
lf->rect.origin.y += shift.height;
lf->used_rect.origin.x += shift.width;
lf->used_rect.origin.y += shift.height;
tc->length += lf->length;
for (i = 0, lf = &tc->linefrags[tc->num_linefrags]; i < num; i++, lf++)
{
lf->rect.origin.x += shift.width;
lf->rect.origin.y += shift.height;
lf->used_rect.origin.x += shift.width;
lf->used_rect.origin.y += shift.height;
}
}
tc->num_soft -= num;
tc->num_linefrags += num;
lf = &tc->linefrags[tc->num_linefrags - 1];
tc->length = lf->pos + lf->length - tc->pos;
layout_glyph = tc->pos + tc->length;
/*
@ -2347,6 +2349,20 @@ forStartOfGlyphRange: (NSRange)glyphRange
return (unsigned int)-1;
}
-(unsigned int) _softInvalidateNumberOfLineFragsInTextContainer: (NSTextContainer *)textContainer
{
int i;
textcontainer_t *tc;
for (i = 0, tc = textcontainers; i < num_textcontainers; i++, tc++)
if (tc->textContainer == textContainer)
break;
if (i == num_textcontainers)
{
NSLog(@"(%s): does not own text container", __PRETTY_FUNCTION__);
return (unsigned int)-1;
}
return tc->num_soft;
}
@end