LCOV - code coverage report
Current view: top level - libreoffice/vcl/headless - svpgdi.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 244 332 73.5 %
Date: 2012-12-27 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      210140 : 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      210140 : }
      63             : 
      64             : // ===========================================================================
      65             : 
      66           2 : bool SvpSalGraphics::drawAlphaBitmap( const SalTwoRect&, const SalBitmap& /*rSourceBitmap*/, const SalBitmap& /*rAlphaBitmap*/ )
      67             : {
      68             :     // TODO(P3) implement alpha blending
      69           2 :     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       16560 : 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       16560 :     m_bClipSetup( false )
      87             : {
      88      281520 :     for( int i = 0; i < MAX_FALLBACK; ++i )
      89      264960 :         m_pServerFont[i] = NULL;
      90       16560 : }
      91             : 
      92       17680 : SvpSalGraphics::~SvpSalGraphics()
      93             : {
      94       17680 : }
      95             : 
      96       17360 : void SvpSalGraphics::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice )
      97             : {
      98       17360 :     m_aOrigDevice = rDevice;
      99       17360 :     ResetClipRegion();
     100             : 
     101             :     // determine matching bitmap format for masks
     102       17360 :     sal_uInt32 nDeviceFmt = m_aDevice->getScanlineFormat();
     103             :     DBG_ASSERT( (nDeviceFmt <= (sal_uInt32)basebmp::Format::MAX), "SVP::setDevice() with invalid bitmap format" );
     104       17360 :     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       16930 :             m_eTextFmt = basebmp::Format::EIGHT_BIT_GREY;
     115       16930 :             break;
     116             :         default:
     117         430 :             m_eTextFmt = basebmp::Format::ONE_BIT_LSB_GREY;
     118         430 :             break;
     119             :     }
     120       17360 : }
     121             : 
     122         267 : void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
     123             : {
     124         267 :     rDPIX = rDPIY = 96;
     125         267 : }
     126             : 
     127        9218 : sal_uInt16 SvpSalGraphics::GetBitCount() const
     128             : {
     129        9218 :     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       17575 : void SvpSalGraphics::ResetClipRegion()
     143             : {
     144       17575 :     m_aDevice = m_aOrigDevice;
     145       17575 :     m_aClipMap.reset();
     146       17575 :     m_bClipSetup = true;
     147       17575 :     m_aClipRegion.SetNull();
     148       17575 : }
     149             : 
     150             : 
     151             : // verify clip for the whole area is setup
     152      207150 : void SvpSalGraphics::ensureClip()
     153             : {
     154      207150 :     if (m_bClipSetup)
     155      207150 :         return;
     156             : 
     157          10 :     m_aDevice = m_aOrigDevice;
     158          10 :     basegfx::B2IVector aSize = m_aDevice->getSize();
     159          10 :     m_aClipMap = basebmp::createBitmapDevice( aSize, false, basebmp::Format::ONE_BIT_MSB_GREY );
     160          10 :     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          10 :     bool bRegionRect = m_aClipRegion.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
     167          41 :     while( bRegionRect )
     168             :     {
     169          21 :         if ( nW && nH )
     170             :         {
     171          21 :             basegfx::B2DPolyPolygon aFull;
     172          21 :             aFull.append( basegfx::tools::createPolygonFromRect( basegfx::B2DRectangle( nX, nY, nX+nW, nY+nH ) ) );
     173          21 :             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          21 :         bRegionRect = m_aClipRegion.ImplGetNextRect( aInfo, nX, nY, nW, nH );
     177             :     }
     178          10 :     m_bClipSetup = true;
     179             : }
     180             : 
     181       37700 : SvpSalGraphics::ClipUndoHandle::~ClipUndoHandle()
     182             : {
     183       18850 :     if( m_aDevice.get() )
     184           8 :         m_rGfx.m_aDevice = m_aDevice;
     185       18850 : }
     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       18850 : bool SvpSalGraphics::isClippedSetup( const basegfx::B2IBox &aRange, SvpSalGraphics::ClipUndoHandle &rUndo )
     193             : {
     194       18850 :     if( m_bClipSetup )
     195       18842 :         return false;
     196             : 
     197           8 :     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           8 :                      Size( aRange.getWidth(), aRange.getHeight() ) );
     207             : 
     208             :     // then see if we are overlapping with just one
     209           8 :     int nHit = 0;
     210           8 :     Rectangle aIterRect, aHitRect;
     211           8 :     RegionHandle aHnd = m_aClipRegion.BeginEnumRects();
     212          32 :     while( m_aClipRegion.GetNextEnumRect( aHnd, aIterRect ) )
     213             :     {
     214          16 :         if( aIterRect.IsOver( aRect ) )
     215             :         {
     216           8 :             aHitRect = aIterRect;
     217           8 :             nHit++;
     218             :         }
     219             :     }
     220           8 :     m_aClipRegion.EndEnumRects (aHnd);
     221             : 
     222           8 :     if( nHit == 0 ) // rendering outside any clipping region
     223             :     {
     224             : //        fprintf (stderr, "denegerate case detected ...\n");
     225           0 :         return true;
     226             :     }
     227           8 :     else if( nHit == 1 ) // common path: rendering against just one clipping region
     228             :     {
     229           8 :         if( aHitRect.IsInside( aRect ) )
     230             :         {
     231             : //        fprintf (stderr, " is inside ! avoid deeper clip ...\n");
     232           0 :             return false;
     233             :         }
     234             : //    fprintf (stderr, " operation only overlaps with a single clip zone\n" );
     235           8 :         rUndo.m_aDevice = m_aDevice;
     236             :         m_aDevice = basebmp::subsetBitmapDevice( m_aOrigDevice,
     237           8 :                                                  basegfx::B2IBox (aHitRect.Left(),
     238           8 :                                                                   aHitRect.Top(),
     239           8 :                                                                   aHitRect.Right(),
     240          32 :                                                                   aHitRect.Bottom()) );
     241           8 :         return false;
     242             :     }
     243             : //    fprintf (stderr, "URK: complex & slow clipping case\n" );
     244             :     // horribly slow & complicated case ...
     245             : 
     246           0 :     ensureClip();
     247           0 :     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        8851 : bool SvpSalGraphics::setClipRegion( const Region& i_rClip )
     263             : {
     264        8851 :     m_aClipRegion = i_rClip;
     265        8851 :     m_aClipMap.reset();
     266        8851 :     if( i_rClip.IsEmpty() )
     267           0 :         m_bClipSetup = true;
     268             : 
     269        8851 :     else if( i_rClip.GetRectCount() == 1 )
     270             :     {
     271        8833 :         m_aClipMap.reset();
     272        8833 :         Rectangle aBoundRect( i_rClip.GetBoundRect() );
     273             :         m_aDevice = basebmp::subsetBitmapDevice( m_aOrigDevice,
     274        8833 :                                                  basegfx::B2IBox(aBoundRect.Left(),aBoundRect.Top(),aBoundRect.Right(),aBoundRect.Bottom()) );
     275        8833 :         m_bClipSetup = true;
     276             :     }
     277             :     else
     278          18 :         m_bClipSetup = false;
     279             : 
     280        8851 :     return true;
     281             : }
     282             : 
     283       17572 : void SvpSalGraphics::SetLineColor()
     284             : {
     285       17572 :     m_bUseLineColor = false;
     286       17572 : }
     287             : 
     288       22176 : void SvpSalGraphics::SetLineColor( SalColor nSalColor )
     289             : {
     290       22176 :     m_bUseLineColor = true;
     291       22176 :     m_aLineColor = basebmp::Color( nSalColor );
     292       22176 : }
     293             : 
     294          21 : void SvpSalGraphics::SetFillColor()
     295             : {
     296          21 :     m_bUseFillColor = false;
     297          21 : }
     298             : 
     299       67654 : void SvpSalGraphics::SetFillColor( SalColor nSalColor )
     300             : {
     301       67654 :     m_bUseFillColor = true;
     302       67654 :     m_aFillColor = basebmp::Color( nSalColor );
     303       67654 : }
     304             : 
     305       16429 : void SvpSalGraphics::SetXORMode( bool bSet, bool )
     306             : {
     307       16429 :     m_aDrawMode = bSet ? basebmp::DrawMode_XOR : basebmp::DrawMode_PAINT;
     308       16429 : }
     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        1330 : void SvpSalGraphics::SetTextColor( SalColor nSalColor )
     345             : {
     346        1330 :     m_aTextColor = basebmp::Color( nSalColor );
     347        1330 : }
     348             : 
     349        4241 : void SvpSalGraphics::drawPixel( long nX, long nY )
     350             : {
     351        4241 :     if( m_bUseLineColor )
     352             :     {
     353        4241 :         ensureClip();
     354             :         m_aDevice->setPixel( basegfx::B2IPoint( nX, nY ),
     355             :                              m_aLineColor,
     356             :                              m_aDrawMode,
     357             :                              m_aClipMap
     358        4241 :                              );
     359             :     }
     360        4241 :     dbgOut( m_aDevice );
     361        4241 : }
     362             : 
     363       21105 : void SvpSalGraphics::drawPixel( long nX, long nY, SalColor nSalColor )
     364             : {
     365       21105 :     basebmp::Color aColor( nSalColor );
     366       21105 :     ensureClip();
     367             :     m_aDevice->setPixel( basegfx::B2IPoint( nX, nY ),
     368             :                          aColor,
     369             :                          m_aDrawMode,
     370             :                          m_aClipMap
     371       21105 :                          );
     372       21105 :     dbgOut( m_aDevice );
     373       21105 : }
     374             : 
     375      101150 : void SvpSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
     376             : {
     377      101150 :     if( m_bUseLineColor )
     378             :     {
     379      101150 :         ensureClip(); // FIXME: for ...
     380             :         m_aDevice->drawLine( basegfx::B2IPoint( nX1, nY1 ),
     381             :                              basegfx::B2IPoint( nX2, nY2 ),
     382             :                              m_aLineColor,
     383             :                              m_aDrawMode,
     384      101150 :                              m_aClipMap );
     385             :     }
     386      101150 :     dbgOut( m_aDevice );
     387      101150 : }
     388             : 
     389       30500 : void SvpSalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight )
     390             : {
     391       30500 :     if( m_bUseLineColor || m_bUseFillColor )
     392             :     {
     393       30500 :         basegfx::B2DPolygon aRect = basegfx::tools::createPolygonFromRect( basegfx::B2DRectangle( nX, nY, nX+nWidth, nY+nHeight ) );
     394       30500 :         ensureClip(); // FIXME: for ...
     395       30500 :         if( m_bUseFillColor )
     396             :         {
     397       30500 :             basegfx::B2DPolyPolygon aPolyPoly( aRect );
     398       30500 :             m_aDevice->fillPolyPolygon( aPolyPoly, m_aFillColor, m_aDrawMode, m_aClipMap );
     399             :         }
     400       30500 :         if( m_bUseLineColor )
     401           3 :             m_aDevice->drawPolygon( aRect, m_aLineColor, m_aDrawMode, m_aClipMap );
     402             :     }
     403       30500 :     dbgOut( m_aDevice );
     404       30500 : }
     405             : 
     406        2884 : void SvpSalGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry )
     407             : {
     408        2884 :     if( m_bUseLineColor && nPoints )
     409             :     {
     410        2884 :         basegfx::B2DPolygon aPoly;
     411        2884 :         aPoly.append( basegfx::B2DPoint( pPtAry->mnX, pPtAry->mnY ), nPoints );
     412        6898 :         for( sal_uLong i = 1; i < nPoints; i++ )
     413        4014 :             aPoly.setB2DPoint( i, basegfx::B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
     414        2884 :         aPoly.setClosed( false );
     415        2884 :         ensureClip(); // FIXME: for ...
     416        2884 :         m_aDevice->drawPolygon( aPoly, m_aLineColor, m_aDrawMode, m_aClipMap );
     417             :     }
     418        2884 :     dbgOut( m_aDevice );
     419        2884 : }
     420             : 
     421       47265 : void SvpSalGraphics::drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry )
     422             : {
     423       47265 :     if( ( m_bUseLineColor || m_bUseFillColor ) && nPoints )
     424             :     {
     425       47265 :         basegfx::B2DPolygon aPoly;
     426       47265 :         aPoly.append( basegfx::B2DPoint( pPtAry->mnX, pPtAry->mnY ), nPoints );
     427      201754 :         for( sal_uLong i = 1; i < nPoints; i++ )
     428      154489 :             aPoly.setB2DPoint( i, basegfx::B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
     429       47265 :         ensureClip(); // FIXME: for ...
     430       47265 :         if( m_bUseFillColor )
     431             :         {
     432       47263 :             aPoly.setClosed( true );
     433       47263 :             m_aDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(aPoly), m_aFillColor, m_aDrawMode, m_aClipMap );
     434             :         }
     435       47265 :         if( m_bUseLineColor )
     436             :         {
     437          37 :             aPoly.setClosed( false );
     438          37 :             m_aDevice->drawPolygon( aPoly, m_aLineColor, m_aDrawMode, m_aClipMap );
     439       47265 :         }
     440             :     }
     441       47265 :     dbgOut( m_aDevice );
     442       47265 : }
     443             : 
     444           5 : void SvpSalGraphics::drawPolyPolygon( sal_uInt32        nPoly,
     445             :                                       const sal_uInt32* pPointCounts,
     446             :                                       PCONSTSALPOINT*   pPtAry )
     447             : {
     448           5 :     if( ( m_bUseLineColor || m_bUseFillColor ) && nPoly )
     449             :     {
     450           5 :         basegfx::B2DPolyPolygon aPolyPoly;
     451          15 :         for( sal_uInt32 nPolygon = 0; nPolygon < nPoly; nPolygon++ )
     452             :         {
     453          10 :             sal_uInt32 nPoints = pPointCounts[nPolygon];
     454          10 :             if( nPoints )
     455             :             {
     456          10 :                 PCONSTSALPOINT pPoints = pPtAry[nPolygon];
     457          10 :                 basegfx::B2DPolygon aPoly;
     458          10 :                 aPoly.append( basegfx::B2DPoint( pPoints->mnX, pPoints->mnY ), nPoints );
     459         156 :                 for( sal_uInt32 i = 1; i < nPoints; i++ )
     460         146 :                     aPoly.setB2DPoint( i, basegfx::B2DPoint( pPoints[i].mnX, pPoints[i].mnY ) );
     461             : 
     462          10 :                 aPolyPoly.append( aPoly );
     463             :             }
     464             :         }
     465           5 :         ensureClip(); // FIXME: for ...
     466           5 :         if( m_bUseFillColor )
     467             :         {
     468           5 :             aPolyPoly.setClosed( true );
     469           5 :             m_aDevice->fillPolyPolygon( aPolyPoly, m_aFillColor, m_aDrawMode, m_aClipMap );
     470             :         }
     471           5 :         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           5 :         }
     478             :     }
     479           5 :     dbgOut( m_aDevice );
     480           5 : }
     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           6 : sal_Bool SvpSalGraphics::drawPolygonBezier( sal_uLong,
     501             :                                             const SalPoint*,
     502             :                                             const sal_uInt8* )
     503             : {
     504           6 :     return sal_False;
     505             : }
     506             : 
     507           5 : sal_Bool SvpSalGraphics::drawPolyPolygonBezier( sal_uInt32,
     508             :                                                 const sal_uInt32*,
     509             :                                                 const SalPoint* const*,
     510             :                                                 const sal_uInt8* const* )
     511             : {
     512           5 :     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           8 : 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           8 :     basegfx::B2IBox aSrcRect( nSrcX, nSrcY, nSrcX+nSrcWidth, nSrcY+nSrcHeight );
     530           8 :     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           8 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     534           8 :     if( !isClippedSetup( aDestRect, aUndo ) )
     535           8 :         m_aDevice->drawBitmap( m_aOrigDevice, aSrcRect, aDestRect, basebmp::DrawMode_PAINT, m_aClipMap );
     536           8 :     dbgOut( m_aDevice );
     537           8 : }
     538             : 
     539        1836 : void SvpSalGraphics::copyBits( const SalTwoRect* pPosAry,
     540             :                                SalGraphics*      pSrcGraphics )
     541             : {
     542             :     SvpSalGraphics* pSrc = pSrcGraphics ?
     543        1836 :         static_cast<SvpSalGraphics*>(pSrcGraphics) : this;
     544             :     basegfx::B2IBox aSrcRect( pPosAry->mnSrcX, pPosAry->mnSrcY,
     545             :                      pPosAry->mnSrcX+pPosAry->mnSrcWidth,
     546        1836 :                      pPosAry->mnSrcY+pPosAry->mnSrcHeight );
     547             :     basegfx::B2IBox aDestRect( pPosAry->mnDestX, pPosAry->mnDestY,
     548             :                       pPosAry->mnDestX+pPosAry->mnDestWidth,
     549        1836 :                       pPosAry->mnDestY+pPosAry->mnDestHeight );
     550             : 
     551        1836 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     552        1836 :     if( !isClippedSetup( aDestRect, aUndo ) )
     553        1836 :         m_aDevice->drawBitmap( pSrc->m_aOrigDevice, aSrcRect, aDestRect, basebmp::DrawMode_PAINT, m_aClipMap );
     554        1836 :     dbgOut( m_aDevice );
     555        1836 : }
     556             : 
     557          10 : void SvpSalGraphics::drawBitmap( const SalTwoRect* pPosAry,
     558             :                                  const SalBitmap& rSalBitmap )
     559             : {
     560          10 :     const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBitmap);
     561             :     basegfx::B2IBox aSrcRect( pPosAry->mnSrcX, pPosAry->mnSrcY,
     562             :                      pPosAry->mnSrcX+pPosAry->mnSrcWidth,
     563          10 :                      pPosAry->mnSrcY+pPosAry->mnSrcHeight );
     564             :     basegfx::B2IBox aDestRect( pPosAry->mnDestX, pPosAry->mnDestY,
     565             :                       pPosAry->mnDestX+pPosAry->mnDestWidth,
     566          10 :                       pPosAry->mnDestY+pPosAry->mnDestHeight );
     567             : 
     568          10 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     569          10 :     if( !isClippedSetup( aDestRect, aUndo ) )
     570          10 :         m_aDevice->drawBitmap( rSrc.getBitmap(), aSrcRect, aDestRect, basebmp::DrawMode_PAINT, m_aClipMap );
     571          10 :     dbgOut( m_aDevice );
     572          10 : }
     573             : 
     574           0 : void SvpSalGraphics::drawBitmap( const SalTwoRect*,
     575             :                                  const SalBitmap&,
     576             :                                  SalColor )
     577             : {
     578             :     // SNI, as in X11 plugin
     579           0 : }
     580             : 
     581           4 : void SvpSalGraphics::drawBitmap( const SalTwoRect* pPosAry,
     582             :                                  const SalBitmap& rSalBitmap,
     583             :                                  const SalBitmap& rTransparentBitmap )
     584             : {
     585           4 :     const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBitmap);
     586           4 :     const SvpSalBitmap& rSrcTrans = static_cast<const SvpSalBitmap&>(rTransparentBitmap);
     587             :     basegfx::B2IBox aSrcRect( pPosAry->mnSrcX, pPosAry->mnSrcY,
     588             :                      pPosAry->mnSrcX+pPosAry->mnSrcWidth,
     589           4 :                      pPosAry->mnSrcY+pPosAry->mnSrcHeight );
     590             :     basegfx::B2IBox aDestRect( pPosAry->mnDestX, pPosAry->mnDestY,
     591             :                       pPosAry->mnDestX+pPosAry->mnDestWidth,
     592           4 :                       pPosAry->mnDestY+pPosAry->mnDestHeight );
     593           4 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     594           4 :     if( !isClippedSetup( aDestRect, aUndo ) )
     595           4 :         m_aDevice->drawMaskedBitmap( rSrc.getBitmap(), rSrcTrans.getBitmap(),
     596           8 :                                      aSrcRect, aDestRect, basebmp::DrawMode_PAINT, m_aClipMap );
     597           4 :     dbgOut( m_aDevice );
     598           4 : }
     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          69 : SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeight )
     632             : {
     633             :     basebmp::BitmapDeviceSharedPtr aCopy =
     634             :         cloneBitmapDevice( basegfx::B2IVector( nWidth, nHeight ),
     635          69 :                            m_aDevice );
     636          69 :     basegfx::B2IBox aSrcRect( nX, nY, nX+nWidth, nY+nHeight );
     637          69 :     basegfx::B2IBox aDestRect( 0, 0, nWidth, nHeight );
     638             : 
     639          69 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     640          69 :     if( !isClippedSetup( aDestRect, aUndo ) )
     641          69 :         aCopy->drawBitmap( m_aOrigDevice, aSrcRect, aDestRect, basebmp::DrawMode_PAINT );
     642             : 
     643          69 :     SvpSalBitmap* pBitmap = new SvpSalBitmap();
     644          69 :     pBitmap->setBitmap( aCopy );
     645          69 :     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        1132 : 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        1132 :     basegfx::B2DPolygon aRect = basegfx::tools::createPolygonFromRect( basegfx::B2DRectangle( nX, nY, nX+nWidth, nY+nHeight ) );
     658        1132 :     basegfx::B2DPolyPolygon aPolyPoly( aRect );
     659        1132 :     basegfx::B2IBox aDestRange( nX, nY, nX + nWidth, nY + nHeight );
     660             : 
     661        1132 :     SvpSalGraphics::ClipUndoHandle aUndo( this );
     662        1132 :     if( !isClippedSetup( aDestRange, aUndo ) )
     663        1132 :         m_aDevice->fillPolyPolygon( aPolyPoly, basebmp::Color( 0xffffff ), basebmp::DrawMode_XOR, m_aClipMap );
     664        1132 :     dbgOut( m_aDevice );
     665        1132 : }
     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           4 : SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
     702             : {
     703           4 :     return SystemGraphicsData();
     704             : }
     705             : 
     706           9 : bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const
     707             : {
     708           9 :     return false;
     709             : }
     710             : 
     711             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10