[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 05:57:15 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 61d958e4d8474bfa33f81e9a77b26eaf1c9dfcb3
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Mar 8 20:58:28 2002 +0000
Instrumentation of the text fragment metrics cache.
Added _FAST_QSTRING_TO_NSSTRING.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@720 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 801cfdc..37ac4bb 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,16 @@
+2002-03-08 Richard Williamson <rjw at apple.com>
+
+ Instrumentation of the text fragment metrics cache.
+ Added _FAST_QSTRING_TO_NSSTRING.
+
+ * src/kwq/KWQFontMetrics.mm: (-[KWQLayoutFragment initWithString:attributes:]),
+ (-[KWQLayoutFragment boundingRect]), (-[KWQLayoutFragment compare:]),
+ (+[KWQLayoutInfo _dumpLayoutCache:]), (+[KWQLayoutInfo _dumpAllLayoutCaches]),
+ (-[KWQLayoutInfo rectForString:]), (QFontMetrics::width),
+ (QFontMetrics::boundingRect), (QFontMetrics::size):
+ * src/kwq/KWQMetrics.h:
+ * src/kwq/qt/qstring.h:
+
2002-03-08 John Sullivan <sullivan at apple.com>
* src/kwq/KWQKHTMLPart.mm: (KHTMLPart::openURL), (KHTMLPart::end):
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 801cfdc..37ac4bb 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,16 @@
+2002-03-08 Richard Williamson <rjw at apple.com>
+
+ Instrumentation of the text fragment metrics cache.
+ Added _FAST_QSTRING_TO_NSSTRING.
+
+ * src/kwq/KWQFontMetrics.mm: (-[KWQLayoutFragment initWithString:attributes:]),
+ (-[KWQLayoutFragment boundingRect]), (-[KWQLayoutFragment compare:]),
+ (+[KWQLayoutInfo _dumpLayoutCache:]), (+[KWQLayoutInfo _dumpAllLayoutCaches]),
+ (-[KWQLayoutInfo rectForString:]), (QFontMetrics::width),
+ (QFontMetrics::boundingRect), (QFontMetrics::size):
+ * src/kwq/KWQMetrics.h:
+ * src/kwq/qt/qstring.h:
+
2002-03-08 John Sullivan <sullivan at apple.com>
* src/kwq/KWQKHTMLPart.mm: (KHTMLPart::openURL), (KHTMLPart::end):
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 801cfdc..37ac4bb 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,16 @@
+2002-03-08 Richard Williamson <rjw at apple.com>
+
+ Instrumentation of the text fragment metrics cache.
+ Added _FAST_QSTRING_TO_NSSTRING.
+
+ * src/kwq/KWQFontMetrics.mm: (-[KWQLayoutFragment initWithString:attributes:]),
+ (-[KWQLayoutFragment boundingRect]), (-[KWQLayoutFragment compare:]),
+ (+[KWQLayoutInfo _dumpLayoutCache:]), (+[KWQLayoutInfo _dumpAllLayoutCaches]),
+ (-[KWQLayoutInfo rectForString:]), (QFontMetrics::width),
+ (QFontMetrics::boundingRect), (QFontMetrics::size):
+ * src/kwq/KWQMetrics.h:
+ * src/kwq/qt/qstring.h:
+
2002-03-08 John Sullivan <sullivan at apple.com>
* src/kwq/KWQKHTMLPart.mm: (KHTMLPart::openURL), (KHTMLPart::end):
diff --git a/WebCore/kwq/KWQFontMetrics.mm b/WebCore/kwq/KWQFontMetrics.mm
index d7d0bc5..9e4e531 100644
--- a/WebCore/kwq/KWQFontMetrics.mm
+++ b/WebCore/kwq/KWQFontMetrics.mm
@@ -53,7 +53,11 @@ const float LargeNumberForText = 1.0e7;
//[textContainer setLineFragmentPadding:0.0f];
cachedRect = NO;
-
+
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+ _accessCount = 0;
+#endif
+
return self;
}
@@ -64,9 +68,26 @@ const float LargeNumberForText = 1.0e7;
boundingRect = [layoutManager boundingRectForGlyphRange: NSMakeRange (0, numberOfGlyphs) inTextContainer: [KWQTextContainer sharedInstance]];
cachedRect = YES;
}
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+ _accessCount++;
+#endif
return boundingRect;
}
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+- (int)_accessCount { return _accessCount; }
+
+- (NSComparisonResult)compare: (id)val
+{
+ if ([val _accessCount] > _accessCount)
+ return NSOrderedDescending;
+ else if ([val _accessCount] < _accessCount)
+ return NSOrderedAscending;
+ return NSOrderedSame;
+}
+
+#endif
+
- (void)dealloc
{
[textStorage release];
@@ -111,6 +132,51 @@ static NSMutableDictionary *metricsCache = nil;
}
}
+#ifdef _DEBUG_LAYOUT_FRAGMENT
++ (void)_dumpLayoutCache: (NSDictionary *)fragCache
+{
+ int i, count;
+ NSArray *stringKeys;
+ NSString *string;
+ KWQLayoutFragment *fragment;
+
+ if (fragCache == nil){
+ fprintf (stdout, "Fragment cache empty\n");
+ return;
+ }
+ fprintf (stdout, " Hits String\n");
+
+ stringKeys = [fragCache keysSortedByValueUsingSelector:@selector(compare:)];
+ count = [stringKeys count];
+ for (i = 0; i < count; i++){
+ string = [stringKeys objectAtIndex: i];
+ fragment = [fragCache objectForKey: [stringKeys objectAtIndex: i]];
+ fprintf (stdout, " %06d \"%s\"\n", [fragment _accessCount], [string cString]);
+ }
+}
+
++ (void)_dumpAllLayoutCaches
+{
+ int i, count;
+ NSFont *font;
+ NSArray *fontKeys;
+ KWQLayoutInfo *layoutInfo;
+ int totalObjects = 0;
+
+ fontKeys = [metricsCache allKeys];
+ count = [fontKeys count];
+ for (i = 0; i < count; i++){
+ font = [fontKeys objectAtIndex: i];
+ layoutInfo = [metricsCache objectForKey: [fontKeys objectAtIndex: i]];
+ fprintf (stdout, "Cache information for font %s %f (%d objects)\n", [[font displayName] cString],[font pointSize], [[layoutInfo _fragmentCache] count]);
+ [KWQLayoutInfo _dumpLayoutCache: [layoutInfo _fragmentCache]];
+ totalObjects += [[layoutInfo _fragmentCache] count];
+ }
+ fprintf (stdout, "Total cached objects %d\n", totalObjects);
+}
+
+#endif
+
+ (KWQLayoutInfo *)getMetricsForFont: (NSFont *)aFont
{
@@ -131,6 +197,9 @@ static NSMutableDictionary *metricsCache = nil;
[metricsCache setObject: info forKey: aFont];
}
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+- (NSDictionary *)_fragmentCache { return fragmentCache; }
+#endif
- initWithFont: (NSFont *)aFont
{
@@ -156,7 +225,6 @@ static NSMutableDictionary *metricsCache = nil;
return cachedValue->layoutManager;
}
-
- (NSRect)rectForString:(NSString *)string
{
KWQLayoutFragment *cachedFragment, *fragment;
@@ -167,6 +235,9 @@ static NSMutableDictionary *metricsCache = nil;
cachedFragment = [fragmentCache objectForKey: string];
if (cachedFragment != nil){
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+ cachedFragment->_accessCount++;
+#endif
return cachedFragment->boundingRect;
}
@@ -316,7 +387,7 @@ int QFontMetrics::width(const QString &qstring, int len) const
if (len != -1)
string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
else
- string = QSTRING_TO_NSSTRING (qstring);
+ string = _FAST_QSTRING_TO_NSSTRING (qstring);
int stringWidth = ROUND_TO_INT([data->info rectForString: string].size.width);
return stringWidth;
}
@@ -329,7 +400,7 @@ QRect QFontMetrics::boundingRect(const QString &qstring, int len) const
if (len != -1)
string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
else
- string = QSTRING_TO_NSSTRING (qstring);
+ string = _FAST_QSTRING_TO_NSSTRING (qstring);
NSRect rect = [data->info rectForString: string];
return QRect(ROUND_TO_INT(rect.origin.x),
@@ -365,7 +436,7 @@ QSize QFontMetrics::size(int, const QString &qstring, int len, int tabstops,
if (len != -1)
string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
else
- string = QSTRING_TO_NSSTRING (qstring);
+ string = _FAST_QSTRING_TO_NSSTRING (qstring);
NSRect rect = [data->info rectForString: string];
return QSize (ROUND_TO_INT(rect.size.width),ROUND_TO_INT(rect.size.height));
diff --git a/WebCore/kwq/KWQMetrics.h b/WebCore/kwq/KWQMetrics.h
index c8f65f1..ba82b12 100644
--- a/WebCore/kwq/KWQMetrics.h
+++ b/WebCore/kwq/KWQMetrics.h
@@ -27,6 +27,8 @@
#import <Cocoa/Cocoa.h>
+#define _DEBUG_LAYOUT_FRAGMENT
+
@interface KWQLayoutInfo : NSObject
{
NSMutableDictionary *attributes;
@@ -43,6 +45,9 @@
- (void)setColor: (NSColor *)color;
- (void)setFont: (NSFont *)aFont;
- (NSDictionary *)attributes;
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+- (NSDictionary *)_fragmentCache;
+#endif
@end
@interface KWQLayoutFragment : NSObject
@@ -51,6 +56,9 @@
NSTextContainer *textContainer;
NSLayoutManager *layoutManager;
NSRect boundingRect;
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+ int _accessCount;
+#endif
BOOL cachedRect;
}
@@ -58,6 +66,10 @@
- (NSRect)boundingRect;
- (void)dealloc;
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+- (int)_accessCount;
+#endif
+
@end
#endif
diff --git a/WebCore/kwq/KWQString.h b/WebCore/kwq/KWQString.h
index c5b24f8..93a6da6 100644
--- a/WebCore/kwq/KWQString.h
+++ b/WebCore/kwq/KWQString.h
@@ -37,6 +37,8 @@
// These macros are TEMPORARY hacks to convert between NSString and QString.
// They should be replaced with correct implementations. They should only be
// used for immutable strings.
+#define _FAST_QSTRING_TO_NSSTRING(aString) \
+ [NSString stringWithCString: aString.latin1()]
#define QSTRING_TO_NSSTRING(aString) \
[NSString stringWithCString: aString.latin1()]
#define QSTRING_TO_NSSTRING_LENGTH(aString,l) \
@@ -60,12 +62,21 @@
#include "qcstring.h"
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+
+// Use with extreme caution. Only use _FAST_QSTRING_TO_NSSTRING if you
+// understand the reference count of the QString's underlying CFString.
+// In cases where QSTRING_TO_NSSTRING is called many times consider using
+// _FAST_QSTRING_TO_NSSTRING to save on unnecessary autoreleasing.
+#define _FAST_QSTRING_TO_NSSTRING(aString) \
+ ((NSString *)(aString.getCFMutableString()))
+
#define QSTRING_TO_NSSTRING(aString) \
[[(NSString *)(aString.getCFMutableString()) retain] autorelease]
#define QSTRING_TO_NSSTRING_LENGTH(aString,l) \
[[[(NSString *)(aString.getCFMutableString()) substringToIndex: l] retain] autorelease]
#define NSSTRING_TO_QSTRING(aString) \
QString::fromCFMutableString((CFMutableStringRef)aString)
+
#endif
class QString;
diff --git a/WebCore/kwq/qt/qstring.h b/WebCore/kwq/qt/qstring.h
index c5b24f8..93a6da6 100644
--- a/WebCore/kwq/qt/qstring.h
+++ b/WebCore/kwq/qt/qstring.h
@@ -37,6 +37,8 @@
// These macros are TEMPORARY hacks to convert between NSString and QString.
// They should be replaced with correct implementations. They should only be
// used for immutable strings.
+#define _FAST_QSTRING_TO_NSSTRING(aString) \
+ [NSString stringWithCString: aString.latin1()]
#define QSTRING_TO_NSSTRING(aString) \
[NSString stringWithCString: aString.latin1()]
#define QSTRING_TO_NSSTRING_LENGTH(aString,l) \
@@ -60,12 +62,21 @@
#include "qcstring.h"
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+
+// Use with extreme caution. Only use _FAST_QSTRING_TO_NSSTRING if you
+// understand the reference count of the QString's underlying CFString.
+// In cases where QSTRING_TO_NSSTRING is called many times consider using
+// _FAST_QSTRING_TO_NSSTRING to save on unnecessary autoreleasing.
+#define _FAST_QSTRING_TO_NSSTRING(aString) \
+ ((NSString *)(aString.getCFMutableString()))
+
#define QSTRING_TO_NSSTRING(aString) \
[[(NSString *)(aString.getCFMutableString()) retain] autorelease]
#define QSTRING_TO_NSSTRING_LENGTH(aString,l) \
[[[(NSString *)(aString.getCFMutableString()) substringToIndex: l] retain] autorelease]
#define NSSTRING_TO_QSTRING(aString) \
QString::fromCFMutableString((CFMutableStringRef)aString)
+
#endif
class QString;
diff --git a/WebCore/src/kwq/KWQFontMetrics.mm b/WebCore/src/kwq/KWQFontMetrics.mm
index d7d0bc5..9e4e531 100644
--- a/WebCore/src/kwq/KWQFontMetrics.mm
+++ b/WebCore/src/kwq/KWQFontMetrics.mm
@@ -53,7 +53,11 @@ const float LargeNumberForText = 1.0e7;
//[textContainer setLineFragmentPadding:0.0f];
cachedRect = NO;
-
+
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+ _accessCount = 0;
+#endif
+
return self;
}
@@ -64,9 +68,26 @@ const float LargeNumberForText = 1.0e7;
boundingRect = [layoutManager boundingRectForGlyphRange: NSMakeRange (0, numberOfGlyphs) inTextContainer: [KWQTextContainer sharedInstance]];
cachedRect = YES;
}
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+ _accessCount++;
+#endif
return boundingRect;
}
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+- (int)_accessCount { return _accessCount; }
+
+- (NSComparisonResult)compare: (id)val
+{
+ if ([val _accessCount] > _accessCount)
+ return NSOrderedDescending;
+ else if ([val _accessCount] < _accessCount)
+ return NSOrderedAscending;
+ return NSOrderedSame;
+}
+
+#endif
+
- (void)dealloc
{
[textStorage release];
@@ -111,6 +132,51 @@ static NSMutableDictionary *metricsCache = nil;
}
}
+#ifdef _DEBUG_LAYOUT_FRAGMENT
++ (void)_dumpLayoutCache: (NSDictionary *)fragCache
+{
+ int i, count;
+ NSArray *stringKeys;
+ NSString *string;
+ KWQLayoutFragment *fragment;
+
+ if (fragCache == nil){
+ fprintf (stdout, "Fragment cache empty\n");
+ return;
+ }
+ fprintf (stdout, " Hits String\n");
+
+ stringKeys = [fragCache keysSortedByValueUsingSelector:@selector(compare:)];
+ count = [stringKeys count];
+ for (i = 0; i < count; i++){
+ string = [stringKeys objectAtIndex: i];
+ fragment = [fragCache objectForKey: [stringKeys objectAtIndex: i]];
+ fprintf (stdout, " %06d \"%s\"\n", [fragment _accessCount], [string cString]);
+ }
+}
+
++ (void)_dumpAllLayoutCaches
+{
+ int i, count;
+ NSFont *font;
+ NSArray *fontKeys;
+ KWQLayoutInfo *layoutInfo;
+ int totalObjects = 0;
+
+ fontKeys = [metricsCache allKeys];
+ count = [fontKeys count];
+ for (i = 0; i < count; i++){
+ font = [fontKeys objectAtIndex: i];
+ layoutInfo = [metricsCache objectForKey: [fontKeys objectAtIndex: i]];
+ fprintf (stdout, "Cache information for font %s %f (%d objects)\n", [[font displayName] cString],[font pointSize], [[layoutInfo _fragmentCache] count]);
+ [KWQLayoutInfo _dumpLayoutCache: [layoutInfo _fragmentCache]];
+ totalObjects += [[layoutInfo _fragmentCache] count];
+ }
+ fprintf (stdout, "Total cached objects %d\n", totalObjects);
+}
+
+#endif
+
+ (KWQLayoutInfo *)getMetricsForFont: (NSFont *)aFont
{
@@ -131,6 +197,9 @@ static NSMutableDictionary *metricsCache = nil;
[metricsCache setObject: info forKey: aFont];
}
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+- (NSDictionary *)_fragmentCache { return fragmentCache; }
+#endif
- initWithFont: (NSFont *)aFont
{
@@ -156,7 +225,6 @@ static NSMutableDictionary *metricsCache = nil;
return cachedValue->layoutManager;
}
-
- (NSRect)rectForString:(NSString *)string
{
KWQLayoutFragment *cachedFragment, *fragment;
@@ -167,6 +235,9 @@ static NSMutableDictionary *metricsCache = nil;
cachedFragment = [fragmentCache objectForKey: string];
if (cachedFragment != nil){
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+ cachedFragment->_accessCount++;
+#endif
return cachedFragment->boundingRect;
}
@@ -316,7 +387,7 @@ int QFontMetrics::width(const QString &qstring, int len) const
if (len != -1)
string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
else
- string = QSTRING_TO_NSSTRING (qstring);
+ string = _FAST_QSTRING_TO_NSSTRING (qstring);
int stringWidth = ROUND_TO_INT([data->info rectForString: string].size.width);
return stringWidth;
}
@@ -329,7 +400,7 @@ QRect QFontMetrics::boundingRect(const QString &qstring, int len) const
if (len != -1)
string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
else
- string = QSTRING_TO_NSSTRING (qstring);
+ string = _FAST_QSTRING_TO_NSSTRING (qstring);
NSRect rect = [data->info rectForString: string];
return QRect(ROUND_TO_INT(rect.origin.x),
@@ -365,7 +436,7 @@ QSize QFontMetrics::size(int, const QString &qstring, int len, int tabstops,
if (len != -1)
string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
else
- string = QSTRING_TO_NSSTRING (qstring);
+ string = _FAST_QSTRING_TO_NSSTRING (qstring);
NSRect rect = [data->info rectForString: string];
return QSize (ROUND_TO_INT(rect.size.width),ROUND_TO_INT(rect.size.height));
diff --git a/WebCore/src/kwq/KWQMetrics.h b/WebCore/src/kwq/KWQMetrics.h
index c8f65f1..ba82b12 100644
--- a/WebCore/src/kwq/KWQMetrics.h
+++ b/WebCore/src/kwq/KWQMetrics.h
@@ -27,6 +27,8 @@
#import <Cocoa/Cocoa.h>
+#define _DEBUG_LAYOUT_FRAGMENT
+
@interface KWQLayoutInfo : NSObject
{
NSMutableDictionary *attributes;
@@ -43,6 +45,9 @@
- (void)setColor: (NSColor *)color;
- (void)setFont: (NSFont *)aFont;
- (NSDictionary *)attributes;
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+- (NSDictionary *)_fragmentCache;
+#endif
@end
@interface KWQLayoutFragment : NSObject
@@ -51,6 +56,9 @@
NSTextContainer *textContainer;
NSLayoutManager *layoutManager;
NSRect boundingRect;
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+ int _accessCount;
+#endif
BOOL cachedRect;
}
@@ -58,6 +66,10 @@
- (NSRect)boundingRect;
- (void)dealloc;
+#ifdef _DEBUG_LAYOUT_FRAGMENT
+- (int)_accessCount;
+#endif
+
@end
#endif
diff --git a/WebCore/src/kwq/qt/qstring.h b/WebCore/src/kwq/qt/qstring.h
index c5b24f8..93a6da6 100644
--- a/WebCore/src/kwq/qt/qstring.h
+++ b/WebCore/src/kwq/qt/qstring.h
@@ -37,6 +37,8 @@
// These macros are TEMPORARY hacks to convert between NSString and QString.
// They should be replaced with correct implementations. They should only be
// used for immutable strings.
+#define _FAST_QSTRING_TO_NSSTRING(aString) \
+ [NSString stringWithCString: aString.latin1()]
#define QSTRING_TO_NSSTRING(aString) \
[NSString stringWithCString: aString.latin1()]
#define QSTRING_TO_NSSTRING_LENGTH(aString,l) \
@@ -60,12 +62,21 @@
#include "qcstring.h"
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+
+// Use with extreme caution. Only use _FAST_QSTRING_TO_NSSTRING if you
+// understand the reference count of the QString's underlying CFString.
+// In cases where QSTRING_TO_NSSTRING is called many times consider using
+// _FAST_QSTRING_TO_NSSTRING to save on unnecessary autoreleasing.
+#define _FAST_QSTRING_TO_NSSTRING(aString) \
+ ((NSString *)(aString.getCFMutableString()))
+
#define QSTRING_TO_NSSTRING(aString) \
[[(NSString *)(aString.getCFMutableString()) retain] autorelease]
#define QSTRING_TO_NSSTRING_LENGTH(aString,l) \
[[[(NSString *)(aString.getCFMutableString()) substringToIndex: l] retain] autorelease]
#define NSSTRING_TO_QSTRING(aString) \
QString::fromCFMutableString((CFMutableStringRef)aString)
+
#endif
class QString;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list