From c2530b02311c46529eed53ee688bf6c83ce4b86e Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Fri, 31 May 2013 08:58:13 +0200 Subject: Band-aid fix for bnc#795857 and the pdf export black background. Problem is the general un-awareness of the code base for inline alpha. Needs larger rework eventually. Change-Id: I01430d9087f98615819f0a7085b93f1c318e8b0b --- vcl/source/gdi/gdimtf.cxx | 60 ++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index ffee7480cda8..019e18e0df84 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -446,39 +446,45 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S } SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap(); - // I don't quite understand this, but the old code didn't work properly on X11 when alpha was used, - // and the commit that changed to the new code relied on alpha support in bitmap - // (which that commit implemented only in X11SalBitmap) and so it didn't work on Windows. - // So keep both. #if defined(UNX) && !defined(ANDROID) && !defined(IOS) && !defined(MACOSX) && !defined(LIBO_HEADLESS) X11SalBitmap* X11Bmp = static_cast< X11SalBitmap* >( pSalBmp ); - 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 - SalBitmap* pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap(); - if( pSalBmp->Create( xBitmapCanvas, aSize ) && pSalMask->Create( xBitmapCanvas, aSize, true ) ) + // for pdf export metafile recording, don't break + // other code's assumption that Bitmap with alpha + // channel comes as BitmapEx + if( !pOut->GetExtOutDevData() ) { - 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; + 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; + } } - delete pSalMask; + else #endif + { + // 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; + } delete pSalBmp; } } -- cgit v1.2.3