[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:11:20 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit e25b576f20add11d49f2af9f6bb7be044fb988f1
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Dec 4 10:34:33 2002 +0000
WebCore
Cache the last used text renderer to avoid expensive lookup
when font hasn't changed.
Reviewed by: maciej
* khtml/rendering/render_flow.cpp:
(RenderFlow::layout):
* kwq/KWQPainter.h:
* kwq/KWQPainter.mm:
(QPainter::_updateRenderer):
(QPainter::drawText):
(QPainter::drawUnderlineForText):
WebKit
Fixed massive performance regression.
We were leaking WebFontCacheKey.
Added a cache of missing fonts to avoid
expensive appkit lookup.
Reviewed by: Maciej
* WebCoreSupport.subproj/WebTextRendererFactory.m:
(-[WebTextRendererFactory cachedFontFromFamily:traits:size:]):
(-[WebTextRendererFactory cachedFontFromFamilies:traits:size:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 366508d..c1d0c8f 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1 +1,16 @@
+2002-12-04 Richard Williamson <rjw at apple.com>
+
+ Cache the last used text renderer to avoid expensive lookup
+ when font hasn't changed.
+
+ Reviewed by: maciej
+
+ * khtml/rendering/render_flow.cpp:
+ (RenderFlow::layout):
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::_updateRenderer):
+ (QPainter::drawText):
+ (QPainter::drawUnderlineForText):
+
== Rolled over to ChangeLog-2002-12-03 ==
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 366508d..c1d0c8f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1 +1,16 @@
+2002-12-04 Richard Williamson <rjw at apple.com>
+
+ Cache the last used text renderer to avoid expensive lookup
+ when font hasn't changed.
+
+ Reviewed by: maciej
+
+ * khtml/rendering/render_flow.cpp:
+ (RenderFlow::layout):
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::_updateRenderer):
+ (QPainter::drawText):
+ (QPainter::drawUnderlineForText):
+
== Rolled over to ChangeLog-2002-12-03 ==
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index b3ffd30..f16a56f 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -226,7 +226,7 @@ void RenderFlow::layout()
KHTMLAssert( !layouted() );
KHTMLAssert( minMaxKnown() );
- KHTMLAssert(!isInline());
+ //KHTMLAssert(!isInline());
int oldWidth = m_width;
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index 004a7ea..787c365 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -97,7 +97,7 @@ public:
bool paintingDisabled() const;
void setPaintingDisabled(bool);
-
+
private:
// no copying or assignment
QPainter(const QPainter &);
@@ -108,6 +108,8 @@ private:
void _drawPoints(const QPointArray &_points, bool winding, int index, int _npoints, bool fill);
+ void _updateRenderer(NSString **families);
+
QPainterPrivate *data;
};
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index c635512..17eeb11 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -46,8 +46,12 @@ struct QPState {
};
struct QPainterPrivate {
+ QPainterPrivate() : lastTextRenderer(0) { }
+ ~QPainterPrivate() { [lastTextRenderer release]; }
QPState state;
QPtrStack<QPState> stack;
+ id<WebCoreTextRenderer>lastTextRenderer;
+ QFont lastFont;
};
QPainter::QPainter() : data(new QPainterPrivate)
@@ -349,6 +353,17 @@ void QPainter::drawTiledPixmap( int x, int y, int w, int h,
[pixmap.imageRenderer tileInRect:NSMakeRect(x, y, w, h) fromPoint:NSMakePoint(sx, sy)];
}
+void QPainter::_updateRenderer(NSString **families)
+{
+ if (data->state.font != data->lastFont || data->lastTextRenderer == 0){
+ data->lastFont = data->state.font;
+ [data->lastTextRenderer release];
+ data->lastTextRenderer =
+ [[[WebCoreTextRendererFactory sharedFactory]
+ rendererWithFamilies:families traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()] retain];
+ }
+}
+
void QPainter::drawText(int x, int y, int, int, int alignmentFlags, const QString &qstring)
{
if (data->state.paintingDisabled)
@@ -358,15 +373,13 @@ void QPainter::drawText(int x, int y, int, int, int alignmentFlags, const QStrin
// css fallback lists are small <= 3.
CREATE_FAMILY_ARRAY(data->state.font, families);
- id<WebCoreTextRenderer> renderer =
- [[WebCoreTextRendererFactory sharedFactory]
- rendererWithFamilies:families traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()];
-
+ _updateRenderer(families);
+
const UniChar* str = (const UniChar*)qstring.unicode();
if (alignmentFlags & Qt::AlignRight)
- x -= ROUND_TO_INT([renderer floatWidthForCharacters:(const UniChar *)str stringLength:qstring.length() fromCharacterPosition:0 numberOfCharacters:qstring.length() withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0 fontFamilies: families]);
+ x -= ROUND_TO_INT([data->lastTextRenderer floatWidthForCharacters:(const UniChar *)str stringLength:qstring.length() fromCharacterPosition:0 numberOfCharacters:qstring.length() withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0 fontFamilies: families]);
- [renderer drawCharacters:str stringLength:qstring.length()
+ [data->lastTextRenderer drawCharacters:str stringLength:qstring.length()
fromCharacterPosition:0
toCharacterPosition:qstring.length()
atPoint:NSMakePoint(x, y)
@@ -388,8 +401,9 @@ void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int t
// css fallback lists are small <= 3.
CREATE_FAMILY_ARRAY(data->state.font, families);
- [[[WebCoreTextRendererFactory sharedFactory]
- rendererWithFamilies:families traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()]
+ _updateRenderer(families);
+
+ [data->lastTextRenderer
drawCharacters:(const UniChar *)str stringLength:len
fromCharacterPosition:from
toCharacterPosition:to
@@ -410,9 +424,9 @@ void QPainter::drawUnderlineForText(int x, int y, const QChar *str, int len)
CREATE_FAMILY_ARRAY(data->state.font, families);
- [[[WebCoreTextRendererFactory sharedFactory]
- rendererWithFamilies:families traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()]
- drawUnderlineForCharacters:(const UniChar *)str stringLength:len
+ _updateRenderer(families);
+
+ [data->lastTextRenderer drawUnderlineForCharacters:(const UniChar *)str stringLength:len
atPoint:NSMakePoint(x,y) withColor:data->state.pen.color().getNSColor()];
}
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 6367aff..5dd23ca 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,16 @@
+2002-12-04 Richard Williamson <rjw at apple.com>
+
+ Fixed massive performance regression.
+ We were leaking WebFontCacheKey.
+ Added a cache of missing fonts to avoid
+ expensive appkit lookup.
+
+ Reviewed by: Maciej
+
+ * WebCoreSupport.subproj/WebTextRendererFactory.m:
+ (-[WebTextRendererFactory cachedFontFromFamily:traits:size:]):
+ (-[WebTextRendererFactory cachedFontFromFamilies:traits:size:]):
+
2002-12-03 Darin Adler <darin at apple.com>
- fixed 3117193 -- REGRESSION: Hang on Hixie's weblog
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m b/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
index 9de1a66..e746478 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
@@ -255,24 +255,36 @@
- (NSFont *)cachedFontFromFamily:(NSString *)family traits:(NSFontTraitMask)traits size:(float)size
{
static NSMutableDictionary *fontCache = nil;
- NSString *fontKey = [[WebFontCacheKey alloc] initWithFamily:family traits:traits size:size];
+ static NSMutableSet *missingFonts = nil;
+ WebFontCacheKey *fontKey;
NSFont *font = nil;
+ if ([family length] == 0)
+ return nil;
+
if (!fontCache) {
fontCache = [[NSMutableDictionary alloc] init];
}
+ fontKey = [[WebFontCacheKey alloc] initWithFamily:family traits:traits size:size];
font = [fontCache objectForKey:fontKey];
if (!font){
- font = [self fontWithFamily:family traits:traits size:size];
- if (font)
- [fontCache setObject:font forKey:fontKey];
+ if (![missingFonts containsObject:fontKey]){
+ font = [self fontWithFamily:family traits:traits size:size];
+ if (font)
+ [fontCache setObject:font forKey:fontKey];
+ else{
+ if (!missingFonts)
+ missingFonts = [[NSMutableSet alloc] init];
+ [missingFonts addObject:fontKey];
+ }
+ }
}
+ [fontKey release];
return font;
}
-
- (NSFont *)cachedFontFromFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size
{
NSFont *font = nil;
@@ -288,7 +300,8 @@
while (families && families[i] != 0 && font == nil){
family = families[i++];
- font = [self cachedFontFromFamily: family traits:traits size:size];
+ if ([family length] != 0)
+ font = [self cachedFontFromFamily: family traits:traits size:size];
}
if (font == nil)
font = [WebTextRendererFactory fallbackFontWithTraits:traits size:size];
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list