LCOV - code coverage report
Current view: top level - libreoffice/vcl/headless - svpgdi.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 248 332 74.7 %
Date: 2012-12-17 Functions: 36 49 73.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "headless/svpgdi.hxx"
      21             : #include "headless/svpbmp.hxx"
      22             : 
      23             : #include <vcl/sysdata.hxx>
      24             : #include <basegfx/range/b2drange.hxx>
      25             : #include <basegfx/range/b2ibox.hxx>
      26             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      27             : #include <basegfx/polygon/b2dpolygon.hxx>
      28             : #include <basegfx/polygon/b2dpolygontools.hxx>
      29             : #include <basebmp/scanlineformats.hxx>
      30             : 
      31             : #include <tools/debug.hxx>
      32             : 
      33             : #if OSL_DEBUG_LEVEL > 2
      34             : #include <basebmp/debug.hxx>
      35             : #include <fstream>
      36             : #include <rtl/strbuf.hxx>
      37             : #include <sys/stat.h>
      38             : #endif
      39             : 
      40             : #include <region.h>
      41             : #include <stdio.h>
      42             : 
      43      485131 : inline void dbgOut( const basebmp::BitmapDeviceSharedPtr&
      44             : #if OSL_DEBUG_LEVEL > 2
      45             : rDevice
      46             : #endif
      47             : )
      48             : {
      49             :     #if OSL_DEBUG_LEVEL > 2
      50             :     static int dbgStreamNum = 0;
      51             :     rtl::OStringBuffer aBuf( 256 );
      52             :     aBuf.append( "debug" );
      53             :     mkdir( aBuf.getStr(), 0777 );
      54             :     aBuf.append( "/" );
      55             :     aBuf.append( sal_Int64(reinterpret_cast<sal_IntPtr>(rDevice.get())), 16 );
      56             :     mkdir( aBuf.getStr(), 0777 );
      57             :     aBuf.append( "/bmp" );
      58             :     aBuf.append( sal_Int32(dbgStreamNum++) );
      59             :     std::fstream bmpstream( aBuf.getStr(), std::ios::out );
      60             :     debugDump( rDevice, bmpstream );
      61             :     #endif
      62      485131 : }
      63             : 
      64             : // ===========================================================================
      65             : 
      66         314 : bool SvpSalGraphics::drawAlphaBitmap( const SalTwoRect&, const SalBitmap& /*rSourceBitmap*/, const SalBitmap& /*rAlphaBitmap*/ )
      67             : {
      68             :     // TODO(P3) implement alpha blending
      69         314 :     return false;
      70             : }
      71             : 
      72           0 : bool SvpSalGraphics::drawAlphaRect( long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, sal_uInt8 /*nTransparency*/ )
      73             : {
      74             :     // TODO(P3) implement alpha blending
      75           0 :     return false;
      76             : }
      77             : 
      78       37134 : SvpSalGraphics::SvpSalGraphics() :
      79             :     m_bUseLineColor( true ),
      80             :     m_aLineColor( COL_BLACK ),
      81             :     m_bUseFillColor( false ),
      82             :     m_aFillColor( COL_WHITE ),
      83             :     m_aTextColor( COL_BLACK ),
      84             :     m_aDrawMode( basebmp::DrawMode_PAINT ),
      85             :     m_eTextFmt( basebmp::Format::EIGHT_BIT_GREY ),
      86       37134 :     m_bClipSetup( false )
      87             : {
      88      631278 :     for( int i = 0; i < MAX_FALLBACK; ++i )
      89      594144 :         m_pServerFont[i] = NULL;
      90       37134 : }
      91             : 
      92       37392 : SvpSalGraphics::~SvpSalGraphics()
      93             : {
      94       37392 : }
      95             : 
      96       39183 : void SvpSalGraphics::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice )
      97             : {
      98       39183 :     m_aOrigDevice = rDevice;
      99       39183 :     ResetClipRegion();
     100             : 
     101             :     // determine matching bitmap format for masks
     102       39183 :     sal_uInt32 nDeviceFmt = m_aDevice->getScanlineFormat();
     103             :     DBG_ASSERT( (nDeviceFmt <= (sal_uInt32)basebmp::Format::MAX), "SVP::setDevice() with invalid bitmap format" );
     104       39183 :     switch( nDeviceFmt )
     105             :     {
     106             :         case basebmp::Format::EIGHT_BIT_GREY:
     107             :         case basebmp::Format::SIXTEEN_BIT_LSB_TC_MASK:
     108             :         case basebmp::Format::SIXTEEN_BIT_MSB_TC_MASK:
     109             :         case basebmp::Format::TWENTYFOUR_BIT_TC_MASK:
     110             :         case basebmp::Format::THIRTYTWO_BIT_TC_MASK_BGRA:
     111             :         case basebmp::Format::THIRTYTWO_BIT_TC_MASK_ARGB:
     112             :         case basebmp::Format::THIRTYTWO_BIT_TC_MASK_ABGR:
     113             :         case basebmp::Format::THIRTYTWO_BIT_TC_MASK_RGBA:
     114       38265 :             m_eTextFmt = basebmp::Format::EIGHT_BIT_GREY;
     115       38265 :             break;
     116             :         default:
     117         918 :             m_eTextFmt = basebmp::Format::ONE_BIT_LSB_GREY;
     118         918 :             break;
     119             :     }
     120       39183 : }
     121             : 
     122         604 : void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
     123             : {
     124         604 :     rDPIX = rDPIY = 96;
     125         604 : }
     126             : 
     127       20845 : sal_uInt16 SvpSalGraphics::GetBitCount() const
     128             : {
     129       20845 :     return SvpElement::getBitCountFromScanlineFormat( m_aDevice->getScanlineFormat() );
     130             : }
     131             : 
     132           0 : long SvpSalGraphics::GetGraphicsWidth() const
     133             : {
     134           0 :     if( m_aDevice.get() )
     135             :     {
     136           0 :         basegfx::B2IVector aSize = m_aOrigDevice->getSize();
     137           0 :         return aSize.getX();
     138             :     }
     139           0 :     return 0;
     140             : }
     141             : 
     142       39759 : void SvpSalGraphics::ResetClipRegion()
     143             : {
     144       39759 :     m_aDevice = m_aOrigDevice;
     145       39759 :     m_aClipMap.reset();
     146       39759 :     m_bClipSetup = true;
     147       39759 :     m_aClipRegion.SetNull();
     148       39759 : }
     149             : 
     150             : 
     151             : // verify clip for the whole area is setup
     152      477956 : void SvpSalGraphics::ensureClip()
     153             : {
     154      477956 :     if (m_bClipSetup)
     155      477956 :         return;
     156             : 
     157         114 :     m_aDevice = m_aOrigDevice;
     158         114 :     basegfx::B2IVector aSize = m_aDevice->getSize();
     159         114 :     m_aClipMap = basebmp::createBitmapDevice( aSize, false, basebmp::Format::ONE_BIT_MSB_GREY );
     160         114 :     m_aClipMap->clear( basebmp::Color(0xFFFFFFFF) );
     161             : 
     162             :     // fprintf( stderr, "non rect clip region set with %d rects:\n",
     163             :     //         (int)m_aClipRegion.GetRectCount() );
     164             :     ImplRegionInfo aInfo;
     165             :     long nX, nY, nW, nH;
     166         114 :     bool bRegionRect = m_aClipRegion.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
     167         727 :     while( bRegionRect )
     168             :     {
     169         499 :         if ( nW && nH )
     170             :         {
     171         499 :             basegfx::B2DPolyPolygon aFull;
     172         499 :             aFull.append( basegfx::tools::createPolygonFromRect( basegfx::B2DRectangle( nX, nY, nX+nW, nY+nH ) ) );
     173         499 :             m_aClipMap->fillPolyPolygon( aFull, basebmp::Color(0), basebmp::DrawMode_PAINT );
     174             :         }
     175             :     //    fprintf( stderr, "\t %ld,%ld %ldx%ld\n", nX, nY, nW, nH );
     176         499 :         bRegionRect = m_aClipRegion.ImplGetNextRect( aInfo, nX, nY, nW, nH );
     177             :     }
     178         114 :     m_bClipSetup = true;
     179             : }
     180             : 
     181       95672 : SvpSalGraphics::ClipUndoHandle::~ClipUndoHandle()
     182             : {
     183       47836 :     if( m_aDevice.get() )
     184          18 :         m_rGfx.m_aDevice = m_aDevice;
     185       47836 : }
     186             : 
     187             : // setup a clip rectangle -only- iff we have to; if aRange
     188             : // is entirely contained inside an existing clip frame, we
     189             : // will avoid setting up the clip bitmap. Similarly if the
     190             : // range doesn't appear at all we return true to avoid
     191             : // rendering
     192       47836 : bool SvpSalGraphics::isClippedSetup( const basegfx::B2IBox &aRange, SvpSalGraphics::ClipUndoHandle &rUndo )
     193             : {
     194       47836 :     if( m_bClipSetup )
     195       47535 :         return false;
     196             : 
     197         301 :     if( m_aClipRegion.IsEmpty() ) // no clipping
     198           0 :         return false;
     199             : 
     200             :     // fprintf( stderr, "ensureClipFor: %d, %d %dx%d\n",
     201             :     //         aRange.getMinX(), aRange.getMinY(),
     202             :     //         (int)aRange.getWidth(), (int)aRange.getHeight() );
     203             : 
     204             :     // first see if aRange is purely internal to one of the clip regions
     205             :     Rectangle aRect( Point( aRange.getMinX(), aRange.getMinY() ),
     206         301 :                      Size( aRange.getWidth(), aRange.getHeight() ) );
     207             : 
     208             :     // then see if we are overlapping with just one
     209         301 :     int nHit = 0;
     210         301 :     Rectangle aIterRect, aHitRect;
     211         301 :     RegionHandle aHnd = m_aClipRegion.BeginEnumRects();
     212        2018 :     while( m_aClipRegion.GetNextEnumRect( aHnd, aIterRect ) )
     213             :     {
     214        1416 :         if( aIterRect.IsOver( aRect ) )
     215             :         {
     216         254 :             aHitRect = aIterRect;
     217         254 :             nHit++;
     218             :         }
     219             :     }
     220         301 :     m_aClipRegion.EndEnumRects (aHnd);
     221             : 
     222         301 :     if( nHit == 0 ) // rendering outside any clipping region
     223             :     {
     224             : //        fprintf (stderr, "denegerate case detected ...\n");
     225         101 :         return true;
     226             :     }
     227         200 :     else if( nHit == 1 ) // common path: rendering against just one clipping region
     228             :     {
     229         174 :         if( aHitRect.IsInside( aRect ) )
     230             :         {
     231             : //        fprintf (stderr, " is inside ! avoid deeper clip ...\n");
     232         156 :             return false;
     233             :         }
     234             : //    fprintf (stderr, " operation only overlaps with a single clip zone\n" );
     235          18 :         rUndo.m_aDevice = m_aDevice;
     236             :         m_aDevice = basebmp::subsetBitmapDevice( m_aOrigDevice,
     237          18 :                                                  basegfx::B2IBox (aHitRect.Left(),
     238          18 :                                                                   aHitRect.Top(),
     239          18 :                                                                   aHitRect.Right(),
     240          72 :                                                                   aHitRect.Bottom()) );
     241          18 :         return false;
     242             :     }
     243             : //    fprintf (stderr, "URK: complex & slow clipping case\n" );
     244             :     // horribly slow & complicated case ...
     245             : 
     246          26 :     ensureClip();
     247          26 :     return false;
     248             : }
     249             : 
     250             : 
     251             : // Clipping by creating unconditional mask bitmaps is horribly
     252             : // slow so defer it, as much as possible. It is common to get
     253             : // 3 rectangles pushed, and have to create a vast off-screen
     254             : // mask only to destroy it shortly afterwards. That is
     255             : // particularly galling if we render only to a small,
     256             : // well defined rectangular area inside one of these clip
     257             : // rectangles.
     258             : //
     259             : // ensureClipFor() or ensureClip() need to be called before
     260             : // real rendering. FIXME: we should prolly push this down to
     261             : // bitmapdevice instead.
     262       21198 : bool SvpSalGraphics::setClipRegion( const Region& i_rClip )
     263             : {
     264       21198 :     m_aClipRegion = i_rClip;
     265       21198 :     m_aClipMap.reset();
     266       21198 :     if( i_rClip.IsEmpty() )
     267           0 :         m_bClipSetup = true;
     268             : 
     269       21198 :     else if( i_rClip.GetRectCount() == 1 )
     270             :     {
     271       21001 :         m_aClipMap.reset();
     272       21001 :         Rectangle aBoundRect( i_rClip.GetBoundRect() );
     273             :         m_aDevice = basebmp::subsetBitmapDevice( m_aOrigDevice,
     274       21001 :                                                  basegfx::B2IBox(aBoundRect.Left(),aBoundRect.Top(),aBoundRect.Right(),aBoundRect.Bottom()) );
     275       21001 :         m_bClipSetup = true;
     276             :     }
     277             :     else
     278         197 :         m_bClipSetup = false;
     279             : 
     280       21198 :     return true;
     281             : }
     282             : 
     283       40271 : void SvpSalGraphics::SetLineColor()
     284             : {
     285       40271 :     m_bUseLineColor = false;
     286       40271 : }
     287             : 
     288       49935 : void SvpSalGraphics::SetLineColor( SalColor nSalColor )
     289             : {
     290       49935 :     m_bUseLineColor = true;
     291       49935 :     m_aLineColor = basebmp::Color( nSalColor );
     292       49935 : }
     293             : 
     294          85 : void SvpSalGraphics::SetFillColor()
     295             : {
     296          85 :     m_bUseFillColor = false;
     297          85 : }
     298             : 
     299      159135 : void SvpSalGraphics::SetFillColor( SalColor nSalColor )
     300             : {
     301      159135 :     m_bUseFillColor = true;
     302      159135 :     m_aFillColor = basebmp::Color( nSalColor );
     303      159135 : }
     304             : 
     305       36894 : void SvpSalGraphics::SetXORMode( bool bSet, bool )
     306             : {
     307       36894 :     m_aDrawMode = bSet ? basebmp::DrawMode_XOR : basebmp::DrawMode_PAINT;
     308       36894 : }
     309             : 
     310           0 : void SvpSalGraphics::SetROPLineColor( SalROPColor nROPColor )
     311             : {
     312           0 :     m_bUseLineColor = true;
     313           0 :     switch( nROPColor )
     314             :     {
     315             :         case SAL_ROP_0:
     316           0 :             m_aLineColor = basebmp::Color( 0 );
     317           0 :             break;
     318             :         case SAL_ROP_1:
     319           0 :             m_aLineColor = basebmp::Color( 0xffffff );
     320           0 :             break;
     321             :         case SAL_ROP_INVERT:
     322           0 :             m_aLineColor = basebmp::Color( 0xffffff );
     323           0 :             break;
     324             :     }
     325           0 : }
     326             : 
     327           0 : void SvpSalGraphics::SetROPFillColor( SalROPColor nROPColor )
     328             : {
     329           0 :     m_bUseFillColor = true;
     330           0 :     switch( nROPColor )
     331             :     {
     332             :         case SAL_ROP_0:
     333           0 :             m_aFillColor = basebmp::Color( 0 );
     334           0 :             break;
     335             :         case SAL_ROP_1:
     336           0 :             m_aFillColor = basebmp::Color( 0xffffff );
     337           0 :             break;
     338             :         case SAL_ROP_INVERT:
     339           0 :             m_aFillColor = basebmp::Color( 0xffffff );
     340           0 :             break;
     341             :     }
     342           0 : }
     343             : 
     344        3102 : void SvpSalGraphics::SetTextColor( SalColor nSalColor )
     345             : {
     346        3102 :     m_aTextColor = basebmp::Color( nSalColor );
     347        3102 : }
     348             : 
     349        9686 : void SvpSalGraphics::drawPixel( long nX, long nY )
     350             : {
     351        9686 :     if( m_bUseLineColor )
     352             :     {
     353        9686 :         ensureClip();
     354             :         m_aDevice->setPixel( basegfx::B2IPoint( nX, nY ),
     355             :                              m_aLineColor,
     356             :                              m_aDrawMode,
     357             :                              m_aClipMap
     358        9686 :                              );
     359             :     }
     360        9686 :     dbgOut( m_aDevice );
     361        9686 : }
     362             : 
     363       48965 : void SvpSalGraphics::drawPixel( long nX, long nY, SalColor nSalColor )
     364             : {
     365       48965 :     basebmp::Color aColor( nSalColor );
     366       48965 :     ensureClip();
     367             :     m_aDevice->setPixel( basegfx::B2IPoint( nX, nY ),
     368             :                          aColor,
     369             :                          m_aDrawMode,
     370             :                          m_aClipMap
     371       48965 :                          );
     372       48965 :     dbgOut( m_aDevice );
     373       48965 : }
     374             : 
     375      227346 : void SvpSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
     376             : {
     377      227346 :     if( m_bUseLineColor )
     378             :     {
     379      227346 :         ensureClip(); // FIXME: for ...
     380             :         m_aDevice->drawLine( basegfx::B2IPoint( nX1, nY1 ),
     381             :                              basegfx::B2IPoint( nX2, nY2 ),
     382             :                              m_aLineColor,
     383             :                              m_aDrawMode,
     384      227346 :                              m_aClipMap );
     385             :     }
     386      227346 :     dbgOut( m_aDevice );
     387      227346 : }
     388             : 
     389       74294 : void SvpSalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight )
     390             : {
     391       74294 :     if( m_bUseLineColor || m_bUseFillColor )
     392             :     {
     393       74294 :         basegfx::B2DPolygon aRect = basegfx::tools::createPolygonFromRect( basegfx::B2DRectangle( nX, nY, nX+nWidth, nY+nHeight ) );
     394       74294 :         ensureClip(); // FIXME: for ...
     395       74294 :         if( m_bUseFillColor )
     396             :         {
     397       74294 :             basegfx::B2DPolyPolygon aPolyPoly( aRect );
     398       74294 :             m_aDevice->fillPolyPolygon( aPolyPoly, m_aFillColor, m_aDrawMode, m_aClipMap );
     399             :         }
     400       74294 :         if( m_bUseLineColor )
     401          51 :             m_aDevice->drawPolygon( aRect, m_aLineColor, m_aDrawMode, m_aClipMap );
     402             :     }
     403       74294 :     dbgOut( m_aDevice );
     404       74294 : }
     405             : 
     406        6730 : void SvpSalGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry )
     407             : {
     408        6730 :     if( m_bUseLineColor && nPoints )
     409             :     {
     410        6730 :         basegfx::B2DPolygon aPoly;
     411        6730 :         aPoly.append( basegfx::B2DPoint( pPtAry->mnX, pPtAry->mnY ), nPoints );
     412       16288 :         for( sal_uLong i = 1; i < nPoints; i++ )
     413        9558 :             aPoly.setB2DPoint( i, basegfx::B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
     414        6730 :         aPoly.setClosed( false );
     415        6730 :         ensureClip(); // FIXME: for ...
     416        6730 :         m_aDevice->drawPolygon( aPoly, m_aLineColor, m_aDrawMode, m_aClipMap );
     417             :     }
     418        6730 :     dbgOut( m_aDevice );
     419        6730 : }
     420             : 
     421      110899 : void SvpSalGraphics::drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry )
     422             : {
     423      110899 :     if( ( m_bUseLineColor || m_bUseFillColor ) && nPoints )
     424             :     {
     425      110899 :         basegfx::B2DPolygon aPoly;
     426      110899 :         aPoly.append( basegfx::B2DPoint( pPtAry->mnX, pPtAry->mnY ), nPoints );
     427      469467 :         for( sal_uLong i = 1; i < nPoints; i++ )
     428      358568 :             aPoly.setB2DPoint( i, basegfx::B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
     429      110899 :         ensureClip(); // FIXME: for ...
     430      110899 :         if( m_bUseFillColor )
     431             :         {
     432      110852 :             aPoly.setClosed( true );
     433      110852 :             m_aDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(aPoly), m_aFillColor, m_aDrawMode, m_aClipMap );
     434             :         }
     435      110899 :         if( m_bUseLineColor )
     436             :         {
     437         193 :             aPoly.setClosed( false );
     438         193 :             m_aDevice->drawPolygon( aPoly, m_aLineColor, m_aDrawMode, m_aClipMap );
     439      110899 :         }
     440             :     }
     441      110899 :     dbgOut( m_aDevice );
     442      110899 : }
     443             : 
     444          10 : void SvpSalGraphics::drawPolyPolygon( sal_uInt32        nPoly,
     445             :                                       const sal_uInt32* pPointCounts,
     446             :                                       PCONSTSALPOINT*   pPtAry )
     447             : {
     448          10 :     if( ( m_bUseLineColor || m_bUseFillColor ) && nPoly )
     449             :     {
     450          10 :         basegfx::B2DPolyPolygon aPolyPoly;
     451          30 :         for( sal_uInt32 nPolygon = 0; nPolygon < nPoly; nPolygon++ )
     452             :         {
     453          20 :             sal_uInt32 nPoints = pPointCounts[nPolygon];
     454          20 :             if( nPoints )
     455             :             {
     456          20 :                 PCONSTSALPOINT pPoints = pPtAry[nPolygon];
     457          20 :                 basegfx::B2DPolygon aPoly;
     458          20 :                 aPoly.append( basegfx::B2DPoint( pPoints->mnX, pPoints->mnY ), nPoints );
     459         312 :                 for( sal_uInt32 i = 1; i < nPoints; i++ )
     460         292 :                     aPoly.setB2DPoint( i, basegfx::B2DPoint( pPoints[i].mnX, pPoints[i].mnY ) );
     461             : 
     462          20 :                 aPolyPoly.append( aPoly );
     463             :             }
     464             :         }
     465          10 :         ensureClip(); // FIXME: for ...
     466          10 :         if( m_bUseFillColor )
     467             :         {
     468          10 :             aPolyPoly.setClosed( true );
     469          10 :             m_aDevice->fillPolyPolygon( aPolyPoly, m_aFillColor, m_aDrawMode, m_aClipMap );
     470             :         }
     471          10 :         if( m_bUseLineColor )
     472             :         {
     473           0 :             aPolyPoly.setClosed( false );
     474           0 :             nPoly = aPolyPoly.count();
     475           0 :             for( sal_uInt32 i = 0; i < nPoly; i++ )
     476           0 :                 m_aDevice->drawPolygon( aPolyPoly.getB2DPolygon(i), m_aLineColor, m_aDrawMode, m_aClipMap );
     477          10 :         }
     478             :     }
     479          10 :     dbgOut( m_aDevice );
     480          10 : }
     481             : 
     482           0 : bool SvpSalGraphics::drawPolyLine(
     483             :     const ::basegfx::B2DPolygon&,
     484             :     double /*fTransparency*/,
     485             :     const ::basegfx::B2DVector& /*rLineWidths*/,
     486             :     basegfx::B2DLineJoin /*eJoin*/,
     487             :     com::sun::star::drawing::LineCap /*eLineCap*/)
     488             : {
     489             :         // TODO: implement and advertise OutDevSupport_B2DDraw support
     490           0 :         return false;
     491             : }
     492             : 
     493           0 : sal_Bool SvpSalGraphics::drawPolyLineBezier( sal_uLong,
     494             :                                              const SalPoint*,
     495             :                                              const sal_uInt8* )
     496             : {
     497           0 :     return sal_False;
     498             : }
     499             : 
     500          12 : sal_Bool SvpSalGraphics::drawPolygonBezier( sal_uLong,
     501             :                                             const SalPoint*,
     502             :                                             const sal_uInt8* )
     503             : {
     504          12 :     return sal_False;
     505             : }
     506             : 
     507          10 : sal_Bool SvpSalGraphics::drawPolyPolygonBezier( sal_uInt32,
     508             :                                                 const sal_uInt32*,
     509             :                                                 const SalPoint* const*,
     510             :                                                 const sal_uInt8* const* )
     511             : {
     512          10 :     return sal_False;
     513             : }
     514             : 
     515           0 : bool SvpSalGraphics::drawPolyPolygon( const basegfx::B2DPolyPolygon&, double /*fTransparency*/ )
     516             : {
     517             :     // TODO: maybe BaseBmp can draw B2DPolyPolygons directly
     518           0 :     return false;
     519             : }
     520             : 
     521          16 : void SvpSalGraphics::copyArea( long nDestX,
     522             :                                       long nDestY,
     523             :                                       long nSrcX,
     524             :                                       long nSrcY,
     525             :                                       long nSrcWidth,
     526             :                                       long nSrcHeight,
     527             :                                       sal_uInt16 /*nFlags*/ )
     528             : {
     529          16 :     basegfx::B2IBox aSrcRect( nSrcX, nSrcY, nSrcX+nSrcWidth, nSrcY+nSrcHeight );
     530          16 :     basegfx::B2IBox aDestRect( nDestX, nDestY, nDestX+nSrcWidth, nDestY+nSrcHeight );
     531             :     // fprintf( stderr, "copyArea %ld pixels - clip region %d\n",
     532             :     //         (long)(nSrcWidth * nSrcHeight), m_aClipMap.get() != NULL );
     533          16 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     534          16 :     if( !isClippedSetup( aDestRect, aUndo ) )
     535          16 :         m_aDevice->drawBitmap( m_aOrigDevice, aSrcRect, aDestRect, basebmp::DrawMode_PAINT, m_aClipMap );
     536          16 :     dbgOut( m_aDevice );
     537          16 : }
     538             : 
     539        4509 : void SvpSalGraphics::copyBits( const SalTwoRect* pPosAry,
     540             :                                SalGraphics*      pSrcGraphics )
     541             : {
     542             :     SvpSalGraphics* pSrc = pSrcGraphics ?
     543        4509 :         static_cast<SvpSalGraphics*>(pSrcGraphics) : this;
     544             :     basegfx::B2IBox aSrcRect( pPosAry->mnSrcX, pPosAry->mnSrcY,
     545             :                      pPosAry->mnSrcX+pPosAry->mnSrcWidth,
     546        4509 :                      pPosAry->mnSrcY+pPosAry->mnSrcHeight );
     547             :     basegfx::B2IBox aDestRect( pPosAry->mnDestX, pPosAry->mnDestY,
     548             :                       pPosAry->mnDestX+pPosAry->mnDestWidth,
     549        4509 :                       pPosAry->mnDestY+pPosAry->mnDestHeight );
     550             : 
     551        4509 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     552        4509 :     if( !isClippedSetup( aDestRect, aUndo ) )
     553        4509 :         m_aDevice->drawBitmap( pSrc->m_aOrigDevice, aSrcRect, aDestRect, basebmp::DrawMode_PAINT, m_aClipMap );
     554        4509 :     dbgOut( m_aDevice );
     555        4509 : }
     556             : 
     557         348 : void SvpSalGraphics::drawBitmap( const SalTwoRect* pPosAry,
     558             :                                  const SalBitmap& rSalBitmap )
     559             : {
     560         348 :     const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBitmap);
     561             :     basegfx::B2IBox aSrcRect( pPosAry->mnSrcX, pPosAry->mnSrcY,
     562             :                      pPosAry->mnSrcX+pPosAry->mnSrcWidth,
     563         348 :                      pPosAry->mnSrcY+pPosAry->mnSrcHeight );
     564             :     basegfx::B2IBox aDestRect( pPosAry->mnDestX, pPosAry->mnDestY,
     565             :                       pPosAry->mnDestX+pPosAry->mnDestWidth,
     566         348 :                       pPosAry->mnDestY+pPosAry->mnDestHeight );
     567             : 
     568         348 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     569         348 :     if( !isClippedSetup( aDestRect, aUndo ) )
     570         313 :         m_aDevice->drawBitmap( rSrc.getBitmap(), aSrcRect, aDestRect, basebmp::DrawMode_PAINT, m_aClipMap );
     571         348 :     dbgOut( m_aDevice );
     572         348 : }
     573             : 
     574           0 : void SvpSalGraphics::drawBitmap( const SalTwoRect*,
     575             :                                  const SalBitmap&,
     576             :                                  SalColor )
     577             : {
     578             :     // SNI, as in X11 plugin
     579           0 : }
     580             : 
     581          14 : void SvpSalGraphics::drawBitmap( const SalTwoRect* pPosAry,
     582             :                                  const SalBitmap& rSalBitmap,
     583             :                                  const SalBitmap& rTransparentBitmap )
     584             : {
     585          14 :     const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBitmap);
     586          14 :     const SvpSalBitmap& rSrcTrans = static_cast<const SvpSalBitmap&>(rTransparentBitmap);
     587             :     basegfx::B2IBox aSrcRect( pPosAry->mnSrcX, pPosAry->mnSrcY,
     588             :                      pPosAry->mnSrcX+pPosAry->mnSrcWidth,
     589          14 :                      pPosAry->mnSrcY+pPosAry->mnSrcHeight );
     590             :     basegfx::B2IBox aDestRect( pPosAry->mnDestX, pPosAry->mnDestY,
     591             :                       pPosAry->mnDestX+pPosAry->mnDestWidth,
     592          14 :                       pPosAry->mnDestY+pPosAry->mnDestHeight );
     593          14 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     594          14 :     if( !isClippedSetup( aDestRect, aUndo ) )
     595          14 :         m_aDevice->drawMaskedBitmap( rSrc.getBitmap(), rSrcTrans.getBitmap(),
     596          28 :                                      aSrcRect, aDestRect, basebmp::DrawMode_PAINT, m_aClipMap );
     597          14 :     dbgOut( m_aDevice );
     598          14 : }
     599             : 
     600           0 : void SvpSalGraphics::drawMask( const SalTwoRect* pPosAry,
     601             :                                const SalBitmap& rSalBitmap,
     602             :                                SalColor nMaskColor )
     603             : {
     604           0 :     const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBitmap);
     605             :     basegfx::B2IBox aSrcRect( pPosAry->mnSrcX, pPosAry->mnSrcY,
     606             :                      pPosAry->mnSrcX+pPosAry->mnSrcWidth,
     607           0 :                      pPosAry->mnSrcY+pPosAry->mnSrcHeight );
     608           0 :     basegfx::B2IPoint aDestPoint( pPosAry->mnDestX, pPosAry->mnDestY );
     609             : 
     610             :     // BitmapDevice::drawMaskedColor works with 0==transparent,
     611             :     // 255==opaque. drawMask() semantic is the other way
     612             :     // around. Therefore, invert mask.
     613             :     basebmp::BitmapDeviceSharedPtr aCopy =
     614             :         cloneBitmapDevice( basegfx::B2IVector( pPosAry->mnSrcWidth, pPosAry->mnSrcHeight ),
     615           0 :                            rSrc.getBitmap() );
     616           0 :     basebmp::Color aBgColor( COL_WHITE );
     617           0 :     aCopy->clear(aBgColor);
     618           0 :     basebmp::Color aFgColor( COL_BLACK );
     619           0 :     aCopy->drawMaskedColor( aFgColor, rSrc.getBitmap(), aSrcRect, basegfx::B2IPoint() );
     620             : 
     621           0 :     basebmp::Color aColor( nMaskColor );
     622           0 :     basegfx::B2IBox aSrcRect2( 0, 0, pPosAry->mnSrcWidth, pPosAry->mnSrcHeight );
     623           0 :     const basegfx::B2IBox aClipRect( aDestPoint, basegfx::B2ITuple( aSrcRect.getWidth(), aSrcRect.getHeight() ) );
     624             : 
     625           0 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     626           0 :     if( !isClippedSetup( aClipRect, aUndo ) )
     627           0 :         m_aDevice->drawMaskedColor( aColor, aCopy, aSrcRect, aDestPoint, m_aClipMap );
     628           0 :     dbgOut( m_aDevice );
     629           0 : }
     630             : 
     631         478 : SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeight )
     632             : {
     633             :     basebmp::BitmapDeviceSharedPtr aCopy =
     634             :         cloneBitmapDevice( basegfx::B2IVector( nWidth, nHeight ),
     635         478 :                            m_aDevice );
     636         478 :     basegfx::B2IBox aSrcRect( nX, nY, nX+nWidth, nY+nHeight );
     637         478 :     basegfx::B2IBox aDestRect( 0, 0, nWidth, nHeight );
     638             : 
     639         478 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     640         478 :     if( !isClippedSetup( aDestRect, aUndo ) )
     641         412 :         aCopy->drawBitmap( m_aOrigDevice, aSrcRect, aDestRect, basebmp::DrawMode_PAINT );
     642             : 
     643         478 :     SvpSalBitmap* pBitmap = new SvpSalBitmap();
     644         478 :     pBitmap->setBitmap( aCopy );
     645         478 :     return pBitmap;
     646             : }
     647             : 
     648           0 : SalColor SvpSalGraphics::getPixel( long nX, long nY )
     649             : {
     650           0 :     basebmp::Color aColor( m_aOrigDevice->getPixel( basegfx::B2IPoint( nX, nY ) ) );
     651           0 :     return aColor.toInt32();
     652             : }
     653             : 
     654        2314 : void SvpSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert /*nFlags*/ )
     655             : {
     656             :     // FIXME: handle SAL_INVERT_50 and SAL_INVERT_TRACKFRAME
     657        2314 :     basegfx::B2DPolygon aRect = basegfx::tools::createPolygonFromRect( basegfx::B2DRectangle( nX, nY, nX+nWidth, nY+nHeight ) );
     658        2314 :     basegfx::B2DPolyPolygon aPolyPoly( aRect );
     659        2314 :     basegfx::B2IBox aDestRange( nX, nY, nX + nWidth, nY + nHeight );
     660             : 
     661        2314 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     662        2314 :     if( !isClippedSetup( aDestRange, aUndo ) )
     663        2314 :         m_aDevice->fillPolyPolygon( aPolyPoly, basebmp::Color( 0xffffff ), basebmp::DrawMode_XOR, m_aClipMap );
     664        2314 :     dbgOut( m_aDevice );
     665        2314 : }
     666             : 
     667           0 : void SvpSalGraphics::invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert /*nFlags*/ )
     668             : {
     669             :     // FIXME: handle SAL_INVERT_50 and SAL_INVERT_TRACKFRAME
     670           0 :     basegfx::B2DPolygon aPoly;
     671           0 :     aPoly.append( basegfx::B2DPoint( pPtAry->mnX, pPtAry->mnY ), nPoints );
     672           0 :     for( sal_uLong i = 1; i < nPoints; i++ )
     673           0 :         aPoly.setB2DPoint( i, basegfx::B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
     674           0 :     aPoly.setClosed( true );
     675           0 :     ensureClip(); // FIXME for ...
     676           0 :     m_aDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(aPoly), basebmp::Color( 0xffffff ), basebmp::DrawMode_XOR, m_aClipMap );
     677           0 :     dbgOut( m_aDevice );
     678           0 : }
     679             : 
     680           0 : sal_Bool SvpSalGraphics::drawEPS( long, long, long, long, void*, sal_uLong )
     681             : {
     682           0 :     return sal_False;
     683             : }
     684             : 
     685           0 : SystemFontData SvpSalGraphics::GetSysFontData( int nFallbacklevel ) const
     686             : {
     687           0 :     SystemFontData aSysFontData;
     688             : 
     689           0 :     if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1;
     690           0 :     if (nFallbacklevel < 0 ) nFallbacklevel = 0;
     691             : 
     692           0 :     aSysFontData.nSize = sizeof( SystemFontData );
     693           0 :     aSysFontData.nFontId = 0;
     694           0 :     aSysFontData.nFontFlags = 0;
     695           0 :     aSysFontData.bFakeBold = false;
     696           0 :     aSysFontData.bFakeItalic = false;
     697           0 :     aSysFontData.bAntialias = true;
     698           0 :     return aSysFontData;
     699             : }
     700             : 
     701           8 : SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
     702             : {
     703           8 :     return SystemGraphicsData();
     704             : }
     705             : 
     706         413 : bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const
     707             : {
     708         413 :     return false;
     709             : }
     710             : 
     711             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10