diff options
Diffstat (limited to 'vcl/aqua/source/gdi/salgdi.cxx')
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 161 |
1 files changed, 78 insertions, 83 deletions
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index cd32820f258c..4eadc86ff15d 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -42,6 +42,7 @@ #include "vcl/sysdata.hxx" #include "vcl/sallayout.hxx" #include "vcl/svapp.hxx" +#include "vcl/region.h" #include "osl/file.hxx" #include "osl/process.h" @@ -59,7 +60,7 @@ using namespace vcl; -typedef unsigned char Boolean; // copied from MacTypes.h, should be properly included +//typedef unsigned char Boolean; // copied from MacTypes.h, should be properly included typedef std::vector<unsigned char> ByteVector; @@ -118,17 +119,15 @@ inline FourCharCode GetTag(const char aTagName[5]) static unsigned GetUShort( const unsigned char* p ){return((p[0]<<8)+p[1]);} static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);} -ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const +const ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const { + // return the cached charmap if( mpCharMap ) - { - // return the cached charmap - mpCharMap->AddReference(); return mpCharMap; - } // set the default charmap mpCharMap = ImplFontCharMap::GetDefaultMap(); + mpCharMap->AddReference(); // get the CMAP byte size ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId ); @@ -502,9 +501,9 @@ void AquaSalGraphics::copyResolution( AquaSalGraphics& rGraphics ) // ----------------------------------------------------------------------- -USHORT AquaSalGraphics::GetBitCount() const +sal_uInt16 AquaSalGraphics::GetBitCount() const { - USHORT nBits = mnBitmapDepth ? mnBitmapDepth : 32;//24; + sal_uInt16 nBits = mnBitmapDepth ? mnBitmapDepth : 32;//24; return nBits; } @@ -611,7 +610,7 @@ void AquaSalGraphics::ResetClipRegion() // ----------------------------------------------------------------------- -void AquaSalGraphics::BeginSetClipRegion( ULONG nRectCount ) +bool AquaSalGraphics::setClipRegion( const Region& i_rClip ) { // release old clip path if( mxClipPath ) @@ -619,41 +618,33 @@ void AquaSalGraphics::BeginSetClipRegion( ULONG nRectCount ) CGPathRelease( mxClipPath ); mxClipPath = NULL; } -} - -// ----------------------------------------------------------------------- - -BOOL AquaSalGraphics::unionClipRegion( long nX, long nY, long nWidth, long nHeight ) -{ - if( (nWidth <= 0) || (nHeight <= 0) ) - return TRUE; - - if( !mxClipPath ) - mxClipPath = CGPathCreateMutable(); - const CGRect aClipRect = {{nX,nY},{nWidth,nHeight}}; - CGPathAddRect( mxClipPath, NULL, aClipRect ); - return TRUE; -} - -// ----------------------------------------------------------------------- - -bool AquaSalGraphics::unionClipRegion( const ::basegfx::B2DPolyPolygon& rPolyPolygon ) -{ - if( rPolyPolygon.count() <= 0 ) - return true; - - if( !mxClipPath ) - mxClipPath = CGPathCreateMutable(); - AddPolyPolygonToPath( mxClipPath, rPolyPolygon, !getAntiAliasB2DDraw(), false ); - return true; -} + mxClipPath = CGPathCreateMutable(); -// ----------------------------------------------------------------------- - -void AquaSalGraphics::EndSetClipRegion() -{ + // set current path, either as polypolgon or sequence of rectangles + if( i_rClip.HasPolyPolygon() ) + { + basegfx::B2DPolyPolygon aClip( const_cast<Region&>(i_rClip).ConvertToB2DPolyPolygon() ); + AddPolyPolygonToPath( mxClipPath, aClip, !getAntiAliasB2DDraw(), false ); + } + else + { + long nX, nY, nW, nH; + ImplRegionInfo aInfo; + bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH ); + while( bRegionRect ) + { + if( nW && nH ) + { + CGRect aRect = {{nX,nY}, {nW,nH}}; + CGPathAddRect( mxClipPath, NULL, aRect ); + } + bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH ); + } + } + // set the current path as clip region if( CheckContext() ) SetState(); + return true; } // ----------------------------------------------------------------------- @@ -796,13 +787,13 @@ void AquaSalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight ) // ----------------------------------------------------------------------- -static void getBoundRect( ULONG nPoints, const SalPoint *pPtAry, long &rX, long& rY, long& rWidth, long& rHeight ) +static void getBoundRect( sal_uLong nPoints, const SalPoint *pPtAry, long &rX, long& rY, long& rWidth, long& rHeight ) { long nX1 = pPtAry->mnX; long nX2 = nX1; long nY1 = pPtAry->mnY; long nY2 = nY1; - for( ULONG n = 1; n < nPoints; n++ ) + for( sal_uLong n = 1; n < nPoints; n++ ) { if( pPtAry[n].mnX < nX1 ) nX1 = pPtAry[n].mnX; @@ -826,7 +817,7 @@ static inline void alignLinePoint( const SalPoint* i_pIn, float& o_fX, float& o_ o_fY = static_cast<float>(i_pIn->mnY ) + 0.5; } -void AquaSalGraphics::drawPolyLine( ULONG nPoints, const SalPoint *pPtAry ) +void AquaSalGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint *pPtAry ) { if( nPoints < 1 ) return; @@ -842,7 +833,7 @@ void AquaSalGraphics::drawPolyLine( ULONG nPoints, const SalPoint *pPtAry ) alignLinePoint( pPtAry, fX, fY ); CGContextMoveToPoint( mrContext, fX, fY ); pPtAry++; - for( ULONG nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) { alignLinePoint( pPtAry, fX, fY ); CGContextAddLineToPoint( mrContext, fX, fY ); @@ -854,7 +845,7 @@ void AquaSalGraphics::drawPolyLine( ULONG nPoints, const SalPoint *pPtAry ) // ----------------------------------------------------------------------- -void AquaSalGraphics::drawPolygon( ULONG nPoints, const SalPoint *pPtAry ) +void AquaSalGraphics::drawPolygon( sal_uLong nPoints, const SalPoint *pPtAry ) { if( nPoints <= 1 ) return; @@ -882,7 +873,7 @@ void AquaSalGraphics::drawPolygon( ULONG nPoints, const SalPoint *pPtAry ) alignLinePoint( pPtAry, fX, fY ); CGContextMoveToPoint( mrContext, fX, fY ); pPtAry++; - for( ULONG nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) { alignLinePoint( pPtAry, fX, fY ); CGContextAddLineToPoint( mrContext, fX, fY ); @@ -892,7 +883,7 @@ void AquaSalGraphics::drawPolygon( ULONG nPoints, const SalPoint *pPtAry ) { CGContextMoveToPoint( mrContext, pPtAry->mnX, pPtAry->mnY ); pPtAry++; - for( ULONG nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) CGContextAddLineToPoint( mrContext, pPtAry->mnX, pPtAry->mnY ); } @@ -902,7 +893,7 @@ void AquaSalGraphics::drawPolygon( ULONG nPoints, const SalPoint *pPtAry ) // ----------------------------------------------------------------------- -void AquaSalGraphics::drawPolyPolygon( ULONG nPolyCount, const ULONG *pPoints, PCONSTSALPOINT *ppPtAry ) +void AquaSalGraphics::drawPolyPolygon( sal_uLong nPolyCount, const sal_uLong *pPoints, PCONSTSALPOINT *ppPtAry ) { if( nPolyCount <= 0 ) return; @@ -912,7 +903,7 @@ void AquaSalGraphics::drawPolyPolygon( ULONG nPolyCount, const ULONG *pPoints, P // find bound rect long leftX = 0, topY = 0, maxWidth = 0, maxHeight = 0; getBoundRect( pPoints[0], ppPtAry[0], leftX, topY, maxWidth, maxHeight ); - for( ULONG n = 1; n < nPolyCount; n++ ) + for( sal_uLong n = 1; n < nPolyCount; n++ ) { long nX = leftX, nY = topY, nW = maxWidth, nH = maxHeight; getBoundRect( pPoints[n], ppPtAry[n], nX, nY, nW, nH ); @@ -947,9 +938,9 @@ void AquaSalGraphics::drawPolyPolygon( ULONG nPolyCount, const ULONG *pPoints, P CGContextBeginPath( mrContext ); if( IsPenVisible() ) { - for( ULONG nPoly = 0; nPoly < nPolyCount; nPoly++ ) + for( sal_uLong nPoly = 0; nPoly < nPolyCount; nPoly++ ) { - const ULONG nPoints = pPoints[nPoly]; + const sal_uLong nPoints = pPoints[nPoly]; if( nPoints > 1 ) { const SalPoint *pPtAry = ppPtAry[nPoly]; @@ -957,7 +948,7 @@ void AquaSalGraphics::drawPolyPolygon( ULONG nPolyCount, const ULONG *pPoints, P alignLinePoint( pPtAry, fX, fY ); CGContextMoveToPoint( mrContext, fX, fY ); pPtAry++; - for( ULONG nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) { alignLinePoint( pPtAry, fX, fY ); CGContextAddLineToPoint( mrContext, fX, fY ); @@ -968,15 +959,15 @@ void AquaSalGraphics::drawPolyPolygon( ULONG nPolyCount, const ULONG *pPoints, P } else { - for( ULONG nPoly = 0; nPoly < nPolyCount; nPoly++ ) + for( sal_uLong nPoly = 0; nPoly < nPolyCount; nPoly++ ) { - const ULONG nPoints = pPoints[nPoly]; + const sal_uLong nPoints = pPoints[nPoly]; if( nPoints > 1 ) { const SalPoint *pPtAry = ppPtAry[nPoly]; CGContextMoveToPoint( mrContext, pPtAry->mnX, pPtAry->mnY ); pPtAry++; - for( ULONG nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + for( sal_uLong nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) CGContextAddLineToPoint( mrContext, pPtAry->mnX, pPtAry->mnY ); CGContextClosePath(mrContext); } @@ -1101,22 +1092,22 @@ bool AquaSalGraphics::drawPolyLine( const ::basegfx::B2DPolygon& rPolyLine, // ----------------------------------------------------------------------- -sal_Bool AquaSalGraphics::drawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +sal_Bool AquaSalGraphics::drawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) { return sal_False; } // ----------------------------------------------------------------------- -sal_Bool AquaSalGraphics::drawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) +sal_Bool AquaSalGraphics::drawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) { return sal_False; } // ----------------------------------------------------------------------- -sal_Bool AquaSalGraphics::drawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, - const SalPoint* const* pPtAry, const BYTE* const* pFlgAry ) +sal_Bool AquaSalGraphics::drawPolyPolygonBezier( sal_uLong nPoly, const sal_uLong* pPoints, + const SalPoint* const* pPtAry, const sal_uInt8* const* pFlgAry ) { return sal_False; } @@ -1202,7 +1193,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect *pPosAry, SalGraphics *pSrcGrap // ----------------------------------------------------------------------- -void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, USHORT nFlags ) +void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, sal_uInt16 nFlags ) { ApplyXorContext(); @@ -1429,7 +1420,7 @@ void AquaSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalIn // ----------------------------------------------------------------------- -void AquaSalGraphics::invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nSalFlags ) +void AquaSalGraphics::invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nSalFlags ) { CGPoint* CGpoints ; if ( CheckContext() ) @@ -1466,8 +1457,8 @@ void AquaSalGraphics::invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert // ----------------------------------------------------------------------- -BOOL AquaSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, - void* pEpsData, ULONG nByteCount ) +sal_Bool AquaSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, + void* pEpsData, sal_uLong nByteCount ) { // convert the raw data to an NSImageRef NSData* xNSData = [NSData dataWithBytes:(void*)pEpsData length:(int)nByteCount]; @@ -1636,7 +1627,7 @@ void AquaSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackL // ----------------------------------------------------------------------- -ULONG AquaSalGraphics::GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ) +sal_uLong AquaSalGraphics::GetKernPairs( sal_uLong nPairs, ImplKernPairData* pKernPairs ) { return 0; } @@ -1817,7 +1808,7 @@ static OSStatus GgoMoveToProc( const Float32Point* pPoint, void* pData ) return eStatus; } -BOOL AquaSalGraphics::GetGlyphOutline( long nGlyphId, basegfx::B2DPolyPolygon& rPolyPoly ) +sal_Bool AquaSalGraphics::GetGlyphOutline( long nGlyphId, basegfx::B2DPolyPolygon& rPolyPoly ) { GgoData aGgoData; aGgoData.mpPolyPoly = &rPolyPoly; @@ -1859,7 +1850,7 @@ long AquaSalGraphics::GetGraphicsWidth() const // ----------------------------------------------------------------------- -BOOL AquaSalGraphics::GetGlyphBoundRect( long nGlyphId, Rectangle& rRect ) +sal_Bool AquaSalGraphics::GetGlyphBoundRect( long nGlyphId, Rectangle& rRect ) { ATSUStyle rATSUStyle = maATSUStyle; // TODO: handle glyph fallback GlyphID aGlyphId = nGlyphId; @@ -1892,7 +1883,7 @@ void AquaSalGraphics::DrawServerFontLayout( const ServerFontLayout& ) // ----------------------------------------------------------------------- -USHORT AquaSalGraphics::SetFont( ImplFontSelectData* pReqFont, int nFallbackLevel ) +sal_uInt16 AquaSalGraphics::SetFont( ImplFontSelectData* pReqFont, int nFallbackLevel ) { if( !pReqFont ) { @@ -2026,7 +2017,7 @@ USHORT AquaSalGraphics::SetFont( ImplFontSelectData* pReqFont, int nFallbackLeve // ----------------------------------------------------------------------- -ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const +const ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const { if( !mpMacFontData ) return ImplFontCharMap::GetDefaultMap(); @@ -2217,10 +2208,10 @@ static bool GetRawFontData( const ImplFontData* pFontData, DBG_ASSERT( (nOfs==nTotalLen), "AquaSalGraphics::CreateFontSubset (nOfs!=nTotalLen)"); - return true; + return sal_True; } -BOOL AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, +sal_Bool AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, const ImplFontData* pFontData, long* pGlyphIDs, sal_uInt8* pEncoding, sal_Int32* pGlyphWidths, int nGlyphCount, FontSubsetInfo& rInfo ) { @@ -2229,7 +2220,7 @@ BOOL AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, // prepare the requested file name for writing the font-subset file rtl::OUString aSysPath; if( osl_File_E_None != osl_getSystemPathFromFileURL( rToFile.pData, &aSysPath.pData ) ) - return FALSE; + return sal_False; const rtl_TextEncoding aThreadEncoding = osl_getThreadTextEncoding(); const ByteString aToFile( rtl::OUStringToOString( aSysPath, aThreadEncoding ) ); @@ -2290,7 +2281,7 @@ BOOL AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, // subset glyphs and get their properties // take care that subset fonts require the NotDef glyph in pos 0 int nOrigCount = nGlyphCount; - USHORT aShortIDs[ 256 ]; + sal_uInt16 aShortIDs[ 256 ]; sal_uInt8 aTempEncs[ 256 ]; int nNotDef = -1; @@ -2310,7 +2301,7 @@ BOOL AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, nGlyphIdx = ::MapChar( pSftFont, static_cast<sal_uInt16>(nGlyphIdx), bVertical ); } } - aShortIDs[i] = static_cast<USHORT>( nGlyphIdx ); + aShortIDs[i] = static_cast<sal_uInt16>( nGlyphIdx ); if( !nGlyphIdx ) if( nNotDef < 0 ) nNotDef = i; // first NotDef glyph found @@ -2338,7 +2329,7 @@ BOOL AquaSalGraphics::CreateFontSubset( const rtl::OUString& rToFile, TTSimpleGlyphMetrics* pGlyphMetrics = ::GetTTSimpleGlyphMetrics( pSftFont, aShortIDs, nGlyphCount, bVertical ); if( !pGlyphMetrics ) - return FALSE; + return sal_False; sal_uInt16 nNotDefAdv = pGlyphMetrics[0].adv; pGlyphMetrics[0].adv = pGlyphMetrics[nNotDef].adv; pGlyphMetrics[nNotDef].adv = nNotDefAdv; @@ -2396,8 +2387,10 @@ void AquaSalGraphics::GetGlyphWidths( const ImplFontData* pFontData, bool bVerti const ImplFontCharMap* pMap = mpMacFontData->GetImplFontCharMap(); DBG_ASSERT( pMap && pMap->GetCharCount(), "no charmap" ); + pMap->AddReference(); // TODO: add and use RAII object instead // get unicode<->glyph encoding + // TODO? avoid sft mapping by using the pMap itself int nCharCount = pMap->GetCharCount(); sal_uInt32 nChar = pMap->GetFirstChar(); for(; --nCharCount >= 0; nChar = pMap->GetNextChar( nChar ) ) @@ -2409,6 +2402,8 @@ void AquaSalGraphics::GetGlyphWidths( const ImplFontData* pFontData, bool bVerti if( nGlyph > 0 ) rUnicodeEnc[ nUcsChar ] = nGlyph; } + + pMap->DeReference(); // TODO: add and use RAII object instead } ::CloseTTFont( pSftFont ); @@ -2625,24 +2620,24 @@ void XorEmulation::SetTarget( int nWidth, int nHeight, int nTargetDepth, nBytesPerRow = 1; } nBytesPerRow *= nWidth; - mnBufferLongs = (nHeight * nBytesPerRow + sizeof(ULONG)-1) / sizeof(ULONG); + mnBufferLongs = (nHeight * nBytesPerRow + sizeof(sal_uLong)-1) / sizeof(sal_uLong); // create a XorMask context - mpMaskBuffer = new ULONG[ mnBufferLongs ]; + mpMaskBuffer = new sal_uLong[ mnBufferLongs ]; mxMaskContext = ::CGBitmapContextCreate( mpMaskBuffer, nWidth, nHeight, nBitsPerComponent, nBytesPerRow, aCGColorSpace, aCGBmpInfo ); // reset the XOR mask to black - memset( mpMaskBuffer, 0, mnBufferLongs * sizeof(ULONG) ); + memset( mpMaskBuffer, 0, mnBufferLongs * sizeof(sal_uLong) ); // a bitmap context will be needed for manual XORing // create one unless the target context is a bitmap context if( nTargetDepth ) - mpTempBuffer = (ULONG*)CGBitmapContextGetData( mxTargetContext ); + mpTempBuffer = (sal_uLong*)CGBitmapContextGetData( mxTargetContext ); if( !mpTempBuffer ) { // create a bitmap context matching to the target context - mpTempBuffer = new ULONG[ mnBufferLongs ]; + mpTempBuffer = new sal_uLong[ mnBufferLongs ]; mxTempContext = ::CGBitmapContextCreate( mpTempBuffer, nWidth, nHeight, nBitsPerComponent, nBytesPerRow, aCGColorSpace, aCGBmpInfo ); @@ -2682,8 +2677,8 @@ bool XorEmulation::UpdateTarget() // do a manual XOR with the XorMask // this approach suffices for simple color manipulations // and also the complex-clipping-XOR-trick used in metafiles - const ULONG* pSrc = mpMaskBuffer; - ULONG* pDst = mpTempBuffer; + const sal_uLong* pSrc = mpMaskBuffer; + sal_uLong* pDst = mpTempBuffer; for( int i = mnBufferLongs; --i >= 0;) *(pDst++) ^= *(pSrc++); @@ -2701,7 +2696,7 @@ bool XorEmulation::UpdateTarget() // reset the XorMask to black again // TODO: not needed for last update - memset( mpMaskBuffer, 0, mnBufferLongs * sizeof(ULONG) ); + memset( mpMaskBuffer, 0, mnBufferLongs * sizeof(sal_uLong) ); // TODO: return FALSE if target was not changed return true; |