LCOV - code coverage report
Current view: top level - vcl/unx/generic/gdi - salgdi.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 583 0.0 %
Date: 2012-08-25 Functions: 0 48 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                 :            : 
      30                 :            : #include "tools/debug.hxx"
      31                 :            : 
      32                 :            : #include "basegfx/polygon/b2dpolygon.hxx"
      33                 :            : #include "basegfx/polygon/b2dpolypolygon.hxx"
      34                 :            : #include "basegfx/polygon/b2dpolypolygontools.hxx"
      35                 :            : #include "basegfx/polygon/b2dpolygontools.hxx"
      36                 :            : #include "basegfx/polygon/b2dpolygonclipper.hxx"
      37                 :            : #include "basegfx/polygon/b2dlinegeometry.hxx"
      38                 :            : #include "basegfx/matrix/b2dhommatrix.hxx"
      39                 :            : #include "basegfx/matrix/b2dhommatrixtools.hxx"
      40                 :            : #include "basegfx/polygon/b2dpolypolygoncutter.hxx"
      41                 :            : #include "basegfx/polygon/b2dtrapezoid.hxx"
      42                 :            : 
      43                 :            : #include "vcl/jobdata.hxx"
      44                 :            : 
      45                 :            : #include "unx/Xproto.h"
      46                 :            : #include "unx/salunx.h"
      47                 :            : #include "unx/saldata.hxx"
      48                 :            : #include "unx/saldisp.hxx"
      49                 :            : #include "unx/salgdi.h"
      50                 :            : #include "unx/salframe.h"
      51                 :            : #include "unx/salvd.h"
      52                 :            : #include <unx/x11/xlimits.hxx>
      53                 :            : 
      54                 :            : #include "generic/printergfx.hxx"
      55                 :            : #include "xrender_peer.hxx"
      56                 :            : #include "region.h"
      57                 :            : 
      58                 :            : #include <vector>
      59                 :            : #include <queue>
      60                 :            : #include <set>
      61                 :            : 
      62                 :            : // -=-= SalPolyLine =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      63                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      64                 :            : #define STATIC_POINTS 64
      65                 :            : 
      66                 :            : class SalPolyLine
      67                 :            : {
      68                 :            :             XPoint              Points_[STATIC_POINTS];
      69                 :            :             XPoint             *pFirst_;
      70                 :            : public:
      71                 :            :     inline                      SalPolyLine( sal_uLong nPoints );
      72                 :            :     inline                      SalPolyLine( sal_uLong nPoints, const SalPoint *p );
      73                 :            :     inline                      ~SalPolyLine();
      74                 :          0 :     inline  XPoint             &operator [] ( sal_uLong n ) const
      75                 :          0 :                                 { return pFirst_[n]; }
      76                 :            : };
      77                 :            : 
      78                 :            : inline SalPolyLine::SalPolyLine( sal_uLong nPoints )
      79                 :            :     : pFirst_( nPoints+1 > STATIC_POINTS ? new XPoint[nPoints+1] : Points_ )
      80                 :            : {}
      81                 :            : 
      82                 :          0 : inline SalPolyLine::SalPolyLine( sal_uLong nPoints, const SalPoint *p )
      83                 :          0 :     : pFirst_( nPoints+1 > STATIC_POINTS ? new XPoint[nPoints+1] : Points_ )
      84                 :            : {
      85                 :          0 :     for( sal_uLong i = 0; i < nPoints; i++ )
      86                 :            :     {
      87                 :          0 :         pFirst_[i].x = (short)p[i].mnX;
      88                 :          0 :         pFirst_[i].y = (short)p[i].mnY;
      89                 :            :     }
      90                 :          0 :     pFirst_[nPoints] = pFirst_[0]; // close polyline
      91                 :          0 : }
      92                 :            : 
      93                 :          0 : inline SalPolyLine::~SalPolyLine()
      94                 :          0 : { if( pFirst_ != Points_ ) delete [] pFirst_; }
      95                 :            : 
      96                 :            : #undef STATIC_POINTS
      97                 :            : // -=-= X11SalGraphics =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      98                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      99                 :          0 : X11SalGraphics::X11SalGraphics()
     100                 :          0 :     : m_nXScreen( 0 )
     101                 :            : {
     102                 :          0 :     m_pFrame            = NULL;
     103                 :          0 :     m_pVDev             = NULL;
     104                 :          0 :     m_pDeleteColormap   = NULL;
     105                 :          0 :     hDrawable_          = None;
     106                 :          0 :     m_aXRenderPicture    = 0;
     107                 :          0 :     m_pXRenderFormat     = NULL;
     108                 :            : 
     109                 :          0 :     mpClipRegion            = NULL;
     110                 :          0 :     pPaintRegion_       = NULL;
     111                 :            : 
     112                 :          0 :     pPenGC_         = NULL;
     113                 :          0 :     nPenPixel_          = 0;
     114                 :          0 :     nPenColor_          = MAKE_SALCOLOR( 0x00, 0x00, 0x00 ); // Black
     115                 :            : 
     116                 :          0 :     pFontGC_            = NULL;
     117                 :          0 :     for( int i = 0; i < MAX_FALLBACK; ++i )
     118                 :          0 :         mpServerFont[i] = NULL;
     119                 :            : 
     120                 :          0 :     nTextPixel_         = 0;
     121                 :          0 :     nTextColor_         = MAKE_SALCOLOR( 0x00, 0x00, 0x00 ); // Black
     122                 :            : 
     123                 :            : #ifdef ENABLE_GRAPHITE
     124                 :            :     // check if graphite fonts have been disabled
     125                 :          0 :     static const char* pDisableGraphiteStr = getenv( "SAL_DISABLE_GRAPHITE" );
     126                 :          0 :     bDisableGraphite_       = pDisableGraphiteStr ? (pDisableGraphiteStr[0]!='0') : sal_False;
     127                 :            : #endif
     128                 :            : 
     129                 :          0 :     pBrushGC_           = NULL;
     130                 :          0 :     nBrushPixel_            = 0;
     131                 :          0 :     nBrushColor_        = MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF ); // White
     132                 :          0 :     hBrush_             = None;
     133                 :            : 
     134                 :          0 :     pMonoGC_            = NULL;
     135                 :          0 :     pCopyGC_            = NULL;
     136                 :          0 :     pMaskGC_            = NULL;
     137                 :          0 :     pInvertGC_          = NULL;
     138                 :          0 :     pInvert50GC_        = NULL;
     139                 :          0 :     pStippleGC_         = NULL;
     140                 :          0 :     pTrackingGC_        = NULL;
     141                 :            : 
     142                 :          0 :     bWindow_            = sal_False;
     143                 :          0 :     bPrinter_           = sal_False;
     144                 :          0 :     bVirDev_            = sal_False;
     145                 :          0 :     bPenGC_         = sal_False;
     146                 :          0 :     bFontGC_            = sal_False;
     147                 :          0 :     bBrushGC_           = sal_False;
     148                 :          0 :     bMonoGC_            = sal_False;
     149                 :          0 :     bCopyGC_            = sal_False;
     150                 :          0 :     bInvertGC_          = sal_False;
     151                 :          0 :     bInvert50GC_        = sal_False;
     152                 :          0 :     bStippleGC_         = sal_False;
     153                 :          0 :     bTrackingGC_        = sal_False;
     154                 :          0 :     bXORMode_           = sal_False;
     155                 :          0 :     bDitherBrush_       = sal_False;
     156                 :          0 : }
     157                 :            : 
     158                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     159                 :          0 : X11SalGraphics::~X11SalGraphics()
     160                 :            : {
     161                 :          0 :     ReleaseFonts();
     162                 :          0 :     freeResources();
     163                 :          0 : }
     164                 :            : 
     165                 :            : // -=-= SalGraphics / X11SalGraphics =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     166                 :            : 
     167                 :          0 : void X11SalGraphics::freeResources()
     168                 :            : {
     169                 :          0 :     Display *pDisplay = GetXDisplay();
     170                 :            : 
     171                 :            :     DBG_ASSERT( !pPaintRegion_, "pPaintRegion_" );
     172                 :          0 :     if( mpClipRegion ) XDestroyRegion( mpClipRegion ), mpClipRegion = None;
     173                 :            : 
     174                 :          0 :     if( hBrush_ )       XFreePixmap( pDisplay, hBrush_ ), hBrush_ = None;
     175                 :          0 :     if( pPenGC_ )       XFreeGC( pDisplay, pPenGC_ ), pPenGC_ = None;
     176                 :          0 :     if( pFontGC_ )      XFreeGC( pDisplay, pFontGC_ ), pFontGC_ = None;
     177                 :          0 :     if( pBrushGC_ )     XFreeGC( pDisplay, pBrushGC_ ), pBrushGC_ = None;
     178                 :          0 :     if( pMonoGC_ )      XFreeGC( pDisplay, pMonoGC_ ), pMonoGC_ = None;
     179                 :          0 :     if( pCopyGC_ )      XFreeGC( pDisplay, pCopyGC_ ), pCopyGC_ = None;
     180                 :          0 :     if( pMaskGC_ )      XFreeGC( pDisplay, pMaskGC_ ), pMaskGC_ = None;
     181                 :          0 :     if( pInvertGC_ )    XFreeGC( pDisplay, pInvertGC_ ), pInvertGC_ = None;
     182                 :          0 :     if( pInvert50GC_ )  XFreeGC( pDisplay, pInvert50GC_ ), pInvert50GC_ = None;
     183                 :          0 :     if( pStippleGC_ )   XFreeGC( pDisplay, pStippleGC_ ), pStippleGC_ = None;
     184                 :          0 :     if( pTrackingGC_ )  XFreeGC( pDisplay, pTrackingGC_ ), pTrackingGC_ = None;
     185                 :          0 :     if( m_pDeleteColormap )
     186                 :          0 :         delete m_pDeleteColormap, m_pColormap = m_pDeleteColormap = NULL;
     187                 :            : 
     188                 :          0 :     if( m_aXRenderPicture )
     189                 :          0 :         XRenderPeer::GetInstance().FreePicture( m_aXRenderPicture ), m_aXRenderPicture = 0;
     190                 :            : 
     191                 :          0 :     bPenGC_ = bFontGC_ = bBrushGC_ = bMonoGC_ = bCopyGC_ = bInvertGC_ = bInvert50GC_ = bStippleGC_ = bTrackingGC_ = false;
     192                 :          0 : }
     193                 :            : 
     194                 :          0 : void X11SalGraphics::SetDrawable( Drawable aDrawable, SalX11Screen nXScreen )
     195                 :            : {
     196                 :            :     // shortcut if nothing changed
     197                 :          0 :     if( hDrawable_ == aDrawable )
     198                 :          0 :         return;
     199                 :            : 
     200                 :            :     // free screen specific resources if needed
     201                 :          0 :     if( nXScreen != m_nXScreen )
     202                 :            :     {
     203                 :          0 :         freeResources();
     204                 :          0 :         m_pColormap = &GetGenericData()->GetSalDisplay()->GetColormap( nXScreen );
     205                 :          0 :         m_nXScreen = nXScreen;
     206                 :            :     }
     207                 :            : 
     208                 :          0 :     hDrawable_ = aDrawable;
     209                 :          0 :     SetXRenderFormat( NULL );
     210                 :          0 :     if( m_aXRenderPicture )
     211                 :            :     {
     212                 :          0 :         XRenderPeer::GetInstance().FreePicture( m_aXRenderPicture );
     213                 :          0 :         m_aXRenderPicture = 0;
     214                 :            :     }
     215                 :            : 
     216                 :          0 :     if( hDrawable_ )
     217                 :            :     {
     218                 :          0 :         nPenPixel_      = GetPixel( nPenColor_ );
     219                 :          0 :         nTextPixel_     = GetPixel( nTextColor_ );
     220                 :          0 :         nBrushPixel_    = GetPixel( nBrushColor_ );
     221                 :            :     }
     222                 :            : }
     223                 :            : 
     224                 :          0 : void X11SalGraphics::Init( SalFrame *pFrame, Drawable aTarget,
     225                 :            :                            SalX11Screen nXScreen )
     226                 :            : {
     227                 :          0 :     m_pColormap = &GetGenericData()->GetSalDisplay()->GetColormap(nXScreen);
     228                 :          0 :     m_nXScreen  = nXScreen;
     229                 :          0 :     SetDrawable( aTarget, nXScreen );
     230                 :            : 
     231                 :          0 :     bWindow_    = sal_True;
     232                 :          0 :     m_pFrame    = pFrame;
     233                 :          0 :     m_pVDev     = NULL;
     234                 :          0 : }
     235                 :            : 
     236                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     237                 :          0 : void X11SalGraphics::DeInit()
     238                 :            : {
     239                 :          0 :     SetDrawable( None, m_nXScreen );
     240                 :          0 : }
     241                 :            : 
     242                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     243                 :          0 : void X11SalGraphics::SetClipRegion( GC pGC, XLIB_Region pXReg ) const
     244                 :            : {
     245                 :          0 :     Display *pDisplay = GetXDisplay();
     246                 :            : 
     247                 :          0 :     int n = 0;
     248                 :            :     XLIB_Region Regions[3];
     249                 :            : 
     250                 :          0 :     if( mpClipRegion )
     251                 :          0 :         Regions[n++] = mpClipRegion;
     252                 :            : 
     253                 :          0 :     if( pXReg && !XEmptyRegion( pXReg ) )
     254                 :          0 :         Regions[n++] = pXReg;
     255                 :            : 
     256                 :          0 :     if( 0 == n )
     257                 :          0 :         XSetClipMask( pDisplay, pGC, None );
     258                 :          0 :     else if( 1 == n )
     259                 :          0 :         XSetRegion( pDisplay, pGC, Regions[0] );
     260                 :            :     else
     261                 :            :     {
     262                 :          0 :         XLIB_Region pTmpRegion = XCreateRegion();
     263                 :          0 :         XIntersectRegion( Regions[0], Regions[1], pTmpRegion );
     264                 :            : 
     265                 :          0 :         XSetRegion( pDisplay, pGC, pTmpRegion );
     266                 :          0 :         XDestroyRegion( pTmpRegion );
     267                 :            :     }
     268                 :          0 : }
     269                 :            : 
     270                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     271                 :          0 : GC X11SalGraphics::SelectPen()
     272                 :            : {
     273                 :          0 :     Display *pDisplay = GetXDisplay();
     274                 :            : 
     275                 :          0 :     if( !pPenGC_ )
     276                 :            :     {
     277                 :            :         XGCValues values;
     278                 :          0 :         values.subwindow_mode       = ClipByChildren;
     279                 :          0 :         values.fill_rule            = EvenOddRule;      // Pict import/ Gradient
     280                 :          0 :         values.graphics_exposures   = False;
     281                 :            : 
     282                 :            :         pPenGC_ = XCreateGC( pDisplay, hDrawable_,
     283                 :            :                              GCSubwindowMode | GCFillRule | GCGraphicsExposures,
     284                 :          0 :                              &values );
     285                 :            :     }
     286                 :            : 
     287                 :          0 :     if( !bPenGC_ )
     288                 :            :     {
     289                 :          0 :         if( nPenColor_ != SALCOLOR_NONE )
     290                 :          0 :             XSetForeground( pDisplay, pPenGC_, nPenPixel_ );
     291                 :          0 :         XSetFunction  ( pDisplay, pPenGC_, bXORMode_ ? GXxor : GXcopy );
     292                 :          0 :         SetClipRegion( pPenGC_ );
     293                 :          0 :         bPenGC_ = sal_True;
     294                 :            :     }
     295                 :            : 
     296                 :          0 :     return pPenGC_;
     297                 :            : }
     298                 :            : 
     299                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     300                 :          0 : GC X11SalGraphics::SelectBrush()
     301                 :            : {
     302                 :          0 :     Display *pDisplay = GetXDisplay();
     303                 :            : 
     304                 :            :     DBG_ASSERT( nBrushColor_ != SALCOLOR_NONE, "Brush Transparent" );
     305                 :            : 
     306                 :          0 :     if( !pBrushGC_ )
     307                 :            :     {
     308                 :            :         XGCValues values;
     309                 :          0 :         values.subwindow_mode       = ClipByChildren;
     310                 :          0 :         values.fill_rule            = EvenOddRule;      // Pict import/ Gradient
     311                 :          0 :         values.graphics_exposures   = False;
     312                 :            : 
     313                 :            :         pBrushGC_ = XCreateGC( pDisplay, hDrawable_,
     314                 :            :                                GCSubwindowMode | GCFillRule | GCGraphicsExposures,
     315                 :          0 :                                &values );
     316                 :            :     }
     317                 :            : 
     318                 :          0 :     if( !bBrushGC_ )
     319                 :            :     {
     320                 :          0 :         if( !bDitherBrush_ )
     321                 :            :         {
     322                 :          0 :             XSetFillStyle ( pDisplay, pBrushGC_, FillSolid );
     323                 :          0 :             XSetForeground( pDisplay, pBrushGC_, nBrushPixel_ );
     324                 :          0 :             if( bPrinter_ )
     325                 :          0 :                 XSetTile( pDisplay, pBrushGC_, None );
     326                 :            :         }
     327                 :            :         else
     328                 :            :         {
     329                 :            :             // Bug in Sun Solaris 2.5.1, XFillPolygon doesn't allways reflect
     330                 :            :             // changes of the tile. PROPERTY_BUG_Tile doesn't fix this !
     331                 :          0 :             if (GetDisplay()->GetProperties() & PROPERTY_BUG_FillPolygon_Tile)
     332                 :          0 :                 XSetFillStyle ( pDisplay, pBrushGC_, FillSolid );
     333                 :            : 
     334                 :          0 :             XSetFillStyle ( pDisplay, pBrushGC_, FillTiled );
     335                 :          0 :             XSetTile      ( pDisplay, pBrushGC_, hBrush_ );
     336                 :            :         }
     337                 :          0 :         XSetFunction  ( pDisplay, pBrushGC_, bXORMode_ ? GXxor : GXcopy );
     338                 :          0 :         SetClipRegion( pBrushGC_ );
     339                 :            : 
     340                 :          0 :         bBrushGC_ = sal_True;
     341                 :            :     }
     342                 :            : 
     343                 :          0 :     return pBrushGC_;
     344                 :            : }
     345                 :            : 
     346                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     347                 :          0 : GC X11SalGraphics::GetTrackingGC()
     348                 :            : {
     349                 :          0 :     const char    dash_list[2] = {2, 2};
     350                 :            : 
     351                 :          0 :     if( !pTrackingGC_ )
     352                 :            :     {
     353                 :            :         XGCValues     values;
     354                 :            : 
     355                 :          0 :         values.graphics_exposures   = False;
     356                 :          0 :         values.foreground           = m_pColormap->GetBlackPixel()
     357                 :          0 :                                       ^ m_pColormap->GetWhitePixel();
     358                 :          0 :         values.function             = GXxor;
     359                 :          0 :         values.line_width           = 1;
     360                 :          0 :         values.line_style           = LineOnOffDash;
     361                 :            : 
     362                 :            :         pTrackingGC_ = XCreateGC( GetXDisplay(), GetDrawable(),
     363                 :            :                                   GCGraphicsExposures | GCForeground | GCFunction
     364                 :            :                                   | GCLineWidth | GCLineStyle,
     365                 :          0 :                                   &values );
     366                 :          0 :         XSetDashes( GetXDisplay(), pTrackingGC_, 0, dash_list, 2 );
     367                 :            :     }
     368                 :            : 
     369                 :          0 :     if( !bTrackingGC_ )
     370                 :            :     {
     371                 :          0 :         SetClipRegion( pTrackingGC_ );
     372                 :          0 :         bTrackingGC_ = sal_True;
     373                 :            :     }
     374                 :            : 
     375                 :          0 :     return pTrackingGC_;
     376                 :            : }
     377                 :            : 
     378                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     379                 :          0 : void X11SalGraphics::DrawLines( sal_uLong              nPoints,
     380                 :            :                                 const SalPolyLine &rPoints,
     381                 :            :                                 GC                 pGC,
     382                 :            :                                 bool               bClose
     383                 :            :                                 )
     384                 :            : {
     385                 :            :     // errechne wie viele Linien XWindow auf einmal zeichnen kann
     386                 :          0 :     sal_uLong nMaxLines = (GetDisplay()->GetMaxRequestSize() - sizeof(xPolyPointReq))
     387                 :          0 :                       / sizeof(xPoint);
     388                 :          0 :     if( nMaxLines > nPoints ) nMaxLines = nPoints;
     389                 :            : 
     390                 :            :     // gebe alle Linien aus, die XWindows zeichnen kann.
     391                 :            :     sal_uLong n;
     392                 :          0 :     for( n = 0; nPoints - n > nMaxLines; n += nMaxLines - 1 )
     393                 :            :         XDrawLines( GetXDisplay(),
     394                 :            :                     GetDrawable(),
     395                 :            :                     pGC,
     396                 :          0 :                     &rPoints[n],
     397                 :            :                     nMaxLines,
     398                 :          0 :                     CoordModeOrigin );
     399                 :            : 
     400                 :          0 :     if( n < nPoints )
     401                 :            :         XDrawLines( GetXDisplay(),
     402                 :            :                     GetDrawable(),
     403                 :            :                     pGC,
     404                 :          0 :                     &rPoints[n],
     405                 :            :                     nPoints - n,
     406                 :          0 :                     CoordModeOrigin );
     407                 :          0 :     if( bClose )
     408                 :            :     {
     409                 :          0 :         if( rPoints[nPoints-1].x != rPoints[0].x || rPoints[nPoints-1].y != rPoints[0].y )
     410                 :          0 :             drawLine( rPoints[nPoints-1].x, rPoints[nPoints-1].y, rPoints[0].x, rPoints[0].y );
     411                 :            :     }
     412                 :          0 : }
     413                 :            : 
     414                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     415                 :            : // Dithern: Calculate a dither-pixmap and make a brush of it
     416                 :            : #define P_DELTA         51
     417                 :            : #define DMAP( v, m )    ((v % P_DELTA) > m ? (v / P_DELTA) + 1 : (v / P_DELTA))
     418                 :            : 
     419                 :          0 : BOOL X11SalGraphics::GetDitherPixmap( SalColor nSalColor )
     420                 :            : {
     421                 :            :     static const short nOrdDither8Bit[ 8 ][ 8 ] =
     422                 :            :     {
     423                 :            :         { 0, 38,  9, 48,  2, 40, 12, 50},
     424                 :            :         {25, 12, 35, 22, 28, 15, 37, 24},
     425                 :            :         { 6, 44,  3, 41,  8, 47,  5, 44},
     426                 :            :         {32, 19, 28, 16, 34, 21, 31, 18},
     427                 :            :         { 1, 40, 11, 49,  0, 39, 10, 48},
     428                 :            :         {27, 14, 36, 24, 26, 13, 36, 23},
     429                 :            :         { 8, 46,  4, 43,  7, 45,  4, 42},
     430                 :            :         {33, 20, 30, 17, 32, 20, 29, 16}
     431                 :            :     };
     432                 :            : 
     433                 :            :     // test for correct depth (8bit)
     434                 :          0 :     if( GetColormap().GetVisual().GetDepth() != 8 )
     435                 :          0 :         return sal_False;
     436                 :            : 
     437                 :            :     char    pBits[64];
     438                 :          0 :     char   *pBitsPtr = pBits;
     439                 :            : 
     440                 :            :     // Set the pallette-entries for the dithering tile
     441                 :          0 :     sal_uInt8 nSalColorRed   = SALCOLOR_RED   ( nSalColor );
     442                 :          0 :     sal_uInt8 nSalColorGreen = SALCOLOR_GREEN ( nSalColor );
     443                 :          0 :     sal_uInt8 nSalColorBlue  = SALCOLOR_BLUE  ( nSalColor );
     444                 :            : 
     445                 :          0 :     for( int nY = 0; nY < 8; nY++ )
     446                 :            :     {
     447                 :          0 :         for( int nX = 0; nX < 8; nX++ )
     448                 :            :         {
     449                 :          0 :             short nMagic = nOrdDither8Bit[nY][nX];
     450                 :          0 :             sal_uInt8 nR   = P_DELTA * DMAP( nSalColorRed,   nMagic );
     451                 :          0 :             sal_uInt8 nG   = P_DELTA * DMAP( nSalColorGreen, nMagic );
     452                 :          0 :             sal_uInt8 nB   = P_DELTA * DMAP( nSalColorBlue,  nMagic );
     453                 :            : 
     454                 :          0 :             *pBitsPtr++ = GetColormap().GetPixel( MAKE_SALCOLOR( nR, nG, nB ) );
     455                 :            :         }
     456                 :            :     }
     457                 :            : 
     458                 :            :     // create the tile as ximage and an according pixmap -> caching
     459                 :            :     XImage *pImage = XCreateImage( GetXDisplay(),
     460                 :          0 :                                    GetColormap().GetXVisual(),
     461                 :            :                                    8,
     462                 :            :                                    ZPixmap,
     463                 :            :                                    0,               // offset
     464                 :            :                                    pBits,           // data
     465                 :            :                                    8, 8,            // width & height
     466                 :            :                                    8,               // bitmap_pad
     467                 :          0 :                                    0 );             // (default) bytes_per_line
     468                 :            : 
     469                 :          0 :     if ( GetDisplay()->GetProperties() & PROPERTY_BUG_Tile )
     470                 :            :     {
     471                 :          0 :         if (hBrush_)
     472                 :          0 :             XFreePixmap (GetXDisplay(), hBrush_);
     473                 :          0 :         hBrush_ = limitXCreatePixmap( GetXDisplay(), GetDrawable(), 8, 8, 8 );
     474                 :            :     }
     475                 :            :     else
     476                 :          0 :     if( !hBrush_ )
     477                 :          0 :         hBrush_ = limitXCreatePixmap( GetXDisplay(), GetDrawable(), 8, 8, 8 );
     478                 :            : 
     479                 :            :     // put the ximage to the pixmap
     480                 :            :     XPutImage( GetXDisplay(),
     481                 :            :                hBrush_,
     482                 :            :                GetDisplay()->GetCopyGC( m_nXScreen ),
     483                 :            :                pImage,
     484                 :            :                0, 0,                        // Source
     485                 :            :                0, 0,                        // Destination
     486                 :          0 :                8, 8 );                      // width & height
     487                 :            : 
     488                 :            :     // destroy image-frame but not palette-data
     489                 :          0 :     pImage->data = NULL;
     490                 :          0 :     XDestroyImage( pImage );
     491                 :            : 
     492                 :          0 :     return sal_True;
     493                 :            : }
     494                 :            : 
     495                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     496                 :          0 : void X11SalGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) // const
     497                 :            : {
     498                 :          0 :     const SalDisplay *pDisplay = GetDisplay();
     499                 :          0 :     if (!pDisplay)
     500                 :            :     {
     501                 :            :         OSL_TRACE("Null display");
     502                 :          0 :         rDPIX = rDPIY = 96;
     503                 :          0 :         return;
     504                 :            :     }
     505                 :            : 
     506                 :          0 :     rDPIX = pDisplay->GetResolution().A();
     507                 :          0 :     rDPIY = pDisplay->GetResolution().B();
     508                 :          0 :     if( !pDisplay->GetExactResolution() && rDPIY < 96 )
     509                 :            :     {
     510                 :          0 :         rDPIX = Divide( rDPIX * 96, rDPIY );
     511                 :          0 :             rDPIY = 96;
     512                 :            :     }
     513                 :          0 :     else if ( rDPIY > 200 )
     514                 :            :     {
     515                 :          0 :         rDPIX = Divide( rDPIX * 200, rDPIY );
     516                 :          0 :         rDPIY = 200;
     517                 :            :     }
     518                 :            : 
     519                 :            :     // #i12705# equalize x- and y-resolution if they are close enough
     520                 :          0 :     if( rDPIX != rDPIY )
     521                 :            :     {
     522                 :            :         // different x- and y- resolutions are usually artifacts of
     523                 :            :         // a wrongly calculated screen size.
     524                 :            : #ifdef DEBUG
     525                 :            :         printf("Forcing Resolution from %" SAL_PRIdINT32 "x%" SAL_PRIdINT32 " to %" SAL_PRIdINT32 "x%" SAL_PRIdINT32 "\n",
     526                 :            :                 rDPIX,rDPIY,rDPIY,rDPIY);
     527                 :            : #endif
     528                 :          0 :         rDPIX = rDPIY; // y-resolution is more trustworthy
     529                 :            :     }
     530                 :            : }
     531                 :            : 
     532                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     533                 :          0 : sal_uInt16 X11SalGraphics::GetBitCount() const
     534                 :            : {
     535                 :          0 :     return GetVisual().GetDepth();
     536                 :            : }
     537                 :            : 
     538                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     539                 :          0 : long X11SalGraphics::GetGraphicsWidth() const
     540                 :            : {
     541                 :          0 :     if( m_pFrame )
     542                 :          0 :         return m_pFrame->maGeometry.nWidth;
     543                 :          0 :     else if( m_pVDev )
     544                 :          0 :         return m_pVDev->GetWidth();
     545                 :            :     else
     546                 :          0 :         return 0;
     547                 :            : }
     548                 :            : 
     549                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     550                 :          0 : long X11SalGraphics::GetGraphicsHeight() const
     551                 :            : {
     552                 :          0 :     if( m_pFrame )
     553                 :          0 :         return m_pFrame->maGeometry.nHeight;
     554                 :          0 :     else if( m_pVDev )
     555                 :          0 :         return m_pVDev->GetHeight();
     556                 :            :     else
     557                 :          0 :         return 0;
     558                 :            : }
     559                 :            : 
     560                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     561                 :          0 : void X11SalGraphics::ResetClipRegion()
     562                 :            : {
     563                 :          0 :     if( mpClipRegion )
     564                 :            :     {
     565                 :          0 :         bPenGC_         = sal_False;
     566                 :          0 :         bFontGC_        = sal_False;
     567                 :          0 :         bBrushGC_       = sal_False;
     568                 :          0 :         bMonoGC_        = sal_False;
     569                 :          0 :         bCopyGC_        = sal_False;
     570                 :          0 :         bInvertGC_      = sal_False;
     571                 :          0 :         bInvert50GC_    = sal_False;
     572                 :          0 :         bStippleGC_     = sal_False;
     573                 :          0 :         bTrackingGC_    = sal_False;
     574                 :            : 
     575                 :          0 :         XDestroyRegion( mpClipRegion );
     576                 :          0 :         mpClipRegion    = NULL;
     577                 :            :     }
     578                 :          0 : }
     579                 :            : 
     580                 :          0 : bool X11SalGraphics::setClipRegion( const Region& i_rClip )
     581                 :            : {
     582                 :          0 :     if( mpClipRegion )
     583                 :          0 :         XDestroyRegion( mpClipRegion );
     584                 :          0 :     mpClipRegion = XCreateRegion();
     585                 :            : 
     586                 :            :     ImplRegionInfo aInfo;
     587                 :            :     long nX, nY, nW, nH;
     588                 :          0 :     bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
     589                 :          0 :     while( bRegionRect )
     590                 :            :     {
     591                 :          0 :         if ( nW && nH )
     592                 :            :         {
     593                 :            :             XRectangle aRect;
     594                 :          0 :             aRect.x         = (short)nX;
     595                 :          0 :             aRect.y         = (short)nY;
     596                 :          0 :             aRect.width     = (unsigned short)nW;
     597                 :          0 :             aRect.height    = (unsigned short)nH;
     598                 :            : 
     599                 :          0 :             XUnionRectWithRegion( &aRect, mpClipRegion, mpClipRegion );
     600                 :            :         }
     601                 :          0 :         bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH );
     602                 :            :     }
     603                 :            : 
     604                 :            :     // done, invalidate GCs
     605                 :          0 :     bPenGC_         = sal_False;
     606                 :          0 :     bFontGC_        = sal_False;
     607                 :          0 :     bBrushGC_       = sal_False;
     608                 :          0 :     bMonoGC_        = sal_False;
     609                 :          0 :     bCopyGC_        = sal_False;
     610                 :          0 :     bInvertGC_      = sal_False;
     611                 :          0 :     bInvert50GC_    = sal_False;
     612                 :          0 :     bStippleGC_     = sal_False;
     613                 :          0 :     bTrackingGC_    = sal_False;
     614                 :            : 
     615                 :          0 :     if( XEmptyRegion( mpClipRegion ) )
     616                 :            :     {
     617                 :          0 :         XDestroyRegion( mpClipRegion );
     618                 :          0 :         mpClipRegion= NULL;
     619                 :            :     }
     620                 :          0 :     return true;
     621                 :            : }
     622                 :            : 
     623                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     624                 :          0 : void X11SalGraphics::SetLineColor()
     625                 :            : {
     626                 :          0 :     if( nPenColor_ != SALCOLOR_NONE )
     627                 :            :     {
     628                 :          0 :         nPenColor_      = SALCOLOR_NONE;
     629                 :          0 :         bPenGC_         = sal_False;
     630                 :            :     }
     631                 :          0 : }
     632                 :            : 
     633                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     634                 :          0 : void X11SalGraphics::SetLineColor( SalColor nSalColor )
     635                 :            : {
     636                 :          0 :     if( nPenColor_ != nSalColor )
     637                 :            :     {
     638                 :          0 :         nPenColor_      = nSalColor;
     639                 :          0 :         nPenPixel_      = GetPixel( nSalColor );
     640                 :          0 :         bPenGC_         = sal_False;
     641                 :            :     }
     642                 :          0 : }
     643                 :            : 
     644                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     645                 :          0 : void X11SalGraphics::SetFillColor()
     646                 :            : {
     647                 :          0 :     if( nBrushColor_ != SALCOLOR_NONE )
     648                 :            :     {
     649                 :          0 :         bDitherBrush_   = sal_False;
     650                 :          0 :         nBrushColor_    = SALCOLOR_NONE;
     651                 :          0 :         bBrushGC_       = sal_False;
     652                 :            :     }
     653                 :          0 : }
     654                 :            : 
     655                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     656                 :          0 : void X11SalGraphics::SetFillColor( SalColor nSalColor )
     657                 :            : {
     658                 :          0 :     if( nBrushColor_ != nSalColor )
     659                 :            :     {
     660                 :          0 :         bDitherBrush_   = sal_False;
     661                 :          0 :         nBrushColor_    = nSalColor;
     662                 :          0 :         nBrushPixel_    = GetPixel( nSalColor );
     663                 :          0 :         if( TrueColor != GetColormap().GetVisual().GetClass()
     664                 :          0 :             && GetColormap().GetColor( nBrushPixel_ ) != nBrushColor_
     665                 :            :             && nSalColor != MAKE_SALCOLOR( 0x00, 0x00, 0x00 ) // black
     666                 :            :             && nSalColor != MAKE_SALCOLOR( 0x00, 0x00, 0x80 ) // blue
     667                 :            :             && nSalColor != MAKE_SALCOLOR( 0x00, 0x80, 0x00 ) // green
     668                 :            :             && nSalColor != MAKE_SALCOLOR( 0x00, 0x80, 0x80 ) // cyan
     669                 :            :             && nSalColor != MAKE_SALCOLOR( 0x80, 0x00, 0x00 ) // red
     670                 :            :             && nSalColor != MAKE_SALCOLOR( 0x80, 0x00, 0x80 ) // magenta
     671                 :            :             && nSalColor != MAKE_SALCOLOR( 0x80, 0x80, 0x00 ) // brown
     672                 :            :             && nSalColor != MAKE_SALCOLOR( 0x80, 0x80, 0x80 ) // gray
     673                 :            :             && nSalColor != MAKE_SALCOLOR( 0xC0, 0xC0, 0xC0 ) // light gray
     674                 :            :             && nSalColor != MAKE_SALCOLOR( 0x00, 0x00, 0xFF ) // light blue
     675                 :            :             && nSalColor != MAKE_SALCOLOR( 0x00, 0xFF, 0x00 ) // light green
     676                 :            :             && nSalColor != MAKE_SALCOLOR( 0x00, 0xFF, 0xFF ) // light cyan
     677                 :            :             && nSalColor != MAKE_SALCOLOR( 0xFF, 0x00, 0x00 ) // light red
     678                 :            :             && nSalColor != MAKE_SALCOLOR( 0xFF, 0x00, 0xFF ) // light magenta
     679                 :            :             && nSalColor != MAKE_SALCOLOR( 0xFF, 0xFF, 0x00 ) // light brown
     680                 :            :             && nSalColor != MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF ) )
     681                 :          0 :             bDitherBrush_ = GetDitherPixmap(nSalColor);
     682                 :          0 :         bBrushGC_       = sal_False;
     683                 :            :     }
     684                 :          0 : }
     685                 :            : 
     686                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     687                 :          0 : void X11SalGraphics::SetROPLineColor( SalROPColor nROPColor )
     688                 :            : {
     689                 :          0 :     switch( nROPColor )
     690                 :            :     {
     691                 :            :         case SAL_ROP_0 : // 0
     692                 :          0 :             nPenPixel_ = (Pixel)0;
     693                 :          0 :             break;
     694                 :            :         case SAL_ROP_1 : // 1
     695                 :          0 :             nPenPixel_ = (Pixel)(1 << GetVisual().GetDepth()) - 1;
     696                 :          0 :             break;
     697                 :            :         case SAL_ROP_INVERT : // 2
     698                 :          0 :             nPenPixel_ = (Pixel)(1 << GetVisual().GetDepth()) - 1;
     699                 :          0 :             break;
     700                 :            :     }
     701                 :          0 :     nPenColor_  = GetColormap().GetColor( nPenPixel_ );
     702                 :          0 :     bPenGC_     = sal_False;
     703                 :          0 : }
     704                 :            : 
     705                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     706                 :          0 : void X11SalGraphics::SetROPFillColor( SalROPColor nROPColor )
     707                 :            : {
     708                 :          0 :     switch( nROPColor )
     709                 :            :     {
     710                 :            :         case SAL_ROP_0 : // 0
     711                 :          0 :             nBrushPixel_ = (Pixel)0;
     712                 :          0 :             break;
     713                 :            :         case SAL_ROP_1 : // 1
     714                 :          0 :             nBrushPixel_ = (Pixel)(1 << GetVisual().GetDepth()) - 1;
     715                 :          0 :             break;
     716                 :            :         case SAL_ROP_INVERT : // 2
     717                 :          0 :             nBrushPixel_ = (Pixel)(1 << GetVisual().GetDepth()) - 1;
     718                 :          0 :             break;
     719                 :            :     }
     720                 :          0 :     bDitherBrush_   = sal_False;
     721                 :          0 :     nBrushColor_    = GetColormap().GetColor( nBrushPixel_ );
     722                 :          0 :     bBrushGC_       = sal_False;
     723                 :          0 : }
     724                 :            : 
     725                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     726                 :          0 : void X11SalGraphics::SetXORMode( bool bSet, bool )
     727                 :            : {
     728                 :          0 :     if( !bXORMode_ == bSet )
     729                 :            :     {
     730                 :          0 :         bXORMode_   = bSet;
     731                 :          0 :         bPenGC_     = sal_False;
     732                 :          0 :         bFontGC_    = sal_False;
     733                 :          0 :         bBrushGC_   = sal_False;
     734                 :          0 :         bMonoGC_        = sal_False;
     735                 :          0 :         bCopyGC_        = sal_False;
     736                 :          0 :         bInvertGC_  = sal_False;
     737                 :          0 :         bInvert50GC_    = sal_False;
     738                 :          0 :         bStippleGC_ = sal_False;
     739                 :          0 :         bTrackingGC_    = sal_False;
     740                 :            :     }
     741                 :          0 : }
     742                 :            : 
     743                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     744                 :          0 : void X11SalGraphics::drawPixel( long nX, long nY )
     745                 :            : {
     746                 :          0 :     if( nPenColor_ !=  SALCOLOR_NONE )
     747                 :          0 :         XDrawPoint( GetXDisplay(), GetDrawable(), SelectPen(), nX, nY );
     748                 :          0 : }
     749                 :            : 
     750                 :          0 : void X11SalGraphics::drawPixel( long nX, long nY, SalColor nSalColor )
     751                 :            : {
     752                 :          0 :     if( nSalColor != SALCOLOR_NONE )
     753                 :            :     {
     754                 :          0 :         Display *pDisplay = GetXDisplay();
     755                 :            : 
     756                 :          0 :         if( (nPenColor_ == SALCOLOR_NONE) && !bPenGC_ )
     757                 :            :         {
     758                 :          0 :             SetLineColor( nSalColor );
     759                 :          0 :             XDrawPoint( pDisplay, GetDrawable(), SelectPen(), nX, nY );
     760                 :          0 :             nPenColor_ = SALCOLOR_NONE;
     761                 :          0 :             bPenGC_ = False;
     762                 :            :         }
     763                 :            :         else
     764                 :            :         {
     765                 :          0 :             GC pGC = SelectPen();
     766                 :            : 
     767                 :          0 :             if( nSalColor != nPenColor_ )
     768                 :          0 :                 XSetForeground( pDisplay, pGC, GetPixel( nSalColor ) );
     769                 :            : 
     770                 :          0 :             XDrawPoint( pDisplay, GetDrawable(), pGC, nX, nY );
     771                 :            : 
     772                 :          0 :             if( nSalColor != nPenColor_ )
     773                 :          0 :                 XSetForeground( pDisplay, pGC, nPenPixel_ );
     774                 :            :         }
     775                 :            :     }
     776                 :          0 : }
     777                 :            : 
     778                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     779                 :          0 : void X11SalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
     780                 :            : {
     781                 :          0 :     if( nPenColor_ != SALCOLOR_NONE )
     782                 :            :     {
     783                 :          0 :         if ( GetDisplay()->GetProperties() & PROPERTY_BUG_DrawLine )
     784                 :            :         {
     785                 :          0 :             GC aGC = SelectPen();
     786                 :          0 :             XDrawPoint (GetXDisplay(), GetDrawable(), aGC, (int)nX1, (int)nY1);
     787                 :          0 :             XDrawPoint (GetXDisplay(), GetDrawable(), aGC, (int)nX2, (int)nY2);
     788                 :          0 :             XDrawLine  (GetXDisplay(), GetDrawable(), aGC, nX1, nY1, nX2, nY2 );
     789                 :            :         }
     790                 :            :         else
     791                 :            :             XDrawLine( GetXDisplay(), GetDrawable(),SelectPen(),
     792                 :          0 :                        nX1, nY1, nX2, nY2 );
     793                 :            :     }
     794                 :          0 : }
     795                 :            : 
     796                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     797                 :          0 : void X11SalGraphics::drawRect( long nX, long nY, long nDX, long nDY )
     798                 :            : {
     799                 :          0 :     if( nBrushColor_ != SALCOLOR_NONE )
     800                 :            :     {
     801                 :            :         XFillRectangle( GetXDisplay(),
     802                 :            :                         GetDrawable(),
     803                 :            :                         SelectBrush(),
     804                 :          0 :                         nX, nY, nDX, nDY );
     805                 :            :     }
     806                 :            :     // Beschreibung DrawRect verkehrt, deshalb -1
     807                 :          0 :     if( nPenColor_ != SALCOLOR_NONE )
     808                 :            :         XDrawRectangle( GetXDisplay(),
     809                 :            :                         GetDrawable(),
     810                 :            :                         SelectPen(),
     811                 :          0 :                         nX, nY, nDX-1, nDY-1 );
     812                 :          0 : }
     813                 :            : 
     814                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     815                 :          0 : void X11SalGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint *pPtAry )
     816                 :            : {
     817                 :          0 :     drawPolyLine( nPoints, pPtAry, false );
     818                 :          0 : }
     819                 :            : 
     820                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     821                 :          0 : void X11SalGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint *pPtAry, bool bClose )
     822                 :            : {
     823                 :          0 :     if( nPenColor_ != 0xFFFFFFFF )
     824                 :            :     {
     825                 :          0 :         SalPolyLine Points( nPoints, pPtAry );
     826                 :            : 
     827                 :          0 :         DrawLines( nPoints, Points, SelectPen(), bClose );
     828                 :            :     }
     829                 :          0 : }
     830                 :            : 
     831                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     832                 :          0 : void X11SalGraphics::drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry )
     833                 :            : {
     834                 :          0 :     if( nPoints == 0 )
     835                 :            :         return;
     836                 :            : 
     837                 :          0 :     if( nPoints < 3 )
     838                 :            :     {
     839                 :          0 :         if( !bXORMode_ )
     840                 :            :         {
     841                 :          0 :             if( 1 == nPoints  )
     842                 :          0 :                 drawPixel( pPtAry[0].mnX, pPtAry[0].mnY );
     843                 :            :             else
     844                 :            :                 drawLine( pPtAry[0].mnX, pPtAry[0].mnY,
     845                 :          0 :                           pPtAry[1].mnX, pPtAry[1].mnY );
     846                 :            :         }
     847                 :            :         return;
     848                 :            :     }
     849                 :            : 
     850                 :          0 :     SalPolyLine Points( nPoints, pPtAry );
     851                 :            : 
     852                 :          0 :     nPoints++;
     853                 :            : 
     854                 :            :     /* WORKAROUND: some Xservers (Xorg, VIA chipset in this case)
     855                 :            :      * do not draw the visible part of a polygon
     856                 :            :      * if it overlaps to the left of screen 0,y.
     857                 :            :      * This happens to be the case in the gradient drawn in the
     858                 :            :      * menubar background. workaround for the special case of
     859                 :            :      * of a rectangle overlapping to the left.
     860                 :            :      */
     861                 :          0 :     if( nPoints == 5 &&
     862                 :          0 :     Points[ 0 ].x == Points[ 1 ].x &&
     863                 :          0 :         Points[ 1 ].y == Points[ 2 ].y &&
     864                 :          0 :         Points[ 2 ].x == Points[ 3 ].x &&
     865                 :          0 :         Points[ 0 ].x == Points[ 4 ].x && Points[ 0 ].y == Points[ 4 ].y
     866                 :            :        )
     867                 :            :     {
     868                 :          0 :         bool bLeft = false;
     869                 :          0 :         bool bRight = false;
     870                 :          0 :         for(unsigned int i = 0; i < nPoints; i++ )
     871                 :            :     {
     872                 :          0 :             if( Points[i].x < 0 )
     873                 :          0 :                 bLeft = true;
     874                 :            :             else
     875                 :          0 :                 bRight= true;
     876                 :            :     }
     877                 :          0 :     if( bLeft && ! bRight )
     878                 :            :         return;
     879                 :          0 :     if( bLeft && bRight )
     880                 :            :         {
     881                 :          0 :             for( unsigned int i = 0; i < nPoints; i++ )
     882                 :          0 :                 if( Points[i].x < 0 )
     883                 :          0 :                     Points[i].x = 0;
     884                 :            :         }
     885                 :            :     }
     886                 :            : 
     887                 :          0 :     if( nBrushColor_ != SALCOLOR_NONE )
     888                 :            :         XFillPolygon( GetXDisplay(),
     889                 :            :                       GetDrawable(),
     890                 :            :                       SelectBrush(),
     891                 :          0 :                       &Points[0], nPoints,
     892                 :          0 :                       Complex, CoordModeOrigin );
     893                 :            : 
     894                 :          0 :     if( nPenColor_ != 0xFFFFFFFF )
     895                 :          0 :         DrawLines( nPoints, Points, SelectPen(), true );
     896                 :            : }
     897                 :            : 
     898                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     899                 :          0 : void X11SalGraphics::drawPolyPolygon( sal_uInt32        nPoly,
     900                 :            :                                    const sal_uInt32    *pPoints,
     901                 :            :                                    PCONSTSALPOINT  *pPtAry )
     902                 :            : {
     903                 :          0 :     if( nBrushColor_ != SALCOLOR_NONE )
     904                 :            :     {
     905                 :            :         sal_uInt32      i, n;
     906                 :          0 :         XLIB_Region pXRegA  = NULL;
     907                 :            : 
     908                 :          0 :         for( i = 0; i < nPoly; i++ ) {
     909                 :          0 :             n = pPoints[i];
     910                 :          0 :             SalPolyLine Points( n, pPtAry[i] );
     911                 :          0 :             if( n > 2 )
     912                 :            :             {
     913                 :          0 :                 XLIB_Region pXRegB = XPolygonRegion( &Points[0], n+1, WindingRule );
     914                 :          0 :                 if( !pXRegA )
     915                 :          0 :                     pXRegA = pXRegB;
     916                 :            :                 else
     917                 :            :                 {
     918                 :          0 :                     XXorRegion( pXRegA, pXRegB, pXRegA );
     919                 :          0 :                     XDestroyRegion( pXRegB );
     920                 :            :                 }
     921                 :            :             }
     922                 :          0 :         }
     923                 :            : 
     924                 :          0 :         if( pXRegA )
     925                 :            :         {
     926                 :            :             XRectangle aXRect;
     927                 :          0 :             XClipBox( pXRegA, &aXRect );
     928                 :            : 
     929                 :          0 :             GC pGC = SelectBrush();
     930                 :          0 :             SetClipRegion( pGC, pXRegA ); // ??? doppelt
     931                 :          0 :             XDestroyRegion( pXRegA );
     932                 :          0 :             bBrushGC_ = sal_False;
     933                 :            : 
     934                 :            :             XFillRectangle( GetXDisplay(),
     935                 :            :                             GetDrawable(),
     936                 :            :                             pGC,
     937                 :          0 :                             aXRect.x, aXRect.y, aXRect.width, aXRect.height );
     938                 :            :         }
     939                 :            :    }
     940                 :            : 
     941                 :          0 :    if( nPenColor_ != SALCOLOR_NONE )
     942                 :          0 :        for( sal_uInt32 i = 0; i < nPoly; i++ )
     943                 :          0 :            drawPolyLine( pPoints[i], pPtAry[i], true );
     944                 :          0 : }
     945                 :            : 
     946                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     947                 :            : 
     948                 :          0 : sal_Bool X11SalGraphics::drawPolyLineBezier( sal_uLong, const SalPoint*, const BYTE* )
     949                 :            : {
     950                 :          0 :     return sal_False;
     951                 :            : }
     952                 :            : 
     953                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     954                 :            : 
     955                 :          0 : sal_Bool X11SalGraphics::drawPolygonBezier( sal_uLong, const SalPoint*, const BYTE* )
     956                 :            : {
     957                 :          0 :     return sal_False;
     958                 :            : }
     959                 :            : 
     960                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     961                 :            : 
     962                 :          0 : sal_Bool X11SalGraphics::drawPolyPolygonBezier( sal_uInt32, const sal_uInt32*,
     963                 :            :                                                 const SalPoint* const*, const BYTE* const* )
     964                 :            : {
     965                 :          0 :     return sal_False;
     966                 :            : }
     967                 :            : 
     968                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     969                 :            : 
     970                 :          0 : void X11SalGraphics::invert( sal_uLong nPoints,
     971                 :            :                              const SalPoint* pPtAry,
     972                 :            :                              SalInvert nFlags )
     973                 :            : {
     974                 :          0 :     SalPolyLine Points ( nPoints, pPtAry );
     975                 :            : 
     976                 :            :     GC pGC;
     977                 :          0 :     if( SAL_INVERT_50 & nFlags )
     978                 :          0 :         pGC = GetInvert50GC();
     979                 :            :     else
     980                 :          0 :         if ( SAL_INVERT_TRACKFRAME & nFlags )
     981                 :          0 :             pGC = GetTrackingGC();
     982                 :            :         else
     983                 :          0 :             pGC = GetInvertGC();
     984                 :            : 
     985                 :          0 :     if( SAL_INVERT_TRACKFRAME & nFlags )
     986                 :          0 :         DrawLines ( nPoints, Points, pGC, true );
     987                 :            :     else
     988                 :            :         XFillPolygon( GetXDisplay(),
     989                 :            :                       GetDrawable(),
     990                 :            :                       pGC,
     991                 :          0 :                       &Points[0], nPoints,
     992                 :          0 :                       Complex, CoordModeOrigin );
     993                 :          0 : }
     994                 :            : 
     995                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     996                 :            : 
     997                 :          0 : BOOL X11SalGraphics::drawEPS( long,long,long,long,void*,sal_uLong )
     998                 :            : {
     999                 :          0 :     return sal_False;
    1000                 :            : }
    1001                 :            : 
    1002                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    1003                 :            : 
    1004                 :          0 : XID X11SalGraphics::GetXRenderPicture()
    1005                 :            : {
    1006                 :          0 :     XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
    1007                 :            : 
    1008                 :          0 :     if( !m_aXRenderPicture )
    1009                 :            :     {
    1010                 :            :         // check xrender support for matching visual
    1011                 :          0 :         XRenderPictFormat* pXRenderFormat = GetXRenderFormat();
    1012                 :          0 :         if( !pXRenderFormat )
    1013                 :          0 :             return 0;
    1014                 :            :         // get the matching xrender target for drawable
    1015                 :          0 :         m_aXRenderPicture = rRenderPeer.CreatePicture( hDrawable_, pXRenderFormat, 0, NULL );
    1016                 :            :     }
    1017                 :            : 
    1018                 :            :     {
    1019                 :            :         // reset clip region
    1020                 :            :         // TODO: avoid clip reset if already done
    1021                 :            :         XRenderPictureAttributes aAttr;
    1022                 :          0 :         aAttr.clip_mask = None;
    1023                 :          0 :         rRenderPeer.ChangePicture( m_aXRenderPicture, CPClipMask, &aAttr );
    1024                 :            :     }
    1025                 :            : 
    1026                 :          0 :     return m_aXRenderPicture;
    1027                 :            : }
    1028                 :            : 
    1029                 :          0 : XRenderPictFormat* X11SalGraphics::GetXRenderFormat() const
    1030                 :            : {
    1031                 :          0 :     if( m_pXRenderFormat == NULL )
    1032                 :          0 :         m_pXRenderFormat = XRenderPeer::GetInstance().FindVisualFormat( GetVisual().visual );
    1033                 :          0 :     return m_pXRenderFormat;
    1034                 :            : }
    1035                 :            : 
    1036                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    1037                 :            : 
    1038                 :          0 : SystemGraphicsData X11SalGraphics::GetGraphicsData() const
    1039                 :            : {
    1040                 :          0 :     SystemGraphicsData aRes;
    1041                 :            : 
    1042                 :          0 :     aRes.nSize = sizeof(aRes);
    1043                 :          0 :     aRes.pDisplay  = GetXDisplay();
    1044                 :          0 :     aRes.hDrawable = hDrawable_;
    1045                 :          0 :     aRes.pVisual   = GetVisual().visual;
    1046                 :          0 :     aRes.nScreen   = m_nXScreen.getXScreen();
    1047                 :          0 :     aRes.nDepth    = GetBitCount();
    1048                 :          0 :     aRes.aColormap = GetColormap().GetXColormap();
    1049                 :          0 :     aRes.pXRenderFormat = m_pXRenderFormat;
    1050                 :          0 :     return aRes;
    1051                 :            : }
    1052                 :            : 
    1053                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    1054                 :            : 
    1055                 :            : // draw a poly-polygon
    1056                 :          0 : bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPolyPoly, double fTransparency )
    1057                 :            : {
    1058                 :            :     // nothing to do for empty polypolygons
    1059                 :          0 :     const int nOrigPolyCount = rOrigPolyPoly.count();
    1060                 :          0 :     if( nOrigPolyCount <= 0 )
    1061                 :          0 :         return sal_True;
    1062                 :            : 
    1063                 :            :     // nothing to do if everything is transparent
    1064                 :          0 :     if( (nBrushColor_ == SALCOLOR_NONE)
    1065                 :            :     &&  (nPenColor_ == SALCOLOR_NONE) )
    1066                 :          0 :         return sal_True;
    1067                 :            : 
    1068                 :            :     // cannot handle pencolor!=brushcolor yet
    1069                 :          0 :     if( (nPenColor_ != SALCOLOR_NONE)
    1070                 :            :     &&  (nPenColor_ != nBrushColor_) )
    1071                 :          0 :         return sal_False;
    1072                 :            : 
    1073                 :            :     // TODO: remove the env-variable when no longer needed
    1074                 :          0 :     static const char* pRenderEnv = getenv( "SAL_DISABLE_RENDER_POLY" );
    1075                 :          0 :     if( pRenderEnv )
    1076                 :          0 :         return sal_False;
    1077                 :            : 
    1078                 :            :     // snap to raster if requested
    1079                 :          0 :     basegfx::B2DPolyPolygon aPolyPoly = rOrigPolyPoly;
    1080                 :          0 :     const bool bSnapToRaster = !getAntiAliasB2DDraw();
    1081                 :          0 :     if( bSnapToRaster )
    1082                 :          0 :         aPolyPoly = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges( aPolyPoly );
    1083                 :            : 
    1084                 :            :     // don't bother with polygons outside of visible area
    1085                 :          0 :     const basegfx::B2DRange aViewRange( 0, 0, GetGraphicsWidth(), GetGraphicsHeight() );
    1086                 :          0 :     aPolyPoly = basegfx::tools::clipPolyPolygonOnRange( aPolyPoly, aViewRange, true, false );
    1087                 :          0 :     if( !aPolyPoly.count() )
    1088                 :          0 :         return true;
    1089                 :            : 
    1090                 :            :     // tesselate the polypolygon into trapezoids
    1091                 :          0 :     basegfx::B2DTrapezoidVector aB2DTrapVector;
    1092                 :          0 :     basegfx::tools::trapezoidSubdivide( aB2DTrapVector, aPolyPoly );
    1093                 :          0 :     const int nTrapCount = aB2DTrapVector.size();
    1094                 :          0 :     if( !nTrapCount )
    1095                 :          0 :         return true;
    1096                 :          0 :     const bool bDrawn = drawFilledTrapezoids( &aB2DTrapVector[0], nTrapCount, fTransparency );
    1097                 :          0 :     return bDrawn;
    1098                 :            : }
    1099                 :            : 
    1100                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    1101                 :            : 
    1102                 :          0 : bool X11SalGraphics::drawFilledTrapezoids( const ::basegfx::B2DTrapezoid* pB2DTraps, int nTrapCount, double fTransparency )
    1103                 :            : {
    1104                 :          0 :     if( nTrapCount <= 0 )
    1105                 :          0 :         return true;
    1106                 :            : 
    1107                 :          0 :     Picture aDstPic = GetXRenderPicture();
    1108                 :            :     // check xrender support for this drawable
    1109                 :          0 :     if( !aDstPic )
    1110                 :          0 :         return false;
    1111                 :            : 
    1112                 :            :      // convert the B2DTrapezoids into XRender-Trapezoids
    1113                 :            :     typedef std::vector<XTrapezoid> TrapezoidVector;
    1114                 :          0 :     TrapezoidVector aTrapVector( nTrapCount );
    1115                 :          0 :     const basegfx::B2DTrapezoid* pB2DTrap = pB2DTraps;
    1116                 :          0 :     for( int i = 0; i < nTrapCount; ++pB2DTrap, ++i )
    1117                 :            :     {
    1118                 :          0 :         XTrapezoid& rTrap = aTrapVector[ i ] ;
    1119                 :            : 
    1120                 :            :          // set y-coordinates
    1121                 :          0 :         const double fY1 = pB2DTrap->getTopY();
    1122                 :          0 :         rTrap.left.p1.y = rTrap.right.p1.y = rTrap.top = XDoubleToFixed( fY1 );
    1123                 :          0 :         const double fY2 = pB2DTrap->getBottomY();
    1124                 :          0 :         rTrap.left.p2.y = rTrap.right.p2.y = rTrap.bottom = XDoubleToFixed( fY2 );
    1125                 :            : 
    1126                 :            :          // set x-coordinates
    1127                 :          0 :         const double fXL1 = pB2DTrap->getTopXLeft();
    1128                 :          0 :         rTrap.left.p1.x = XDoubleToFixed( fXL1 );
    1129                 :          0 :         const double fXR1 = pB2DTrap->getTopXRight();
    1130                 :          0 :         rTrap.right.p1.x = XDoubleToFixed( fXR1 );
    1131                 :          0 :         const double fXL2 = pB2DTrap->getBottomXLeft();
    1132                 :          0 :         rTrap.left.p2.x = XDoubleToFixed( fXL2 );
    1133                 :          0 :         const double fXR2 = pB2DTrap->getBottomXRight();
    1134                 :          0 :         rTrap.right.p2.x = XDoubleToFixed( fXR2 );
    1135                 :            :     }
    1136                 :            : 
    1137                 :            :     // get xrender Picture for polygon foreground
    1138                 :            :     // TODO: cache it like the target picture which uses GetXRenderPicture()
    1139                 :          0 :     XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
    1140                 :          0 :     SalDisplay::RenderEntry& rEntry = GetDisplay()->GetRenderEntries( m_nXScreen )[ 32 ];
    1141                 :          0 :     if( !rEntry.m_aPicture )
    1142                 :            :     {
    1143                 :          0 :         Display* pXDisplay = GetXDisplay();
    1144                 :            : 
    1145                 :          0 :         rEntry.m_aPixmap = limitXCreatePixmap( pXDisplay, hDrawable_, 1, 1, 32 );
    1146                 :            :         XRenderPictureAttributes aAttr;
    1147                 :          0 :         aAttr.repeat = true;
    1148                 :            : 
    1149                 :          0 :         XRenderPictFormat* pXRPF = rRenderPeer.FindStandardFormat( PictStandardARGB32 );
    1150                 :          0 :         rEntry.m_aPicture = rRenderPeer.CreatePicture( rEntry.m_aPixmap, pXRPF, CPRepeat, &aAttr );
    1151                 :            :     }
    1152                 :            : 
    1153                 :            :     // set polygon foreground color and opacity
    1154                 :          0 :     XRenderColor aRenderColor = GetXRenderColor( nBrushColor_ , fTransparency );
    1155                 :          0 :     rRenderPeer.FillRectangle( PictOpSrc, rEntry.m_aPicture, &aRenderColor, 0, 0, 1, 1 );
    1156                 :            : 
    1157                 :            :     // set clipping
    1158                 :            :     // TODO: move into GetXRenderPicture?
    1159                 :          0 :     if( mpClipRegion && !XEmptyRegion( mpClipRegion ) )
    1160                 :          0 :         rRenderPeer.SetPictureClipRegion( aDstPic, mpClipRegion );
    1161                 :            : 
    1162                 :            :     // render the trapezoids
    1163                 :          0 :     const XRenderPictFormat* pMaskFormat = rRenderPeer.GetStandardFormatA8();
    1164                 :            :     rRenderPeer.CompositeTrapezoids( PictOpOver,
    1165                 :          0 :         rEntry.m_aPicture, aDstPic, pMaskFormat, 0, 0, &aTrapVector[0], aTrapVector.size() );
    1166                 :            : 
    1167                 :          0 :     return true;
    1168                 :            : }
    1169                 :            : 
    1170                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    1171                 :            : 
    1172                 :          0 : bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, double fTransparency, const ::basegfx::B2DVector& rLineWidth, basegfx::B2DLineJoin eLineJoin)
    1173                 :            : {
    1174                 :          0 :     const bool bIsHairline = (rLineWidth.getX() == rLineWidth.getY()) && (rLineWidth.getX() <= 1.2);
    1175                 :            : 
    1176                 :            :     // #i101491#
    1177                 :          0 :     if( !bIsHairline && (rPolygon.count() > 1000) )
    1178                 :            :     {
    1179                 :            :         // the used basegfx::tools::createAreaGeometry is simply too
    1180                 :            :         // expensive with very big polygons; fallback to caller (who
    1181                 :            :         // should use ImplLineConverter normally)
    1182                 :            :         // AW: ImplLineConverter had to be removed since it does not even
    1183                 :            :         // know LineJoins, so the fallback will now prepare the line geometry
    1184                 :            :         // the same way.
    1185                 :          0 :         return false;
    1186                 :            :     }
    1187                 :            : 
    1188                 :            :     // temporarily adjust brush color to pen color
    1189                 :            :     // since the line is drawn as an area-polygon
    1190                 :          0 :     const SalColor aKeepBrushColor = nBrushColor_;
    1191                 :          0 :     nBrushColor_ = nPenColor_;
    1192                 :            : 
    1193                 :            :     // #i11575#desc5#b adjust B2D tesselation result to raster positions
    1194                 :          0 :     basegfx::B2DPolygon aPolygon = rPolygon;
    1195                 :          0 :     const double fHalfWidth = 0.5 * rLineWidth.getX();
    1196                 :          0 :     aPolygon.transform( basegfx::tools::createTranslateB2DHomMatrix(+fHalfWidth,+fHalfWidth) );
    1197                 :            : 
    1198                 :            :     // shortcut for hairline drawing to improve performance
    1199                 :          0 :     bool bDrawnOk = true;
    1200                 :          0 :     if( bIsHairline )
    1201                 :            :     {
    1202                 :            :         // hairlines can benefit from a simplified tesselation
    1203                 :            :         // e.g. for hairlines the linejoin style can be ignored
    1204                 :          0 :         basegfx::B2DTrapezoidVector aB2DTrapVector;
    1205                 :          0 :         basegfx::tools::createLineTrapezoidFromB2DPolygon( aB2DTrapVector, aPolygon, rLineWidth.getX() );
    1206                 :            : 
    1207                 :            :         // draw tesselation result
    1208                 :          0 :         const int nTrapCount = aB2DTrapVector.size();
    1209                 :          0 :         if( nTrapCount > 0 )
    1210                 :          0 :             bDrawnOk = drawFilledTrapezoids( &aB2DTrapVector[0], nTrapCount, fTransparency );
    1211                 :            : 
    1212                 :            :         // restore the original brush GC
    1213                 :          0 :         nBrushColor_ = aKeepBrushColor;
    1214                 :          0 :         return bDrawnOk;
    1215                 :            :     }
    1216                 :            : 
    1217                 :            :     // get the area polygon for the line polygon
    1218                 :          0 :     if( (rLineWidth.getX() != rLineWidth.getY())
    1219                 :          0 :     && !basegfx::fTools::equalZero( rLineWidth.getY() ) )
    1220                 :            :     {
    1221                 :            :         // prepare for createAreaGeometry() with anisotropic linewidth
    1222                 :          0 :         aPolygon.transform( basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getX() / rLineWidth.getY()));
    1223                 :            :     }
    1224                 :            : 
    1225                 :            :     // create the area-polygon for the line
    1226                 :          0 :     const basegfx::B2DPolyPolygon aAreaPolyPoly( basegfx::tools::createAreaGeometry(aPolygon, fHalfWidth, eLineJoin) );
    1227                 :            : 
    1228                 :          0 :     if( (rLineWidth.getX() != rLineWidth.getY())
    1229                 :          0 :     && !basegfx::fTools::equalZero( rLineWidth.getX() ) )
    1230                 :            :     {
    1231                 :            :         // postprocess createAreaGeometry() for anisotropic linewidth
    1232                 :          0 :         aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getY() / rLineWidth.getX()));
    1233                 :            :     }
    1234                 :            : 
    1235                 :            :     // draw each area polypolygon component individually
    1236                 :            :     // to emulate the polypolygon winding rule "non-zero"
    1237                 :          0 :     const int nPolyCount = aAreaPolyPoly.count();
    1238                 :          0 :     for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx )
    1239                 :            :     {
    1240                 :          0 :         const ::basegfx::B2DPolyPolygon aOnePoly( aAreaPolyPoly.getB2DPolygon( nPolyIdx ) );
    1241                 :          0 :         bDrawnOk = drawPolyPolygon( aOnePoly, fTransparency );
    1242                 :          0 :         if( !bDrawnOk )
    1243                 :            :             break;
    1244                 :          0 :     }
    1245                 :            : 
    1246                 :            :     // restore the original brush GC
    1247                 :          0 :     nBrushColor_ = aKeepBrushColor;
    1248                 :          0 :     return bDrawnOk;
    1249                 :            : }
    1250                 :            : 
    1251                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    1252                 :            : 
    1253                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10