diff options
Diffstat (limited to 'vcl/unx/source/gdi')
-rw-r--r-- | vcl/unx/source/gdi/salgdi.cxx | 29 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi2.cxx | 21 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi3.cxx | 7 | ||||
-rw-r--r-- | vcl/unx/source/gdi/xrender_peer.hxx | 23 |
4 files changed, 38 insertions, 42 deletions
diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index 2b21397248ef..60acda82091e 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salgdi.cxx,v $ - * $Revision: 1.53 $ + * $Revision: 1.53.16.1 $ * * This file is part of OpenOffice.org. * @@ -1361,36 +1361,25 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly } // create xrender Picture for polygon foreground - Display* pXDisplay = GetXDisplay(); - int nVisualDepth = pVisualFormat->depth; - SalDisplay::RenderEntry& rEntry = GetDisplay()->GetRenderEntries( m_nScreen )[ nVisualDepth ]; + SalDisplay::RenderEntry& rEntry = GetDisplay()->GetRenderEntries( m_nScreen )[ 32 ]; if( !rEntry.m_aPicture ) { -#ifdef DBG_UTIL - int iDummy; - unsigned uDummy; - XLIB_Window wDummy; - unsigned int nDrawDepth; - ::XGetGeometry( pXDisplay, hDrawable_, &wDummy, &iDummy, &iDummy, - &uDummy, &uDummy, &uDummy, &nDrawDepth ); - DBG_ASSERT( static_cast<unsigned>(nVisualDepth) == nDrawDepth, "depth messed up for XRender" ); -#endif // DBG_UTIL - - rEntry.m_aPixmap = ::XCreatePixmap( pXDisplay, hDrawable_, 1, 1, nVisualDepth ); + Display* pXDisplay = GetXDisplay(); + + rEntry.m_aPixmap = ::XCreatePixmap( pXDisplay, hDrawable_, 1, 1, 32 ); XRenderPictureAttributes aAttr; aAttr.repeat = true; - XRenderPictFormat* pXRPF = rRenderPeer.FindStandardFormat(PictStandardARGB32); - rEntry.m_aPicture = rRenderPeer.CreatePicture ( rEntry.m_aPixmap, pXRPF, CPRepeat, aAttr ); + XRenderPictFormat* pXRPF = rRenderPeer.FindStandardFormat( PictStandardARGB32 ); + rEntry.m_aPicture = rRenderPeer.CreatePicture( rEntry.m_aPixmap, pXRPF, CPRepeat, &aAttr ); } // set polygon foreground color and opacity - XRenderColor aRenderColor = GetXRenderColor( nBrushColor_ , fTransparency); + XRenderColor aRenderColor = GetXRenderColor( nBrushColor_ , fTransparency ); rRenderPeer.FillRectangle( PictOpSrc, rEntry.m_aPicture, &aRenderColor, 0, 0, 1, 1 ); // notify xrender of target drawable - XRenderPictureAttributes aAttr; - Picture aDst = rRenderPeer.CreatePicture( hDrawable_, pVisualFormat, 0, aAttr ); + Picture aDst = rRenderPeer.CreatePicture( hDrawable_, pVisualFormat, 0, NULL ); // set clipping if( pClipRegion_ && !XEmptyRegion( pClipRegion_ ) ) diff --git a/vcl/unx/source/gdi/salgdi2.cxx b/vcl/unx/source/gdi/salgdi2.cxx index f0dbc771ff76..8086ea8e8ea5 100644 --- a/vcl/unx/source/gdi/salgdi2.cxx +++ b/vcl/unx/source/gdi/salgdi2.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salgdi2.cxx,v $ - * $Revision: 1.47 $ + * $Revision: 1.47.16.1 $ * * This file is part of OpenOffice.org. * @@ -820,8 +820,7 @@ bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, if( !pDstVisFmt ) return false; - XRenderPictureAttributes aAttr; - Picture aDstPic = rPeer.CreatePicture( hDrawable_, pDstVisFmt, 0, aAttr ); + Picture aDstPic = rPeer.CreatePicture( hDrawable_, pDstVisFmt, 0, NULL ); if( !aDstPic ) return false; @@ -844,7 +843,7 @@ bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, return false; XRenderPictFormat* pSrcVisFmt = pDstVisFmt; - Picture aSrcPic = rPeer.CreatePicture( aSrcPM, pSrcVisFmt, 0, aAttr ); + Picture aSrcPic = rPeer.CreatePicture( aSrcPM, pSrcVisFmt, 0, NULL ); if( !aSrcPic ) return false; @@ -899,8 +898,9 @@ bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, const_cast<SalBitmap&>(rAlphaBmp).ReleaseBuffer( pAlphaBuffer, TRUE ); + XRenderPictureAttributes aAttr; aAttr.repeat = true; - Picture aAlphaPic = rPeer.CreatePicture( aAlphaPM, pAlphaFormat, CPRepeat, aAttr ); + Picture aAlphaPic = rPeer.CreatePicture( aAlphaPM, pAlphaFormat, CPRepeat, &aAttr ); if( !aAlphaPic ) return false; @@ -948,17 +948,12 @@ bool X11SalGraphics::drawAlphaRect( long nX, long nY, long nWidth, if( !pDstVisFmt ) return false; - XRenderPictureAttributes aAttr; - Picture aDstPic = rPeer.CreatePicture( hDrawable_, pDstVisFmt, 0, aAttr ); + Picture aDstPic = rPeer.CreatePicture( hDrawable_, pDstVisFmt, 0, NULL ); if( !aDstPic ) return false; - XRenderColor aRenderColor = { - SALCOLOR_RED(nBrushColor_), - SALCOLOR_GREEN(nBrushColor_), - SALCOLOR_BLUE(nBrushColor_), - 255 - 255L*nTransparency/100 - }; + const double fTransparency = (100 - nTransparency) * (1.0/100); + const XRenderColor aRenderColor = GetXRenderColor( nBrushColor_ , fTransparency); rPeer.FillRectangle( PictOpOver, aDstPic, diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx index 5caaaa81c425..f9fcf0929a88 100644 --- a/vcl/unx/source/gdi/salgdi3.cxx +++ b/vcl/unx/source/gdi/salgdi3.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salgdi3.cxx,v $ - * $Revision: 1.158 $ + * $Revision: 1.157.12.2 $ * * This file is part of OpenOffice.org. * @@ -1053,7 +1053,7 @@ void X11SalGraphics::DrawServerAAFontString( const ServerFontLayout& rLayout ) XRenderPictureAttributes aAttr; aAttr.repeat = true; - rEntry.m_aPicture = rRenderPeer.CreatePicture ( rEntry.m_aPixmap, pVisualFormat, CPRepeat, aAttr ); + rEntry.m_aPicture = rRenderPeer.CreatePicture ( rEntry.m_aPixmap, pVisualFormat, CPRepeat, &aAttr ); } // set font foreground color and opacity @@ -1061,8 +1061,7 @@ void X11SalGraphics::DrawServerAAFontString( const ServerFontLayout& rLayout ) rRenderPeer.FillRectangle( PictOpSrc, rEntry.m_aPicture, &aRenderColor, 0, 0, 1, 1 ); // notify xrender of target drawable - XRenderPictureAttributes aAttr; - Picture aDst = rRenderPeer.CreatePicture( hDrawable_, pVisualFormat, 0, aAttr ); + Picture aDst = rRenderPeer.CreatePicture( hDrawable_, pVisualFormat, 0, NULL ); // set clipping if( pClipRegion_ && !XEmptyRegion( pClipRegion_ ) ) diff --git a/vcl/unx/source/gdi/xrender_peer.hxx b/vcl/unx/source/gdi/xrender_peer.hxx index 6b5a7688575c..24abd9d239e2 100644 --- a/vcl/unx/source/gdi/xrender_peer.hxx +++ b/vcl/unx/source/gdi/xrender_peer.hxx @@ -65,7 +65,7 @@ public: XRenderPictFormat* FindPictureFormat( unsigned long nMask, const XRenderPictFormat& ) const; Picture CreatePicture( Drawable, const XRenderPictFormat*, - unsigned long nDrawable, const XRenderPictureAttributes& ) const; + unsigned long nDrawable, const XRenderPictureAttributes* ) const; void SetPictureClipRegion( Picture, XLIB_Region ) const; void CompositePicture( int nOp, Picture aSrc, Picture aMask, Picture aDst, int nXSrc, int nYSrc, int nXMask, int nYMask, @@ -183,14 +183,14 @@ inline XRenderPictFormat* XRenderPeer::FindPictureFormat( unsigned long nFormatM inline Picture XRenderPeer::CreatePicture( Drawable aDrawable, const XRenderPictFormat* pVisFormat, unsigned long nValueMask, - const XRenderPictureAttributes& rRenderAttr ) const + const XRenderPictureAttributes* pRenderAttr ) const { #ifdef XRENDER_LINK return XRenderCreatePicture( mpDisplay, aDrawable, pVisFormat, - nValueMask, &rRenderAttr ); + nValueMask, pRenderAttr ); #else return (*mpXRenderCreatePicture)( mpDisplay, aDrawable, pVisFormat, - nValueMask, &rRenderAttr ); + nValueMask, pRenderAttr ); #endif } @@ -350,10 +350,23 @@ inline Picture& ScopedPic::Get() inline XRenderColor GetXRenderColor( const SalColor& rSalColor, double fTransparency = 0.0 ) { XRenderColor aRetVal; + // convert the SalColor aRetVal.red = SALCOLOR_RED( rSalColor ); aRetVal.red |= (aRetVal.red << 8); aRetVal.green = SALCOLOR_GREEN( rSalColor ); aRetVal.green |= (aRetVal.green << 8); aRetVal.blue = SALCOLOR_BLUE( rSalColor ); aRetVal.blue |= (aRetVal.blue << 8); - aRetVal.alpha = static_cast< unsigned short >((1.0 - fTransparency) * double(0xffff)); + + // handle transparency + aRetVal.alpha = 0xFFFF; // default to opaque + if( fTransparency != 0 ) + { + const double fAlpha = 1.0 - fTransparency; + aRetVal.alpha = static_cast<sal_uInt16>(fAlpha * 0xFFFF + 0.5); + // xrender wants pre-multiplied colors + aRetVal.red = static_cast<sal_uInt16>(fAlpha * aRetVal.red + 0.5); + aRetVal.green = static_cast<sal_uInt16>(fAlpha * aRetVal.green + 0.5); + aRetVal.blue = static_cast<sal_uInt16>(fAlpha * aRetVal.blue + 0.5); + } + return aRetVal; } |