LCOV - code coverage report
Current view: top level - vcl/inc/unx - salgdi.h (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 14 0.0 %
Date: 2012-08-25 Functions: 0 9 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_SALGDI_H
      30                 :            : #define _SV_SALGDI_H
      31                 :            : 
      32                 :            : #include "tools/fract.hxx"
      33                 :            : 
      34                 :            : #include "vcl/salgtype.hxx"
      35                 :            : #include "vcl/vclenum.hxx"
      36                 :            : 
      37                 :            : #include "salstd.hxx"
      38                 :            : #include "salgdi.hxx"
      39                 :            : #include "sallayout.hxx"
      40                 :            : #include "vclpluginapi.h"
      41                 :            : 
      42                 :            : #include <deque>
      43                 :            : 
      44                 :            : // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      45                 :            : class ImplFontMetricData;
      46                 :            : class FontSelectPattern;
      47                 :            : class SalBitmap;
      48                 :            : class SalColormap;
      49                 :            : class SalDisplay;
      50                 :            : class SalFrame;
      51                 :            : class X11SalVirtualDevice;
      52                 :            : class SalPolyLine;
      53                 :            : class PspSalPrinter;
      54                 :            : class PspSalInfoPrinter;
      55                 :            : class ServerFont;
      56                 :            : class ImplLayoutArgs;
      57                 :            : class ServerFontLayout;
      58                 :            : 
      59                 :            : namespace basegfx {
      60                 :            :     class B2DTrapezoid;
      61                 :            : }
      62                 :            : 
      63                 :            : // -=-= SalGraphicsData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      64                 :            : 
      65                 :            : typedef struct FT_FaceRec_* FT_Face;
      66                 :            : 
      67                 :            : class CairoFontsCache
      68                 :            : {
      69                 :            : public:
      70                 :            :     struct CacheId
      71                 :            :     {
      72                 :            :         FT_Face maFace;
      73                 :            :         const void *mpOptions;
      74                 :            :         bool mbEmbolden;
      75                 :            :         bool mbVerticalMetrics;
      76                 :          0 :         bool operator ==(const CacheId& rOther) const
      77                 :            :         {
      78                 :            :             return maFace == rOther.maFace &&
      79                 :            :                 mpOptions == rOther.mpOptions &&
      80                 :            :                 mbEmbolden == rOther.mbEmbolden &&
      81                 :          0 :                 mbVerticalMetrics == rOther.mbVerticalMetrics;
      82                 :            :         }
      83                 :            :     };
      84                 :            : private:
      85                 :            :     static int mnRefCount;
      86                 :            :     typedef std::deque< std::pair<void *, CacheId> > LRUFonts;
      87                 :            :     static LRUFonts maLRUFonts;
      88                 :            : public:
      89                 :            :     CairoFontsCache();
      90                 :            :     static void  CacheFont(void *pFont, const CacheId &rId);
      91                 :            :     static void* FindCachedFont(const CacheId &rId);
      92                 :            :     ~CairoFontsCache();
      93                 :            : };
      94                 :            : 
      95                 :            : class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics
      96                 :            : {
      97                 :            :     friend class            ServerFontLayout;
      98                 :            : protected:
      99                 :            :     SalFrame*               m_pFrame; // the SalFrame which created this Graphics or NULL
     100                 :            :     X11SalVirtualDevice*    m_pVDev;  // the SalVirtualDevice which created this Graphics or NULL
     101                 :            : 
     102                 :            :     const SalColormap*      m_pColormap;
     103                 :            :     SalColormap    *m_pDeleteColormap;
     104                 :            :     Drawable        hDrawable_;     // use
     105                 :            :     SalX11Screen    m_nXScreen;
     106                 :            :     mutable XRenderPictFormat* m_pXRenderFormat;
     107                 :            :     XID             m_aXRenderPicture;
     108                 :            :     CairoFontsCache m_aCairoFontsCache;
     109                 :            : 
     110                 :            :     XLIB_Region     pPaintRegion_;
     111                 :            :     XLIB_Region     mpClipRegion;
     112                 :            : 
     113                 :            :     GC              pPenGC_;        // Pen attributes
     114                 :            :     SalColor        nPenColor_;
     115                 :            :     Pixel           nPenPixel_;
     116                 :            : 
     117                 :            :     GC              pFontGC_;       // Font attributes
     118                 :            :     ServerFont*             mpServerFont[ MAX_FALLBACK ];
     119                 :            : 
     120                 :            :     SalColor        nTextColor_;
     121                 :            :     Pixel           nTextPixel_;
     122                 :            :     sal_Bool            bFontVertical_;
     123                 :            : 
     124                 :            :     sal_Bool            bDisableGraphite_;
     125                 :            : 
     126                 :            :     GC              pBrushGC_;      // Brush attributes
     127                 :            :     SalColor        nBrushColor_;
     128                 :            :     Pixel           nBrushPixel_;
     129                 :            :     Pixmap          hBrush_;        // Dither
     130                 :            : 
     131                 :            :     GC              pMonoGC_;
     132                 :            :     GC              pCopyGC_;
     133                 :            :     GC              pMaskGC_;
     134                 :            :     GC              pInvertGC_;
     135                 :            :     GC              pInvert50GC_;
     136                 :            :     GC              pStippleGC_;
     137                 :            :     GC              pTrackingGC_;
     138                 :            : 
     139                 :            :     sal_Bool            bWindow_ : 1;       // is Window
     140                 :            :     sal_Bool            bPrinter_ : 1;      // is Printer
     141                 :            :     sal_Bool            bVirDev_ : 1;       // is VirDev
     142                 :            :     sal_Bool            bPenGC_ : 1;        // is Pen GC valid
     143                 :            :     sal_Bool            bFontGC_ : 1;       // is Font GC valid
     144                 :            :     sal_Bool            bBrushGC_ : 1;      // is Brush GC valid
     145                 :            :     sal_Bool            bMonoGC_ : 1;       // is Mono GC valid
     146                 :            :     sal_Bool            bCopyGC_ : 1;       // is Copy GC valid
     147                 :            :     sal_Bool            bInvertGC_ : 1;     // is Invert GC valid
     148                 :            :     sal_Bool            bInvert50GC_ : 1;   // is Invert50 GC valid
     149                 :            :     sal_Bool            bStippleGC_ : 1;    // is Stipple GC valid
     150                 :            :     sal_Bool            bTrackingGC_ : 1;   // is Tracking GC valid
     151                 :            :     bool            bXORMode_ : 1;      // is ROP XOR Mode set
     152                 :            :     sal_Bool            bDitherBrush_ : 1;  // is solid or tile
     153                 :            : 
     154                 :            :     using SalGraphics::SetClipRegion;
     155                 :            :     void            SetClipRegion( GC          pGC,
     156                 :            :                                    XLIB_Region pXReg = NULL ) const;
     157                 :            : 
     158                 :            :     GC              GetTrackingGC();
     159                 :            :     GC              GetInvertGC();
     160                 :            :     GC              GetInvert50GC();
     161                 :            :     GC              CreateGC( Drawable      hDrawable,
     162                 :            :                               unsigned long nMask = GCGraphicsExposures );
     163                 :            :     GC              SelectPen();
     164                 :            :     GC              SelectBrush();
     165                 :            :     void            DrawLines( sal_uIntPtr              nPoints,
     166                 :            :                                const SalPolyLine &rPoints,
     167                 :            :                                GC                 pGC,
     168                 :            :                                bool bClose
     169                 :            :                                );
     170                 :            :     sal_Bool            GetDitherPixmap ( SalColor nSalColor );
     171                 :            : 
     172                 :            :     inline  GC              GetMonoGC( Pixmap hPixmap );
     173                 :            :     inline  GC              GetCopyGC();
     174                 :            :     inline  GC              GetStippleGC();
     175                 :            : 
     176                 :            :     using SalGraphics::DrawBitmap;
     177                 :            :     void            DrawBitmap( const SalTwoRect *pPosAry,
     178                 :            :                                 SalGraphics      *pThis,
     179                 :            :                                 const SalBitmap  &rSalBitmap,
     180                 :            :                                 const SalBitmap  &rTransparentBitmap,
     181                 :            :                                 SalColor          nTransparentColor );
     182                 :            : 
     183                 :            :     GC                      GetFontGC();
     184                 :            :     bool                    setFont( const FontSelectPattern* pEntry, int nFallbackLevel );
     185                 :            : 
     186                 :            :     void                    drawMaskedBitmap( const SalTwoRect* pPosAry,
     187                 :            :                                               const SalBitmap& rSalBitmap,
     188                 :            :                                               const SalBitmap& rTransparentBitmap );
     189                 :            : 
     190                 :            : protected:
     191                 :            :     void                    DrawPrinterString( const SalLayout& );
     192                 :            : 
     193                 :            :     void                    DrawServerFontString( const ServerFontLayout& );
     194                 :            : 
     195                 :            :     void freeResources();
     196                 :            : public:
     197                 :            :                             X11SalGraphics();
     198                 :            :     virtual             ~X11SalGraphics();
     199                 :            : 
     200                 :            :             void            Init( SalFrame *pFrame, Drawable aDrawable, SalX11Screen nXScreen );
     201                 :            :             void            Init( X11SalVirtualDevice *pVirtualDevice, SalColormap* pColormap = NULL, bool bDeleteColormap = false );
     202                 :            :             void            Init( class ImplSalPrinterData *pPrinter );
     203                 :            :             void            DeInit();
     204                 :            : 
     205                 :            :     inline  const SalDisplay*   GetDisplay() const;
     206                 :            :     inline  Display*            GetXDisplay() const;
     207                 :            :     inline  const SalVisual&    GetVisual() const;
     208                 :          0 :     inline  Drawable        GetDrawable() const { return hDrawable_; }
     209                 :            :     void                    SetDrawable( Drawable d, SalX11Screen nXScreen );
     210                 :            :     XID                     GetXRenderPicture();
     211                 :            :     XRenderPictFormat*      GetXRenderFormat() const;
     212                 :          0 :     inline  void            SetXRenderFormat( XRenderPictFormat* pXRenderFormat ) { m_pXRenderFormat = pXRenderFormat; }
     213                 :          0 :     inline  const SalColormap&    GetColormap() const { return *m_pColormap; }
     214                 :            :     using SalGraphics::GetPixel;
     215                 :            :     inline  Pixel           GetPixel( SalColor nSalColor ) const;
     216                 :            : 
     217                 :          0 :     SalX11Screen            GetScreenNumber() const { return m_nXScreen; }
     218                 :            : 
     219                 :            :     // overload all pure virtual methods
     220                 :            :     virtual void            GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY );
     221                 :            :     virtual sal_uInt16          GetBitCount() const;
     222                 :            :     virtual long            GetGraphicsWidth() const;
     223                 :            :     virtual long            GetGraphicsHeight() const;
     224                 :            : 
     225                 :            :     virtual void            ResetClipRegion();
     226                 :            :     virtual bool            setClipRegion( const Region& );
     227                 :            : 
     228                 :            :     virtual void            SetLineColor();
     229                 :            :     virtual void            SetLineColor( SalColor nSalColor );
     230                 :            :     virtual void            SetFillColor();
     231                 :            : 
     232                 :            :     virtual void            SetFillColor( SalColor nSalColor );
     233                 :            : 
     234                 :            :     virtual void            SetXORMode( bool bSet, bool );
     235                 :            : 
     236                 :            :     virtual void            SetROPLineColor( SalROPColor nROPColor );
     237                 :            :     virtual void            SetROPFillColor( SalROPColor nROPColor );
     238                 :            : 
     239                 :            :     virtual void            SetTextColor( SalColor nSalColor );
     240                 :            :     virtual sal_uInt16          SetFont( FontSelectPattern*, int nFallbackLevel );
     241                 :            :     virtual void            GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
     242                 :            :     virtual sal_uLong           GetKernPairs( sal_uLong nMaxPairs, ImplKernPairData* );
     243                 :            :     virtual const ImplFontCharMap* GetImplFontCharMap() const;
     244                 :            :     virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
     245                 :            :     virtual void            GetDevFontList( ImplDevFontList* );
     246                 :            :     virtual void            GetDevFontSubstList( OutputDevice* );
     247                 :            :     virtual bool            AddTempDevFont( ImplDevFontList*, const rtl::OUString& rFileURL, const rtl::OUString& rFontName );
     248                 :            :     virtual sal_Bool            CreateFontSubset( const rtl::OUString& rToFile,
     249                 :            :                                               const PhysicalFontFace*,
     250                 :            :                                               sal_Int32* pGlyphIDs,
     251                 :            :                                               sal_uInt8* pEncoding,
     252                 :            :                                               sal_Int32* pWidths,
     253                 :            :                                               int nGlyphs,
     254                 :            :                                               FontSubsetInfo& rInfo
     255                 :            :                                               );
     256                 :            :     virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded );
     257                 :            :     virtual const void* GetEmbedFontData( const PhysicalFontFace*,
     258                 :            :                                           const sal_Ucs* pUnicodes,
     259                 :            :                                           sal_Int32* pWidths,
     260                 :            :                                           FontSubsetInfo& rInfo,
     261                 :            :                                           long* pDataLen );
     262                 :            :     virtual void            FreeEmbedFontData( const void* pData, long nDataLen );
     263                 :            :     virtual void            GetGlyphWidths( const PhysicalFontFace*,
     264                 :            :                                             bool bVertical,
     265                 :            :                                             Int32Vector& rWidths,
     266                 :            :                                             Ucs2UIntMap& rUnicodeEnc );
     267                 :            :     virtual sal_Bool            GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& );
     268                 :            :     virtual sal_Bool            GetGlyphOutline( sal_GlyphId nIndex, ::basegfx::B2DPolyPolygon& );
     269                 :            :     virtual SalLayout*      GetTextLayout( ImplLayoutArgs&, int nFallbackLevel );
     270                 :            :     virtual void            DrawServerFontLayout( const ServerFontLayout& );
     271                 :            :     virtual bool            supportsOperation( OutDevSupportType ) const;
     272                 :            :     virtual void            drawPixel( long nX, long nY );
     273                 :            :     virtual void            drawPixel( long nX, long nY, SalColor nSalColor );
     274                 :            :     virtual void            drawLine( long nX1, long nY1, long nX2, long nY2 );
     275                 :            :     virtual void            drawRect( long nX, long nY, long nWidth, long nHeight );
     276                 :            :     void                    drawPolyLine( sal_uIntPtr nPoints, const SalPoint* pPtAry, bool bClose );
     277                 :            :     virtual void            drawPolyLine( sal_uIntPtr nPoints, const SalPoint* pPtAry );
     278                 :            :     virtual void            drawPolygon( sal_uIntPtr nPoints, const SalPoint* pPtAry );
     279                 :            :     virtual void            drawPolyPolygon( sal_uInt32 nPoly,
     280                 :            :                                              const sal_uInt32* pPoints,
     281                 :            :                                              PCONSTSALPOINT* pPtAry );
     282                 :            :     virtual bool            drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency );
     283                 :            :     virtual bool            drawPolyLine( const ::basegfx::B2DPolygon&, double fTransparency, const ::basegfx::B2DVector& rLineWidth, basegfx::B2DLineJoin );
     284                 :            :     virtual bool            drawFilledTrapezoids( const ::basegfx::B2DTrapezoid*, int nTrapCount, double fTransparency );
     285                 :            : 
     286                 :            : #if 1 // TODO: remove these obselete methods
     287                 :            :     virtual sal_Bool        drawPolyLineBezier( sal_uIntPtr nPoints,
     288                 :            :                                                 const SalPoint* pPtAry,
     289                 :            :                                                 const sal_uInt8* pFlgAry );
     290                 :            :     virtual sal_Bool        drawPolygonBezier( sal_uIntPtr nPoints,
     291                 :            :                                                const SalPoint* pPtAry,
     292                 :            :                                                const sal_uInt8* pFlgAry );
     293                 :            :     virtual sal_Bool        drawPolyPolygonBezier( sal_uInt32 nPoly,
     294                 :            :                                                    const sal_uInt32* pPoints,
     295                 :            :                                                    const SalPoint* const* pPtAry,
     296                 :            :                                                    const sal_uInt8* const* pFlgAry );
     297                 :            : #endif
     298                 :            : 
     299                 :            :     virtual void            copyArea( long nDestX,
     300                 :            :                                       long nDestY,
     301                 :            :                                       long nSrcX,
     302                 :            :                                       long nSrcY,
     303                 :            :                                       long nSrcWidth,
     304                 :            :                                       long nSrcHeight,
     305                 :            :                                       sal_uInt16 nFlags );
     306                 :            :     virtual void            copyBits( const SalTwoRect* pPosAry,
     307                 :            :                                       SalGraphics* pSrcGraphics );
     308                 :            :     virtual void            drawBitmap( const SalTwoRect* pPosAry,
     309                 :            :                                         const SalBitmap& rSalBitmap );
     310                 :            :     virtual void            drawBitmap( const SalTwoRect* pPosAry,
     311                 :            :                                         const SalBitmap& rSalBitmap,
     312                 :            :                                         SalColor nTransparentColor );
     313                 :            :     virtual void            drawBitmap( const SalTwoRect* pPosAry,
     314                 :            :                                         const SalBitmap& rSalBitmap,
     315                 :            :                                         const SalBitmap& rMaskBitmap );
     316                 :            :     virtual void            drawMask( const SalTwoRect* pPosAry,
     317                 :            :                                       const SalBitmap& rSalBitmap,
     318                 :            :                                       SalColor nMaskColor );
     319                 :            :     virtual SalBitmap*      getBitmap( long nX, long nY, long nWidth, long nHeight );
     320                 :            :     virtual SalColor        getPixel( long nX, long nY );
     321                 :            :     virtual void            invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags );
     322                 :            :     virtual void            invert( sal_uIntPtr nPoints, const SalPoint* pPtAry, SalInvert nFlags );
     323                 :            : 
     324                 :            :     virtual sal_Bool            drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uIntPtr nSize );
     325                 :            : 
     326                 :            :     virtual bool            drawAlphaBitmap( const SalTwoRect&,
     327                 :            :                                              const SalBitmap& rSourceBitmap,
     328                 :            :                                              const SalBitmap& rAlphaBitmap );
     329                 :            : 
     330                 :            :     virtual bool            drawAlphaRect( long nX, long nY, long nWidth,
     331                 :            :                                            long nHeight, sal_uInt8 nTransparency );
     332                 :            : 
     333                 :            :     virtual SystemGraphicsData GetGraphicsData() const;
     334                 :            :     virtual SystemFontData     GetSysFontData( int nFallbacklevel ) const;
     335                 :            : 
     336                 :            :     /*  use to handle GraphicsExpose/NoExpose after XCopyArea & friends
     337                 :            :      *  if pFrame is not NULL, corresponding Paint events are generated
     338                 :            :      *  and dispatched to pFrame
     339                 :            :      *
     340                 :            :      *  it is imperative to eat up graphics exposes even in case you don't need
     341                 :            :      *  them because the next one using XCopyArea can depend on them
     342                 :            :      */
     343                 :            :     void YieldGraphicsExpose();
     344                 :            : 
     345                 :            :     // do XCopyArea or XGet/PutImage depending on screen numbers
     346                 :            :     // signature is like XCopyArea with screen numbers added
     347                 :            :     static void CopyScreenArea( Display* pDisplay,
     348                 :            :                                 Drawable aSrc, SalX11Screen nXScreenSrc, int nSrcDepth,
     349                 :            :                                 Drawable aDest, SalX11Screen nXScreenDest, int nDestDepth,
     350                 :            :                                 GC aDestGC,
     351                 :            :                                 int src_x, int src_y,
     352                 :            :                                 unsigned int w, unsigned int h,
     353                 :            :                                 int dest_x, int dest_y );
     354                 :            :     static void releaseGlyphPeer();
     355                 :            : };
     356                 :            : 
     357                 :            : 
     358                 :          0 : inline const SalDisplay *X11SalGraphics::GetDisplay() const
     359                 :          0 : { return GetColormap().GetDisplay(); }
     360                 :            : 
     361                 :          0 : inline const SalVisual& X11SalGraphics::GetVisual() const
     362                 :          0 : { return GetColormap().GetVisual(); }
     363                 :            : 
     364                 :          0 : inline Display *X11SalGraphics::GetXDisplay() const
     365                 :          0 : { return GetColormap().GetXDisplay(); }
     366                 :            : 
     367                 :          0 : inline Pixel X11SalGraphics::GetPixel( SalColor nSalColor ) const
     368                 :          0 : { return GetColormap().GetPixel( nSalColor ); }
     369                 :            : 
     370                 :            : 
     371                 :            : // -=-= Shortcuts =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     372                 :            : 
     373                 :            : #ifdef DBG_UTIL
     374                 :            : #define stderr0( s )            fprintf( stderr, s )
     375                 :            : #else
     376                 :            : #define stderr0( s )            ;
     377                 :            : #endif
     378                 :            : 
     379                 :            : #endif // _SV_SALGDI_H
     380                 :            : 
     381                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10