[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
rjw
rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:45:23 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 818e0f5b7f15ec03bbcf692866f128f017fdbc7c
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Jun 13 05:58:23 2003 +0000
Restoring fix for 3221078 that I earlier backed out in a
panic about performance. In careful performance testing
I now see no performance regression, and maybe a tiny improvement.
The earlier performance regression Vicki saw was entirely
due to the incorrect checkin for the fix to 3288532.
Reviewed by Chris & Gramps.
* WebCoreSupport.subproj/WebTextRenderer.h:
* WebCoreSupport.subproj/WebTextRenderer.m:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4540 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 1c29db4..d210233 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,18 @@
2003-06-12 Richard Williamson <rjw at apple.com>
+ Restoring fix for 3221078 that I earlier backed out in a
+ panic about performance. In careful performance testing
+ I now see no performance regression, and maybe a tiny improvement.
+ The earlier performance regression Vicki saw was entirely
+ due to the incorrect checkin for the fix to 3288532.
+
+ Reviewed by Chris & Gramps.
+
+ * WebCoreSupport.subproj/WebTextRenderer.h:
+ * WebCoreSupport.subproj/WebTextRenderer.m:
+
+2003-06-12 Richard Williamson <rjw at apple.com>
+
Correct fix for 3288532 again. This time will feeling!
Reviewed by Gramps.
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.h b/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
index d329cb4..31fb373 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
@@ -10,7 +10,10 @@ typedef struct WidthEntry WidthEntry;
typedef struct GlyphMap GlyphMap;
typedef struct GlyphEntry GlyphEntry;
typedef struct UnicodeGlyphMap UnicodeGlyphMap;
+typedef struct SubstituteFontWidthMap SubstituteFontWidthMap;
+/// Should be more than enough for normal usage.
+#define NUM_SUBSTITUTE_FONT_MAPS 10
@interface WebTextRenderer : NSObject <WebCoreTextRenderer>
{
@@ -31,6 +34,10 @@ typedef struct UnicodeGlyphMap UnicodeGlyphMap;
float roundedSpaceWidth;
float adjustedSpaceWidth;
+ int numSubstituteFontWidthMaps;
+ int maxSubstituteFontWidthMaps;
+ SubstituteFontWidthMap *substituteFontWidthMaps;
+
@private
BOOL usingPrinterFont;
}
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
index 760a156..c8c6131 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
@@ -85,6 +85,11 @@ struct UnicodeGlyphMap {
GlyphEntry *glyphs;
};
+struct SubstituteFontWidthMap {
+ NSFont *font;
+ WidthMap *map;
+};
+
@interface NSLanguage : NSObject
{
@@ -121,7 +126,7 @@ static CFCharacterSetRef nonBaseChars = NULL;
@interface WebTextRenderer (WebPrivate)
-- (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID;
+- (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID font:(NSFont *)font;
- (ATSGlyphRef)extendCharacterToGlyphMapToInclude:(UniChar) c;
- (ATSGlyphRef)extendUnicodeCharacterToGlyphMapToInclude: (UnicodeChar)c;
- (void)updateGlyphEntryForCharacter: (UniChar)c glyphID: (ATSGlyphRef)glyphID font: (NSFont *)substituteFont;
@@ -180,60 +185,93 @@ static inline ATSGlyphRef glyphForUnicodeCharacter (UnicodeGlyphMap *map, Unicod
static double totalCGGetAdvancesTime = 0;
#endif
-static inline WebGlyphWidth widthForGlyph (WebTextRenderer *renderer, WidthMap *map, ATSGlyphRef glyph, NSFont *font)
+static inline SubstituteFontWidthMap *mapForSubstituteFont(WebTextRenderer *renderer, NSFont *font)
+{
+ int i;
+
+ for (i = 0; i < renderer->numSubstituteFontWidthMaps; i++){
+ if (font == renderer->substituteFontWidthMaps[i].font)
+ return &renderer->substituteFontWidthMaps[i];
+ }
+
+ if (renderer->numSubstituteFontWidthMaps+1 == renderer->maxSubstituteFontWidthMaps){
+ renderer->maxSubstituteFontWidthMaps = renderer->maxSubstituteFontWidthMaps * 2;
+ renderer->substituteFontWidthMaps = realloc (renderer->substituteFontWidthMaps, renderer->maxSubstituteFontWidthMaps);
+ }
+
+ renderer->substituteFontWidthMaps[renderer->numSubstituteFontWidthMaps].font = font;
+ return &renderer->substituteFontWidthMaps[renderer->numSubstituteFontWidthMaps++];
+}
+
+static inline WebGlyphWidth widthFromMap (WebTextRenderer *renderer, WidthMap *map, ATSGlyphRef glyph, NSFont *font)
{
WebGlyphWidth width = UNINITIALIZED_GLYPH_WIDTH;
BOOL errorResult;
- if (map == 0){
- map = [renderer extendGlyphToWidthMapToInclude: glyph];
- return widthForGlyph (renderer, map, glyph, font);
- }
-
- if (glyph >= map->startRange && glyph <= map->endRange){
- width = map->widths[glyph-map->startRange].width;
- if (width == UNINITIALIZED_GLYPH_WIDTH){
+ while (1){
+ if (map == 0)
+ map = [renderer extendGlyphToWidthMapToInclude: glyph font:font];
-#ifdef _TIMING
- double startTime = CFAbsoluteTimeGetCurrent();
+ if (glyph >= map->startRange && glyph <= map->endRange){
+ width = map->widths[glyph-map->startRange].width;
+ if (width == UNINITIALIZED_GLYPH_WIDTH){
+
+#ifdef _TIMING
+ double startTime = CFAbsoluteTimeGetCurrent();
#endif
- if (font)
- errorResult = CGFontGetGlyphScaledAdvances ([font _backingCGSFont], &glyph, 1, &map->widths[glyph-map->startRange].width, [renderer->font pointSize]);
- else
- errorResult = CGFontGetGlyphScaledAdvances ([renderer->font _backingCGSFont], &glyph, 1, &map->widths[glyph-map->startRange].width, [renderer->font pointSize]);
- if (errorResult == 0)
- [NSException raise:NSInternalInconsistencyException format:@"Optimization assumption violation: unable to cache glyph widths - for %@ %f", [renderer->font displayName], [renderer->font pointSize]];
-
-#ifdef _TIMING
- double thisTime = CFAbsoluteTimeGetCurrent() - startTime;
- totalCGGetAdvancesTime += thisTime;
+ if (font)
+ errorResult = CGFontGetGlyphScaledAdvances ([font _backingCGSFont], &glyph, 1, &map->widths[glyph-map->startRange].width, [renderer->font pointSize]);
+ else
+ errorResult = CGFontGetGlyphScaledAdvances ([renderer->font _backingCGSFont], &glyph, 1, &map->widths[glyph-map->startRange].width, [renderer->font pointSize]);
+ if (errorResult == 0)
+ [NSException raise:NSInternalInconsistencyException format:@"Optimization assumption violation: unable to cache glyph widths - for %@ %f", [renderer->font displayName], [renderer->font pointSize]];
+
+#ifdef _TIMING
+ double thisTime = CFAbsoluteTimeGetCurrent() - startTime;
+ totalCGGetAdvancesTime += thisTime;
#endif
- width = map->widths[glyph-map->startRange].width;
+ width = map->widths[glyph-map->startRange].width;
+ }
}
+
+ if (width == UNINITIALIZED_GLYPH_WIDTH){
+ map = map->next;
+ continue;
+ }
+
+ // Hack to ensure that characters that match the width of the space character
+ // have the same integer width as the space character. This is necessary so
+ // glyphs in fixed pitch fonts all have the same integer width. We can't depend
+ // on the fixed pitch property of NSFont because that isn't set for all
+ // monospaced fonts, in particular Courier! This has the downside of inappropriately
+ // adjusting the widths of characters in non-monospaced fonts that are coincidentally
+ // the same width as a space in that font. In practice this is not an issue as the
+ // adjustment is always as the sub-pixel level.
+ if (width == renderer->spaceWidth)
+ return renderer->ceiledSpaceWidth;
+
+ return width;
}
+ // never get here.
+ return 0;
+}
- if (width == UNINITIALIZED_GLYPH_WIDTH)
- width = widthForGlyph (renderer, map->next, glyph, font);
-
- // Hack to ensure that characters that match the width of the space character
- // have the same integer width as the space character. This is necessary so
- // glyphs in fixed pitch fonts all have the same integer width. We can't depend
- // on the fixed pitch property of NSFont because that isn't set for all
- // monospaced fonts, in particular Courier! This has the downside of inappropriately
- // adjusting the widths of characters in non-monospaced fonts that are coincidentally
- // the same width as a space in that font. In practice this is not an issue as the
- // adjustment is always as the sub-pixel level.
- if (width == renderer->spaceWidth)
- return renderer->ceiledSpaceWidth;
+static inline WebGlyphWidth widthForGlyph (WebTextRenderer *renderer, ATSGlyphRef glyph, NSFont *font)
+{
+ WidthMap *map;
- return width;
-}
+ if (font && font != renderer->font)
+ map = mapForSubstituteFont(renderer, font)->map;
+ else
+ map = renderer->glyphToWidthMap;
+ return widthFromMap (renderer, map, glyph, font);
+}
static inline WebGlyphWidth widthForCharacter (WebTextRenderer *renderer, UniChar c, NSFont **font)
{
ATSGlyphRef glyphID = glyphForCharacter(renderer->characterToGlyphMap, c, font);
- return widthForGlyph (renderer, renderer->glyphToWidthMap, glyphID, *font);
+ return widthForGlyph (renderer, glyphID, *font);
}
@@ -432,7 +470,7 @@ static inline BOOL _fontContainsString (NSFont *font, NSString *string)
float _spaceWidth;
spaceGlyph = [self extendCharacterToGlyphMapToInclude: c];
- _spaceWidth = widthForGlyph(self, glyphToWidthMap, spaceGlyph, 0);
+ _spaceWidth = widthForGlyph(self, spaceGlyph, 0);
ceiledSpaceWidth = (float)CEIL_TO_INT(_spaceWidth);
roundedSpaceWidth = (float)ROUND_TO_INT(_spaceWidth);
if ([font isFixedPitch] || [font _isFakeFixedPitch]){
@@ -452,6 +490,9 @@ static inline BOOL _fontContainsString (NSFont *font, NSString *string)
[NSException raise:NSInternalInconsistencyException format:@"%@: Don't know how to pack glyphs for font %@ %f", self, [f displayName], [f pointSize]];
[super init];
+
+ maxSubstituteFontWidthMaps = NUM_SUBSTITUTE_FONT_MAPS;
+ substituteFontWidthMaps = calloc (1, maxSubstituteFontWidthMaps * sizeof(SubstituteFontWidthMap));
font = [(p ? [f printerFont] : [f screenFont]) retain];
usingPrinterFont = p;
@@ -952,7 +993,7 @@ static const char *joiningNames[] = {
// determine the characters cluster from this base character.
#ifdef DEBUG_DIACRITICAL
if (IsNonBaseChar(c)){
- printf ("NonBaseCharacter 0x%04x, joining attribute %d(%s), combining class %d, direction %d, glyph %d, width %f\n", c, WebCoreUnicodeJoiningFunction(c), joiningNames(WebCoreUnicodeJoiningFunction(c)), WebCoreUnicodeCombiningClassFunction(c), WebCoreUnicodeDirectionFunction(c), glyphID, widthForGlyph(self, glyphToWidthMap, glyphID));
+ printf ("NonBaseCharacter 0x%04x, joining attribute %d(%s), combining class %d, direction %d, glyph %d, width %f\n", c, WebCoreUnicodeJoiningFunction(c), joiningNames(WebCoreUnicodeJoiningFunction(c)), WebCoreUnicodeCombiningClassFunction(c), WebCoreUnicodeDirectionFunction(c), glyphID, widthForGlyph(self, glyphID));
}
#endif
@@ -1043,7 +1084,7 @@ static const char *joiningNames[] = {
}
}
else
- lastWidth = widthForGlyph(self, glyphToWidthMap, glyphID, substituteFont);
+ lastWidth = widthForGlyph(self, glyphID, substituteFont);
if (fontBuffer){
fontBuffer[numGlyphs] = (substituteFont ? substituteFont: font);
@@ -1242,16 +1283,21 @@ static const char *joiningNames[] = {
}
-- (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID
+- (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID font:(NSFont *)subFont
{
- WidthMap *map = (WidthMap *)calloc (1, sizeof(WidthMap));
+ WidthMap *map = (WidthMap *)calloc (1, sizeof(WidthMap)), **rootMap;
unsigned int end;
ATSGlyphRef start;
unsigned int blockSize;
unsigned int i, count;
- if (glyphToWidthMap == 0){
- if ([font numberOfGlyphs] < INITIAL_BLOCK_SIZE)
+ if (subFont && subFont != font)
+ rootMap = &mapForSubstituteFont(self,subFont)->map;
+ else
+ rootMap = &glyphToWidthMap;
+
+ if (*rootMap == 0){
+ if ([(subFont ? subFont : font) numberOfGlyphs] < INITIAL_BLOCK_SIZE)
blockSize = [font numberOfGlyphs];
else
blockSize = INITIAL_BLOCK_SIZE;
@@ -1275,10 +1321,10 @@ static const char *joiningNames[] = {
map->widths[i].width = UNINITIALIZED_GLYPH_WIDTH;
}
- if (glyphToWidthMap == 0)
- glyphToWidthMap = map;
+ if (*rootMap == 0)
+ *rootMap = map;
else {
- WidthMap *lastMap = glyphToWidthMap;
+ WidthMap *lastMap = *rootMap;
while (lastMap->next != 0)
lastMap = lastMap->next;
lastMap->next = map;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list