xref: /aoo41x/main/vcl/unx/headless/svpgdi.cxx (revision 54ae6a37)
19f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59f62ea84SAndrew Rist  * distributed with this work for additional information
69f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
109f62ea84SAndrew Rist  *
119f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
129f62ea84SAndrew Rist  *
139f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist  * software distributed under the License is distributed on an
159f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
179f62ea84SAndrew Rist  * specific language governing permissions and limitations
189f62ea84SAndrew Rist  * under the License.
199f62ea84SAndrew Rist  *
209f62ea84SAndrew Rist  *************************************************************/
219f62ea84SAndrew Rist 
229f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "svpgdi.hxx"
25cdf0e10cSrcweir #include "svpbmp.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vcl/sysdata.hxx>
28cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx>
29cdf0e10cSrcweir #include <basegfx/range/b2irange.hxx>
30cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx>
31cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
32cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
33cdf0e10cSrcweir #include <basebmp/scanlineformats.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 2
38cdf0e10cSrcweir #include <basebmp/debug.hxx>
39cdf0e10cSrcweir #include <fstream>
40cdf0e10cSrcweir #include <rtl/strbuf.hxx>
41cdf0e10cSrcweir #include <sys/stat.h>
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <svppspgraphics.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace basegfx;
47cdf0e10cSrcweir using namespace basebmp;
48cdf0e10cSrcweir 
dbgOut(const BitmapDeviceSharedPtr & rDevice)49cdf0e10cSrcweir inline void dbgOut( const BitmapDeviceSharedPtr&
50cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 2
51cdf0e10cSrcweir rDevice
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir     #if OSL_DEBUG_LEVEL > 2
56cdf0e10cSrcweir     static int dbgStreamNum = 0;
57cdf0e10cSrcweir     rtl::OStringBuffer aBuf( 256 );
58cdf0e10cSrcweir     aBuf.append( "debug" );
59cdf0e10cSrcweir     mkdir( aBuf.getStr(), 0777 );
60cdf0e10cSrcweir     aBuf.append( "/" );
61cdf0e10cSrcweir     aBuf.append( sal_Int64(reinterpret_cast<sal_uInt32>(rDevice.get())), 16 );
62cdf0e10cSrcweir     mkdir( aBuf.getStr(), 0777 );
63cdf0e10cSrcweir     aBuf.append( "/bmp" );
64cdf0e10cSrcweir     aBuf.append( sal_Int32(dbgStreamNum++) );
65cdf0e10cSrcweir     std::fstream bmpstream( aBuf.getStr(), std::ios::out );
66cdf0e10cSrcweir     debugDump( rDevice, bmpstream );
67cdf0e10cSrcweir     #endif
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir // ===========================================================================
71cdf0e10cSrcweir 
drawAlphaBitmap(const SalTwoRect &,const SalBitmap &,const SalBitmap &)72cdf0e10cSrcweir bool SvpSalGraphics::drawAlphaBitmap( const SalTwoRect&, const SalBitmap& /*rSourceBitmap*/, const SalBitmap& /*rAlphaBitmap*/ )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	// TODO(P3) implement alpha blending
75cdf0e10cSrcweir 	return false;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
drawTransformedBitmap(const basegfx::B2DPoint & rNull,const basegfx::B2DPoint & rX,const basegfx::B2DPoint & rY,const SalBitmap & rSourceBitmap,const SalBitmap * pAlphaBitmap)785f27b83cSArmin Le Grand bool SvpSalGraphics::drawTransformedBitmap(
795f27b83cSArmin Le Grand     const basegfx::B2DPoint& rNull,
805f27b83cSArmin Le Grand     const basegfx::B2DPoint& rX,
815f27b83cSArmin Le Grand     const basegfx::B2DPoint& rY,
825f27b83cSArmin Le Grand     const SalBitmap& rSourceBitmap,
835f27b83cSArmin Le Grand     const SalBitmap* pAlphaBitmap)
845f27b83cSArmin Le Grand {
855f27b83cSArmin Le Grand     // here direct support for transformed bitmaps can be impemented
865f27b83cSArmin Le Grand     (void)rNull; (void)rX; (void)rY; (void)rSourceBitmap; (void)pAlphaBitmap;
875f27b83cSArmin Le Grand     return false;
885f27b83cSArmin Le Grand }
895f27b83cSArmin Le Grand 
drawAlphaRect(long,long,long,long,sal_uInt8)90cdf0e10cSrcweir bool SvpSalGraphics::drawAlphaRect( long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, sal_uInt8 /*nTransparency*/ )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	// TODO(P3) implement alpha blending
93cdf0e10cSrcweir 	return false;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
SvpSalGraphics()96cdf0e10cSrcweir SvpSalGraphics::SvpSalGraphics() :
97cdf0e10cSrcweir     m_bUseLineColor( true ),
98cdf0e10cSrcweir     m_aLineColor( COL_BLACK ),
99cdf0e10cSrcweir     m_bUseFillColor( false ),
100cdf0e10cSrcweir     m_aFillColor( COL_WHITE ),
101cdf0e10cSrcweir     m_aTextColor( COL_BLACK ),
102cdf0e10cSrcweir     m_aDrawMode( DrawMode_PAINT ),
103cdf0e10cSrcweir     m_eTextFmt( Format::EIGHT_BIT_GREY )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir     for( int i = 0; i < MAX_FALLBACK; ++i )
106cdf0e10cSrcweir         m_pServerFont[i] = NULL;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
~SvpSalGraphics()109cdf0e10cSrcweir SvpSalGraphics::~SvpSalGraphics()
110cdf0e10cSrcweir {
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
setDevice(BitmapDeviceSharedPtr & rDevice)113cdf0e10cSrcweir void SvpSalGraphics::setDevice( BitmapDeviceSharedPtr& rDevice )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     m_aDevice = rDevice;
116cdf0e10cSrcweir     m_aOrigDevice = rDevice;
117cdf0e10cSrcweir     m_aClipMap.reset();
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     // determine matching bitmap format for masks
120cdf0e10cSrcweir     sal_uInt32 nDeviceFmt = m_aDevice->getScanlineFormat();
121cdf0e10cSrcweir     DBG_ASSERT( (nDeviceFmt <= (sal_uInt32)Format::MAX), "SVP::setDevice() with invalid bitmap format" );
122cdf0e10cSrcweir     switch( nDeviceFmt )
123cdf0e10cSrcweir     {
124cdf0e10cSrcweir         case Format::EIGHT_BIT_GREY:
125cdf0e10cSrcweir         case Format::SIXTEEN_BIT_LSB_TC_MASK:
126cdf0e10cSrcweir         case Format::SIXTEEN_BIT_MSB_TC_MASK:
127cdf0e10cSrcweir         case Format::TWENTYFOUR_BIT_TC_MASK:
128cdf0e10cSrcweir         case Format::THIRTYTWO_BIT_TC_MASK:
129cdf0e10cSrcweir             m_eTextFmt = Format::EIGHT_BIT_GREY;
130cdf0e10cSrcweir             break;
131cdf0e10cSrcweir         default:
132cdf0e10cSrcweir             m_eTextFmt = Format::ONE_BIT_LSB_GREY;
133cdf0e10cSrcweir             break;
134cdf0e10cSrcweir     }
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
GetResolution(sal_Int32 & rDPIX,sal_Int32 & rDPIY)137cdf0e10cSrcweir void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     rDPIX = rDPIY = 96;
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
GetBitCount()142cdf0e10cSrcweir sal_uInt16 SvpSalGraphics::GetBitCount()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir     return SvpElement::getBitCountFromScanlineFormat( m_aDevice->getScanlineFormat() );
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
GetGraphicsWidth() const147cdf0e10cSrcweir long SvpSalGraphics::GetGraphicsWidth() const
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     if( m_aDevice.get() )
150cdf0e10cSrcweir     {
151cdf0e10cSrcweir         B2IVector aSize = m_aDevice->getSize();
152cdf0e10cSrcweir         return aSize.getX();
153cdf0e10cSrcweir     }
154cdf0e10cSrcweir     return 0;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
ResetClipRegion()157cdf0e10cSrcweir void SvpSalGraphics::ResetClipRegion()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     m_aDevice = m_aOrigDevice;
160cdf0e10cSrcweir     m_aClipMap.reset();
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
setClipRegion(const Region & i_rClip)1635f27b83cSArmin Le Grand bool SvpSalGraphics::setClipRegion( const Region& i_rClip )
1645f27b83cSArmin Le Grand {
1655f27b83cSArmin Le Grand     if( i_rClip.IsEmpty() )
1665f27b83cSArmin Le Grand     {
1675f27b83cSArmin Le Grand         m_aClipMap.reset();
1685f27b83cSArmin Le Grand         return true;
1695f27b83cSArmin Le Grand     }
1705f27b83cSArmin Le Grand 
1715f27b83cSArmin Le Grand     RectangleVector aRectangles;
1725f27b83cSArmin Le Grand     i_rClip.GetRegionRectangles(aRectangles);
1735f27b83cSArmin Le Grand 
1745f27b83cSArmin Le Grand     if(1 == aRectangles.size())
1755f27b83cSArmin Le Grand     {
1765f27b83cSArmin Le Grand         m_aClipMap.reset();
1775f27b83cSArmin Le Grand         const Rectangle& aBoundRect = aRectangles[0];
1785f27b83cSArmin Le Grand         m_aDevice = basebmp::subsetBitmapDevice(
1795f27b83cSArmin Le Grand             m_aOrigDevice,
1805f27b83cSArmin Le Grand             basegfx::B2IRange(aBoundRect.Left(),aBoundRect.Top(),aBoundRect.Right(),aBoundRect.Bottom()) );
1815f27b83cSArmin Le Grand         return true;
1825f27b83cSArmin Le Grand     }
1835f27b83cSArmin Le Grand 
1845f27b83cSArmin Le Grand     m_aDevice = m_aOrigDevice;
1855f27b83cSArmin Le Grand     B2IVector aSize = m_aDevice->getSize();
1865f27b83cSArmin Le Grand     m_aClipMap = createBitmapDevice( aSize, false, Format::ONE_BIT_MSB_GREY );
1875f27b83cSArmin Le Grand     m_aClipMap->clear( basebmp::Color(0xFFFFFFFF) );
1885f27b83cSArmin Le Grand 
1895f27b83cSArmin Le Grand     for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++)
1905f27b83cSArmin Le Grand     {
1915f27b83cSArmin Le Grand         const long nW(aRectIter->GetWidth());
1925f27b83cSArmin Le Grand 
1935f27b83cSArmin Le Grand         if(nW)
1945f27b83cSArmin Le Grand         {
1955f27b83cSArmin Le Grand             const long nH(aRectIter->GetHeight());
1965f27b83cSArmin Le Grand 
1975f27b83cSArmin Le Grand             if(nH)
1985f27b83cSArmin Le Grand             {
1995f27b83cSArmin Le Grand                 B2DPolyPolygon aFull;
2005f27b83cSArmin Le Grand 
2015f27b83cSArmin Le Grand                 aFull.append(
2025f27b83cSArmin Le Grand                     tools::createPolygonFromRect(
2035f27b83cSArmin Le Grand                         B2DRectangle(
2045f27b83cSArmin Le Grand                             aRectIter->Left(),
2055f27b83cSArmin Le Grand                             aRectIter->Top(),
2065f27b83cSArmin Le Grand                             aRectIter->Left() + nW,
2075f27b83cSArmin Le Grand                             aRectIter->Top() + nH)));
2085f27b83cSArmin Le Grand                 m_aClipMap->fillPolyPolygon(aFull, basebmp::Color(0), DrawMode_PAINT);
2095f27b83cSArmin Le Grand             }
2105f27b83cSArmin Le Grand         }
2115f27b83cSArmin Le Grand     }
2125f27b83cSArmin Le Grand 
2135f27b83cSArmin Le Grand     //ImplRegionInfo aInfo;
2145f27b83cSArmin Le Grand     //long nX, nY, nW, nH;
2155f27b83cSArmin Le Grand     //bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
2165f27b83cSArmin Le Grand     //while( bRegionRect )
2175f27b83cSArmin Le Grand     //{
2185f27b83cSArmin Le Grand     //    if ( nW && nH )
2195f27b83cSArmin Le Grand     //    {
2205f27b83cSArmin Le Grand     //        B2DPolyPolygon aFull;
2215f27b83cSArmin Le Grand     //        aFull.append( tools::createPolygonFromRect( B2DRectangle( nX, nY, nX+nW, nY+nH ) ) );
2225f27b83cSArmin Le Grand     //        m_aClipMap->fillPolyPolygon( aFull, basebmp::Color(0), DrawMode_PAINT );
2235f27b83cSArmin Le Grand     //    }
2245f27b83cSArmin Le Grand     //    bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH );
2255f27b83cSArmin Le Grand     //}
2265f27b83cSArmin Le Grand     return true;
2275f27b83cSArmin Le Grand }
228cdf0e10cSrcweir 
SetLineColor()229cdf0e10cSrcweir void SvpSalGraphics::SetLineColor()
230cdf0e10cSrcweir {
231cdf0e10cSrcweir     m_bUseLineColor = false;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
SetLineColor(SalColor nSalColor)234cdf0e10cSrcweir void SvpSalGraphics::SetLineColor( SalColor nSalColor )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir     m_bUseLineColor = true;
237cdf0e10cSrcweir     m_aLineColor = basebmp::Color( nSalColor );
238cdf0e10cSrcweir }
239cdf0e10cSrcweir 
SetFillColor()240cdf0e10cSrcweir void SvpSalGraphics::SetFillColor()
241cdf0e10cSrcweir {
242cdf0e10cSrcweir     m_bUseFillColor = false;
243cdf0e10cSrcweir }
244cdf0e10cSrcweir 
SetFillColor(SalColor nSalColor)245cdf0e10cSrcweir void SvpSalGraphics::SetFillColor( SalColor nSalColor )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir     m_bUseFillColor = true;
248cdf0e10cSrcweir     m_aFillColor = basebmp::Color( nSalColor );
249cdf0e10cSrcweir }
250cdf0e10cSrcweir 
SetXORMode(bool bSet,bool)251cdf0e10cSrcweir void SvpSalGraphics::SetXORMode( bool bSet, bool )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir     m_aDrawMode = bSet ? DrawMode_XOR : DrawMode_PAINT;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
SetROPLineColor(SalROPColor nROPColor)256cdf0e10cSrcweir void SvpSalGraphics::SetROPLineColor( SalROPColor nROPColor )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir     m_bUseLineColor = true;
259cdf0e10cSrcweir     switch( nROPColor )
260cdf0e10cSrcweir     {
261cdf0e10cSrcweir         case SAL_ROP_0:
262cdf0e10cSrcweir             m_aLineColor = basebmp::Color( 0 );
263cdf0e10cSrcweir             break;
264cdf0e10cSrcweir         case SAL_ROP_1:
265cdf0e10cSrcweir             m_aLineColor = basebmp::Color( 0xffffff );
266cdf0e10cSrcweir             break;
267cdf0e10cSrcweir         case SAL_ROP_INVERT:
268cdf0e10cSrcweir             m_aLineColor = basebmp::Color( 0xffffff );
269cdf0e10cSrcweir             break;
270cdf0e10cSrcweir     }
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
SetROPFillColor(SalROPColor nROPColor)273cdf0e10cSrcweir void SvpSalGraphics::SetROPFillColor( SalROPColor nROPColor )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     m_bUseFillColor = true;
276cdf0e10cSrcweir     switch( nROPColor )
277cdf0e10cSrcweir     {
278cdf0e10cSrcweir         case SAL_ROP_0:
279cdf0e10cSrcweir             m_aFillColor = basebmp::Color( 0 );
280cdf0e10cSrcweir             break;
281cdf0e10cSrcweir         case SAL_ROP_1:
282cdf0e10cSrcweir             m_aFillColor = basebmp::Color( 0xffffff );
283cdf0e10cSrcweir             break;
284cdf0e10cSrcweir         case SAL_ROP_INVERT:
285cdf0e10cSrcweir             m_aFillColor = basebmp::Color( 0xffffff );
286cdf0e10cSrcweir             break;
287cdf0e10cSrcweir     }
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
SetTextColor(SalColor nSalColor)290cdf0e10cSrcweir void SvpSalGraphics::SetTextColor( SalColor nSalColor )
291cdf0e10cSrcweir {
292cdf0e10cSrcweir     m_aTextColor = basebmp::Color( nSalColor );
293cdf0e10cSrcweir }
294cdf0e10cSrcweir 
drawPixel(long nX,long nY)295cdf0e10cSrcweir void SvpSalGraphics::drawPixel( long nX, long nY )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir     if( m_bUseLineColor )
298cdf0e10cSrcweir         m_aDevice->setPixel( B2IPoint( nX, nY ),
299cdf0e10cSrcweir                              m_aLineColor,
300cdf0e10cSrcweir                              m_aDrawMode,
301cdf0e10cSrcweir                              m_aClipMap
302cdf0e10cSrcweir                              );
303cdf0e10cSrcweir     dbgOut( m_aDevice );
304cdf0e10cSrcweir }
305cdf0e10cSrcweir 
drawPixel(long nX,long nY,SalColor nSalColor)306cdf0e10cSrcweir void SvpSalGraphics::drawPixel( long nX, long nY, SalColor nSalColor )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir     basebmp::Color aColor( nSalColor );
309cdf0e10cSrcweir     m_aDevice->setPixel( B2IPoint( nX, nY ),
310cdf0e10cSrcweir                          aColor,
311cdf0e10cSrcweir                          m_aDrawMode,
312cdf0e10cSrcweir                          m_aClipMap
313cdf0e10cSrcweir                          );
314cdf0e10cSrcweir     dbgOut( m_aDevice );
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
drawLine(long nX1,long nY1,long nX2,long nY2)317cdf0e10cSrcweir void SvpSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir     if( m_bUseLineColor )
320cdf0e10cSrcweir         m_aDevice->drawLine( B2IPoint( nX1, nY1 ),
321cdf0e10cSrcweir                              B2IPoint( nX2, nY2 ),
322cdf0e10cSrcweir                              m_aLineColor,
323cdf0e10cSrcweir                              m_aDrawMode,
324cdf0e10cSrcweir                              m_aClipMap );
325cdf0e10cSrcweir     dbgOut( m_aDevice );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir 
drawRect(long nX,long nY,long nWidth,long nHeight)328cdf0e10cSrcweir void SvpSalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir     if( m_bUseLineColor || m_bUseFillColor )
331cdf0e10cSrcweir     {
332cdf0e10cSrcweir         B2DPolygon aRect = tools::createPolygonFromRect( B2DRectangle( nX, nY, nX+nWidth, nY+nHeight ) );
333cdf0e10cSrcweir         if( m_bUseFillColor )
334cdf0e10cSrcweir         {
335cdf0e10cSrcweir             B2DPolyPolygon aPolyPoly( aRect );
336cdf0e10cSrcweir             m_aDevice->fillPolyPolygon( aPolyPoly, m_aFillColor, m_aDrawMode, m_aClipMap );
337cdf0e10cSrcweir         }
338cdf0e10cSrcweir         if( m_bUseLineColor )
339cdf0e10cSrcweir             m_aDevice->drawPolygon( aRect, m_aLineColor, m_aDrawMode, m_aClipMap );
340cdf0e10cSrcweir     }
341cdf0e10cSrcweir     dbgOut( m_aDevice );
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
drawPolyLine(sal_uInt32 nPoints,const SalPoint * pPtAry)344*54ae6a37SHerbert Dürr void SvpSalGraphics::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir     if( m_bUseLineColor && nPoints )
347cdf0e10cSrcweir     {
348cdf0e10cSrcweir         B2DPolygon aPoly;
349cdf0e10cSrcweir         aPoly.append( B2DPoint( pPtAry->mnX, pPtAry->mnY ), nPoints );
350cdf0e10cSrcweir         for( sal_uLong i = 1; i < nPoints; i++ )
351cdf0e10cSrcweir             aPoly.setB2DPoint( i, B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
352cdf0e10cSrcweir         aPoly.setClosed( false );
353cdf0e10cSrcweir         m_aDevice->drawPolygon( aPoly, m_aLineColor, m_aDrawMode, m_aClipMap );
354cdf0e10cSrcweir     }
355cdf0e10cSrcweir     dbgOut( m_aDevice );
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
drawPolygon(sal_uInt32 nPoints,const SalPoint * pPtAry)358*54ae6a37SHerbert Dürr void SvpSalGraphics::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir     if( ( m_bUseLineColor || m_bUseFillColor ) && nPoints )
361cdf0e10cSrcweir     {
362cdf0e10cSrcweir         B2DPolygon aPoly;
363cdf0e10cSrcweir         aPoly.append( B2DPoint( pPtAry->mnX, pPtAry->mnY ), nPoints );
364cdf0e10cSrcweir         for( sal_uLong i = 1; i < nPoints; i++ )
365cdf0e10cSrcweir             aPoly.setB2DPoint( i, B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
366cdf0e10cSrcweir         if( m_bUseFillColor )
367cdf0e10cSrcweir         {
368cdf0e10cSrcweir             aPoly.setClosed( true );
369cdf0e10cSrcweir             m_aDevice->fillPolyPolygon( B2DPolyPolygon(aPoly), m_aFillColor, m_aDrawMode, m_aClipMap );
370cdf0e10cSrcweir         }
371cdf0e10cSrcweir         if( m_bUseLineColor )
372cdf0e10cSrcweir         {
373cdf0e10cSrcweir             aPoly.setClosed( false );
374cdf0e10cSrcweir             m_aDevice->drawPolygon( aPoly, m_aLineColor, m_aDrawMode, m_aClipMap );
375cdf0e10cSrcweir         }
376cdf0e10cSrcweir     }
377cdf0e10cSrcweir     dbgOut( m_aDevice );
378cdf0e10cSrcweir }
379cdf0e10cSrcweir 
drawPolyPolygon(sal_uInt32 nPoly,const sal_uInt32 * pPointCounts,PCONSTSALPOINT * pPtAry)380*54ae6a37SHerbert Dürr void SvpSalGraphics::drawPolyPolygon( sal_uInt32 nPoly,
381cdf0e10cSrcweir                                       const sal_uInt32* pPointCounts,
382cdf0e10cSrcweir                                       PCONSTSALPOINT*   pPtAry )
383cdf0e10cSrcweir {
384cdf0e10cSrcweir     if( ( m_bUseLineColor || m_bUseFillColor ) && nPoly )
385cdf0e10cSrcweir     {
386cdf0e10cSrcweir         B2DPolyPolygon aPolyPoly;
387cdf0e10cSrcweir         for( sal_uInt32 nPolygon = 0; nPolygon < nPoly; nPolygon++ )
388cdf0e10cSrcweir         {
389cdf0e10cSrcweir             sal_uInt32 nPoints = pPointCounts[nPolygon];
390cdf0e10cSrcweir             if( nPoints )
391cdf0e10cSrcweir             {
392cdf0e10cSrcweir                 PCONSTSALPOINT pPoints = pPtAry[nPolygon];
393cdf0e10cSrcweir                 B2DPolygon aPoly;
394cdf0e10cSrcweir                 aPoly.append( B2DPoint( pPoints->mnX, pPoints->mnY ), nPoints );
395cdf0e10cSrcweir                 for( sal_uInt32 i = 1; i < nPoints; i++ )
396cdf0e10cSrcweir                     aPoly.setB2DPoint( i, B2DPoint( pPoints[i].mnX, pPoints[i].mnY ) );
397cdf0e10cSrcweir 
398cdf0e10cSrcweir                 aPolyPoly.append( aPoly );
399cdf0e10cSrcweir             }
400cdf0e10cSrcweir         }
401cdf0e10cSrcweir         if( m_bUseFillColor )
402cdf0e10cSrcweir         {
403cdf0e10cSrcweir             aPolyPoly.setClosed( true );
404cdf0e10cSrcweir             m_aDevice->fillPolyPolygon( aPolyPoly, m_aFillColor, m_aDrawMode, m_aClipMap );
405cdf0e10cSrcweir         }
406cdf0e10cSrcweir         if( m_bUseLineColor )
407cdf0e10cSrcweir         {
408cdf0e10cSrcweir             aPolyPoly.setClosed( false );
409cdf0e10cSrcweir             nPoly = aPolyPoly.count();
410cdf0e10cSrcweir             for( sal_uInt32 i = 0; i < nPoly; i++ )
411cdf0e10cSrcweir                 m_aDevice->drawPolygon( aPolyPoly.getB2DPolygon(i), m_aLineColor, m_aDrawMode, m_aClipMap );
412cdf0e10cSrcweir         }
413cdf0e10cSrcweir     }
414cdf0e10cSrcweir     dbgOut( m_aDevice );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
drawPolyLine(const::basegfx::B2DPolygon &,double,const::basegfx::B2DVector &,basegfx::B2DLineJoin,com::sun::star::drawing::LineCap)4175aaf853bSArmin Le Grand bool SvpSalGraphics::drawPolyLine(
4185aaf853bSArmin Le Grand     const ::basegfx::B2DPolygon&,
4195aaf853bSArmin Le Grand     double /*fTransparency*/,
4205aaf853bSArmin Le Grand     const ::basegfx::B2DVector& /*rLineWidths*/,
4215aaf853bSArmin Le Grand     basegfx::B2DLineJoin /*eJoin*/,
4225aaf853bSArmin Le Grand     com::sun::star::drawing::LineCap /*eLineCap*/)
423cdf0e10cSrcweir {
424cdf0e10cSrcweir         // TODO: implement and advertise OutDevSupport_B2DDraw support
425cdf0e10cSrcweir         return false;
426cdf0e10cSrcweir }
427cdf0e10cSrcweir 
drawPolyLineBezier(sal_uInt32,const SalPoint *,const sal_uInt8 *)428*54ae6a37SHerbert Dürr sal_Bool SvpSalGraphics::drawPolyLineBezier( sal_uInt32,
429cdf0e10cSrcweir                                              const SalPoint*,
430cdf0e10cSrcweir                                              const sal_uInt8* )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir     return sal_False;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
drawPolygonBezier(sal_uInt32,const SalPoint *,const sal_uInt8 *)435*54ae6a37SHerbert Dürr sal_Bool SvpSalGraphics::drawPolygonBezier( sal_uInt32,
436cdf0e10cSrcweir                                             const SalPoint*,
437cdf0e10cSrcweir                                             const sal_uInt8* )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir     return sal_False;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
drawPolyPolygonBezier(sal_uInt32,const sal_uInt32 *,const SalPoint * const *,const sal_uInt8 * const *)442cdf0e10cSrcweir sal_Bool SvpSalGraphics::drawPolyPolygonBezier( sal_uInt32,
443cdf0e10cSrcweir                                                 const sal_uInt32*,
444cdf0e10cSrcweir                                                 const SalPoint* const*,
445cdf0e10cSrcweir                                                 const sal_uInt8* const* )
446cdf0e10cSrcweir {
447cdf0e10cSrcweir     return sal_False;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
drawPolyPolygon(const basegfx::B2DPolyPolygon &,double)450cdf0e10cSrcweir bool SvpSalGraphics::drawPolyPolygon( const basegfx::B2DPolyPolygon&, double /*fTransparency*/ )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir     // TODO: maybe BaseBmp can draw B2DPolyPolygons directly
453cdf0e10cSrcweir     return false;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
copyArea(long nDestX,long nDestY,long nSrcX,long nSrcY,long nSrcWidth,long nSrcHeight,sal_uInt16)456cdf0e10cSrcweir void SvpSalGraphics::copyArea( long nDestX,
457cdf0e10cSrcweir                                       long nDestY,
458cdf0e10cSrcweir                                       long nSrcX,
459cdf0e10cSrcweir                                       long nSrcY,
460cdf0e10cSrcweir                                       long nSrcWidth,
461cdf0e10cSrcweir                                       long nSrcHeight,
462cdf0e10cSrcweir                                       sal_uInt16 /*nFlags*/ )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir     B2IRange aSrcRect( nSrcX, nSrcY, nSrcX+nSrcWidth, nSrcY+nSrcHeight );
465cdf0e10cSrcweir     B2IRange aDestRect( nDestX, nDestY, nDestX+nSrcWidth, nDestY+nSrcHeight );
466cdf0e10cSrcweir     m_aDevice->drawBitmap( m_aOrigDevice, aSrcRect, aDestRect, DrawMode_PAINT, m_aClipMap );
467cdf0e10cSrcweir     dbgOut( m_aDevice );
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
copyBits(const SalTwoRect & rPosAry,SalGraphics * pSrcGraphics)4705f27b83cSArmin Le Grand void SvpSalGraphics::copyBits( const SalTwoRect& rPosAry,
471cdf0e10cSrcweir                                SalGraphics*      pSrcGraphics )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir     SvpSalGraphics* pSrc = pSrcGraphics ?
474cdf0e10cSrcweir         static_cast<SvpSalGraphics*>(pSrcGraphics) : this;
4755f27b83cSArmin Le Grand     B2IRange aSrcRect( rPosAry.mnSrcX, rPosAry.mnSrcY,
4765f27b83cSArmin Le Grand                        rPosAry.mnSrcX+rPosAry.mnSrcWidth,
4775f27b83cSArmin Le Grand                        rPosAry.mnSrcY+rPosAry.mnSrcHeight );
4785f27b83cSArmin Le Grand     B2IRange aDestRect( rPosAry.mnDestX, rPosAry.mnDestY,
4795f27b83cSArmin Le Grand                         rPosAry.mnDestX+rPosAry.mnDestWidth,
4805f27b83cSArmin Le Grand                         rPosAry.mnDestY+rPosAry.mnDestHeight );
481cdf0e10cSrcweir     m_aDevice->drawBitmap( pSrc->m_aOrigDevice, aSrcRect, aDestRect, DrawMode_PAINT, m_aClipMap );
482cdf0e10cSrcweir     dbgOut( m_aDevice );
483cdf0e10cSrcweir }
484cdf0e10cSrcweir 
drawBitmap(const SalTwoRect & rPosAry,const SalBitmap & rSalBitmap)4855f27b83cSArmin Le Grand void SvpSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir     const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBitmap);
4885f27b83cSArmin Le Grand     B2IRange aSrcRect( rPosAry.mnSrcX, rPosAry.mnSrcY,
4895f27b83cSArmin Le Grand                        rPosAry.mnSrcX+rPosAry.mnSrcWidth,
4905f27b83cSArmin Le Grand                        rPosAry.mnSrcY+rPosAry.mnSrcHeight );
4915f27b83cSArmin Le Grand     B2IRange aDestRect( rPosAry.mnDestX, rPosAry.mnDestY,
4925f27b83cSArmin Le Grand                         rPosAry.mnDestX+rPosAry.mnDestWidth,
4935f27b83cSArmin Le Grand                         rPosAry.mnDestY+rPosAry.mnDestHeight );
494cdf0e10cSrcweir     m_aDevice->drawBitmap( rSrc.getBitmap(), aSrcRect, aDestRect, DrawMode_PAINT, m_aClipMap );
495cdf0e10cSrcweir     dbgOut( m_aDevice );
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
drawBitmap(const SalTwoRect &,const SalBitmap &,SalColor)4985f27b83cSArmin Le Grand void SvpSalGraphics::drawBitmap( const SalTwoRect&,
499cdf0e10cSrcweir                                  const SalBitmap&,
500cdf0e10cSrcweir                                  SalColor )
501cdf0e10cSrcweir {
502cdf0e10cSrcweir     // SNI, as in X11 plugin
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
drawBitmap(const SalTwoRect & rPosAry,const SalBitmap & rSalBitmap,const SalBitmap & rTransparentBitmap)5055f27b83cSArmin Le Grand void SvpSalGraphics::drawBitmap( const SalTwoRect& rPosAry,
506cdf0e10cSrcweir                                  const SalBitmap& rSalBitmap,
507cdf0e10cSrcweir                                  const SalBitmap& rTransparentBitmap )
508cdf0e10cSrcweir {
509cdf0e10cSrcweir     const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBitmap);
510cdf0e10cSrcweir     const SvpSalBitmap& rSrcTrans = static_cast<const SvpSalBitmap&>(rTransparentBitmap);
5115f27b83cSArmin Le Grand     B2IRange aSrcRect( rPosAry.mnSrcX, rPosAry.mnSrcY,
5125f27b83cSArmin Le Grand                        rPosAry.mnSrcX+rPosAry.mnSrcWidth,
5135f27b83cSArmin Le Grand                        rPosAry.mnSrcY+rPosAry.mnSrcHeight );
5145f27b83cSArmin Le Grand     B2IRange aDestRect( rPosAry.mnDestX, rPosAry.mnDestY,
5155f27b83cSArmin Le Grand                         rPosAry.mnDestX+rPosAry.mnDestWidth,
5165f27b83cSArmin Le Grand                         rPosAry.mnDestY+rPosAry.mnDestHeight );
517cdf0e10cSrcweir     m_aDevice->drawMaskedBitmap( rSrc.getBitmap(), rSrcTrans.getBitmap(), aSrcRect, aDestRect, DrawMode_PAINT, m_aClipMap );
518cdf0e10cSrcweir     dbgOut( m_aDevice );
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
drawMask(const SalTwoRect & rPosAry,const SalBitmap & rSalBitmap,SalColor nMaskColor)5215f27b83cSArmin Le Grand void SvpSalGraphics::drawMask( const SalTwoRect& rPosAry,
522cdf0e10cSrcweir                                const SalBitmap& rSalBitmap,
523cdf0e10cSrcweir                                SalColor nMaskColor )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir     const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBitmap);
5265f27b83cSArmin Le Grand     B2IRange aSrcRect( rPosAry.mnSrcX, rPosAry.mnSrcY,
5275f27b83cSArmin Le Grand                        rPosAry.mnSrcX+rPosAry.mnSrcWidth,
5285f27b83cSArmin Le Grand                        rPosAry.mnSrcY+rPosAry.mnSrcHeight );
5295f27b83cSArmin Le Grand     B2IPoint aDestPoint( rPosAry.mnDestX, rPosAry.mnDestY );
530cdf0e10cSrcweir 
531cdf0e10cSrcweir     // BitmapDevice::drawMaskedColor works with 0==transparent,
532cdf0e10cSrcweir     // 255==opaque. drawMask() semantic is the other way
533cdf0e10cSrcweir     // around. Therefore, invert mask.
534cdf0e10cSrcweir     BitmapDeviceSharedPtr aCopy =
5355f27b83cSArmin Le Grand         cloneBitmapDevice( B2IVector( rPosAry.mnSrcWidth, rPosAry.mnSrcHeight ),
536cdf0e10cSrcweir                            rSrc.getBitmap() );
537cdf0e10cSrcweir     basebmp::Color aBgColor( COL_WHITE );
538cdf0e10cSrcweir     aCopy->clear(aBgColor);
539cdf0e10cSrcweir     basebmp::Color aFgColor( COL_BLACK );
540cdf0e10cSrcweir     aCopy->drawMaskedColor( aFgColor, rSrc.getBitmap(), aSrcRect, B2IPoint() );
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     basebmp::Color aColor( nMaskColor );
5435f27b83cSArmin Le Grand     B2IRange aSrcRect2( 0, 0, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight );
544cdf0e10cSrcweir     m_aDevice->drawMaskedColor( aColor, aCopy, aSrcRect, aDestPoint, m_aClipMap );
545cdf0e10cSrcweir     dbgOut( m_aDevice );
546cdf0e10cSrcweir }
547cdf0e10cSrcweir 
getBitmap(long nX,long nY,long nWidth,long nHeight)548cdf0e10cSrcweir SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeight )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir     BitmapDeviceSharedPtr aCopy =
551cdf0e10cSrcweir         cloneBitmapDevice( B2IVector( nWidth, nHeight ),
552cdf0e10cSrcweir                            m_aDevice );
553cdf0e10cSrcweir     B2IRange aSrcRect( nX, nY, nX+nWidth, nY+nHeight );
554cdf0e10cSrcweir     B2IRange aDestRect( 0, 0, nWidth, nHeight );
555cdf0e10cSrcweir     aCopy->drawBitmap( m_aOrigDevice, aSrcRect, aDestRect, DrawMode_PAINT );
556cdf0e10cSrcweir 
557cdf0e10cSrcweir     SvpSalBitmap* pBitmap = new SvpSalBitmap();
558cdf0e10cSrcweir     pBitmap->setBitmap( aCopy );
559cdf0e10cSrcweir     return pBitmap;
560cdf0e10cSrcweir }
561cdf0e10cSrcweir 
getPixel(long nX,long nY)562cdf0e10cSrcweir SalColor SvpSalGraphics::getPixel( long nX, long nY )
563cdf0e10cSrcweir {
564cdf0e10cSrcweir     basebmp::Color aColor( m_aDevice->getPixel( B2IPoint( nX, nY ) ) );
565cdf0e10cSrcweir     return aColor.toInt32();
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
invert(long nX,long nY,long nWidth,long nHeight,SalInvert)568cdf0e10cSrcweir void SvpSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert /*nFlags*/ )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir     // FIXME: handle SAL_INVERT_50 and SAL_INVERT_TRACKFRAME
571cdf0e10cSrcweir     B2DPolygon aRect = tools::createPolygonFromRect( B2DRectangle( nX, nY, nX+nWidth, nY+nHeight ) );
572cdf0e10cSrcweir     B2DPolyPolygon aPolyPoly( aRect );
573cdf0e10cSrcweir     m_aDevice->fillPolyPolygon( aPolyPoly, basebmp::Color( 0xffffff ), DrawMode_XOR, m_aClipMap );
574cdf0e10cSrcweir     dbgOut( m_aDevice );
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
invert(sal_uInt32 nPoints,const SalPoint * pPtAry,SalInvert)577*54ae6a37SHerbert Dürr void SvpSalGraphics::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert /*nFlags*/ )
578cdf0e10cSrcweir {
579cdf0e10cSrcweir     // FIXME: handle SAL_INVERT_50 and SAL_INVERT_TRACKFRAME
580cdf0e10cSrcweir     B2DPolygon aPoly;
581cdf0e10cSrcweir     aPoly.append( B2DPoint( pPtAry->mnX, pPtAry->mnY ), nPoints );
582cdf0e10cSrcweir     for( sal_uLong i = 1; i < nPoints; i++ )
583cdf0e10cSrcweir         aPoly.setB2DPoint( i, B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
584cdf0e10cSrcweir     aPoly.setClosed( true );
585cdf0e10cSrcweir     m_aDevice->fillPolyPolygon( B2DPolyPolygon(aPoly), basebmp::Color( 0xffffff ), DrawMode_XOR, m_aClipMap );
586cdf0e10cSrcweir     dbgOut( m_aDevice );
587cdf0e10cSrcweir }
588cdf0e10cSrcweir 
drawEPS(long,long,long,long,void *,sal_uLong)589cdf0e10cSrcweir sal_Bool SvpSalGraphics::drawEPS( long, long, long, long, void*, sal_uLong )
590cdf0e10cSrcweir {
591cdf0e10cSrcweir     return sal_False;
592cdf0e10cSrcweir }
593cdf0e10cSrcweir 
GetSysFontData(int nFallbacklevel) const594cdf0e10cSrcweir SystemFontData SvpSalGraphics::GetSysFontData( int nFallbacklevel ) const
595cdf0e10cSrcweir {
596cdf0e10cSrcweir     SystemFontData aSysFontData;
597cdf0e10cSrcweir 
598cdf0e10cSrcweir     if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1;
599cdf0e10cSrcweir     if (nFallbacklevel < 0 ) nFallbacklevel = 0;
600cdf0e10cSrcweir 
601cdf0e10cSrcweir     aSysFontData.nSize = sizeof( SystemFontData );
602cdf0e10cSrcweir     aSysFontData.nFontId = 0;
603cdf0e10cSrcweir     aSysFontData.nFontFlags = 0;
604cdf0e10cSrcweir     aSysFontData.bFakeBold = false;
605cdf0e10cSrcweir     aSysFontData.bFakeItalic = false;
606cdf0e10cSrcweir     aSysFontData.bAntialias = true;
607cdf0e10cSrcweir     return aSysFontData;
608cdf0e10cSrcweir }
609cdf0e10cSrcweir 
GetGraphicsData() const610cdf0e10cSrcweir SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
611cdf0e10cSrcweir {
612cdf0e10cSrcweir     SystemGraphicsData aRes;
613cdf0e10cSrcweir     aRes.nSize = sizeof(aRes);
614cdf0e10cSrcweir 	aRes.hDrawable = 0;
615cdf0e10cSrcweir 	aRes.pRenderFormat = 0;
616cdf0e10cSrcweir     return aRes;
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
supportsOperation(OutDevSupportType) const619cdf0e10cSrcweir bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const
620cdf0e10cSrcweir {
621cdf0e10cSrcweir     return false;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir 
624