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

List:       kde-commits
Subject:    KDE/kdegraphics/kolourpaint/pixmapfx
From:       Clarence Dang <dang () kde ! org>
Date:       2007-10-12 0:11:43
Message-ID: 1192147903.110167.31068.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 724323 by dang:

Remove unexecutable 32-bit-QPixmap code path in kpPixmapFX::hasMask() and \
hasAlphaChannel().  Assert this unexecutability in initMaskOpsPost(). +debug.


 M  +5 -6      kpPixmapFX.h  
 M  +8 -38     kpPixmapFX_MaskOps.cpp  


--- trunk/KDE/kdegraphics/kolourpaint/pixmapfx/kpPixmapFX.h #724322:724323
@@ -439,14 +439,13 @@
     // Called by initPost() - do not call directly.
     static void initMaskOpsPost ();
 
-    // You must use this instead of QPixmap::hasAlpha() or
-    // !QPixmap::mask().isNull(), which give unexpectedly different results
-    // at 32bpp, compared to other screen depths (e.g. 16bpp and 24bpp).
+    // You should use this instead of !QPixmap::mask().isNull(), as this
+    // is faster, and instead of QPixmap::hasAlpha(), for encapsulation
+    // purposes.
     static bool hasMask (const QPixmap &pixmap);
 
-    // You must use this instead of QPixmap::hasAlphaChannel(),
-    // which gives unexpectedly different results at 32bpp, compared to
-    // other screen depths (e.g. 16bpp and 2bpp).
+    // You should use this instead of QPixmap::hasAlphaChannel(),
+    // for encapsulation purposes.
     static bool hasAlphaChannel (const QPixmap &pixmap);
 
     // Controls whether the KP_PFX_CHECK_NO_ALPHA_CHANNEL assert, if it
--- trunk/KDE/kdegraphics/kolourpaint/pixmapfx/kpPixmapFX_MaskOps.cpp #724322:724323
@@ -175,7 +175,9 @@
 void kpPixmapFX::initMaskOpsPost ()
 {
 #if DEBUG_KP_PIXMAP_FX
-    kDebug () << "kpPixmapFX::initMaskOpsPost(): QPixmap().depth()=" << QPixmap \
().depth (); +    kDebug () << "kpPixmapFX::initMaskOpsPost():"
+              << "QPixmap().depth()=" << QPixmap ().depth ()
+              << "QPixmap::defaultDepth()=" << QPixmap::defaultDepth ();
 #endif
 
     // Check KolourPaint invariant.
@@ -183,55 +185,22 @@
     KP_PFX_CHECK_NO_ALPHA_CHANNEL (QPixmap (1, 1));
     Q_ASSERT (QPixmap ().depth () == QPixmap::defaultDepth ());
     Q_ASSERT (QPixmap (1, 1).depth () == QPixmap::defaultDepth ());
+
+    // initMaskOpsPre() should have ensured this (if it was 32 previously, it
+    // should now be 24 due to the disabling of XRENDER).
+    Q_ASSERT (QPixmap::defaultDepth () < 32);
 }
 
 
 // public static
 bool kpPixmapFX::hasMask (const QPixmap &pixmap)
 {
-#ifdef Q_WS_X11
-    if (QPixmap::defaultDepth () == 32)
-    {
-        // Note:
-        //
-        // QPixmap::mask() is hideously slow, and always returns a non-null
-        // mask, if the pixmap has an alpha channel (even if the channel is
-        // supposed to be empty).
-        //
-        // initMaskOpsPre() has already disabled XRENDER.
-        //
-        // Without XRENDER, pixmaps definitely don't have alpha channels.
-        // As a result, QPixmap::mask() will be fast and, if there is no mask,
-        // it will correctly return a null bitmap.
-
-
-        // We need this code path since QPixmap::hasAlpha() lies and returns
-        // true purely because the depth is 32.
-        //
-        // Note: QPixmap::mask() is slightly slow even on a pixmap without an
-        //       alpha channel.
-        return !pixmap.mask ().isNull ();
-    }
-#endif
-
     return pixmap.hasAlpha ();
 }
 
-
 // public static
 bool kpPixmapFX::hasAlphaChannel (const QPixmap &pixmap)
 {
-#ifdef Q_WS_X11
-    if (QPixmap::defaultDepth () == 32)
-    {
-        // We need this code path since QPixmap::hasAlphaChannel() lies
-        // and returns true purely because the depth is 32.
-        //
-        // Without XRENDER, pixmaps definitely don't have alpha channels.
-        return false;
-    }
-#endif
-
     return pixmap.hasAlphaChannel ();
 }
 
@@ -405,3 +374,4 @@
 }
 
 
+


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

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