Kaydet (Commit) 03b4c0e0 authored tarafından Michael Meeks's avatar Michael Meeks

Revert "fix canvas bitmap rendering (argb32 pixmaps) fixes color in n#780830"

This reverts commit 46e53913.

Conflicts:
	vcl/inc/salbmp.hxx
	vcl/source/gdi/gdimtf.cxx
	vcl/unx/generic/gdi/salgdi2.cxx

Change-Id: Ifa893b687c724ea71655aa4e084a44858695073e
üst 056c7b46
...@@ -47,7 +47,6 @@ public: ...@@ -47,7 +47,6 @@ public:
virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > xBitmapCanvas, virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > xBitmapCanvas,
Size& rSize, Size& rSize,
bool bMask = false ) = 0; bool bMask = false ) = 0;
virtual bool HasAlpha() const { return false; }
virtual void Destroy() = 0; virtual void Destroy() = 0;
virtual Size GetSize() const = 0; virtual Size GetSize() const = 0;
virtual sal_uInt16 GetBitCount() const = 0; virtual sal_uInt16 GetBitCount() const = 0;
......
...@@ -75,7 +75,6 @@ private: ...@@ -75,7 +75,6 @@ private:
BitmapBuffer* mpDIB; BitmapBuffer* mpDIB;
ImplSalDDB* mpDDB; ImplSalDDB* mpDDB;
bool mbGrey; bool mbGrey;
bool mbHasAlpha;
public: public:
...@@ -150,8 +149,6 @@ public: ...@@ -150,8 +149,6 @@ public:
virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ); virtual BitmapBuffer* AcquireBuffer( bool bReadOnly );
virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ); virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
virtual bool GetSystemData( BitmapSystemData& rData ); virtual bool GetSystemData( BitmapSystemData& rData );
virtual bool HasAlpha() const { return mbHasAlpha; }
virtual void SetHasAlpha( bool bHasAlpha ) { mbHasAlpha = bHasAlpha; }
}; };
// -------------- // --------------
......
...@@ -322,11 +322,6 @@ public: ...@@ -322,11 +322,6 @@ public:
const SalBitmap& rSourceBitmap, const SalBitmap& rSourceBitmap,
const SalBitmap& rAlphaBitmap ); 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, virtual bool drawAlphaRect( long nX, long nY, long nWidth,
long nHeight, sal_uInt8 nTransparency ); long nHeight, sal_uInt8 nTransparency );
......
...@@ -446,46 +446,22 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S ...@@ -446,46 +446,22 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
} }
SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap(); SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
#if defined(UNX) && !defined(ANDROID) && !defined(IOS) && !defined(MACOSX) && !defined(LIBO_HEADLESS) SalBitmap* pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap();
X11SalBitmap* X11Bmp = static_cast< X11SalBitmap* >( pSalBmp ); 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() )
{
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
{ {
// for Windows and Mac, exclusively use this code Bitmap aBitmap( pSalBmp );
// path. The inline alpha on X11 is a hack. Bitmap aMask( pSalMask );
SalBitmap* pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap(); AlphaMask aAlphaMask( aMask );
if( pSalBmp->Create( xBitmapCanvas, aSize ) && pSalMask->Create( xBitmapCanvas, aSize, true ) ) BitmapEx aBitmapEx( aBitmap, aAlphaMask );
{ if ( pOut->GetMapMode() == MAP_PIXEL )
Bitmap aBitmap( pSalBmp ); pOut->DrawBitmapEx( rPos, aBitmapEx );
Bitmap aMask( pSalMask ); else
AlphaMask aAlphaMask( aMask ); pOut->DrawBitmapEx( rPos, rLogicDestSize, aBitmapEx );
BitmapEx aBitmapEx( aBitmap, aAlphaMask ); return true;
if ( pOut->GetMapMode() == MAP_PIXEL )
pOut->DrawBitmapEx( rPos, aBitmapEx );
else
pOut->DrawBitmapEx( rPos, rLogicDestSize, aBitmapEx );
return true;
}
delete pSalMask;
} }
delete pSalBmp; delete pSalBmp;
delete pSalMask;
} }
} }
} }
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include <unx/salbmp.h> #include <unx/salbmp.h>
#include <unx/salinst.h> #include <unx/salinst.h>
#include <unx/x11/xlimits.hxx> #include <unx/x11/xlimits.hxx>
#include "xrender_peer.hxx"
#if defined HAVE_VALGRIND_HEADERS #if defined HAVE_VALGRIND_HEADERS
#include <valgrind/memcheck.h> #include <valgrind/memcheck.h>
...@@ -67,7 +66,6 @@ X11SalBitmap::X11SalBitmap() ...@@ -67,7 +66,6 @@ X11SalBitmap::X11SalBitmap()
: mpDIB( NULL ) : mpDIB( NULL )
, mpDDB( NULL ) , mpDDB( NULL )
, mbGrey( false ) , mbGrey( false )
, mbHasAlpha( false )
{ {
} }
......
...@@ -479,10 +479,7 @@ void X11SalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSa ...@@ -479,10 +479,7 @@ void X11SalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSa
XChangeGC( pXDisp, aGC, nValues, &aNewVal ); XChangeGC( pXDisp, aGC, nValues, &aNewVal );
} }
if ( rSalBitmap.GetBitCount() == 32 && rSalBitmap.HasAlpha() ) static_cast<const X11SalBitmap&>(rSalBitmap).ImplDraw( aDrawable, m_nXScreen, nDepth, *pPosAry, aGC );
drawAlphaBitmapOpt( *pPosAry, rSalBitmap, rSalBitmap, false );
else
static_cast<const X11SalBitmap&>(rSalBitmap).ImplDraw( aDrawable, m_nXScreen, nDepth, *pPosAry, aGC );
if( rSalBitmap.GetBitCount() == 1 ) if( rSalBitmap.GetBitCount() == 1 )
XChangeGC( pXDisp, aGC, nValues, &aOldVal ); XChangeGC( pXDisp, aGC, nValues, &aOldVal );
...@@ -605,16 +602,10 @@ void X11SalGraphics::drawMaskedBitmap( const SalTwoRect* pPosAry, ...@@ -605,16 +602,10 @@ void X11SalGraphics::drawMaskedBitmap( const SalTwoRect* pPosAry,
} }
bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
const SalBitmap& rSrcBitmap, const SalBitmap& rAlphaBmp ) 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 )
{ {
// non 8-bit alpha not implemented yet // non 8-bit alpha not implemented yet
if( bUseAlphaBitmap && rAlphaBmp.GetBitCount() != 8 ) if( rAlphaBmp.GetBitCount() != 8 )
return false; return false;
// horizontal mirroring not implemented yet // horizontal mirroring not implemented yet
...@@ -636,12 +627,10 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR, ...@@ -636,12 +627,10 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
const SalVisual& rSalVis = pSalDisp->GetVisual( m_nXScreen ); const SalVisual& rSalVis = pSalDisp->GetVisual( m_nXScreen );
Display* pXDisplay = pSalDisp->GetDisplay(); Display* pXDisplay = pSalDisp->GetDisplay();
Picture aAlphaPic = 0;
Pixmap aAlphaPM = 0;
// create source Picture // create source Picture
int nDepth = m_pVDev ? m_pVDev->GetDepth() : rSalVis.GetDepth(); int nDepth = m_pVDev ? m_pVDev->GetDepth() : rSalVis.GetDepth();
const X11SalBitmap& rSrcX11Bmp = static_cast<const X11SalBitmap&>( rSrcBitmap ); 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 ) if( !pSrcDDB )
return false; return false;
...@@ -649,7 +638,7 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR, ...@@ -649,7 +638,7 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
// we requested. E.g. mask pixmaps are always compatible with the drawable // we requested. E.g. mask pixmaps are always compatible with the drawable
// TODO: find an appropriate picture format for these cases // TODO: find an appropriate picture format for these cases
// then remove the workaround below and the one for #i75531# // then remove the workaround below and the one for #i75531#
if( bUseAlphaBitmap && nDepth != pSrcDDB->ImplGetDepth() ) if( nDepth != pSrcDDB->ImplGetDepth() )
return false; return false;
Pixmap aSrcPM = pSrcDDB->ImplGetPixmap(); Pixmap aSrcPM = pSrcDDB->ImplGetPixmap();
...@@ -660,88 +649,81 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR, ...@@ -660,88 +649,81 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
// TODO: use scoped picture // TODO: use scoped picture
Visual* pSrcXVisual = rSalVis.GetVisual(); Visual* pSrcXVisual = rSalVis.GetVisual();
XRenderPeer& rPeer = XRenderPeer::GetInstance(); XRenderPeer& rPeer = XRenderPeer::GetInstance();
XRenderPictFormat* pSrcVisFmt = bUseAlphaBitmap ? rPeer.FindVisualFormat( pSrcXVisual ) : rPeer.FindStandardFormat( PictStandardARGB32 ); XRenderPictFormat* pSrcVisFmt = rPeer.FindVisualFormat( pSrcXVisual );
if( !pSrcVisFmt ) if( !pSrcVisFmt )
return false; return false;
Picture aSrcPic = rPeer.CreatePicture( aSrcPM, pSrcVisFmt, 0, NULL ); Picture aSrcPic = rPeer.CreatePicture( aSrcPM, pSrcVisFmt, 0, NULL );
if( !aSrcPic ) if( !aSrcPic )
return false; return false;
if ( bUseAlphaBitmap ) { // create alpha Picture
// create alpha Picture
// TODO: use SalX11Bitmap functionality and caching for the Alpha Pixmap // 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 // problem is that they don't provide an 8bit Pixmap on a non-8bit display
BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rAlphaBmp).AcquireBuffer( sal_True ); 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 // an XImage needs its data top_down
// TODO: make upper layers use standard alpha // TODO: avoid wrongly oriented images in upper layers!
long* pLDst = (long*)pAlphaBits; const int nImageSize = pAlphaBuffer->mnHeight * pAlphaBuffer->mnScanlineSize;
for( int i = nImageSize/sizeof(long); --i >= 0; ++pLDst ) const char* pSrcBits = (char*)pAlphaBuffer->mpBits;
*pLDst = ~*pLDst; char* pAlphaBits = new char[ nImageSize ];
if( BMP_SCANLINE_ADJUSTMENT( pAlphaBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
char* pCDst = (char*)pLDst; memcpy( pAlphaBits, pSrcBits, nImageSize );
for( int i = nImageSize & (sizeof(long)-1); --i >= 0; ++pCDst ) else
*pCDst = ~*pCDst; {
char* pDstBits = pAlphaBits + nImageSize;
const XRenderPictFormat* pAlphaFormat = rPeer.GetStandardFormatA8(); const int nLineSize = pAlphaBuffer->mnScanlineSize;
XImage* pAlphaImg = XCreateImage( pXDisplay, pSrcXVisual, 8, ZPixmap, 0, for(; (pDstBits -= nLineSize) >= pAlphaBits; pSrcBits += nLineSize )
pAlphaBits, pAlphaBuffer->mnWidth, pAlphaBuffer->mnHeight, memcpy( pDstBits, pSrcBits, nLineSize );
pAlphaFormat->depth, pAlphaBuffer->mnScanlineSize ); }
aAlphaPM = limitXCreatePixmap( pXDisplay, hDrawable_, // the alpha values need to be inverted for XRender
rTR.mnDestWidth, rTR.mnDestHeight, 8 ); // TODO: make upper layers use standard alpha
long* pLDst = (long*)pAlphaBits;
XGCValues aAlphaGCV; for( int i = nImageSize/sizeof(long); --i >= 0; ++pLDst )
aAlphaGCV.function = GXcopy; *pLDst = ~*pLDst;
GC aAlphaGC = XCreateGC( pXDisplay, aAlphaPM, GCFunction, &aAlphaGCV );
XPutImage( pXDisplay, aAlphaPM, aAlphaGC, pAlphaImg, char* pCDst = (char*)pLDst;
rTR.mnSrcX, rTR.mnSrcY, 0, 0, rTR.mnDestWidth, rTR.mnDestHeight ); for( int i = nImageSize & (sizeof(long)-1); --i >= 0; ++pCDst )
XFreeGC( pXDisplay, aAlphaGC ); *pCDst = ~*pCDst;
XFree( pAlphaImg );
if( pAlphaBits != (char*)pAlphaBuffer->mpBits ) const XRenderPictFormat* pAlphaFormat = rPeer.GetStandardFormatA8();
delete[] pAlphaBits; XImage* pAlphaImg = XCreateImage( pXDisplay, pSrcXVisual, 8, ZPixmap, 0,
pAlphaBits, pAlphaBuffer->mnWidth, pAlphaBuffer->mnHeight,
const_cast<SalBitmap&>(rAlphaBmp).ReleaseBuffer( pAlphaBuffer, sal_True ); pAlphaFormat->depth, pAlphaBuffer->mnScanlineSize );
XRenderPictureAttributes aAttr; Pixmap aAlphaPM = limitXCreatePixmap( pXDisplay, hDrawable_,
aAttr.repeat = true; rTR.mnDestWidth, rTR.mnDestHeight, 8 );
aAlphaPic = rPeer.CreatePicture( aAlphaPM, pAlphaFormat, CPRepeat, &aAttr );
if( !aAlphaPic ) XGCValues aAlphaGCV;
return false; 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 // set clipping
if( mpClipRegion && !XEmptyRegion( mpClipRegion ) ) if( mpClipRegion && !XEmptyRegion( mpClipRegion ) )
rPeer.SetPictureClipRegion( aDstPic, mpClipRegion ); rPeer.SetPictureClipRegion( aDstPic, mpClipRegion );
// paint source * mask over destination picture // paint source * mask over destination picture
rPeer.CompositePicture( PictOpOver, aSrcPic, bUseAlphaBitmap ? aAlphaPic : None, aDstPic, rPeer.CompositePicture( PictOpOver, aSrcPic, aAlphaPic, aDstPic,
rTR.mnSrcX, rTR.mnSrcY, 0, 0, rTR.mnSrcX, rTR.mnSrcY, 0, 0,
rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight ); rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight );
if ( bUseAlphaBitmap ) rPeer.FreePicture( aAlphaPic );
{ XFreePixmap(pXDisplay, aAlphaPM);
if ( aAlphaPic )
rPeer.FreePicture( aAlphaPic );
if ( aAlphaPM )
XFreePixmap( pXDisplay, aAlphaPM );
}
rPeer.FreePicture( aSrcPic ); rPeer.FreePicture( aSrcPic );
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment