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

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

Generated by: LCOV version 1.10