[webkit-changes] cvs commit: WebKit/WebCoreSupport.subproj
WebTextRenderer.m
Tim
tomernic at opensource.apple.com
Thu Dec 8 15:05:32 PST 2005
tomernic 05/12/08 15:05:32
Modified: . Tag: Safari-2-0-branch ChangeLog
WebCoreSupport.subproj Tag: Safari-2-0-branch
WebTextRenderer.m
Log:
Merged fix from TOT to Safari-2-0-branch.
Bug #: none
Submitted by: timo
Reviewed by: eseidel & darin
Changed some of the run measurement methods to C functions
to avoid overhead associated with objc_msgSend().
* WebCoreSupport.subproj/WebTextRenderer.m:
(-[WebTextRenderer floatWidthForRun:style:widths:]):
Updated to call new run measurement functions instead
of calling ObjC methods.
(-[WebTextRenderer CG_drawRun:style:geometry:]): ditto
(floatWidthForRun): ditto
(CG_floatWidthForRun): ditto
(ATSU_floatWidthForRun): ditto
(widthForNextCharacter): ditto
Revision Changes Path
No revision
No revision
1.3118.4.89 +20 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3118.4.88
retrieving revision 1.3118.4.89
diff -u -r1.3118.4.88 -r1.3118.4.89
--- ChangeLog 6 Dec 2005 23:33:54 -0000 1.3118.4.88
+++ ChangeLog 8 Dec 2005 23:05:16 -0000 1.3118.4.89
@@ -1,3 +1,23 @@
+2005-12-08 Tim Omernick <timo at apple.com>
+
+ Merged fix from TOT to Safari-2-0-branch.
+
+ Bug #: none
+ Submitted by: timo
+ Reviewed by: eseidel & darin
+ Changed some of the run measurement methods to C functions
+ to avoid overhead associated with objc_msgSend().
+
+ * WebCoreSupport.subproj/WebTextRenderer.m:
+ (-[WebTextRenderer floatWidthForRun:style:widths:]):
+ Updated to call new run measurement functions instead
+ of calling ObjC methods.
+ (-[WebTextRenderer CG_drawRun:style:geometry:]): ditto
+ (floatWidthForRun): ditto
+ (CG_floatWidthForRun): ditto
+ (ATSU_floatWidthForRun): ditto
+ (widthForNextCharacter): ditto
+
=== WebKit-417.7 ===
2005-12-06 David Harrison <harrison at apple.com>
No revision
No revision
1.165.8.10 +29 -36 WebKit/WebCoreSupport.subproj/WebTextRenderer.m
Index: WebTextRenderer.m
===================================================================
RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebTextRenderer.m,v
retrieving revision 1.165.8.9
retrieving revision 1.165.8.10
diff -u -r1.165.8.9 -r1.165.8.10
--- WebTextRenderer.m 10 Nov 2005 23:29:38 -0000 1.165.8.9
+++ WebTextRenderer.m 8 Dec 2005 23:05:31 -0000 1.165.8.10
@@ -27,6 +27,12 @@
#import <unicode/uchar.h>
#import <unicode/unorm.h>
+#if defined(__GNUC__) && (__GNUC__ > 3)
+#define ALWAYS_INLINE __attribute__ ((always_inline))
+#else
+#define ALWAYS_INLINE inline
+#endif
+
// FIXME: FATAL_ALWAYS seems like a bad idea; lets stop using it.
// SPI from other frameworks.
@@ -138,11 +144,12 @@
- (ATSGlyphRef)_extendUnicodeCharacterToGlyphMapToInclude: (UnicodeChar)c;
- (void)_updateGlyphEntryForCharacter: (UniChar)c glyphID: (ATSGlyphRef)glyphID font: (NSFont *)substituteFont;
-- (float)_floatWidthForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style widths:(float *)widthBuffer fonts:(NSFont **)fontBuffer glyphs:(CGGlyph *)glyphBuffer startPosition:(float *)startPosition numGlyphs:(int *)_numGlyphs;
+static inline float _floatWidthForRun(const WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, float *widthBuffer, NSFont **fontBuffer, CGGlyph *glyphBuffer, float *startPosition, int *_numGlyphs);
// Measuring runs.
-- (float)_CG_floatWidthForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style widths: (float *)widthBuffer fonts: (NSFont **)fontBuffer glyphs: (CGGlyph *)glyphBuffer startPosition:(float *)startPosition numGlyphs: (int *)_numGlyphs;
-- (float)_ATSU_floatWidthForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style;
+static ALWAYS_INLINE float _CG_floatWidthForRun(const WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, float *widthBuffer, NSFont **fontBuffer, CGGlyph *glyphBuffer, float *startPosition, int *_numGlyphs);
+static ALWAYS_INLINE float _ATSU_floatWidthForRun(const WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style);
+static ATSTrapezoid _trapezoidForRun(const WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, NSPoint p);
// Drawing runs.
- (void)_CG_drawRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style geometry:(const WebCoreTextGeometry *)geometry;
@@ -547,10 +554,10 @@
- (float)floatWidthForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style widths:(float *)widthBuffer
{
- if (style->smallCaps && !isSmallCapsRenderer) {
- return [[self _smallCapsRenderer] _floatWidthForRun:run style:style widths:widthBuffer fonts:nil glyphs:nil startPosition:nil numGlyphs:nil];
- }
- return [self _floatWidthForRun:run style:style widths:widthBuffer fonts:nil glyphs:nil startPosition:nil numGlyphs:nil];
+ if (style->smallCaps && !isSmallCapsRenderer)
+ return _floatWidthForRun([self _smallCapsRenderer], run, style, widthBuffer, nil, nil, nil, nil);
+
+ return _floatWidthForRun(self, run, style, widthBuffer, nil, nil, nil, nil);
}
- (void)drawLineForCharacters:(NSPoint)point yOffset:(float)yOffset width: (int)width color:(NSColor *)color thickness:(float)thickness
@@ -1068,13 +1075,7 @@
fontBuffer = localFontBuffer;
}
- [self _floatWidthForRun:run
- style:style
- widths:widthBuffer
- fonts:fontBuffer
- glyphs:glyphBuffer
- startPosition:&startX
- numGlyphs: &numGlyphs];
+ _floatWidthForRun(self, run, style, widthBuffer, fontBuffer, glyphBuffer, &startX, &numGlyphs);
// Eek. We couldn't generate ANY glyphs for the run.
if (numGlyphs <= 0)
@@ -1186,16 +1187,15 @@
};
#endif
-- (float)_floatWidthForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style widths:(float *)widthBuffer fonts:(NSFont **)fontBuffer glyphs:(CGGlyph *)glyphBuffer startPosition:(float *)startPosition numGlyphs:(int *)_numGlyphs
+static inline float _floatWidthForRun(const WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, float *widthBuffer, NSFont **fontBuffer, CGGlyph *glyphBuffer, float *startPosition, int *_numGlyphs)
{
if (shouldUseATSU(run))
- return [self _ATSU_floatWidthForRun:run style:style];
+ return _ATSU_floatWidthForRun(renderer, run, style);
- return [self _CG_floatWidthForRun:run style:style widths:widthBuffer fonts:fontBuffer glyphs:glyphBuffer startPosition:startPosition numGlyphs:_numGlyphs];
-
+ return _CG_floatWidthForRun(renderer, run, style, widthBuffer, fontBuffer, glyphBuffer, startPosition, _numGlyphs);
}
-- (float)_CG_floatWidthForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style widths: (float *)widthBuffer fonts: (NSFont **)fontBuffer glyphs: (CGGlyph *)glyphBuffer startPosition:(float *)startPosition numGlyphs: (int *)_numGlyphs
+static ALWAYS_INLINE float _CG_floatWidthForRun(const WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, float *widthBuffer, NSFont **fontBuffer, CGGlyph *glyphBuffer, float *startPosition, int *_numGlyphs)
{
float _nextWidth;
CharacterWidthIterator widthIterator;
@@ -1203,7 +1203,7 @@
ATSGlyphRef glyphUsed;
int numGlyphs = 0;
- initializeCharacterWidthIterator(&widthIterator, self, run, style);
+ initializeCharacterWidthIterator(&widthIterator, (WebTextRenderer *)renderer, run, style);
if (startPosition)
*startPosition = widthIterator.widthToStart;
while (widthIterator.currentCharacter < (unsigned)widthIterator.run->to) {
@@ -1561,7 +1561,7 @@
}
-- (ATSTrapezoid)_trapezoidForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style atPoint:(NSPoint )p
+static ATSTrapezoid _trapezoidForRun(const WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style, NSPoint p)
{
// The only Cocoa call here is the self call to
// _createATSUTextLayoutForRun:, which is exception-safe.
@@ -1573,7 +1573,7 @@
return nilTrapezoid;
}
- ATSUTextLayout layout = [self _createATSUTextLayoutForRun:run style:style];
+ ATSUTextLayout layout = [renderer _createATSUTextLayoutForRun:run style:style];
ATSTrapezoid firstGlyphBounds;
ItemCount actualNumBounds;
@@ -1590,11 +1590,11 @@
}
-- (float)_ATSU_floatWidthForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style
+static ALWAYS_INLINE float _ATSU_floatWidthForRun(const WebTextRenderer *renderer, const WebCoreTextRun *run, const WebCoreTextStyle *style)
{
ATSTrapezoid oGlyphBounds;
- oGlyphBounds = [self _trapezoidForRun:run style:style atPoint:NSMakePoint (0,0)];
+ oGlyphBounds = _trapezoidForRun(renderer, run, style, NSMakePoint(0, 0));
float width =
MAX(FixedToFloat(oGlyphBounds.upperRight.x), FixedToFloat(oGlyphBounds.lowerRight.x)) -
@@ -1642,8 +1642,8 @@
- (void)_ATSU_drawHighlightForRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style geometry:(const WebCoreTextGeometry *)geometry
{
// The only Cocoa calls made here are to NSColor and NSBezierPath,
- // plus the self calls to _createATSUTextLayoutForRun: and
- // _trapezoidForRun:. These are all exception-safe.
+ // plus the self call to _createATSUTextLayoutForRun.
+ // These are all exception-safe.
ATSUTextLayout layout;
int from, to;
@@ -1683,8 +1683,8 @@
// ATSU provides the bounds of the glyphs for the run with an origin of
// (0,0), so we need to find the width of the glyphs immediately before
// the actually selected glyphs.
- ATSTrapezoid leadingTrapezoid = [self _trapezoidForRun:&leadingRun style:style atPoint:geometry->point];
- ATSTrapezoid selectedTrapezoid = [self _trapezoidForRun:run style:style atPoint:geometry->point];
+ ATSTrapezoid leadingTrapezoid = _trapezoidForRun(self, &leadingRun, style, geometry->point);
+ ATSTrapezoid selectedTrapezoid = _trapezoidForRun(self, run, style, geometry->point);
float backgroundWidth =
MAX(FixedToFloat(selectedTrapezoid.upperRight.x), FixedToFloat(selectedTrapezoid.lowerRight.x)) -
@@ -2185,14 +2185,7 @@
WebTextRenderer *substituteRenderer;
substituteRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:substituteFont usingPrinterFont:renderer->usingPrinterFont];
- width = [substituteRenderer
- _floatWidthForRun:&clusterRun
- style:&clusterStyle
- widths: nil
- fonts: nil
- glyphs: &localGlyphBuffer[0]
- startPosition:nil
- numGlyphs:&cNumGlyphs];
+ width = _floatWidthForRun(substituteRenderer, &clusterRun, &clusterStyle, nil, nil, &localGlyphBuffer[0], nil, &cNumGlyphs);
_fontUsed = substituteFont;
_glyphUsed = localGlyphBuffer[0];
More information about the webkit-changes
mailing list