<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>114938</bug_id>
          
          <creation_ts>2005-10-23 15:14:24 +0000</creation_ts>
          <short_desc>Background painting tries to paint too much</short_desc>
          <delta_ts>2006-06-19 23:35:36 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>konqueror</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>estevam</reporter>
          <assigned_to name="Konqueror Bugs">konqueror-bugs-null</assigned_to>
          <cc>maksim</cc>
    
    <cc>raditzman</cc>
    
    <cc>thundercloud</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>383857</commentid>
    <comment_count>0</comment_count>
    <who name="">estevam</who>
    <bug_when>2005-10-23 15:14:24 +0000</bug_when>
    <thetext>Version:           3.4.3 (using KDE 3.4.3 Level &quot;b&quot; , SUSE 10.0 UNSUPPORTED)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-15-default

Try to visit http://www.largadoemguarapari.blogspot.com and Konqueror will work very slow. 100% of cpu usage!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>383884</commentid>
    <comment_count>1</comment_count>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2005-10-23 17:14:26 +0000</bug_when>
    <thetext>Here is where it&apos;s getting stuck:
#7  0xb7069eb5 in QPainter::drawTiledPixmap () from /opt/kde3.4/lib/libqt-mt.so.3
#8  0xb63d5b81 in khtml::RenderBox::paintBackgroundExtended (this=0x84f24f8, p=0x84bf5d0, c=@0xbfaa200c,
    bgLayer=0x851b254, clipy=706, cliph=128, _tx=0, _ty=0, w=780, h=34323, bleft=0, bright=0)
    at /home/maksim/kde3/kdelibs/khtml/rendering/render_box.cpp:539


538             if (cw&gt;0 &amp;&amp; ch&gt;0)
539                 p-&gt;drawTiledPixmap(cx, cy, cw, ch, bg-&gt;tiled_pixmap(c), sx, sy);

(gdb) print ch
34323

this should clearly use cliph!
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>390752</commentid>
    <comment_count>2</comment_count>
    <who name="">estevam</who>
    <bug_when>2005-11-17 03:55:34 +0000</bug_when>
    <thetext>Same problem in 3.5RC1. Fix it pls!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>407482</commentid>
    <comment_count>3</comment_count>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2006-01-19 19:13:50 +0000</bug_when>
    <thetext>*** Bug 107812 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>407528</commentid>
    <comment_count>4</comment_count>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2006-01-19 21:48:02 +0000</bug_when>
    <thetext>*** Bug 111218 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>409107</commentid>
    <comment_count>5</comment_count>
    <who name="Maksim Orlovich">maksim</who>
    <bug_when>2006-01-26 16:40:11 +0000</bug_when>
    <thetext>SVN commit 502582 by orlovich:

Speedup: Cleanup and consolidate the tiled_pixmap background handling code into just one path.
This adds preblend and fixes other bugs in the alpha-specific path I added. 
The net result is that some web pages paint a lot faster. In particular, most of the stuff in 
#114938 and its dupes are pretty decent now. (I still need to investigate whether there 
was some truth in my original analysis, though, so keeping it open for now until I talk it over
with Carewolf)

Thanks to BCoppens and FredrikH for help with this, in particular in spotting the real problem.
CCBUG:114938


 M  +20 -59    loader.cpp  


--- branches/KDE/3.5/kdelibs/khtml/misc/loader.cpp #502581:502582
@@ -492,8 +492,8 @@
 
 const QPixmap &amp;CachedImage::tiled_pixmap(const QColor&amp; newc)
 {
-    static QRgb bgTransparant = qRgba( 0, 0, 0, 0xFF );
-    if ( (bgColor != bgTransparant) &amp;&amp; (bgColor != newc.rgb()) ) {
+    static QRgb bgTransparent = qRgba( 0, 0, 0, 0xFF );
+    if ( (bgColor != bgTransparent) &amp;&amp; (bgColor != newc.rgb()) ) {
         delete bg; bg = 0;
     }
 
@@ -511,6 +511,21 @@
     QSize s(pixmap_size());
     int w = r.width();
     int h = r.height();
+
+    const QPixmap* src; //source for pretiling, if any
+    //See whether we can - and should - pre-blend
+    if (isvalid &amp;&amp; (r.hasAlphaChannel() || r.mask() )) {
+        bg = new QPixmap(w, h);
+        bg-&gt;fill(newc);
+        bitBlt(bg, 0, 0, &amp;r);
+        bgColor = newc.rgb();
+        src     = bg;
+    } else {
+        src     = &amp;r;
+        bgColor = bgTransparent;
+    }
+
+    //See whether to pre-tile.
     if ( w*h &lt; 8192 )
     {
         if ( r.width() &lt; BGMINWIDTH )
@@ -519,74 +534,20 @@
             h = ((BGMINHEIGHT / s.height())+1) * s.height();
     }
 
-#ifdef Q_WS_X11
-    if ( r.hasAlphaChannel() &amp;&amp;
-         ((w != r.width()) || (h != r.height())) )
+    if ( w != r.width() || h != r.height() )
     {
         bg = new QPixmap(w, h);
         //Tile horizontally on the first stripe
         for (int x = 0; x &lt; w; x += r.width())
-            copyBlt(bg, x, 0, &amp;r, 0, 0, r.width(), r.height());
+            copyBlt(bg, x, 0, src, 0, 0, r.width(), r.height());
 
         //Copy first stripe down
         for (int y = r.height(); y &lt; h; y += r.height())
             copyBlt(bg, 0, y, bg, 0, 0, w, r.height());
-
-        return *bg;
     }
-#endif
 
-    if (
-#ifdef Q_WS_X11
-        !r.hasAlphaChannel() &amp;&amp;
-#endif
-        ( (w != r.width()) || (h != r.height()) || (isvalid &amp;&amp; r.mask())) )
-    {
-        QPixmap pix = r;
-        if ( w != r.width() || (isvalid &amp;&amp; pix.mask()))
-        {
-            bg = new QPixmap(w, r.height());
-            QPainter p(bg);
-            if(isvalid) p.fillRect(0, 0, w, r.height(), newc);
-            p.drawTiledPixmap(0, 0, w, r.height(), pix);
-            p.end();
-
-            if(!isvalid &amp;&amp; pix.mask())
-            {
-                // unfortunately our anti-transparency trick doesn&apos;t work here
-                // we need to create a mask.
-                QBitmap newmask(w, r.height());
-                QPainter pm(&amp;newmask);
-                pm.drawTiledPixmap(0, 0, w, r.height(), *pix.mask());
-                bg-&gt;setMask(newmask);
-                bgColor = bgTransparant;
-            }
-            else
-                bgColor= newc.rgb();
-            pix = *bg;
-        }
-        if ( h != r.height() )
-        {
-            delete bg;
-            bg = new QPixmap(w, h);
-            QPainter p(bg);
-            if(isvalid) p.fillRect(0, 0, w, h, newc);
-            p.drawTiledPixmap(0, 0, w, h, pix);
-            if(!isvalid &amp;&amp; pix.mask())
-            {
-                // unfortunately our anti-transparency trick doesn&apos;t work here
-                // we need to create a mask.
-                QBitmap newmask(w, h);
-                QPainter pm(&amp;newmask);
-                pm.drawTiledPixmap(0, 0, w, h, *pix.mask());
-                bg-&gt;setMask(newmask);
-                bgColor = bgTransparant;
-            }
-            else
-                bgColor= newc.rgb();
-        }
+    if (bg)
         return *bg;
-    }
 
     return r;
 }
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>426597</commentid>
    <comment_count>6</comment_count>
    <who name="Leo Spalteholz">leo</who>
    <bug_when>2006-04-01 01:08:52 +0000</bug_when>
    <thetext>Well with 3.5.2 this seems to be mostly fixed.  At least konqueror doesn&apos;t slow down very much.  There is something weird still going on though.  When I load the page, konqueror CPU is low, but then climbs to about 30% as I scroll down the page.  Then the CPU usage of Xorg goes to about 65% and stays there.  When I click &quot;stop animations&quot;, konqueror CPU usage goes to zero, and xorg drops to 30%.  This happens even with no animated images on the screen. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>448015</commentid>
    <comment_count>7</comment_count>
    <who name="Allan Sandfeld">kde</who>
    <bug_when>2006-06-19 23:35:36 +0000</bug_when>
    <thetext>The exact complain of this bug report have been fixed in 3.5.3 (background restrained to clip). And the linked webpage doesn&apos;t seem so slow either.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>