WebCore:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 May 2004 23:47:08 +0000 (23:47 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 May 2004 23:47:08 +0000 (23:47 +0000)
        Reviewed by Darin.

- avoid redecoding animated images that are only used once for
~2.5% iBench speedup (WebCore part of fix)

        * khtml/rendering/render_image.cpp:
        (RenderImage::setPixmap): Maintain use count for pixmap.
        (RenderImage::~RenderImage): Likewise.
        * kwq/KWQPixmap.h:
        * kwq/KWQPixmap.mm:
        (QPixmap::increaseUseCount): Call WebCoreImageRenderer
        (QPixmap::decreaseUseCount): Call WebCoreImageRenderer
        * kwq/WebCoreImageRenderer.h: Prototype new protocol methods.

WebKit:

        Reviewed by Darin.

- avoid redecoding animated images that are only used once for
~2.5% iBench speedup (WebCore part of fix)

        * WebCoreSupport.subproj/WebImageRenderer.h:
        * WebCoreSupport.subproj/WebImageRenderer.m:
        (-[WebImageRenderer increaseUseCount]):
        (-[WebImageRenderer decreaseUseCount]):
        (-[WebImageRenderer retainOrCopyIfNeeded]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6574 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/rendering/render_image.cpp
WebCore/kwq/KWQPixmap.h
WebCore/kwq/KWQPixmap.mm
WebCore/kwq/WebCoreImageRenderer.h
WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebImageRenderer.h
WebKit/WebCoreSupport.subproj/WebImageRenderer.m

index 13b8536f4185460987c9384388ccc591bdfacebb..6788645e9bd8d0e5b802194da0410f5c0968a108 100644 (file)
@@ -1,3 +1,19 @@
+2004-05-09  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+
+       - avoid redecoding animated images that are only used once for
+       ~2.5% iBench speedup (WebCore part of fix)
+
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::setPixmap): Maintain use count for pixmap.
+        (RenderImage::~RenderImage): Likewise.
+        * kwq/KWQPixmap.h:
+        * kwq/KWQPixmap.mm:
+        (QPixmap::increaseUseCount): Call WebCoreImageRenderer
+        (QPixmap::decreaseUseCount): Call WebCoreImageRenderer
+        * kwq/WebCoreImageRenderer.h: Prototype new protocol methods.
+
 2004-05-10  David Hyatt  <hyatt@apple.com>
 
        Make sure that when finished parsing if all the right conditions are met, we just go ahead and updateRendering and
index 19f3514892b309f70b8dd1b421fd917e67310eba..1a2c995f620ac6fec8459decaa80e780ad825899 100644 (file)
@@ -63,6 +63,7 @@ RenderImage::RenderImage(NodeImpl *_node)
 RenderImage::~RenderImage()
 {
     if(image) image->deref(this);
+    pix.decreaseUseCount();
 }
 
 void RenderImage::setStyle(RenderStyle* _style)
@@ -162,7 +163,13 @@ void RenderImage::setPixmap( const QPixmap &p, const QRect& r, CachedImage *o)
     pix.stopAnimations();
 #endif
     
+#if APPLE_CHANGES
+    pix.decreaseUseCount();
+#endif
     pix = p;
+#if APPLE_CHANGES
+    p.increaseUseCount();
+#endif
 
     if (needlayout) {
         if (!selfNeedsLayout())
index 7feb699558a682415f6c9c3ad64ee34f6312ccd4..13cdc93350d5c0cec358afef41a4916ea7a74582 100644 (file)
@@ -82,6 +82,9 @@ public:
     void stopAnimations();
 
     WebCoreImageRendererPtr image() { return imageRenderer; };
+
+    void increaseUseCount() const;
+    void decreaseUseCount() const;
     
 private:
 
index d8deb30bd94f7a085256c0d752e55a97efa5c835..e0fd2e411c36d893ac1b596d1177f833056f503f 100644 (file)
@@ -195,6 +195,16 @@ QPixmap &QPixmap::operator=(const QPixmap &assignFrom)
     return *this;
 }
 
+void QPixmap::increaseUseCount() const
+{
+    [imageRenderer increaseUseCount];
+}
+
+void QPixmap::decreaseUseCount() const
+{
+    [imageRenderer decreaseUseCount];
+}
+
 void QPixmap::stopAnimations()
 {
     [imageRenderer stopAnimation];
index 2214027c66a80bba0a67e297c63cf29fe6c9b5fa..db4b41aa567290e1ff93436ef5d60f4fcde2543e 100644 (file)
@@ -37,4 +37,6 @@
 - (void)tileInRect:(NSRect)r fromPoint:(NSPoint)p;
 - (BOOL)isNull;
 - (id <WebCoreImageRenderer>)retainOrCopyIfNeeded;
+- (void)increaseUseCount;
+- (void)decreaseUseCount;
 @end
index bfa1ba8b7de3779f546094c4373b0c94f581bfff..f1d66e6f62a73ce886bbfd15a64da74043085091 100644 (file)
@@ -1,3 +1,16 @@
+2004-05-10  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+
+       - avoid redecoding animated images that are only used once for
+       ~2.5% iBench speedup (WebCore part of fix)
+
+        * WebCoreSupport.subproj/WebImageRenderer.h:
+        * WebCoreSupport.subproj/WebImageRenderer.m:
+        (-[WebImageRenderer increaseUseCount]):
+        (-[WebImageRenderer decreaseUseCount]):
+        (-[WebImageRenderer retainOrCopyIfNeeded]):
+
 2004-05-10  Maciej Stachowiak  <mjs@apple.com>
 
         Fix build.
index da57d3cd5a797314930d7e9c1a48b4180a9b992a..da26b9660621c0fd321b12273812e055e0ccaf8a 100644 (file)
@@ -28,6 +28,7 @@
     
     NSString *MIMEType;
     BOOL isNull;
+    int useCount;
 @public    
     NSData *originalData;
 }
index 34fab8063a247ef48285fae8e92749472b49954d..9880cc659cf6d6b1c442c38e8756a16043fc9470 100644 (file)
@@ -115,11 +115,27 @@ static NSMutableSet *activeImageRenderers;
     return result;
 }
 
+- (void)increaseUseCount
+{
+    useCount++;
+}
+
+- (void)decreaseUseCount
+{
+    useCount--;
+}
+
 - (id <WebCoreImageRenderer>)retainOrCopyIfNeeded
 {
     WebImageRenderer *copy;
 
-    if (originalData){
+    // If an animated image appears multiple times in a given page, we
+    // must create multiple WebCoreImageRenderers so that each copy
+    // animates. However, we don't want to incur the expense of
+    // re-decoding for the very first use on a page, since QPixmap
+    // assignment always calls this method, even when just fetching
+    // the image from the cache for the first time for a page.
+    if (originalData && useCount){
         copy = [[[WebImageRendererFactory sharedFactory] imageRendererWithData:originalData MIMEType:MIMEType] retain];
     }
     else {