[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - 3 commits - canvas/source vcl/inc vcl/source vcl/unx

Michael Meeks michael.meeks at suse.com
Wed Jun 12 01:54:10 PDT 2013


 canvas/source/cairo/cairo_canvasbitmap.cxx |  161 ++++++++++++-----------------
 canvas/source/cairo/cairo_canvasbitmap.hxx |    4 
 canvas/source/cairo/cairo_xlib_cairo.cxx   |    7 -
 canvas/source/cairo/cairo_xlib_cairo.hxx   |    1 
 vcl/inc/salbmp.hxx                         |    1 
 vcl/inc/unx/salbmp.h                       |    7 -
 vcl/inc/unx/salgdi.h                       |    5 
 vcl/inc/vcl/bitmap.hxx                     |    3 
 vcl/inc/vcl/bitmapex.hxx                   |   11 +
 vcl/source/gdi/bitmap.cxx                  |   13 --
 vcl/source/gdi/bitmapex.cxx                |   78 +++++++++++++-
 vcl/source/gdi/gdimtf.cxx                  |   64 +----------
 vcl/source/helper/canvastools.cxx          |   25 ----
 vcl/unx/generic/gdi/salbmp.cxx             |   18 ---
 vcl/unx/generic/gdi/salgdi2.cxx            |  151 ++++++++++++---------------
 15 files changed, 239 insertions(+), 310 deletions(-)

New commits:
commit d6f58fd25eeca84a94528409a05b80aa5172b8b8
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Mon Jun 10 17:02:06 2013 +0100

    Cairo canvas fixes
    
    + Move BitmapEx construction from an XBitmapCanvas into BitmapEx
      where (arguably) it will be easier to re-factor later, treat a
      mask fetch failure as if we have no mask
    + Teach the cairo canvas to return a non-pre-multiplied RGB +
      separate Alpha BitmapEx when it can to avoid unpleasantness with
      the underlying X resources.
    + Add tentative code-path to convert 32bit color Bitmaps into
      24bit color, to avoid confusing X
    
    Change-Id: Iaf6998c796aea6d73c57bed2bc03152d9636d5f5
    
    Conflicts:
    	vcl/source/gdi/gdimtf.cxx

diff --git a/canvas/source/cairo/cairo_canvasbitmap.cxx b/canvas/source/cairo/cairo_canvasbitmap.cxx
index 91f6194..062af84 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.cxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.cxx
@@ -23,6 +23,9 @@
 
 #include "cairo_canvasbitmap.hxx"
 
+#include <vcl/bmpacc.hxx>
+#include <vcl/bitmapex.hxx>
+
 #ifdef CAIRO_HAS_XLIB_SURFACE
 # include "cairo_xlib_cairo.hxx"
 #elif defined CAIRO_HAS_QUARTZ_SURFACE
@@ -144,7 +147,67 @@ namespace cairocanvas
         {
             case 0:
             {
-                aRV = uno::Any( reinterpret_cast<sal_Int64>( (BitmapEx*) NULL ) );
+                aRV = uno::Any( reinterpret_cast<sal_Int64>( (BitmapEx *) NULL ) );
+                if ( !mbHasAlpha )
+                    break;
+
+                ::Size aSize( maSize.getX(), maSize.getY() );
+                // FIXME: if we could teach VCL/ about cairo handles, life could
+                // be significantly better here perhaps.
+                cairo_surface_t *pPixels;
+                pPixels = cairo_image_surface_create( CAIRO_FORMAT_ARGB32,
+                                                      aSize.Width(), aSize.Height() );
+                cairo_t *pCairo = cairo_create( pPixels );
+                if( !pPixels || !pCairo )
+                    break;
+
+                // suck ourselves from the X server to this buffer so then we can fiddle with
+                // Alpha to turn it into the ultra-lame vcl required format and then push it
+                // all back again later at vast expense [ urgh ]
+                cairo_set_source_surface( pCairo, getSurface()->getCairoSurface().get(), 0, 0 );
+                cairo_set_operator( pCairo, CAIRO_OPERATOR_SOURCE );
+                cairo_paint( pCairo );
+
+                ::Bitmap aRGB( aSize, 24 );
+                ::AlphaMask aMask( aSize );
+
+                BitmapWriteAccess *pRGBWrite( aRGB.AcquireWriteAccess() );
+                BitmapWriteAccess *pMaskWrite( aMask.AcquireWriteAccess() );
+
+                unsigned char *pSrc = cairo_image_surface_get_data( pPixels );
+                unsigned int nStride = cairo_image_surface_get_stride( pPixels );
+                for( unsigned long y = 0; y < (unsigned long) aSize.Height(); y++ )
+                {
+                    sal_uInt32 *pPix = (sal_uInt32 *)(pSrc + nStride * y);
+                    for( unsigned long x = 0; x < (unsigned long) aSize.Width(); x++ )
+                    {
+                        sal_uInt8 nAlpha = (*pPix >> 24);
+                        sal_uInt8 nR = (*pPix >> 16) & 0xff;
+                        sal_uInt8 nG = (*pPix >> 8) & 0xff;
+                        sal_uInt8 nB = *pPix & 0xff;
+                        if( nAlpha != 0 && nAlpha != 255 )
+                        {
+//                            fprintf (stderr, "From A(0x%.2x) 0x%.2x 0x%.2x 0x%.2x -> ",
+//                                     nAlpha, nR, nG, nB );
+                            // Cairo uses pre-multiplied alpha - we do not => re-multiply
+                            nR = (sal_uInt8) MinMax( ((sal_uInt32)nR * 255) / nAlpha, 0, 255 );
+                            nG = (sal_uInt8) MinMax( ((sal_uInt32)nG * 255) / nAlpha, 0, 255 );
+                            nB = (sal_uInt8) MinMax( ((sal_uInt32)nB * 255) / nAlpha, 0, 255 );
+//                            fprintf (stderr, "0x%.2x 0x%.2x 0x%.2x\n", nR, nG, nB );
+                        }
+                        pRGBWrite->SetPixel( y, x, BitmapColor( nR, nG, nB ) );
+                        pMaskWrite->SetPixel( y, x, BitmapColor( 255 - nAlpha ) );
+                        pPix++;
+                    }
+                }
+                aMask.ReleaseAccess( pMaskWrite );
+                aRGB.ReleaseAccess( pRGBWrite );
+
+                ::BitmapEx *pBitmapEx = new ::BitmapEx( aRGB, aMask );
+
+                cairo_surface_destroy( pPixels );
+
+                aRV = uno::Any( reinterpret_cast<sal_Int64>( pBitmapEx ) );
                 break;
             }
             case 1:
@@ -179,71 +242,9 @@ namespace cairocanvas
             }
             case 2:
             {
-#ifdef CAIRO_HAS_XLIB_SURFACE
-                uno::Sequence< uno::Any > args( 3 );
-                SurfaceSharedPtr pAlphaSurface = mpSurfaceProvider->createSurface( maSize, CAIRO_CONTENT_COLOR );
-                CairoSharedPtr   pAlphaCairo = pAlphaSurface->getCairo();
-                X11Surface* pXlibSurface=dynamic_cast<X11Surface*>(pAlphaSurface.get());
-                OSL_ASSERT(pXlibSurface);
-
-                // create RGB image (levels of gray) of alpha channel of original picture
-                cairo_set_source_rgba( pAlphaCairo.get(), 1, 1, 1, 1 );
-                cairo_set_operator( pAlphaCairo.get(), CAIRO_OPERATOR_SOURCE );
-                cairo_paint( pAlphaCairo.get() );
-                cairo_set_source_surface( pAlphaCairo.get(), mpBufferSurface->getCairoSurface().get(), 0, 0 );
-                cairo_set_operator( pAlphaCairo.get(), CAIRO_OPERATOR_XOR );
-                cairo_paint( pAlphaCairo.get() );
-                pAlphaCairo.reset();
-
-                X11PixmapSharedPtr pPixmap = pXlibSurface->getPixmap();
-                args[0] = uno::Any( true );
-                args[1] = ::com::sun::star::uno::Any( pPixmap->mhDrawable );
-                args[2] = ::com::sun::star::uno::Any( sal_Int32( pXlibSurface->getDepth () ) );
-                pPixmap->clear(); // caller takes ownership of pixmap
-
-                // return pixmap and alphachannel pixmap - it will be used in BitmapEx
-                aRV = uno::Any( args );
-#elif defined CAIRO_HAS_QUARTZ_SURFACE
-                SurfaceSharedPtr pAlphaSurface = mpSurfaceProvider->createSurface( maSize, CAIRO_CONTENT_COLOR );
-                CairoSharedPtr   pAlphaCairo = pAlphaSurface->getCairo();
-                QuartzSurface* pQuartzSurface=dynamic_cast<QuartzSurface*>(pAlphaSurface.get());
-                OSL_ASSERT(pQuartzSurface);
-
-                // create RGB image (levels of gray) of alpha channel of original picture
-                cairo_set_source_rgba( pAlphaCairo.get(), 1, 1, 1, 1 );
-                cairo_set_operator( pAlphaCairo.get(), CAIRO_OPERATOR_SOURCE );
-                cairo_paint( pAlphaCairo.get() );
-                cairo_set_source_surface( pAlphaCairo.get(), mpBufferSurface->getCairoSurface().get(), 0, 0 );
-                cairo_set_operator( pAlphaCairo.get(), CAIRO_OPERATOR_XOR );
-                cairo_paint( pAlphaCairo.get() );
-                pAlphaCairo.reset();
-
-                uno::Sequence< uno::Any > args( 1 );
-                args[0] = uno::Any( sal_IntPtr (pQuartzSurface->getCGContext()) );
-                // return ??? and alphachannel ??? - it will be used in BitmapEx
-                aRV = uno::Any( args );
-#elif defined CAIRO_HAS_WIN32_SURFACE
-                SurfaceSharedPtr pAlphaSurface = mpSurfaceProvider->createSurface( maSize, CAIRO_CONTENT_COLOR );
-                CairoSharedPtr   pAlphaCairo = pAlphaSurface->getCairo();
-
-                // create RGB image (levels of gray) of alpha channel of original picture
-                cairo_set_source_rgba( pAlphaCairo.get(), 1, 1, 1, 1 );
-                cairo_set_operator( pAlphaCairo.get(), CAIRO_OPERATOR_SOURCE );
-                cairo_paint( pAlphaCairo.get() );
-                cairo_set_source_surface( pAlphaCairo.get(), mpBufferSurface->getCairoSurface().get(), 0, 0 );
-                cairo_set_operator( pAlphaCairo.get(), CAIRO_OPERATOR_XOR );
-                cairo_paint( pAlphaCairo.get() );
-                pAlphaCairo.reset();
-
-                // cant seem to retrieve HBITMAP from cairo. copy content then
-                uno::Sequence< uno::Any > args( 1 );
-                args[1] = uno::Any( sal_Int64(surface2HBitmap(pAlphaSurface,maSize)) );
-
-                aRV = uno::Any( args );
-                // caller frees the bitmap
-#else
-# error Please define fast prop retrieval for your platform!
-#endif
+                // Always return nothing - for the RGB surface support.
+                // Alpha code paths go via the above case 0.
+                aRV = uno::Any();
                 break;
             }
         }
diff --git a/vcl/inc/vcl/bitmapex.hxx b/vcl/inc/vcl/bitmapex.hxx
index 9eaaf61..d0c1f98 100644
--- a/vcl/inc/vcl/bitmapex.hxx
+++ b/vcl/inc/vcl/bitmapex.hxx
@@ -25,6 +25,12 @@
 #include <vcl/alpha.hxx>
 #include <tools/color.hxx>
 
+#include <com/sun/star/uno/Reference.hxx>
+
+namespace com { namespace sun { namespace star { namespace rendering {
+    class XBitmapCanvas;
+} } } }
+
 // -------------------
 // - TransparentType -
 // -------------------
@@ -382,6 +388,11 @@ public:
     friend VCL_DLLPUBLIC SvStream&  operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx );
     friend VCL_DLLPUBLIC SvStream&  operator>>( SvStream& rIStm, BitmapEx& rBitmapEx );
     static BitmapEx AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize);
+
+    /// populate from a canvas implementation
+    bool Create( const ::com::sun::star::uno::Reference<
+                 ::com::sun::star::rendering::XBitmapCanvas > &xBitmapCanvas,
+                 const Size &rSize );
 };
 
 #endif // _SV_BITMAPEX_HXX
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index 45fe0aa..59fc06a 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <ctype.h>
 
 #include <rtl/crc.h>
@@ -39,6 +38,13 @@
 #include <image.h>
 #include <impimagetree.hxx>
 
+// BitmapEx::Create
+#include <salbmp.hxx>
+#include <salinst.hxx>
+#include <svdata.hxx>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+using namespace ::com::sun::star;
+
 BitmapEx::BitmapEx() :
         eTransparent( TRANSPARENT_NONE ),
         bAlpha      ( sal_False )
@@ -856,4 +862,74 @@ SvStream& operator>>( SvStream& rIStm, BitmapEx& rBitmapEx )
     return rIStm;
 }
 
+// Shift alpha transparent pixels between cppcanvas/ implementations
+// and vcl in a generally grotesque and under-performing fashion
+bool BitmapEx::Create( const ::com::sun::star::uno::Reference<
+                       ::com::sun::star::rendering::XBitmapCanvas > &xBitmapCanvas,
+                       const Size &rSize )
+{
+    SetEmpty();
+    Size aSize( rSize );
+
+    uno::Reference< beans::XFastPropertySet > xFastPropertySet( xBitmapCanvas, uno::UNO_QUERY );
+    if( xFastPropertySet.get() )
+    {
+        // 0 means get BitmapEx
+        uno::Any aAny = xFastPropertySet->getFastPropertyValue( 0 );
+        BitmapEx* pBitmapEx = (BitmapEx*) *reinterpret_cast<const sal_Int64*>(aAny.getValue());
+        if( pBitmapEx )
+        {
+            *this = *pBitmapEx;
+            delete pBitmapEx;
+            return true;
+        }
+    }
+
+    SalBitmap* pSalBmp, *pSalMask;
+
+    pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
+    pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap();
+
+    if( pSalBmp->Create( xBitmapCanvas, aSize ) )
+    {
+#ifdef CLAMP_BITDEPTH_PARANOIA
+        // did we get alpha mixed up in the bitmap itself
+        // eg. Cairo Canvas ... yes performance of this is awful.
+        if( pSalBmp->GetBitCount() > 24 )
+        {
+            // Format convert the pixels with generic code
+            Bitmap aSrcPixels( pSalBmp );
+            aBitmap = Bitmap( rSize, 24 );
+            BitmapReadAccess aSrcRead( aSrcPixels );
+            BitmapWriteAccess aDestWrite( aBitmap );
+            aDestWrite.CopyBuffer( aSrcRead );
+        }
+        else
+#endif
+            aBitmap = Bitmap( pSalBmp );
+
+        aBitmapSize = rSize;
+        if ( pSalMask->Create( xBitmapCanvas, aSize, true ) )
+        {
+            aMask = Bitmap( pSalMask );
+            bAlpha = sal_True;
+            aBitmapSize = rSize;
+            eTransparent = !aMask ? TRANSPARENT_NONE : TRANSPARENT_BITMAP;
+
+            return true;
+        }
+        else
+        {
+            bAlpha = sal_False;
+            eTransparent = TRANSPARENT_NONE;
+            return true;
+        }
+    }
+
+    delete pSalBmp;
+    delete pSalMask;
+
+    return false;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 33e304b..f43b6ca 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -487,35 +487,16 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
                         xMtfFastPropertySet->setFastPropertyValue( 0, uno::Any( reinterpret_cast<sal_Int64>( this ) ) );
 
                     xMtfRenderer->draw( rDestSize.Width(), rDestSize.Height() );
+                }
 
-                    uno::Reference< beans::XFastPropertySet > xFastPropertySet( xBitmapCanvas, uno::UNO_QUERY );
-                    if( xFastPropertySet.get() )
-                    {
-                        // 0 means get BitmapEx
-                        uno::Any aAny = xFastPropertySet->getFastPropertyValue( 0 );
-                        BitmapEx* pBitmapEx = (BitmapEx*) *reinterpret_cast<const sal_Int64*>(aAny.getValue());
-                        if( pBitmapEx ) {
-                            pOut->DrawBitmapEx( rPos, rLogicDestSize, *pBitmapEx );
-                            delete pBitmapEx;
-                            return true;
-                        }
-                    }
-
-                    SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
-                    SalBitmap* pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap();
-
-                    if( pSalBmp->Create( xBitmapCanvas, aSize ) && pSalMask->Create( xBitmapCanvas, aSize, true ) )
-                    {
-                        Bitmap aBitmap( pSalBmp );
-                        Bitmap aMask( pSalMask );
-                        AlphaMask aAlphaMask( aMask );
-                        BitmapEx aBitmapEx( aBitmap, aAlphaMask );
+                BitmapEx aBitmapEx;
+                if( aBitmapEx.Create( xBitmapCanvas, aSize ) )
+                {
+                    if ( pOut->GetMapMode() == MAP_PIXEL )
                         pOut->DrawBitmapEx( rPos, aBitmapEx );
-                        return true;
-                    }
-
-                    delete pSalBmp;
-                    delete pSalMask;
+                    else
+                        pOut->DrawBitmapEx( rPos, rLogicDestSize, aBitmapEx );
+                    return true;
                 }
             }
         }
commit 352580fedebcb9ae3c4200d343f88f98b9faa22a
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Wed Jun 12 09:20:19 2013 +0100

    Revert "pass argb32 pixmaps from vcl to canvas, avoiding x11 roundtrips"
    
    This reverts commit 6b8e311ddc633bb13053d13c5d0f29240039846b.
    
    Conflicts:
    	canvas/source/cairo/cairo_canvasbitmap.cxx
    	vcl/unx/generic/gdi/salgdi2.cxx

diff --git a/canvas/source/cairo/cairo_canvasbitmap.cxx b/canvas/source/cairo/cairo_canvasbitmap.cxx
index 6839548..91f6194 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.cxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.cxx
@@ -134,30 +134,6 @@ namespace cairocanvas
         return maCanvasHelper.repaint( pSurface, viewState, renderState );
     }
 
-    void SAL_CALL CanvasBitmap::setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rAny )  throw (uno::RuntimeException)
-    {
-        sal_Int64 nPointer;
-
-        if ( nHandle == 0 )
-        {
-            rAny >>= nPointer;
-
-            if ( nPointer )
-            {
-                ::Bitmap *pBitmap = reinterpret_cast< ::Bitmap* >( nPointer );
-
-                mpBufferSurface = createSurface( *pBitmap );
-                mpBufferCairo = mpBufferSurface->getCairo();
-
-                ::Size aSize( pBitmap->GetSizePixel() );
-                maSize = ::basegfx::B2ISize( aSize.getWidth(), aSize.getHeight() );
-
-                maCanvasHelper.setSize( maSize );
-                maCanvasHelper.setSurface( mpBufferSurface, mbHasAlpha );
-            }
-        }
-    }
-
     uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle )  throw (uno::RuntimeException)
     {
         uno::Any aRV( sal_Int32(0) );
@@ -176,11 +152,10 @@ namespace cairocanvas
 #ifdef CAIRO_HAS_XLIB_SURFACE
                 X11Surface* pXlibSurface=dynamic_cast<X11Surface*>(mpBufferSurface.get());
                 OSL_ASSERT(pXlibSurface);
-                uno::Sequence< uno::Any > args( 4 );
+                uno::Sequence< uno::Any > args( 3 );
                 args[0] = uno::Any( false );  // do not call XFreePixmap on it
                 args[1] = uno::Any( pXlibSurface->getPixmap()->mhDrawable );
                 args[2] = uno::Any( sal_Int32( pXlibSurface->getDepth() ) );
-                args[3] = uno::Any( sal_Int64( pXlibSurface->getVisual () ) );
 
                 aRV = uno::Any( args );
 #elif defined CAIRO_HAS_QUARTZ_SURFACE
@@ -205,7 +180,7 @@ namespace cairocanvas
             case 2:
             {
 #ifdef CAIRO_HAS_XLIB_SURFACE
-                uno::Sequence< uno::Any > args( 4 );
+                uno::Sequence< uno::Any > args( 3 );
                 SurfaceSharedPtr pAlphaSurface = mpSurfaceProvider->createSurface( maSize, CAIRO_CONTENT_COLOR );
                 CairoSharedPtr   pAlphaCairo = pAlphaSurface->getCairo();
                 X11Surface* pXlibSurface=dynamic_cast<X11Surface*>(pAlphaSurface.get());
@@ -224,7 +199,6 @@ namespace cairocanvas
                 args[0] = uno::Any( true );
                 args[1] = ::com::sun::star::uno::Any( pPixmap->mhDrawable );
                 args[2] = ::com::sun::star::uno::Any( sal_Int32( pXlibSurface->getDepth () ) );
-                args[3] = ::com::sun::star::uno::Any( sal_Int64( pXlibSurface->getVisual () ) );
                 pPixmap->clear(); // caller takes ownership of pixmap
 
                 // return pixmap and alphachannel pixmap - it will be used in BitmapEx
diff --git a/canvas/source/cairo/cairo_canvasbitmap.hxx b/canvas/source/cairo/cairo_canvasbitmap.hxx
index bef03f5..b1d669e 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.hxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.hxx
@@ -115,14 +115,14 @@ namespace cairocanvas
         //     2nd the pixmap handle
         //     3rd the pixmap depth
         virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle)  throw (::com::sun::star::uno::RuntimeException);
-        virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&)  throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&)  throw (::com::sun::star::uno::RuntimeException) {}
 
     private:
         SurfaceProviderRef        mpSurfaceProvider;
         ::cairo::SurfaceSharedPtr mpBufferSurface;
         ::cairo::CairoSharedPtr   mpBufferCairo;
 
-        ::basegfx::B2ISize        maSize;
+        const ::basegfx::B2ISize  maSize;
         const bool                mbHasAlpha;
     };
 }
diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx
index 3086fd5..cd13ea1 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.cxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.cxx
@@ -187,7 +187,7 @@ namespace cairo
         mpSurface(
             cairo_xlib_surface_create( (Display*)rSysData.pDisplay,
                                        (Drawable)rData.aPixmap,
-                                       (Visual*) (rData.aVisual ? rData.aVisual : rSysData.pVisual),
+                                       (Visual*) rSysData.pVisual,
                                        rData.mnWidth, rData.mnHeight ),
             &cairo_surface_destroy)
     {
@@ -312,11 +312,6 @@ namespace cairo
         return -1;
     }
 
-    void* X11Surface::getVisual() const
-    {
-        return cairo_xlib_surface_get_visual( mpSurface.get() );
-    }
-
     SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface )
     {
         return SurfaceSharedPtr(new X11Surface(rSurface));
diff --git a/canvas/source/cairo/cairo_xlib_cairo.hxx b/canvas/source/cairo/cairo_xlib_cairo.hxx
index 080258b..105c570 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.hxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.hxx
@@ -92,7 +92,6 @@ namespace cairo {
         X11PixmapSharedPtr getPixmap() const { return mpPixmap; }
         void* getRenderFormat() const { return maSysData.pRenderFormat; }
         long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; }
-        void* getVisual() const;
     };
 }
 
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index 59a1285..866412d 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -79,7 +79,6 @@ public:
 
     SAL_DLLPRIVATE bool         ImplCreateFromDrawable(
                                     Drawable aDrawable,
-                                    void* pVisual,
                                     SalX11Screen nXScreen,
                                     long nDrawableDepth,
                                     long nX,
@@ -160,7 +159,6 @@ class ImplSalDDB
 private:
 
     Pixmap          maPixmap;
-    void*           mpVisual;
     SalTwoRect      maTwoRect;
     long            mnDepth;
     SalX11Screen    mnXScreen;
@@ -192,7 +190,6 @@ public:
 
                     ImplSalDDB(
                         Drawable aDrawable,
-                        void *pVisual,
                         SalX11Screen nXScreen,
                         long nDrawableDepth,
                         long nX,
@@ -204,7 +201,6 @@ public:
                     ~ImplSalDDB();
 
     Pixmap          ImplGetPixmap() const { return maPixmap; }
-    void*           ImplGetVisual() const { return mpVisual; }
     long            ImplGetWidth() const { return maTwoRect.mnDestWidth; }
     long            ImplGetHeight() const { return maTwoRect.mnDestHeight; }
     long            ImplGetDepth() const { return mnDepth; }
diff --git a/vcl/inc/vcl/bitmap.hxx b/vcl/inc/vcl/bitmap.hxx
index df42f93..ea52068 100644
--- a/vcl/inc/vcl/bitmap.hxx
+++ b/vcl/inc/vcl/bitmap.hxx
@@ -325,7 +325,6 @@ struct BitmapSystemData
     void* rImageContext;     //Image context (CGContextRef)
     #else
     void* aPixmap;
-    void* aVisual;
     #endif
     int mnWidth;
     int mnHeight;
@@ -847,8 +846,6 @@ public:
                                     const BmpFilterParam* pFilterParam = NULL,
                                     const Link* pProgress = NULL );
 
-    bool                        HasAlpha();
-
 public:
     BitmapReadAccess*       AcquireReadAccess();
     BitmapWriteAccess*      AcquireWriteAccess();
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 98de0a4..436092a 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -1901,17 +1901,4 @@ bool Bitmap::GetSystemData( BitmapSystemData& rData ) const
     return bRet;
 }
 
-bool Bitmap::HasAlpha()
-{
-    bool bRet = false;
-    if( mpImpBmp )
-    {
-        SalBitmap* pSalBitmap = mpImpBmp->ImplGetSalBitmap();
-        if( pSalBitmap )
-            bRet = pSalBitmap->HasAlpha();
-    }
-
-    return bRet;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx
index d05f7e7..75ad872 100644
--- a/vcl/source/helper/canvastools.cxx
+++ b/vcl/source/helper/canvastools.cxx
@@ -21,8 +21,6 @@
 #include <rtl/logfile.hxx>
 #include <cppuhelper/compbase1.hxx>
 
-#include <com/sun/star/beans/XFastPropertySet.hpp>
-
 #include <com/sun/star/geometry/RealSize2D.hpp>
 #include <com/sun/star/geometry/RealPoint2D.hpp>
 #include <com/sun/star/geometry/RealRectangle2D.hpp>
@@ -72,32 +70,11 @@ namespace vcl
 {
     namespace unotools
     {
-        uno::Reference< rendering::XBitmap > xBitmapFromBitmapEx( const uno::Reference< rendering::XGraphicDevice >& xGraphicDevice,
+        uno::Reference< rendering::XBitmap > xBitmapFromBitmapEx( const uno::Reference< rendering::XGraphicDevice >&    /*xGraphicDevice*/,
                                                                   const ::BitmapEx&                                     inputBitmap )
         {
             RTL_LOGFILE_CONTEXT( aLog, "::vcl::unotools::xBitmapFromBitmapEx()" );
 
-            if ( inputBitmap.GetBitmap().HasAlpha() )
-            {
-                geometry::IntegerSize2D aSize;
-
-                aSize.Width = aSize.Height = 1;
-
-                uno::Reference< rendering::XBitmap > xBitmap = xGraphicDevice->createCompatibleAlphaBitmap( aSize );
-
-                uno::Reference< beans::XFastPropertySet > rPropSet( xBitmap, uno::UNO_QUERY );
-                if ( rPropSet.is() )
-                {
-                    Bitmap aBitmap = inputBitmap.GetBitmap();
-                    rPropSet->setFastPropertyValue( 0, uno::Any( sal_Int64( &aBitmap )));
-
-                    aSize = xBitmap->getSize();
-
-                    if ( aSize.Width != 1 || aSize.Height != 1 )
-                        return xBitmap;
-                }
-            }
-
             return new vcl::unotools::VclCanvasBitmap( inputBitmap );
         }
 
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index 7f587c6..aee24dd 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -564,7 +564,6 @@ XImage* X11SalBitmap::ImplCreateXImage(
 // -----------------------------------------------------------------------------
 bool X11SalBitmap::ImplCreateFromDrawable(
     Drawable aDrawable,
-    void *pVisual,
     SalX11Screen nScreen,
     long nDrawableDepth,
     long nX,
@@ -575,7 +574,7 @@ bool X11SalBitmap::ImplCreateFromDrawable(
     Destroy();
 
     if( aDrawable && nWidth && nHeight && nDrawableDepth )
-        mpDDB = new ImplSalDDB( aDrawable, pVisual, nScreen, nDrawableDepth, nX, nY, nWidth, nHeight );
+        mpDDB = new ImplSalDDB( aDrawable, nScreen, nDrawableDepth, nX, nY, nWidth, nHeight );
 
     return( mpDDB != NULL );
 }
@@ -735,8 +734,7 @@ bool X11SalBitmap::Create( const SalBitmap& rSSalBmp )
     }
     else if(  rSalBmp.mpDDB )
         ImplCreateFromDrawable( rSalBmp.mpDDB->ImplGetPixmap(),
-                                rSalBmp.mpDDB->ImplGetVisual(),
-                               rSalBmp.mpDDB->ImplGetScreen(),
+                                rSalBmp.mpDDB->ImplGetScreen(),
                                 rSalBmp.mpDDB->ImplGetDepth(),
                                 0, 0, rSalBmp.mpDDB->ImplGetWidth(), rSalBmp.mpDDB->ImplGetHeight() );
 
@@ -775,13 +773,11 @@ bool X11SalBitmap::Create(
 
         if( xFastPropertySet->getFastPropertyValue(bMask ? 2 : 1) >>= args ) {
             long pixmapHandle;
-            sal_Int64 nVisualPtr;
-            if( args.getLength() >= 4 && ( args[1] >>= pixmapHandle ) && ( args[2] >>= depth ) && ( args[3] >>= nVisualPtr ) ) {
+            if( ( args[1] >>= pixmapHandle ) && ( args[2] >>= depth ) ) {
 
                 mbGrey = bMask;
                 bool bSuccess = ImplCreateFromDrawable(
                                     pixmapHandle,
-                                    reinterpret_cast<void*>(nVisualPtr),
                                     // FIXME: this seems multi-screen broken to me
                                     SalX11Screen( 0 ),
                                     depth,
@@ -893,7 +889,6 @@ bool X11SalBitmap::GetSystemData( BitmapSystemData& rData )
         // prolly not a good idea, since it's accessed from
         // non-platform aware code in vcl/bitmap.hxx)
         rData.aPixmap = (void*)mpDDB->ImplGetPixmap();
-        rData.aVisual = mpDDB->ImplGetVisual ();
         rData.mnWidth = mpDDB->ImplGetWidth ();
         rData.mnHeight = mpDDB->ImplGetHeight ();
         return true;
@@ -909,7 +904,6 @@ bool X11SalBitmap::GetSystemData( BitmapSystemData& rData )
 ImplSalDDB::ImplSalDDB( XImage* pImage, Drawable aDrawable,
                         SalX11Screen nXScreen, const SalTwoRect& rTwoRect )
     : maPixmap    ( 0 )
-    , mpVisual    ( NULL )
     , maTwoRect   ( rTwoRect )
     , mnDepth     ( pImage->depth )
     , mnXScreen   ( nXScreen )
@@ -941,15 +935,13 @@ ImplSalDDB::ImplSalDDB( XImage* pImage, Drawable aDrawable,
 
 ImplSalDDB::ImplSalDDB(
     Drawable aDrawable,
-    void *pVisual,
     SalX11Screen nXScreen,
     long nDrawableDepth,
     long nX,
     long nY,
     long nWidth,
     long nHeight
-)   : mpVisual    ( pVisual )
-    , mnDepth( nDrawableDepth )
+)   : mnDepth( nDrawableDepth )
     , mnXScreen( nXScreen )
 {
     SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 1553fba..97d1924 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -90,7 +90,7 @@ void X11SalGraphics::CopyScreenArea( Display* pDisplay,
     else
     {
         X11SalBitmap aBM;
-        aBM.ImplCreateFromDrawable( aSrc, NULL, nXScreenSrc, nSrcDepth, src_x, src_y, w, h );
+        aBM.ImplCreateFromDrawable( aSrc, nXScreenSrc, nSrcDepth, src_x, src_y, w, h );
         SalTwoRect aTwoRect;
         aTwoRect.mnSrcX = aTwoRect.mnSrcY = 0;
         aTwoRect.mnSrcWidth = aTwoRect.mnDestWidth = w;
@@ -894,7 +894,7 @@ SalBitmap *X11SalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
         nBitCount = 1;
 
     if( ! bFakeWindowBG )
-        pSalBitmap->ImplCreateFromDrawable( GetDrawable(), NULL, m_nXScreen, nBitCount, nX, nY, nDX, nDY );
+        pSalBitmap->ImplCreateFromDrawable( GetDrawable(), m_nXScreen, nBitCount, nX, nY, nDX, nDY );
     else
         pSalBitmap->Create( Size( nDX, nDY ), (nBitCount > 8) ? 24 : nBitCount, BitmapPalette( nBitCount > 8 ? nBitCount : 0 ) );
 
commit 548cf61edf5c3b0960dca7090c380ddc94ed6567
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Mon Jun 10 12:10:50 2013 +0100

    Revert "fix canvas bitmap rendering (argb32 pixmaps) fixes color in n#780830"
    
    This reverts commit 1a977c09ec478b58eaa49a2372ca8696c4fbe336.
    
    Conflicts:
    	vcl/inc/salbmp.hxx
    	vcl/source/gdi/gdimtf.cxx
    	vcl/unx/generic/gdi/salgdi2.cxx

diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index 4db53dc..99b5e6a 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -47,7 +47,6 @@ public:
     virtual bool            Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > xBitmapCanvas,
                                     Size& rSize,
                                     bool bMask = false ) = 0;
-    virtual bool            HasAlpha() const { return false; }
     virtual void            Destroy() = 0;
     virtual Size            GetSize() const = 0;
     virtual sal_uInt16          GetBitCount() const = 0;
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index 70307a1..59a1285 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -74,7 +74,6 @@ private:
     BitmapBuffer*   mpDIB;
     ImplSalDDB*     mpDDB;
     bool            mbGrey;
-    bool            mbHasAlpha;
 
 public:
 
@@ -150,8 +149,6 @@ public:
     virtual BitmapBuffer*       AcquireBuffer( bool bReadOnly );
     virtual void                ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
     virtual bool                GetSystemData( BitmapSystemData& rData );
-    virtual bool                HasAlpha() const { return mbHasAlpha; }
-    virtual void                SetHasAlpha( bool bHasAlpha ) { mbHasAlpha = bHasAlpha; }
 };
 
 // --------------
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 3684dd0..f1039e9 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -324,11 +324,6 @@ public:
                                              const SalBitmap& rSourceBitmap,
                                              const SalBitmap& rAlphaBitmap );
 
-    bool                    drawAlphaBitmapOpt( const SalTwoRect&,
-                                                const SalBitmap& rSourceBitmap,
-                                                const SalBitmap& rAlphaBitmap,
-                                                bool bUseAlphaBitmap = true );
-
     virtual bool            drawAlphaRect( long nX, long nY, long nWidth,
                                            long nHeight, sal_uInt8 nTransparency );
 
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 9bfcc5a..33e304b 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -502,49 +502,20 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
                     }
 
                     SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
-#ifdef UNX
-                    X11SalBitmap* X11Bmp = static_cast< X11SalBitmap* >( pSalBmp );
+                    SalBitmap* pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap();
 
-                    // for pdf export metafile recording, don't break
-                    // other code's assumption that Bitmap with alpha
-                    // channel comes as BitmapEx
-                    if( !pOut->GetExtOutDevData() )
-                    {
-                        X11Bmp->SetHasAlpha( true );
-                        if( X11Bmp->Create( xBitmapCanvas, aSize ) )
-                        {
-                            Bitmap aBitmap( X11Bmp );
-                            if ( pOut->GetMapMode() == MAP_PIXEL )
-                                pOut->DrawBitmap( rPos, aBitmap );
-                            else
-                                pOut->DrawBitmap( rPos, rLogicDestSize, aBitmap );
-                            return true;
-                        }
-                    }
-                    else
-#endif
+                    if( pSalBmp->Create( xBitmapCanvas, aSize ) && pSalMask->Create( xBitmapCanvas, aSize, true ) )
                     {
-                        // for Windows and Mac, exclusively use this
-                        // code path. The inline alpha on X11 is a
-                        // hack.
-                        SalBitmap* pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap();
-                        if( pSalBmp->Create( xBitmapCanvas, aSize ) && pSalMask->Create( xBitmapCanvas, aSize, true ) )
-                        {
-                            Bitmap aBitmap( pSalBmp );
-                            Bitmap aMask( pSalMask );
-                            AlphaMask aAlphaMask( aMask );
-                            BitmapEx aBitmapEx( aBitmap, aAlphaMask );
-                            if ( pOut->GetMapMode() == MAP_PIXEL )
-                                pOut->DrawBitmapEx( rPos, aBitmapEx );
-                            else
-                                pOut->DrawBitmapEx( rPos, rLogicDestSize, aBitmapEx );
-                            return true;
-                        }
-
-                        delete pSalMask;
+                        Bitmap aBitmap( pSalBmp );
+                        Bitmap aMask( pSalMask );
+                        AlphaMask aAlphaMask( aMask );
+                        BitmapEx aBitmapEx( aBitmap, aAlphaMask );
+                        pOut->DrawBitmapEx( rPos, aBitmapEx );
+                        return true;
                     }
 
                     delete pSalBmp;
+                    delete pSalMask;
                 }
             }
         }
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index bf9a703..7f587c6 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -42,7 +42,6 @@
 #include <unx/salbmp.h>
 #include <unx/salinst.h>
 #include <unx/x11/xlimits.hxx>
-#include "xrender_peer.hxx"
 
 #if defined HAVE_VALGRIND_HEADERS
 #include <valgrind/memcheck.h>
@@ -66,7 +65,6 @@ X11SalBitmap::X11SalBitmap()
     : mpDIB( NULL )
     , mpDDB( NULL )
     , mbGrey( false )
-    , mbHasAlpha( false )
 {
 }
 
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index bbc9c6b..1553fba 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -495,10 +495,7 @@ void X11SalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSa
         XChangeGC( pXDisp, aGC, nValues, &aNewVal );
     }
 
-    if ( rSalBitmap.GetBitCount() == 32 && rSalBitmap.HasAlpha() )
-        drawAlphaBitmapOpt( *pPosAry, rSalBitmap, rSalBitmap, false );
-    else
-        static_cast<const X11SalBitmap&>(rSalBitmap).ImplDraw( aDrawable, m_nXScreen, nDepth, *pPosAry, aGC );
+    static_cast<const X11SalBitmap&>(rSalBitmap).ImplDraw( aDrawable, m_nXScreen, nDepth, *pPosAry, aGC );
 
     if( rSalBitmap.GetBitCount() == 1 )
         XChangeGC( pXDisp, aGC, nValues, &aOldVal );
@@ -626,17 +623,10 @@ void X11SalGraphics::drawMaskedBitmap( const SalTwoRect* pPosAry,
 
 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
-                                      const SalBitmap& rSrcBitmap, const SalBitmap& rAlphaBmp )
-{
-    return drawAlphaBitmapOpt( rTR, rSrcBitmap, rAlphaBmp );
-}
-
-// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
-                                         const SalBitmap& rSrcBitmap, const SalBitmap& rAlphaBmp, bool bUseAlphaBitmap )
+    const SalBitmap& rSrcBitmap, const SalBitmap& rAlphaBmp )
 {
     // non 8-bit alpha not implemented yet
-    if( bUseAlphaBitmap && rAlphaBmp.GetBitCount() != 8 )
+    if( rAlphaBmp.GetBitCount() != 8 )
         return false;
 
     // horizontal mirroring not implemented yet
@@ -658,12 +648,10 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
     const SalVisual& rSalVis = pSalDisp->GetVisual( m_nXScreen );
     Display* pXDisplay = pSalDisp->GetDisplay();
 
-    Picture aAlphaPic = 0;
-    Pixmap aAlphaPM = 0;
     // create source Picture
     int nDepth = m_pVDev ? m_pVDev->GetDepth() : rSalVis.GetDepth();
     const X11SalBitmap& rSrcX11Bmp = static_cast<const X11SalBitmap&>( rSrcBitmap );
-    ImplSalDDB* pSrcDDB = rSrcX11Bmp.ImplGetDDB( hDrawable_, m_nXScreen, bUseAlphaBitmap ? nDepth : 32, rTR );
+    ImplSalDDB* pSrcDDB = rSrcX11Bmp.ImplGetDDB( hDrawable_, m_nXScreen, nDepth, rTR );
     if( !pSrcDDB )
         return false;
 
@@ -671,7 +659,7 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
     // we requested. E.g. mask pixmaps are always compatible with the drawable
     // TODO: find an appropriate picture format for these cases
     //       then remove the workaround below and the one for #i75531#
-    if( bUseAlphaBitmap && nDepth != pSrcDDB->ImplGetDepth() )
+    if( nDepth != pSrcDDB->ImplGetDepth() )
         return false;
 
     Pixmap aSrcPM = pSrcDDB->ImplGetPixmap();
@@ -682,86 +670,81 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
     // TODO: use scoped picture
     Visual* pSrcXVisual = rSalVis.GetVisual();
     XRenderPeer& rPeer = XRenderPeer::GetInstance();
-    XRenderPictFormat* pSrcVisFmt = bUseAlphaBitmap ? rPeer.FindVisualFormat( pSrcXVisual ) : rPeer.FindStandardFormat( PictStandardARGB32 );
+    XRenderPictFormat* pSrcVisFmt = rPeer.FindVisualFormat( pSrcXVisual );
     if( !pSrcVisFmt )
         return false;
     Picture aSrcPic = rPeer.CreatePicture( aSrcPM, pSrcVisFmt, 0, NULL );
     if( !aSrcPic )
         return false;
 
-    if ( bUseAlphaBitmap ) {
-        // create alpha Picture
+    // create alpha Picture
 
-        // TODO: use SalX11Bitmap functionality and caching for the Alpha Pixmap
-        // problem is that they don't provide an 8bit Pixmap on a non-8bit display
-        BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rAlphaBmp).AcquireBuffer( sal_True );
+    // TODO: use SalX11Bitmap functionality and caching for the Alpha Pixmap
+    // problem is that they don't provide an 8bit Pixmap on a non-8bit display
+    BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rAlphaBmp).AcquireBuffer( sal_True );
 
-        // an XImage needs its data top_down
-        // TODO: avoid wrongly oriented images in upper layers!
-        const int nImageSize = pAlphaBuffer->mnHeight * pAlphaBuffer->mnScanlineSize;
-        const char* pSrcBits = (char*)pAlphaBuffer->mpBits;
-        char* pAlphaBits = new char[ nImageSize ];
-        if( BMP_SCANLINE_ADJUSTMENT( pAlphaBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
-            memcpy( pAlphaBits, pSrcBits, nImageSize );
-        else
-            {
-                char* pDstBits = pAlphaBits + nImageSize;
-                const int nLineSize = pAlphaBuffer->mnScanlineSize;
-                for(; (pDstBits -= nLineSize) >= pAlphaBits; pSrcBits += nLineSize )
-                    memcpy( pDstBits, pSrcBits, nLineSize );
-            }
-
-        // the alpha values need to be inverted for XRender
-        // TODO: make upper layers use standard alpha
-        long* pLDst = (long*)pAlphaBits;
-        for( int i = nImageSize/sizeof(long); --i >= 0; ++pLDst )
-            *pLDst = ~*pLDst;
-
-        char* pCDst = (char*)pLDst;
-        for( int i = nImageSize & (sizeof(long)-1); --i >= 0; ++pCDst )
-            *pCDst = ~*pCDst;
-
-        const XRenderPictFormat* pAlphaFormat = rPeer.GetStandardFormatA8();
-        XImage* pAlphaImg = XCreateImage( pXDisplay, pSrcXVisual, 8, ZPixmap, 0,
-                                          pAlphaBits, pAlphaBuffer->mnWidth, pAlphaBuffer->mnHeight,
-                                          pAlphaFormat->depth, pAlphaBuffer->mnScanlineSize );
-
-        aAlphaPM = limitXCreatePixmap( pXDisplay, hDrawable_,
-                                       rTR.mnDestWidth, rTR.mnDestHeight, 8 );
-
-        XGCValues aAlphaGCV;
-        aAlphaGCV.function = GXcopy;
-        GC aAlphaGC = XCreateGC( pXDisplay, aAlphaPM, GCFunction, &aAlphaGCV );
-        XPutImage( pXDisplay, aAlphaPM, aAlphaGC, pAlphaImg,
-                   rTR.mnSrcX, rTR.mnSrcY, 0, 0, rTR.mnDestWidth, rTR.mnDestHeight );
-        XFreeGC( pXDisplay, aAlphaGC );
-        XFree( pAlphaImg );
-        if( pAlphaBits != (char*)pAlphaBuffer->mpBits )
-            delete[] pAlphaBits;
-
-        const_cast<SalBitmap&>(rAlphaBmp).ReleaseBuffer( pAlphaBuffer, sal_True );
-
-        XRenderPictureAttributes aAttr;
-        aAttr.repeat = true;
-        aAlphaPic = rPeer.CreatePicture( aAlphaPM, pAlphaFormat, CPRepeat, &aAttr );
-        if( !aAlphaPic )
-            return false;
-    }
+    // an XImage needs its data top_down
+    // TODO: avoid wrongly oriented images in upper layers!
+    const int nImageSize = pAlphaBuffer->mnHeight * pAlphaBuffer->mnScanlineSize;
+    const char* pSrcBits = (char*)pAlphaBuffer->mpBits;
+    char* pAlphaBits = new char[ nImageSize ];
+    if( BMP_SCANLINE_ADJUSTMENT( pAlphaBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
+        memcpy( pAlphaBits, pSrcBits, nImageSize );
+    else
+    {
+        char* pDstBits = pAlphaBits + nImageSize;
+        const int nLineSize = pAlphaBuffer->mnScanlineSize;
+        for(; (pDstBits -= nLineSize) >= pAlphaBits; pSrcBits += nLineSize )
+            memcpy( pDstBits, pSrcBits, nLineSize );
+    }
+
+    // the alpha values need to be inverted for XRender
+    // TODO: make upper layers use standard alpha
+    long* pLDst = (long*)pAlphaBits;
+    for( int i = nImageSize/sizeof(long); --i >= 0; ++pLDst )
+        *pLDst = ~*pLDst;
+
+    char* pCDst = (char*)pLDst;
+    for( int i = nImageSize & (sizeof(long)-1); --i >= 0; ++pCDst )
+        *pCDst = ~*pCDst;
+
+    const XRenderPictFormat* pAlphaFormat = rPeer.GetStandardFormatA8();
+    XImage* pAlphaImg = XCreateImage( pXDisplay, pSrcXVisual, 8, ZPixmap, 0,
+        pAlphaBits, pAlphaBuffer->mnWidth, pAlphaBuffer->mnHeight,
+        pAlphaFormat->depth, pAlphaBuffer->mnScanlineSize );
+
+    Pixmap aAlphaPM = limitXCreatePixmap( pXDisplay, hDrawable_,
+        rTR.mnDestWidth, rTR.mnDestHeight, 8 );
+
+    XGCValues aAlphaGCV;
+    aAlphaGCV.function = GXcopy;
+    GC aAlphaGC = XCreateGC( pXDisplay, aAlphaPM, GCFunction, &aAlphaGCV );
+    XPutImage( pXDisplay, aAlphaPM, aAlphaGC, pAlphaImg,
+        rTR.mnSrcX, rTR.mnSrcY, 0, 0, rTR.mnDestWidth, rTR.mnDestHeight );
+    XFreeGC( pXDisplay, aAlphaGC );
+    XFree( pAlphaImg );
+    if( pAlphaBits != (char*)pAlphaBuffer->mpBits )
+        delete[] pAlphaBits;
+
+    const_cast<SalBitmap&>(rAlphaBmp).ReleaseBuffer( pAlphaBuffer, sal_True );
+
+    XRenderPictureAttributes aAttr;
+    aAttr.repeat = true;
+    Picture aAlphaPic = rPeer.CreatePicture( aAlphaPM, pAlphaFormat, CPRepeat, &aAttr );
+    if( !aAlphaPic )
+        return false;
 
     // set clipping
     if( mpClipRegion && !XEmptyRegion( mpClipRegion ) )
         rPeer.SetPictureClipRegion( aDstPic, mpClipRegion );
 
     // paint source * mask over destination picture
-    rPeer.CompositePicture( PictOpOver, aSrcPic, bUseAlphaBitmap ? aAlphaPic : None, aDstPic,
-                            rTR.mnSrcX, rTR.mnSrcY, 0, 0,
-                            rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight );
+    rPeer.CompositePicture( PictOpOver, aSrcPic, aAlphaPic, aDstPic,
+        rTR.mnSrcX, rTR.mnSrcY, 0, 0,
+        rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight );
 
-    if ( bUseAlphaBitmap )
-    {
-        rPeer.FreePicture( aAlphaPic );
-        XFreePixmap( pXDisplay, aAlphaPM);
-    }
+    rPeer.FreePicture( aAlphaPic );
+    XFreePixmap(pXDisplay, aAlphaPM);
     rPeer.FreePicture( aSrcPic );
     return true;
 }


More information about the Libreoffice-commits mailing list