[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/khtml/misc
From:       Maks Orlovich <maksim () kde ! org>
Date:       2004-05-29 16:18:42
Message-ID: 20040529161842.44E1F126E9 () office ! kde ! org
[Download RAW message or body]

CVS commit by orlovich: 

Implement pre-tiling of pixmaps w/alpha channel, fixing rendering speed on websites 
that have small semi-transparent background images (#63935)

Also remove the KHTMLPixmap hack, since it's no longer needed with Qt >= 3.2 providing 
hasAlphaChannel()

CCMAIL:63935-done@bugs.kde.org


  M +24 -14    loader.cpp   1.173


--- kdelibs/khtml/misc/loader.cpp  #1.172:1.173
@@ -478,17 +478,4 @@ void CachedImage::deref( CachedObjectCli
 #define BGMINHEIGHT     32
 
-namespace khtml {
-
-class KHTMLPixmap : public QPixmap
-{
-public:
-#ifdef Q_WS_X11
-    bool hasAlphaImage() const { return data->alphapm; }
-#else
-    bool hasAlphaImage() const { return false; }
-#endif
-};
-
-} // namespace khtml
 
 const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
@@ -520,5 +507,26 @@ const QPixmap &CachedImage::tiled_pixmap
             h = ((BGMINHEIGHT / s.height())+1) * s.height();
     }
-    if ( !static_cast<const KHTMLPixmap*>( &r )->hasAlphaImage() &&
+
+#ifdef Q_WS_X11
+    if ( r.hasAlphaChannel() && 
+         ((w != r.width()) || (h != r.height())) )
+    {
+        bg = new QPixmap(w, h);
+        //Tile horizontally on the first stripe
+        for (int x = 0; x < w; x += r.width())
+            copyBlt(bg, x, 0, &r, 0, 0, r.width(), r.height());
+        
+        //Copy first stripe down
+        for (int y = r.height(); y < h; y += r.height())
+            copyBlt(bg, 0, y, bg, 0, 0, w, r.height());
+        
+        return *bg;
+    }
+#endif    
+    
+    if ( 
+#ifdef Q_WS_X11    
+        !r.hasAlphaChannel() &&
+#endif
         ( (w != r.width()) || (h != r.height()) || (isvalid && r.mask())) )
     {
@@ -530,4 +538,6 @@ const QPixmap &CachedImage::tiled_pixmap
             if(isvalid) p.fillRect(0, 0, w, r.height(), newc);
             p.drawTiledPixmap(0, 0, w, r.height(), pix);
+            p.end();
+
             if(!isvalid && pix.mask())
             {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic