LCOV - code coverage report
Current view: top level - vcl/unx/generic/gdi - xrender_peer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SV_XRENDER_PEER_HXX
      30                 :            : #define _SV_XRENDER_PEER_HXX
      31                 :            : 
      32                 :            : #include <tools/prex.h>
      33                 :            : struct _XTrap; // on some older systems this is not declared within Xrender.h
      34                 :            : #include <X11/extensions/Xrender.h>
      35                 :            : #include <tools/postx.h>
      36                 :            : 
      37                 :            : #include <vcl/salgtype.hxx>
      38                 :            : #include <osl/module.h>
      39                 :            : 
      40                 :            : class XRenderPeer
      41                 :            : {
      42                 :            : public:
      43                 :            :     static XRenderPeer& GetInstance();
      44                 :            : 
      45                 :            : private:
      46                 :            :                         XRenderPeer();
      47                 :            :     void                InitRenderLib();
      48                 :            : 
      49                 :            :     Display*            mpDisplay;
      50                 :            :     XRenderPictFormat*  mpStandardFormatA8;
      51                 :            : 
      52                 :            : public:
      53                 :            :     XRenderPictFormat* GetStandardFormatA8() const;
      54                 :            :     XRenderPictFormat* FindStandardFormat(int nFormat) const;
      55                 :            : 
      56                 :            :     // the methods below are thin wrappers for the XRENDER API
      57                 :            :     XRenderPictFormat* FindVisualFormat( Visual* ) const;
      58                 :            :     XRenderPictFormat* FindPictureFormat( unsigned long nMask,
      59                 :            :         const XRenderPictFormat& ) const;
      60                 :            :     Picture     CreatePicture( Drawable, const XRenderPictFormat*,
      61                 :            :                     unsigned long nDrawable, const XRenderPictureAttributes* ) const;
      62                 :            :     void        ChangePicture( Picture, unsigned long nValueMask,
      63                 :            :                     const XRenderPictureAttributes* ) const;
      64                 :            :     void        SetPictureClipRegion( Picture, XLIB_Region ) const;
      65                 :            :     void        CompositePicture( int nOp, Picture aSrc, Picture aMask, Picture aDst,
      66                 :            :                     int nXSrc, int nYSrc, int nXMask, int nYMask,
      67                 :            :                     int nXDst, int nYDst, unsigned nWidth, unsigned nHeight ) const;
      68                 :            :     void        FreePicture( Picture ) const;
      69                 :            : 
      70                 :            :     GlyphSet    CreateGlyphSet() const;
      71                 :            :     void        FreeGlyphSet( GlyphSet ) const;
      72                 :            :     void        AddGlyph( GlyphSet, Glyph nGlyphId, const XGlyphInfo&,
      73                 :            :                     const char* pBuffer, int nBufSize ) const;
      74                 :            :     void        FreeGlyph( GlyphSet, Glyph nGlyphId ) const;
      75                 :            :     void        CompositeString32( Picture aSrc, Picture aDst, GlyphSet,
      76                 :            :                     int nDstX, int nDstY, const unsigned* pText, int nTextLen ) const;
      77                 :            :     void        FillRectangle( int nOp, Picture aDst, const XRenderColor*,
      78                 :            :                                int nX, int nY, unsigned nW, unsigned nH ) const;
      79                 :            :     void        CompositeTrapezoids( int nOp, Picture aSrc, Picture aDst,
      80                 :            :                     const XRenderPictFormat*, int nXSrc, int nYSrc,
      81                 :            :                     const XTrapezoid*, int nCount ) const;
      82                 :            :     void        AddTraps( Picture aDst, int nXOfs, int nYOfs,
      83                 :            :                     const _XTrap*, int nCount ) const;
      84                 :            : };
      85                 :            : 
      86                 :            : //=====================================================================
      87                 :            : 
      88                 :          0 : inline XRenderPictFormat* XRenderPeer::GetStandardFormatA8() const
      89                 :            : {
      90                 :          0 :     return mpStandardFormatA8;
      91                 :            : }
      92                 :            : 
      93                 :          0 : inline XRenderPictFormat* XRenderPeer::FindStandardFormat(int nFormat) const
      94                 :            : {
      95                 :          0 :     return XRenderFindStandardFormat(mpDisplay, nFormat);
      96                 :            : }
      97                 :            : 
      98                 :          0 : inline XRenderPictFormat* XRenderPeer::FindVisualFormat( Visual* pVisual ) const
      99                 :            : {
     100                 :          0 :     return XRenderFindVisualFormat ( mpDisplay, pVisual );
     101                 :            : }
     102                 :            : 
     103                 :          0 : inline XRenderPictFormat* XRenderPeer::FindPictureFormat( unsigned long nFormatMask,
     104                 :            :     const XRenderPictFormat& rFormatAttr ) const
     105                 :            : {
     106                 :          0 :     return XRenderFindFormat( mpDisplay, nFormatMask, &rFormatAttr, 0 );
     107                 :            : }
     108                 :            : 
     109                 :          0 : inline Picture XRenderPeer::CreatePicture( Drawable aDrawable,
     110                 :            :     const XRenderPictFormat* pVisFormat, unsigned long nValueMask,
     111                 :            :     const XRenderPictureAttributes* pRenderAttr ) const
     112                 :            : {
     113                 :            :     return XRenderCreatePicture( mpDisplay, aDrawable, pVisFormat,
     114                 :          0 :                                  nValueMask, pRenderAttr );
     115                 :            : }
     116                 :            : 
     117                 :          0 : inline void XRenderPeer::ChangePicture( Picture aPicture,
     118                 :            :     unsigned long nValueMask, const XRenderPictureAttributes* pRenderAttr ) const
     119                 :            : {
     120                 :          0 :     XRenderChangePicture( mpDisplay, aPicture, nValueMask, pRenderAttr );
     121                 :          0 : }
     122                 :            : 
     123                 :          0 : inline void XRenderPeer::SetPictureClipRegion( Picture aPicture,
     124                 :            :     XLIB_Region aXlibRegion ) const
     125                 :            : {
     126                 :          0 :     XRenderSetPictureClipRegion( mpDisplay, aPicture, aXlibRegion );
     127                 :          0 : }
     128                 :            : 
     129                 :          0 : inline void XRenderPeer::CompositePicture( int nXRenderOp,
     130                 :            :     Picture aSrcPic, Picture aMaskPic, Picture aDstPic,
     131                 :            :     int nSrcX, int nSrcY, int nMaskX, int nMaskY, int nDstX, int nDstY,
     132                 :            :     unsigned nWidth, unsigned nHeight ) const
     133                 :            : {
     134                 :            :     XRenderComposite( mpDisplay, nXRenderOp, aSrcPic, aMaskPic, aDstPic,
     135                 :          0 :                       nSrcX, nSrcY, nMaskX, nMaskY, nDstX, nDstY, nWidth, nHeight );
     136                 :          0 : }
     137                 :            : 
     138                 :          0 : inline void XRenderPeer::FreePicture( Picture aPicture ) const
     139                 :            : {
     140                 :          0 :     XRenderFreePicture( mpDisplay, aPicture );
     141                 :          0 : }
     142                 :            : 
     143                 :            : inline GlyphSet XRenderPeer::CreateGlyphSet() const
     144                 :            : {
     145                 :            :     return XRenderCreateGlyphSet( mpDisplay, mpStandardFormatA8 );
     146                 :            : }
     147                 :            : 
     148                 :            : inline void XRenderPeer::FreeGlyphSet( GlyphSet aGS ) const
     149                 :            : {
     150                 :            :     XRenderFreeGlyphSet( mpDisplay, aGS );
     151                 :            : }
     152                 :            : 
     153                 :            : inline void XRenderPeer::AddGlyph( GlyphSet aGS, Glyph nGlyphId,
     154                 :            :     const XGlyphInfo& rGI, const char* pBuffer, int nBufSize ) const
     155                 :            : {
     156                 :            :     XRenderAddGlyphs( mpDisplay, aGS, &nGlyphId, &rGI, 1,
     157                 :            :                       const_cast<char*>(pBuffer), nBufSize );
     158                 :            : }
     159                 :            : 
     160                 :            : inline void XRenderPeer::FreeGlyph( GlyphSet aGS, Glyph nGlyphId ) const
     161                 :            : {
     162                 :            :     (void)aGS; (void)nGlyphId;
     163                 :            : 
     164                 :            :     // XRenderFreeGlyphs not implemented yet for version<=0.2
     165                 :            :     // #108209# disabled because of crash potential,
     166                 :            :     // the glyph leak is not too bad because they will
     167                 :            :     // be cleaned up when the glyphset is released
     168                 :            : }
     169                 :            : 
     170                 :            : inline void XRenderPeer::CompositeString32( Picture aSrc, Picture aDst,
     171                 :            :     GlyphSet aGlyphSet, int nDstX, int nDstY,
     172                 :            :     const unsigned* pText, int nTextLen ) const
     173                 :            : {
     174                 :            :     XRenderCompositeString32( mpDisplay, PictOpOver, aSrc, aDst, NULL,
     175                 :            :                               aGlyphSet, 0, 0, nDstX, nDstY, pText, nTextLen );
     176                 :            : }
     177                 :            : 
     178                 :          0 : inline void XRenderPeer::FillRectangle( int a, Picture b, const XRenderColor* c,
     179                 :            :     int d, int e, unsigned int f, unsigned int g) const
     180                 :            : {
     181                 :          0 :     XRenderFillRectangle( mpDisplay, a, b, c, d, e, f, g );
     182                 :          0 : }
     183                 :            : 
     184                 :            : 
     185                 :          0 : inline void XRenderPeer::CompositeTrapezoids( int nOp,
     186                 :            :     Picture aSrc, Picture aDst, const XRenderPictFormat* pXRPF,
     187                 :            :     int nXSrc, int nYSrc, const XTrapezoid* pXT, int nCount ) const
     188                 :            : {
     189                 :            :     XRenderCompositeTrapezoids( mpDisplay, nOp, aSrc, aDst, pXRPF,
     190                 :          0 :         nXSrc, nYSrc, pXT, nCount );
     191                 :          0 : }
     192                 :            : 
     193                 :            : inline void XRenderPeer::AddTraps( Picture aDst, int nXOfs, int nYOfs,
     194                 :            :     const _XTrap* pTraps, int nCount ) const
     195                 :            : {
     196                 :            :     XRenderAddTraps( mpDisplay, aDst, nXOfs, nYOfs, pTraps, nCount );
     197                 :            : }
     198                 :            : 
     199                 :            : //=====================================================================
     200                 :            : 
     201                 :          0 : inline XRenderColor GetXRenderColor( const SalColor& rSalColor, double fTransparency = 0.0 )
     202                 :            : {
     203                 :            :     XRenderColor aRetVal;
     204                 :            :     // convert the SalColor
     205                 :          0 :     aRetVal.red   = SALCOLOR_RED(   rSalColor ); aRetVal.red   |= (aRetVal.red   << 8);
     206                 :          0 :     aRetVal.green = SALCOLOR_GREEN( rSalColor ); aRetVal.green |= (aRetVal.green << 8);
     207                 :          0 :     aRetVal.blue  = SALCOLOR_BLUE(  rSalColor ); aRetVal.blue  |= (aRetVal.blue  << 8);
     208                 :            : 
     209                 :            :     // handle transparency
     210                 :          0 :     aRetVal.alpha = 0xFFFF; // default to opaque
     211                 :          0 :     if( fTransparency != 0 )
     212                 :            :     {
     213                 :          0 :         const double fAlpha = 1.0 - fTransparency;
     214                 :          0 :         aRetVal.alpha = static_cast<sal_uInt16>(fAlpha * 0xFFFF + 0.5);
     215                 :            :         // xrender wants pre-multiplied colors
     216                 :          0 :         aRetVal.red   = static_cast<sal_uInt16>(fAlpha * aRetVal.red + 0.5);
     217                 :          0 :         aRetVal.green = static_cast<sal_uInt16>(fAlpha * aRetVal.green + 0.5);
     218                 :          0 :         aRetVal.blue  = static_cast<sal_uInt16>(fAlpha * aRetVal.blue + 0.5);
     219                 :            :     }
     220                 :            : 
     221                 :          0 :     return aRetVal;
     222                 :            : }
     223                 :            : 
     224                 :            : //=====================================================================
     225                 :            : 
     226                 :            : #endif // _SV_XRENDER_PEER_HXX
     227                 :            : 
     228                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10