vcl/inc/quartz/salgdi.h | 4 vcl/inc/quartz/utils.h | 2 vcl/quartz/CTRunData.cxx | 5 vcl/quartz/ctfonts.cxx | 150 ++++++++----- vcl/quartz/ctlayout.cxx | 18 + vcl/quartz/salbmp.cxx | 296 +++++++++++++++----------- vcl/quartz/salgdi.cxx | 275 ++++++++++++++---------- vcl/quartz/salgdicommon.cxx | 488 ++++++++++++++++++++++++-------------------- vcl/quartz/salgdiutils.cxx | 74 +++--- vcl/quartz/salvd.cxx | 88 +++++-- vcl/quartz/utils.cxx | 33 ++ 11 files changed, 856 insertions(+), 577 deletions(-)
New commits: commit b20becf9e3934914b3291ca73962fbaddf616b74 Author: Norbert Thiebaud <[email protected]> Date: Tue Aug 11 20:19:37 2015 -0500 cosmetic: clean-up vcl/quartz Change-Id: I6f15e7ce90598eb4f8e7bb59c7c65d1aa333b972 Reviewed-on: https://gerrit.libreoffice.org/17661 Tested-by: Jenkins <[email protected]> Reviewed-by: Norbert Thiebaud <[email protected]> diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 557d1496..72cd424 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -141,11 +141,11 @@ class AquaSalGraphics : public SalGraphics { friend class CTLayout; protected: + CGLayerRef mxLayer; // Quartz graphics layer + CGContextRef mrContext; // Quartz drawing context #ifdef MACOSX AquaSalFrame* mpFrame; #endif - CGLayerRef mxLayer; // Quartz graphics layer - CGContextRef mrContext; // Quartz drawing context int mnContextStackDepth; XorEmulation* mpXorEmulation; int mnXorMode; // 0: off 1: on 2: invert only diff --git a/vcl/inc/quartz/utils.h b/vcl/inc/quartz/utils.h index e408250..57a0402 100644 --- a/vcl/inc/quartz/utils.h +++ b/vcl/inc/quartz/utils.h @@ -45,8 +45,6 @@ std::ostream &operator <<(std::ostream& s, const CGSize &rSize); std::ostream &operator <<(std::ostream& s, CGColorRef pSize); std::ostream &operator <<(std::ostream& s, const CGAffineTransform &aXform); -#define CG_TRACE( e ) SAL_INFO( "vcl.cg", e ) - #endif // INCLUDED_VCL_INC_QUARTZ_UTILS_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/quartz/CTRunData.cxx b/vcl/quartz/CTRunData.cxx index 7ef3891..8f58d47 100644 --- a/vcl/quartz/CTRunData.cxx +++ b/vcl/quartz/CTRunData.cxx @@ -7,11 +7,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> #include <sal/types.h> + #include <cassert> -#include "quartz/utils.h" #include "CTRunData.hxx" +#include "quartz/utils.h" + CTRunData::CTRunData( CTRunRef pRun, int start) : ownership_flags(0) diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index 274da6b..321f371 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -17,27 +17,26 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "impfont.hxx" -#include "outfont.hxx" -#include "PhysicalFontCollection.hxx" -#include "sallayout.hxx" +#include <sal/config.h> + +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + +#include <vcl/settings.hxx> + +#include "ctfonts.hxx" +#include "impfont.hxx" #ifdef MACOSX -#include "osx/salinst.h" #include "osx/saldata.hxx" -// kCTForegroundColorFromContextAttributeName is available on 10.5, but it is "hidden" -#ifndef kCTForegroundColorFromContextAttributeName -extern const CFStringRef kCTForegroundColorFromContextAttributeName; -#endif +#include "osx/salinst.h" #endif +#include "outfont.hxx" +#include "PhysicalFontCollection.hxx" #include "quartz/salgdi.h" #include "quartz/utils.h" -#include "ctfonts.hxx" - -#include <vcl/settings.hxx> +#include "sallayout.hxx" -#include "basegfx/polygon/b2dpolygon.hxx" -#include "basegfx/matrix/b2dhommatrix.hxx" inline double toRadian(int nDegree) { @@ -45,10 +44,10 @@ inline double toRadian(int nDegree) } CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD ) -: mpFontData( static_cast<CoreTextFontData const *>(rFSD.mpFontData) ) -, mfFontStretch( 1.0 ) -, mfFontRotation( 0.0 ) -, mpStyleDict( NULL ) + : mpFontData( static_cast<CoreTextFontData const *>(rFSD.mpFontData) ) + , mfFontStretch( 1.0 ) + , mfFontRotation( 0.0 ) + , mpStyleDict( NULL ) { const FontSelectPattern* const pReqFont = &rFSD; @@ -70,7 +69,8 @@ CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD ) // create the style object for CoreText font attributes static const CFIndex nMaxDictSize = 16; // TODO: does this really suffice? mpStyleDict = CFDictionaryCreateMutable( NULL, nMaxDictSize, - &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks ); + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks ); CFBooleanRef pCFVertBool = pReqFont->mbVertical ? kCFBooleanTrue : kCFBooleanFalse; CFDictionarySetValue( mpStyleDict, kCTVerticalFormsAttributeName, pCFVertBool ); @@ -86,8 +86,9 @@ CoreTextStyle::CoreTextStyle( const FontSelectPattern& rFSD ) } // fake italic - if (((pReqFont->GetSlant() == ITALIC_NORMAL) || (pReqFont->GetSlant() == ITALIC_OBLIQUE)) - && (mpFontData->GetSlant() == ITALIC_NONE)) + if (((pReqFont->GetSlant() == ITALIC_NORMAL) || + (pReqFont->GetSlant() == ITALIC_OBLIQUE)) && + (mpFontData->GetSlant() == ITALIC_NONE)) { aMatrix = CGAffineTransformConcat(aMatrix, CGAffineTransformMake(1, 0, toRadian(120), 1, 0, 0)); } @@ -166,31 +167,42 @@ static void MyCGPathApplierFunc( void* pData, const CGPathElement* pElement ) { case kCGPathElementCloseSubpath: case kCGPathElementMoveToPoint: - if( nPointCount > 0 ) { + if( nPointCount > 0 ) + { static_cast<GgoData*>(pData)->mpPolyPoly->append( rPolygon ); rPolygon.clear(); } // fall through for kCGPathElementMoveToPoint: if( pElement->type != kCGPathElementMoveToPoint ) + { break; + } case kCGPathElementAddLineToPoint: rPolygon.append( basegfx::B2DPoint( +pElement->points[0].x, -pElement->points[0].y ) ); break; + case kCGPathElementAddCurveToPoint: rPolygon.append( basegfx::B2DPoint( +pElement->points[2].x, -pElement->points[2].y ) ); - rPolygon.setNextControlPoint( nPointCount-1, basegfx::B2DPoint( pElement->points[0].x, -pElement->points[0].y ) ); - rPolygon.setPrevControlPoint( nPointCount+0, basegfx::B2DPoint( pElement->points[1].x, -pElement->points[1].y ) ); + rPolygon.setNextControlPoint( nPointCount - 1, + basegfx::B2DPoint( pElement->points[0].x, + -pElement->points[0].y ) ); + rPolygon.setPrevControlPoint( nPointCount + 0, + basegfx::B2DPoint( pElement->points[1].x, + -pElement->points[1].y ) ); + break; + + case kCGPathElementAddQuadCurveToPoint: + { + const basegfx::B2DPoint aStartPt = rPolygon.getB2DPoint( nPointCount-1 ); + const basegfx::B2DPoint aCtrPt1( (aStartPt.getX() + 2 * pElement->points[0].x) / 3.0, + (aStartPt.getY() - 2 * pElement->points[0].y) / 3.0 ); + const basegfx::B2DPoint aCtrPt2( (+2 * pElement->points[0].x + pElement->points[1].x) / 3.0, + (-2 * pElement->points[0].y - pElement->points[1].y) / 3.0 ); + rPolygon.append( basegfx::B2DPoint( +pElement->points[1].x, -pElement->points[1].y ) ); + rPolygon.setNextControlPoint( nPointCount-1, aCtrPt1 ); + rPolygon.setPrevControlPoint( nPointCount+0, aCtrPt2 ); + } break; - case kCGPathElementAddQuadCurveToPoint: { - const basegfx::B2DPoint aStartPt = rPolygon.getB2DPoint( nPointCount-1 ); - const basegfx::B2DPoint aCtrPt1( (aStartPt.getX() + 2* pElement->points[0].x) / 3.0, - (aStartPt.getY() - 2 * pElement->points[0].y) / 3.0 ); - const basegfx::B2DPoint aCtrPt2( (+2 * +pElement->points[0].x + pElement->points[1].x) / 3.0, - (-2 * pElement->points[0].y - pElement->points[1].y) / 3.0 ); - rPolygon.append( basegfx::B2DPoint( +pElement->points[1].x, -pElement->points[1].y ) ); - rPolygon.setNextControlPoint( nPointCount-1, aCtrPt1 ); - rPolygon.setPrevControlPoint( nPointCount+0, aCtrPt2 ); - } break; } } @@ -202,7 +214,8 @@ bool CoreTextStyle::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolyg // XXX: this is broken if the glyph came from fallback font CTFontRef pCTFont = static_cast<CTFontRef>(CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName )); CGPathRef xPath = CTFontCreatePathForGlyph( pCTFont, nCGGlyph, NULL ); - if (!xPath) { + if (!xPath) + { return false; } @@ -262,8 +275,8 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool // all CoreText fonts are device fonts that can rotate just fine ImplDevFontAttributes rDFA; rDFA.mbOrientation = true; - rDFA.mbDevice = true; - rDFA.mnQuality = 0; + rDFA.mbDevice = true; + rDFA.mnQuality = 0; // reset the font attributes rDFA.SetFamilyType( FAMILY_DONTKNOW ); @@ -280,9 +293,12 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool // get font name #ifdef MACOSX const OUString aUILang = Application::GetSettings().GetUILanguageTag().getLanguage(); - CFStringRef pUILang = CFStringCreateWithCharacters( kCFAllocatorDefault, aUILang.getStr(), aUILang.getLength() ); + CFStringRef pUILang = CFStringCreateWithCharacters( kCFAllocatorDefault, + aUILang.getStr(), aUILang.getLength() ); CFStringRef pLang = NULL; - CFStringRef pFamilyName = static_cast<CFStringRef>(CTFontDescriptorCopyLocalizedAttribute( pFD, kCTFontFamilyNameAttribute, &pLang )); + CFStringRef pFamilyName = static_cast<CFStringRef>( + CTFontDescriptorCopyLocalizedAttribute( pFD, kCTFontFamilyNameAttribute, &pLang )); + if ( !pLang || ( CFStringCompare( pUILang, pLang, 0 ) != kCFCompareEqualTo )) { if(pFamilyName) @@ -305,7 +321,8 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool rDFA.SetStyleName( GetOUString( pStyleName ) ); // get font-enabled status - if( bFontEnabled ) { + if( bFontEnabled ) + { int bEnabled = TRUE; // by default (and when we're on OS X < 10.6) it's "enabled" CFNumberRef pEnabled = static_cast<CFNumberRef>(CTFontDescriptorCopyAttribute( pFD, kCTFontEnabledAttribute )); CFNumberGetValue( pEnabled, kCFNumberIntType, &bEnabled ); @@ -319,7 +336,8 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool // TODO: use other traits such as MonoSpace/Condensed/Expanded or Vertical too SInt64 nSymbolTrait = 0; CFNumberRef pSymbolNum = NULL; - if( CFDictionaryGetValueIfPresent( pAttrDict, kCTFontSymbolicTrait, reinterpret_cast<const void**>(&pSymbolNum) ) ) { + if( CFDictionaryGetValueIfPresent( pAttrDict, kCTFontSymbolicTrait, reinterpret_cast<const void**>(&pSymbolNum) ) ) + { CFNumberGetValue( pSymbolNum, kCFNumberSInt64Type, &nSymbolTrait ); rDFA.SetSymbolFlag( ((nSymbolTrait & kCTFontClassMaskTrait) == kCTFontSymbolicClass) ); } @@ -329,14 +347,21 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool CFNumberRef pWeightNum = static_cast<CFNumberRef>(CFDictionaryGetValue( pAttrDict, kCTFontWeightTrait )); CFNumberGetValue( pWeightNum, kCFNumberDoubleType, &fWeight ); int nInt = WEIGHT_NORMAL; - if( fWeight > 0 ) { + if( fWeight > 0 ) + { nInt = rint(WEIGHT_NORMAL + fWeight * ((WEIGHT_BLACK - WEIGHT_NORMAL)/0.68)); if( nInt > WEIGHT_BLACK ) + { nInt = WEIGHT_BLACK; - } else if( fWeight < 0 ) { + } + } + else if( fWeight < 0 ) + { nInt = rint(WEIGHT_NORMAL + fWeight * ((WEIGHT_NORMAL - WEIGHT_THIN)/0.9)); if( nInt < WEIGHT_THIN ) + { nInt = WEIGHT_THIN; + } } rDFA.SetWeight( (FontWeight)nInt ); @@ -345,21 +370,30 @@ ImplDevFontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool CFNumberRef pSlantNum = static_cast<CFNumberRef>(CFDictionaryGetValue( pAttrDict, kCTFontSlantTrait )); CFNumberGetValue( pSlantNum, kCFNumberDoubleType, &fSlant ); if( fSlant >= 0.035 ) + { rDFA.SetItalic( ITALIC_NORMAL ); - + } // get width trait double fWidth = 0; CFNumberRef pWidthNum = static_cast<CFNumberRef>(CFDictionaryGetValue( pAttrDict, kCTFontWidthTrait )); CFNumberGetValue( pWidthNum, kCFNumberDoubleType, &fWidth ); nInt = WIDTH_NORMAL; - if( fWidth > 0 ) { + + if( fWidth > 0 ) + { nInt = rint( WIDTH_NORMAL + fWidth * ((WIDTH_ULTRA_EXPANDED - WIDTH_NORMAL)/0.4)); if( nInt > WIDTH_ULTRA_EXPANDED ) + { nInt = WIDTH_ULTRA_EXPANDED; - } else if( fWidth < 0 ) { + } + } + else if( fWidth < 0 ) + { nInt = rint( WIDTH_NORMAL + fWidth * ((WIDTH_NORMAL - WIDTH_ULTRA_CONDENSED)/0.5)); if( nInt < WIDTH_ULTRA_CONDENSED ) + { nInt = WIDTH_ULTRA_CONDENSED; + } } rDFA.SetWidthType( (FontWidth)nInt ); @@ -389,21 +423,27 @@ static void CTFontEnumCallBack( const void* pValue, void* pContext ) } SystemFontList::SystemFontList() -: mpCTFontCollection( NULL ) -, mpCTFontArray( NULL ) + : mpCTFontCollection( NULL ) + , mpCTFontArray( NULL ) {} SystemFontList::~SystemFontList() { CTFontContainer::const_iterator it = maFontContainer.begin(); for(; it != maFontContainer.end(); ++it ) + { delete (*it).second; + } maFontContainer.clear(); if( mpCTFontArray ) + { CFRelease( mpCTFontArray ); + } if( mpCTFontCollection ) + { CFRelease( mpCTFontCollection ); + } } void SystemFontList::AddFont( CoreTextFontData* pFontData ) @@ -416,14 +456,18 @@ void SystemFontList::AnnounceFonts( PhysicalFontCollection& rFontCollection ) co { CTFontContainer::const_iterator it = maFontContainer.begin(); for(; it != maFontContainer.end(); ++it ) + { rFontCollection.Add( (*it).second->Clone() ); + } } CoreTextFontData* SystemFontList::GetFontDataFromId( sal_IntPtr nFontId ) const { CTFontContainer::const_iterator it = maFontContainer.find( nFontId ); if( it == maFontContainer.end() ) + { return NULL; + } return (*it).second; } @@ -432,12 +476,15 @@ bool SystemFontList::Init() // enumerate available system fonts static const int nMaxDictEntries = 8; CFMutableDictionaryRef pCFDict = CFDictionaryCreateMutable( NULL, - nMaxDictEntries, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks ); + nMaxDictEntries, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks ); + CFDictionaryAddValue( pCFDict, kCTFontCollectionRemoveDuplicatesOption, kCFBooleanTrue ); mpCTFontCollection = CTFontCollectionCreateFromAvailableFonts( pCFDict ); CFRelease( pCFDict ); - mpCTFontArray = CTFontCollectionCreateMatchingFontDescriptors( mpCTFontCollection ); + const int nFontCount = CFArrayGetCount( mpCTFontArray ); const CFRange aFullRange = CFRangeMake( 0, nFontCount ); CFArrayApplyFunction( mpCTFontArray, aFullRange, CTFontEnumCallBack, this ); @@ -448,7 +495,8 @@ bool SystemFontList::Init() SystemFontList* GetCoretextFontList() { SystemFontList* pList = new SystemFontList(); - if( !pList->Init() ) { + if( !pList->Init() ) + { delete pList; return NULL; } diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx index 20dca01..f1acd17 100644 --- a/vcl/quartz/ctlayout.cxx +++ b/vcl/quartz/ctlayout.cxx @@ -17,14 +17,16 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <sal/types.h> +#include <sal/config.h> + #include <boost/ptr_container/ptr_vector.hpp> -#include "tools/debug.hxx" -#include "quartz/utils.h" +#include <sal/types.h> +#include <tools/debug.hxx> #include "ctfonts.hxx" #include "CTRunData.hxx" +#include "quartz/utils.h" class CTLayout : public SalLayout @@ -625,7 +627,9 @@ DeviceCoordinate CTLayout::FillDXArray( DeviceCoordinate* pDXArray ) const for( int i = 0; i != nGlyphCount; ++i ) { const int nRelIndex = aIndexVector[i]; - SAL_INFO( "vcl.ct", "aWidthVector[ g:" << i << "-> c:" << nRelIndex << " ] = " << aWidthVector[nRelIndex] << " + " << aSizeVector[i].width << " = " << aWidthVector[nRelIndex] + aSizeVector[i].width); + SAL_INFO( "vcl.ct", "aWidthVector[ g:" << i << "-> c:" << nRelIndex << " ] = " << + aWidthVector[nRelIndex] << " + " << aSizeVector[i].width << " = " << + aWidthVector[nRelIndex] + aSizeVector[i].width); aWidthVector[nRelIndex] += aSizeVector[i].width; } } @@ -666,19 +670,25 @@ sal_Int32 CTLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate n // check if the original extra-width guess was good if( !nCharExtra ) nBestGuess = nNewIndex; + if( nBestGuess == nNewIndex ) break; + // prepare another round for a different number of characters CFIndex nNewGuess = (nNewIndex + nBestGuess + 1) / 2; if( nNewGuess == nBestGuess ) + { nNewGuess += (nNewIndex > nBestGuess) ? +1 : -1; + } nBestGuess = nNewGuess; } // suggest the best fitting cluster break as breaking position CFRelease( aCTTypeSetter ); + const int nIndex = nBestGuess + mnMinCharPos; SAL_INFO("vcl.ct", "GetTextBreak nIndex:" << nIndex); + return nIndex; } diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index 7dbbfb0..8463d06 100644 --- a/vcl/quartz/salbmp.cxx +++ b/vcl/quartz/salbmp.cxx @@ -22,16 +22,14 @@ #include <cstddef> #include <limits> -#include "basebmp/scanlineformats.hxx" -#include "basebmp/color.hxx" - -#include "basegfx/vector/b2ivector.hxx" - -#include "tools/color.hxx" - -#include "vcl/bitmap.hxx" -#include "vcl/salbtype.hxx" +#include <basebmp/scanlineformats.hxx> +#include <basebmp/color.hxx> +#include <basegfx/vector/b2ivector.hxx> +#include <tools/color.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/salbtype.hxx> +#include "bmpfast.hxx" #include "quartz/salbmp.h" #include "quartz/utils.h" @@ -41,8 +39,6 @@ #include "saldatabasic.hxx" #endif -#include "bmpfast.hxx" - static const unsigned long k16BitRedColorMask = 0x00007c00; static const unsigned long k16BitGreenColorMask = 0x000003e0; static const unsigned long k16BitBlueColorMask = 0x0000001f; @@ -61,6 +57,7 @@ static void writeImageToFile(CGImageRef image, const char *baseName) static bool bDoIt = getenv("DBG_WRITE_CGIMAGES"); if (!bDoIt) return; + static int counter = 0; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; @@ -69,9 +66,12 @@ static void writeImageToFile(CGImageRef image, const char *baseName) CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, NULL); CGImageDestinationAddImage(destination, image, nil); - if (!CGImageDestinationFinalize(destination)) { + if (!CGImageDestinationFinalize(destination)) + { NSLog(@"Failed to write image to %@", path); - } else { + } + else + { SAL_DEBUG("--- saved image " << baseName << " to " << [path UTF8String]); } @@ -88,16 +88,17 @@ static void writeImageToFile(CGImageRef image, const char *baseName) static bool isValidBitCount( sal_uInt16 nBitCount ) { - return (nBitCount == 1) || (nBitCount == 4) || (nBitCount == 8) || (nBitCount == 16) || (nBitCount == 24) || (nBitCount == 32); + return (nBitCount == 1) || (nBitCount == 4) || (nBitCount == 8) || + (nBitCount == 16) || (nBitCount == 24) || (nBitCount == 32); } QuartzSalBitmap::QuartzSalBitmap() -: mxGraphicContext( NULL ) -, mxCachedImage( NULL ) -, mnBits(0) -, mnWidth(0) -, mnHeight(0) -, mnBytesPerRow(0) + : mxGraphicContext( NULL ) + , mxCachedImage( NULL ) + , mnBits(0) + , mnWidth(0) + , mnHeight(0) + , mnBytesPerRow(0) { } @@ -114,14 +115,18 @@ bool QuartzSalBitmap::Create( CGLayerRef xLayer, int nBitmapBits, // sanitize input parameters if( nX < 0 ) nWidth += nX, nX = 0; + if( nY < 0 ) nHeight += nY, nY = 0; + const CGSize aLayerSize = CGLayerGetSize( xLayer ); - CG_TRACE( "CGLayerGetSize(" << xLayer << ") = " << aLayerSize ); + SAL_INFO("vcl.cg", "CGLayerGetSize(" << xLayer << ") = " << aLayerSize ); if( nWidth >= (int)aLayerSize.width - nX ) nWidth = (int)aLayerSize.width - nX; + if( nHeight >= (int)aLayerSize.height - nY ) nHeight = (int)aLayerSize.height - nY; + if( (nWidth < 0) || (nHeight < 0) ) nWidth = nHeight = 0; @@ -137,7 +142,7 @@ bool QuartzSalBitmap::Create( CGLayerRef xLayer, int nBitmapBits, const CGPoint aSrcPoint = { static_cast<CGFloat>(-nX), static_cast<CGFloat>(-nY) }; if(mxGraphicContext) // remove warning { - CG_TRACE( "CGContextDrawLayerAtPoint(" << mxGraphicContext << "," << aSrcPoint << "," << xLayer << ")" ); + SAL_INFO("vcl.cg", "CGContextDrawLayerAtPoint(" << mxGraphicContext << "," << aSrcPoint << "," << xLayer << ")" ); CGContextDrawLayerAtPoint( mxGraphicContext, aSrcPoint, xLayer ); } return true; @@ -147,6 +152,7 @@ bool QuartzSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapP { if( !isValidBitCount( nBits ) ) return false; + maPalette = rBitmapPalette; mnBits = nBits; mnWidth = rSize.Width(); @@ -177,14 +183,18 @@ bool QuartzSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount if( AllocateUserData() ) { - ConvertBitmapData( mnWidth, mnHeight, mnBits, mnBytesPerRow, maPalette, maUserBuffer.get(), rSourceBitmap.mnBits, rSourceBitmap.mnBytesPerRow, rSourceBitmap.maPalette, rSourceBitmap.maUserBuffer.get() ); + ConvertBitmapData( mnWidth, mnHeight, mnBits, mnBytesPerRow, maPalette, + maUserBuffer.get(), rSourceBitmap.mnBits, + rSourceBitmap.mnBytesPerRow, rSourceBitmap.maPalette, + rSourceBitmap.maUserBuffer.get() ); return true; } } return false; } -bool QuartzSalBitmap::Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas >& /*xBitmapCanvas*/, Size& /*rSize*/, bool /*bMask*/ ) +bool QuartzSalBitmap::Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& /*xBitmapCanvas*/, + Size& /*rSize*/, bool /*bMask*/ ) { return false; } @@ -199,14 +209,14 @@ void QuartzSalBitmap::DestroyContext() { if( mxCachedImage ) { - CG_TRACE( "CGImageRelease(" << mxCachedImage << ")" ); + SAL_INFO("vcl.cg", "CGImageRelease(" << mxCachedImage << ")" ); CGImageRelease( mxCachedImage ); mxCachedImage = NULL; } if( mxGraphicContext ) { - CG_TRACE( "CGContextRelease(" << mxGraphicContext << ")" ); + SAL_INFO("vcl.cg", "CGContextRelease(" << mxGraphicContext << ")" ); CGContextRelease( mxGraphicContext ); mxGraphicContext = NULL; maContextBuffer.reset(); @@ -257,9 +267,11 @@ bool QuartzSalBitmap::CreateContext() #endif if( !bSkipConversion ) + { ConvertBitmapData( mnWidth, mnHeight, - 32, nContextBytesPerRow, maPalette, maContextBuffer.get(), - mnBits, mnBytesPerRow, maPalette, maUserBuffer.get() ); + 32, nContextBytesPerRow, maPalette, maContextBuffer.get(), + mnBits, mnBytesPerRow, maPalette, maUserBuffer.get() ); + } } catch( const std::bad_alloc& ) { @@ -270,8 +282,9 @@ bool QuartzSalBitmap::CreateContext() if( maContextBuffer.get() ) { mxGraphicContext = CGBitmapContextCreate( maContextBuffer.get(), mnWidth, mnHeight, - bitsPerComponent, nContextBytesPerRow, aCGColorSpace, aCGBmpInfo ); - CG_TRACE( "CGBitmapContextCreate(" << mnWidth << "x" << mnHeight << "x" << bitsPerComponent << ") = " << mxGraphicContext ); + bitsPerComponent, nContextBytesPerRow, + aCGColorSpace, aCGBmpInfo ); + SAL_INFO("vcl.cg", "CGBitmapContextCreate(" << mnWidth << "x" << mnHeight << "x" << bitsPerComponent << ") = " << mxGraphicContext ); } if( !mxGraphicContext ) @@ -302,8 +315,8 @@ bool QuartzSalBitmap::AllocateUserData() } bool alloc = false; - if (mnBytesPerRow != 0 - && mnBytesPerRow <= std::numeric_limits<sal_uInt32>::max() / mnHeight) + if (mnBytesPerRow != 0 && + mnBytesPerRow <= std::numeric_limits<sal_uInt32>::max() / mnHeight) { try { @@ -314,8 +327,7 @@ bool QuartzSalBitmap::AllocateUserData() } if (!alloc) { - SAL_WARN( - "vcl.quartz", "bad alloc " << mnBytesPerRow << "x" << mnHeight); + SAL_WARN( "vcl.quartz", "bad alloc " << mnBytesPerRow << "x" << mnHeight); maUserBuffer.reset( static_cast<sal_uInt8*>(NULL) ); mnBytesPerRow = 0; } @@ -323,7 +335,9 @@ bool QuartzSalBitmap::AllocateUserData() else { for (size_t i = 0; i < mnBytesPerRow * mnHeight; i++) + { maUserBuffer.get()[i] = (i & 0xFF); + } } #endif @@ -429,23 +443,25 @@ private: public: explicit ImplPixelFormat8( const BitmapPalette& rPalette ) - : mrPalette( rPalette ) - { - } + : mrPalette( rPalette ) + { + } virtual void StartLine( sal_uInt8* pLine ) SAL_OVERRIDE { pData = pLine; } virtual void SkipPixel( sal_uInt32 nPixel ) SAL_OVERRIDE - { - pData += nPixel; - } + { + pData += nPixel; + } virtual ColorData ReadPixel() SAL_OVERRIDE - { - return mrPalette[ *pData++ ].operator Color().GetColor(); - } + { + return mrPalette[ *pData++ ].operator Color().GetColor(); + } virtual void WritePixel( ColorData nColor ) SAL_OVERRIDE - { - const BitmapColor aColor( COLORDATA_RED( nColor ), COLORDATA_GREEN( nColor ), COLORDATA_BLUE( nColor ) ); - *pData++ = static_cast< sal_uInt8 >( mrPalette.GetBestIndex( aColor ) ); - } + { + const BitmapColor aColor( COLORDATA_RED( nColor ), + COLORDATA_GREEN( nColor ), + COLORDATA_BLUE( nColor ) ); + *pData++ = static_cast< sal_uInt8 >( mrPalette.GetBestIndex( aColor ) ); + } }; class ImplPixelFormat4 : public ImplPixelFormat @@ -458,36 +474,40 @@ private: public: explicit ImplPixelFormat4( const BitmapPalette& rPalette ) - : mrPalette( rPalette ) - { - } + : mrPalette( rPalette ) + { + } virtual void SkipPixel( sal_uInt32 nPixel ) SAL_OVERRIDE - { - mnX += nPixel; - if( (nPixel & 1) ) - mnShift ^= 4; - } + { + mnX += nPixel; + if( (nPixel & 1) ) + { + mnShift ^= 4; + } + } virtual void StartLine( sal_uInt8* pLine ) SAL_OVERRIDE - { - pData = pLine; - mnX = 0; - mnShift = 4; - } + { + pData = pLine; + mnX = 0; + mnShift = 4; + } virtual ColorData ReadPixel() SAL_OVERRIDE - { - const BitmapColor& rColor = mrPalette[( pData[mnX >> 1] >> mnShift) & 0x0f]; - mnX++; - mnShift ^= 4; - return rColor.operator Color().GetColor(); - } + { + const BitmapColor& rColor = mrPalette[( pData[mnX >> 1] >> mnShift) & 0x0f]; + mnX++; + mnShift ^= 4; + return rColor.operator Color().GetColor(); + } virtual void WritePixel( ColorData nColor ) SAL_OVERRIDE - { - const BitmapColor aColor( COLORDATA_RED( nColor ), COLORDATA_GREEN( nColor ), COLORDATA_BLUE( nColor ) ); - pData[mnX>>1] &= (0xf0 >> mnShift); - pData[mnX>>1] |= (static_cast< sal_uInt8 >( mrPalette.GetBestIndex( aColor ) ) & 0x0f); - mnX++; - mnShift ^= 4; - } + { + const BitmapColor aColor( COLORDATA_RED( nColor ), + COLORDATA_GREEN( nColor ), + COLORDATA_BLUE( nColor ) ); + pData[mnX>>1] &= (0xf0 >> mnShift); + pData[mnX>>1] |= (static_cast< sal_uInt8 >( mrPalette.GetBestIndex( aColor ) ) & 0x0f); + mnX++; + mnShift ^= 4; + } }; class ImplPixelFormat1 : public ImplPixelFormat @@ -499,33 +519,39 @@ private: public: explicit ImplPixelFormat1( const BitmapPalette& rPalette ) - : mrPalette( rPalette ) - { - } + : mrPalette( rPalette ) + { + } virtual void SkipPixel( sal_uInt32 nPixel ) SAL_OVERRIDE - { - mnX += nPixel; - } + { + mnX += nPixel; + } virtual void StartLine( sal_uInt8* pLine ) SAL_OVERRIDE - { - pData = pLine; - mnX = 0; - } + { + pData = pLine; + mnX = 0; + } virtual ColorData ReadPixel() SAL_OVERRIDE - { - const BitmapColor& rColor = mrPalette[ (pData[mnX >> 3 ] >> ( 7 - ( mnX & 7 ) )) & 1]; - mnX++; - return rColor.operator Color().GetColor(); - } + { + const BitmapColor& rColor = mrPalette[ (pData[mnX >> 3 ] >> ( 7 - ( mnX & 7 ) )) & 1]; + mnX++; + return rColor.operator Color().GetColor(); + } virtual void WritePixel( ColorData nColor ) SAL_OVERRIDE - { - const BitmapColor aColor( COLORDATA_RED( nColor ), COLORDATA_GREEN( nColor ), COLORDATA_BLUE( nColor ) ); - if( mrPalette.GetBestIndex( aColor ) & 1 ) - pData[ mnX >> 3 ] |= 1 << ( 7 - ( mnX & 7 ) ); - else - pData[ mnX >> 3 ] &= ~( 1 << ( 7 - ( mnX & 7 ) ) ); - mnX++; - } + { + const BitmapColor aColor( COLORDATA_RED( nColor ), + COLORDATA_GREEN( nColor ), + COLORDATA_BLUE( nColor ) ); + if( mrPalette.GetBestIndex( aColor ) & 1 ) + { + pData[ mnX >> 3 ] |= 1 << ( 7 - ( mnX & 7 ) ); + } + else + { + pData[ mnX >> 3 ] &= ~( 1 << ( 7 - ( mnX & 7 ) ) ); + } + mnX++; + } }; ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette ) @@ -538,19 +564,25 @@ ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalet case 16: return new ImplPixelFormat16; case 24: return new ImplPixelFormat24; case 32: return new ImplPixelFormat32; + default: + assert(false); + return nullptr; } return 0; } -} +} // namespace void QuartzSalBitmap::ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight, - sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, const BitmapPalette& rDestPalette, sal_uInt8* pDestData, - sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData ) + sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, + const BitmapPalette& rDestPalette, sal_uInt8* pDestData, + sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, + const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData ) { - if( (nDestBytesPerRow == nSrcBytesPerRow) && (nDestBits == nSrcBits) && ((nSrcBits != 8) || (rDestPalette.operator==( rSrcPalette ))) ) + if( (nDestBytesPerRow == nSrcBytesPerRow) && + (nDestBits == nSrcBits) && ((nSrcBits != 8) || (rDestPalette.operator==( rSrcPalette ))) ) { // simple case, same format, so just copy memcpy( pDestData, pSrcData, nHeight * nDestBytesPerRow ); @@ -598,8 +630,9 @@ void QuartzSalBitmap::ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight, sal_uInt32 nX = nWidth; while( nX-- ) + { pD->WritePixel( pS->ReadPixel() ); - + } pSrcData += nSrcBytesPerRow; pDestData += nDestBytesPerRow; } @@ -671,7 +704,7 @@ const BitmapPalette& GetDefaultPalette( int mnBits, bool bMonochrome ) aDefPalette256[i] = BitmapColor( aImplSalSysPalEntryAry[i].mnRed, aImplSalSysPalEntryAry[i].mnGreen, aImplSalSysPalEntryAry[i].mnBlue ); - } + } aDefPalette2[0] = BitmapColor( 0, 0, 0 ); aDefPalette2[1] = BitmapColor( 0xff, 0xff, 0xff ); @@ -753,7 +786,9 @@ void QuartzSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMo { maPalette = pBuffer->maPalette; if( mxGraphicContext ) + { DestroyContext(); + } } delete pBuffer; @@ -764,11 +799,14 @@ CGImageRef QuartzSalBitmap::CreateCroppedImage( int nX, int nY, int nNewWidth, i if( !mxCachedImage ) { if( !mxGraphicContext ) + { if( !const_cast<QuartzSalBitmap*>(this)->CreateContext() ) + { return NULL; - + } + } mxCachedImage = CGBitmapContextCreateImage( mxGraphicContext ); - CG_TRACE( "CGBitmapContextCreateImage(" << mxGraphicContext << ") = " << mxCachedImage ); + SAL_INFO("vcl.cg", "CGBitmapContextCreateImage(" << mxGraphicContext << ") = " << mxCachedImage ); } CGImageRef xCroppedImage = NULL; @@ -776,7 +814,7 @@ CGImageRef QuartzSalBitmap::CreateCroppedImage( int nX, int nY, int nNewWidth, i if( !nX && !nY && (mnWidth == nNewWidth) && (mnHeight == nNewHeight) ) { xCroppedImage = mxCachedImage; - CG_TRACE( "CFRetain(" << xCroppedImage << ")" ); + SAL_INFO("vcl.cg", "CFRetain(" << xCroppedImage << ")" ); CFRetain( xCroppedImage ); } else @@ -784,7 +822,7 @@ CGImageRef QuartzSalBitmap::CreateCroppedImage( int nX, int nY, int nNewWidth, i nY = mnHeight - (nY + nNewHeight); // adjust for y-mirrored context const CGRect aCropRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { static_cast<CGFloat>(nNewWidth), static_cast<CGFloat>(nNewHeight) } }; xCroppedImage = CGImageCreateWithImageInRect( mxCachedImage, aCropRect ); - CG_TRACE( "CGImageCreateWithImageInRect(" << mxCachedImage << "," << aCropRect << ") = " << xCroppedImage ); + SAL_INFO("vcl.cg", "CGImageCreateWithImageInRect(" << mxCachedImage << "," << aCropRect << ") = " << xCroppedImage ); } return xCroppedImage; @@ -819,18 +857,19 @@ CGImageRef QuartzSalBitmap::CreateWithMask( const QuartzSalBitmap& rMask, void* pMaskMem = rtl_allocateMemory( nMaskBytesPerRow * nHeight ); CGContextRef xMaskContext = CGBitmapContextCreate( pMaskMem, nWidth, nHeight, 8, nMaskBytesPerRow, GetSalData()->mxGraySpace, kCGImageAlphaNone ); - CG_TRACE( "CGBitmapContextCreate(" << nWidth << "x" << nHeight << "x8," << nMaskBytesPerRow << ") = " << xMaskContext ); - CG_TRACE( "CGContextDrawImage(" << xMaskContext << "," << xImageRect << "," << xMask << ")" ); + SAL_INFO("vcl.cg", "CGBitmapContextCreate(" << nWidth << "x" << nHeight << "x8," << nMaskBytesPerRow << ") = " << xMaskContext ); + SAL_INFO("vcl.cg", "CGContextDrawImage(" << xMaskContext << "," << xImageRect << "," << xMask << ")" ); CGContextDrawImage( xMaskContext, xImageRect, xMask ); - CG_TRACE( "CFRelease(" << xMask << ")" ); + SAL_INFO("vcl.cg", "CFRelease(" << xMask << ")" ); CFRelease( xMask ); CGDataProviderRef xDataProvider( CGDataProviderCreateWithData( NULL, pMaskMem, nHeight * nMaskBytesPerRow, &CFRTLFree ) ); + static const CGFloat* pDecode = NULL; xMask = CGImageMaskCreate( nWidth, nHeight, 8, 8, nMaskBytesPerRow, xDataProvider, pDecode, false ); - CG_TRACE( "CGImageMaskCreate(" << nWidth << "," << nHeight << ",8,8) = " << xMask ); + SAL_INFO("vcl.cg", "CGImageMaskCreate(" << nWidth << "," << nHeight << ",8,8) = " << xMask ); CFRelease( xDataProvider ); - CG_TRACE( "CFRelease(" << xMaskContext << ")" ); + SAL_INFO("vcl.cg", "CFRelease(" << xMaskContext << ")" ); CFRelease( xMaskContext ); } @@ -839,18 +878,20 @@ CGImageRef QuartzSalBitmap::CreateWithMask( const QuartzSalBitmap& rMask, // combine image and alpha mask CGImageRef xMaskedImage = CGImageCreateWithMask( xImage, xMask ); - CG_TRACE( "CGImageCreateWithMask(" << xImage << "," << xMask << ") = " << xMaskedImage ); + SAL_INFO("vcl.cg", "CGImageCreateWithMask(" << xImage << "," << xMask << ") = " << xMaskedImage ); DBG_WRITE_IMAGE(xImage, "xImage"); DBG_WRITE_IMAGE(xMaskedImage, "xMaskedImage"); - CG_TRACE( "CFRelease(" << xMask << ")" ); + SAL_INFO("vcl.cg", "CFRelease(" << xMask << ")" ); CFRelease( xMask ); - CG_TRACE( "CFRelease(" << xImage << ")" ); + SAL_INFO("vcl.cg", "CFRelease(" << xImage << ")" ); CFRelease( xImage ); return xMaskedImage; } -/** creates an image from the given rectangle, replacing all black pixels with nMaskColor and make all other full transparent */ -CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth, int nHeight, SalColor nMaskColor ) const +/** creates an image from the given rectangle, replacing all black pixels + with nMaskColor and make all other full transparent */ +CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth, + int nHeight, SalColor nMaskColor ) const { CGImageRef xMask = 0; if( maUserBuffer.get() && (nX + nWidth <= mnWidth) && (nY + nHeight <= mnHeight) ) @@ -888,7 +929,7 @@ CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth, int nHe CGDataProviderRef xDataProvider( CGDataProviderCreateWithData(NULL, pMaskBuffer, nHeight * nDestBytesPerRow, &CFRTLFree) ); xMask = CGImageCreate(nWidth, nHeight, 8, 32, nDestBytesPerRow, GetSalData()->mxRGBSpace, kCGImageAlphaPremultipliedFirst, xDataProvider, NULL, true, kCGRenderingIntentDefault); - CG_TRACE( "CGImageCreate(" << nWidth << "x" << nHeight << "x8) = " << xMask ); + SAL_INFO("vcl.cg", "CGImageCreate(" << nWidth << "x" << nHeight << "x8) = " << xMask ); CFRelease(xDataProvider); } else @@ -918,14 +959,15 @@ bool QuartzSalBitmap::GetSystemData( BitmapSystemData& rData ) bRet = true; if ((CGBitmapContextGetBitsPerPixel(mxGraphicContext) == 32) && - (CGBitmapContextGetBitmapInfo(mxGraphicContext) & kCGBitmapByteOrderMask) != kCGBitmapByteOrder32Host) { + (CGBitmapContextGetBitmapInfo(mxGraphicContext) & kCGBitmapByteOrderMask) != kCGBitmapByteOrder32Host) + { /** * We need to hack things because VCL does not use kCGBitmapByteOrder32Host, while Cairo requires it. */ OSL_TRACE("QuartzSalBitmap::%s(): kCGBitmapByteOrder32Host not found => inserting it.",__func__); CGImageRef xImage = CGBitmapContextCreateImage (mxGraphicContext); - CG_TRACE( "CGBitmapContextCreateImage(" << mxGraphicContext << ") = " << xImage ); + SAL_INFO("vcl.cg", "CGBitmapContextCreateImage(" << mxGraphicContext << ") = " << xImage ); // re-create the context with single change: include kCGBitmapByteOrder32Host flag. CGContextRef mxGraphicContextNew = CGBitmapContextCreate( CGBitmapContextGetData(mxGraphicContext), @@ -935,27 +977,27 @@ bool QuartzSalBitmap::GetSystemData( BitmapSystemData& rData ) CGBitmapContextGetBytesPerRow(mxGraphicContext), CGBitmapContextGetColorSpace(mxGraphicContext), CGBitmapContextGetBitmapInfo(mxGraphicContext) | kCGBitmapByteOrder32Host); - CG_TRACE( "CGBitmapContextCreate(" << CGBitmapContextGetWidth(mxGraphicContext) << "x" << CGBitmapContextGetHeight(mxGraphicContext) << "x" << CGBitmapContextGetBitsPerComponent(mxGraphicContext) << ") = " << mxGraphicContextNew ); + SAL_INFO("vcl.cg", "CGBitmapContextCreate(" << CGBitmapContextGetWidth(mxGraphicContext) << "x" << CGBitmapContextGetHeight(mxGraphicContext) << "x" << CGBitmapContextGetBitsPerComponent(mxGraphicContext) << ") = " << mxGraphicContextNew ); - CG_TRACE( "CFRelease(" << mxGraphicContext << ")" ); + SAL_INFO("vcl.cg", "CFRelease(" << mxGraphicContext << ")" ); CFRelease(mxGraphicContext); // Needs to be flipped - CG_TRACE( "CGContextSaveGState(" << mxGraphicContextNew << ")" ); + SAL_INFO("vcl.cg", "CGContextSaveGState(" << mxGraphicContextNew << ")" ); CGContextSaveGState( mxGraphicContextNew ); - CG_TRACE( "CGContextTranslateCTM(" << mxGraphicContextNew << ",0," << CGBitmapContextGetHeight(mxGraphicContextNew) << ")" ); + SAL_INFO("vcl.cg", "CGContextTranslateCTM(" << mxGraphicContextNew << ",0," << CGBitmapContextGetHeight(mxGraphicContextNew) << ")" ); CGContextTranslateCTM (mxGraphicContextNew, 0, CGBitmapContextGetHeight(mxGraphicContextNew)); - CG_TRACE( "CGContextScaleCTM(" << mxGraphicContextNew << ",1,-1)" ); + SAL_INFO("vcl.cg", "CGContextScaleCTM(" << mxGraphicContextNew << ",1,-1)" ); CGContextScaleCTM (mxGraphicContextNew, 1.0, -1.0); - CG_TRACE( "CGContextDrawImage(" << mxGraphicContextNew << "," << CGRectMake(0, 0, CGImageGetWidth(xImage), CGImageGetHeight(xImage)) << "," << xImage << ")" ); + SAL_INFO("vcl.cg", "CGContextDrawImage(" << mxGraphicContextNew << "," << CGRectMake(0, 0, CGImageGetWidth(xImage), CGImageGetHeight(xImage)) << "," << xImage << ")" ); CGContextDrawImage(mxGraphicContextNew, CGRectMake( 0, 0, CGImageGetWidth(xImage), CGImageGetHeight(xImage)), xImage); // Flip back - CG_TRACE( "CGContextRestoreGState(" << mxGraphicContextNew << ")" ); + SAL_INFO("vcl.cg", "CGContextRestoreGState(" << mxGraphicContextNew << ")" ); CGContextRestoreGState( mxGraphicContextNew ); - CG_TRACE( "CGImageRelease(" << xImage << ")" ); + SAL_INFO("vcl.cg", "CGImageRelease(" << xImage << ")" ); CGImageRelease( xImage ); mxGraphicContext = mxGraphicContextNew; } diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index f900bfa..ec7b0e0 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -17,75 +17,68 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> #include <config_folders.h> -#include "sal/config.h" - -#include "osl/file.hxx" -#include "osl/process.h" - -#include "osl/mutex.hxx" - -#include "rtl/bootstrap.h" -#include "rtl/strbuf.hxx" - -#include "basegfx/range/b2drectangle.hxx" -#include "basegfx/polygon/b2dpolygon.hxx" -#include "basegfx/polygon/b2dpolygontools.hxx" -#include "basegfx/matrix/b2dhommatrix.hxx" -#include "basegfx/matrix/b2dhommatrixtools.hxx" - -#include "vcl/sysdata.hxx" -#include "vcl/svapp.hxx" -#include "vcl/metric.hxx" +#include <basebmp/scanlineformats.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/range/b2drectangle.hxx> +#include <osl/file.hxx> +#include <osl/mutex.hxx> +#include <osl/process.h> +#include <rtl/bootstrap.h> +#include <rtl/strbuf.hxx> + +#include <vcl/metric.hxx> +#include <vcl/svapp.hxx> +#include <vcl/sysdata.hxx> +#include "ctfonts.hxx" +#include "fontsubset.hxx" #include "impfont.hxx" - -#include "quartz/salgdi.h" -#include "quartz/utils.h" - #ifdef MACOSX #include "osx/salframe.h" #endif - +#include "quartz/salgdi.h" +#include "quartz/utils.h" #ifdef IOS #include "saldatabasic.hxx" -#include <basebmp/scanlineformats.hxx> #endif - -#include "ctfonts.hxx" - -#include "fontsubset.hxx" #include "sallayout.hxx" #include "sft.hxx" using namespace vcl; CoreTextFontData::CoreTextFontData( const CoreTextFontData& rSrc ) -: PhysicalFontFace( rSrc ) -, mnFontId( rSrc.mnFontId ) -, mbOs2Read( rSrc.mbOs2Read ) -, mbHasOs2Table( rSrc.mbHasOs2Table ) -, mbCmapEncodingRead( rSrc.mbCmapEncodingRead ) + : PhysicalFontFace( rSrc ) + , mnFontId( rSrc.mnFontId ) + , mbOs2Read( rSrc.mbOs2Read ) + , mbHasOs2Table( rSrc.mbHasOs2Table ) + , mbCmapEncodingRead( rSrc.mbCmapEncodingRead ) { if( rSrc.mpCharMap ) mpCharMap = rSrc.mpCharMap; } CoreTextFontData::CoreTextFontData( const ImplDevFontAttributes& rDFA, sal_IntPtr nFontId ) -: PhysicalFontFace( rDFA, 0 ) -, mnFontId( nFontId ) -, mbOs2Read( false ) -, mbHasOs2Table( false ) -, mbCmapEncodingRead( false ) -, mbFontCapabilitiesRead( false ) + : PhysicalFontFace( rDFA, 0 ) + , mnFontId( nFontId ) + , mbOs2Read( false ) + , mbHasOs2Table( false ) + , mbCmapEncodingRead( false ) + , mbFontCapabilitiesRead( false ) { } CoreTextFontData::~CoreTextFontData() { if( mpCharMap ) + { mpCharMap = 0; + } } sal_IntPtr CoreTextFontData::GetFontId() const @@ -118,6 +111,7 @@ const FontCharMapPtr CoreTextFontData::GetFontCharMap() const DBG_ASSERT( (nRawLength > 0), "CoreTextFontData::GetFontCharMap : GetFontTable2 failed!\n"); if( nRawLength <= 0 ) return mpCharMap; + DBG_ASSERT( (nBufSize==nRawLength), "CoreTextFontData::GetFontCharMap : ByteCount mismatch!\n"); // parse the CMAP @@ -167,10 +161,9 @@ bool CoreTextFontData::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilit if( nRawLength > 0 ) { const unsigned char* pOS2Table = &aBuffer[0]; - vcl::getTTCoverage( - maFontCapabilities.maUnicodeRange, - maFontCapabilities.maCodePageRange, - pOS2Table, nRawLength); + vcl::getTTCoverage( maFontCapabilities.maUnicodeRange, + maFontCapabilities.maCodePageRange, + pOS2Table, nRawLength); } } rFontCapabilities = maFontCapabilities; @@ -182,6 +175,7 @@ void CoreTextFontData::ReadOs2Table() const // read this only once per font if( mbOs2Read ) return; + mbOs2Read = true; mbHasOs2Table = false; @@ -197,6 +191,7 @@ void CoreTextFontData::ReadOs2Table() const DBG_ASSERT( (nRawLength > 0), "CoreTextFontData::ReadOs2Table : GetFontTable2 failed!\n"); if( nRawLength <= 0 ) return; + DBG_ASSERT( (nBufSize==nRawLength), "CoreTextFontData::ReadOs2Table : ByteCount mismatch!\n"); mbHasOs2Table = true; @@ -209,6 +204,7 @@ void CoreTextFontData::ReadMacCmapEncoding() const // read this only once per font if( mbCmapEncodingRead ) return; + mbCmapEncodingRead = true; const int nBufSize = GetFontTable( "cmap", NULL ); @@ -227,12 +223,12 @@ void CoreTextFontData::ReadMacCmapEncoding() const return; } -AquaSalGraphics::AquaSalGraphics(): +AquaSalGraphics::AquaSalGraphics() + : mxLayer( NULL ) + , mrContext( NULL ) #ifdef MACOSX - mpFrame( NULL ), + , mpFrame( NULL ) #endif - mxLayer( NULL ) - , mrContext( NULL ) #if OSL_DEBUG_LEVEL > 0 , mnContextStackDepth( 0 ) #endif @@ -267,7 +263,7 @@ AquaSalGraphics::~AquaSalGraphics() if( mxClipPath ) { - CG_TRACE( "CGPathRelease(" << mxClipPath << ")" ); + SAL_INFO("vcl.cg", "CGPathRelease(" << mxClipPath << ")" ); CGPathRelease( mxClipPath ); } @@ -282,7 +278,7 @@ AquaSalGraphics::~AquaSalGraphics() #endif if( mxLayer ) { - CG_TRACE( "CGLayerRelease(" << mxLayer << ")" ); + SAL_INFO("vcl.cg", "CGLayerRelease(" << mxLayer << ")" ); CGLayerRelease( mxLayer ); } else if( mrContext @@ -292,7 +288,7 @@ AquaSalGraphics::~AquaSalGraphics() ) { // destroy backbuffer bitmap context that we created ourself - CG_TRACE( "CGContextRelease(" << mrContext << ")" ); + SAL_INFO("vcl.cg", "CGContextRelease(" << mrContext << ")" ); CGContextRelease( mrContext ); mrContext = NULL; } @@ -346,7 +342,9 @@ static void AddTempFontDir( const OUString &rFontDirUrl ) osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL ); rcOSL = aDirItem.getFileStatus( aFileStatus ); if ( rcOSL == osl::FileBase::E_None ) + { AddTempDevFont(aFileStatus.getFileURL()); + } } } } @@ -356,6 +354,7 @@ static void AddLocalTempFontDirs() static bool bFirst = true; if( !bFirst ) return; + bFirst = false; // add private font files @@ -477,7 +476,7 @@ bool AquaSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabiliti // fake a SFNT font directory entry for a font table // see http://developer.apple.com/fonts/TTRefMan/RM06/Chap6.html#Directory static void FakeDirEntry( const char aTag[5], ByteCount nOfs, ByteCount nLen, - const unsigned char* /*pData*/, unsigned char*& rpDest ) + const unsigned char* /*pData*/, unsigned char*& rpDest ) { // write entry tag rpDest[ 0] = aTag[0]; @@ -518,7 +517,9 @@ bool AquaSalGraphics::GetRawFontData( const PhysicalFontFace* pFontData, rBuffer.resize( nCffSize); const int nCffRead = pMacFont->GetFontTable( "CFF ", &rBuffer[0]); if( nCffRead != nCffSize) + { return false; + } return true; } } @@ -527,18 +528,23 @@ bool AquaSalGraphics::GetRawFontData( const PhysicalFontFace* pFontData, const int nHeadSize = pMacFont->GetFontTable( "head", NULL); if( nHeadSize <= 0) return false; + const int nMaxpSize = pMacFont->GetFontTable( "maxp", NULL); if( nMaxpSize <= 0) return false; + const int nCmapSize = pMacFont->GetFontTable( "cmap", NULL); if( nCmapSize <= 0) return false; + const int nNameSize = pMacFont->GetFontTable( "name", NULL); if( nNameSize <= 0) return false; + const int nHheaSize = pMacFont->GetFontTable( "hhea", NULL); if( nHheaSize <= 0) return false; + const int nHmtxSize = pMacFont->GetFontTable( "hmtx", NULL); if( nHmtxSize <= 0) return false; @@ -551,6 +557,7 @@ bool AquaSalGraphics::GetRawFontData( const PhysicalFontFace* pFontData, nLocaSize = pMacFont->GetFontTable( "loca", NULL); if( nLocaSize <= 0) return false; + nGlyfSize = pMacFont->GetFontTable( "glyf", NULL); if( nGlyfSize <= 0) return false; @@ -570,10 +577,15 @@ bool AquaSalGraphics::GetRawFontData( const PhysicalFontFace* pFontData, const ByteCount nFdirSize = 12 + 16*nTableCount; ByteCount nTotalSize = nFdirSize; nTotalSize += nHeadSize + nMaxpSize + nNameSize + nCmapSize; + if( nGlyfSize ) + { nTotalSize += nLocaSize + nGlyfSize; + } else + { nTotalSize += nCffSize; + } nTotalSize += nHheaSize + nHmtxSize; nTotalSize += nPrepSize + nCvtSize + nFpgmSize; rBuffer.resize( nTotalSize ); @@ -595,58 +607,78 @@ bool AquaSalGraphics::GetRawFontData( const PhysicalFontFace* pFontData, unsigned char* pFakeEntry = &rBuffer[12]; if( nCmapSize != pMacFont->GetFontTable( "cmap", &rBuffer[nOfs])) return false; + FakeDirEntry( "cmap", nOfs, nCmapSize, &rBuffer[0], pFakeEntry ); nOfs += nCmapSize; - if( nCvtSize ) { + if( nCvtSize ) + { if( nCvtSize != pMacFont->GetFontTable( "cvt ", &rBuffer[nOfs])) return false; + FakeDirEntry( "cvt ", nOfs, nCvtSize, &rBuffer[0], pFakeEntry ); nOfs += nCvtSize; } - if( nFpgmSize ) { + if( nFpgmSize ) + { if( nFpgmSize != pMacFont->GetFontTable( "fpgm", &rBuffer[nOfs])) return false; + FakeDirEntry( "fpgm", nOfs, nFpgmSize, &rBuffer[0], pFakeEntry ); nOfs += nFpgmSize; } - if( nCffSize ) { + if( nCffSize ) + { if( nCffSize != pMacFont->GetFontTable( "CFF ", &rBuffer[nOfs])) return false; + FakeDirEntry( "CFF ", nOfs, nCffSize, &rBuffer[0], pFakeEntry ); nOfs += nGlyfSize; - } else { + } + else + { if( nGlyfSize != pMacFont->GetFontTable( "glyf", &rBuffer[nOfs])) return false; + FakeDirEntry( "glyf", nOfs, nGlyfSize, &rBuffer[0], pFakeEntry ); nOfs += nGlyfSize; + if( nLocaSize != pMacFont->GetFontTable( "loca", &rBuffer[nOfs])) return false; + FakeDirEntry( "loca", nOfs, nLocaSize, &rBuffer[0], pFakeEntry ); nOfs += nLocaSize; } if( nHeadSize != pMacFont->GetFontTable( "head", &rBuffer[nOfs])) return false; + FakeDirEntry( "head", nOfs, nHeadSize, &rBuffer[0], pFakeEntry ); nOfs += nHeadSize; + if( nHheaSize != pMacFont->GetFontTable( "hhea", &rBuffer[nOfs])) return false; + FakeDirEntry( "hhea", nOfs, nHheaSize, &rBuffer[0], pFakeEntry ); nOfs += nHheaSize; if( nHmtxSize != pMacFont->GetFontTable( "hmtx", &rBuffer[nOfs])) return false; + FakeDirEntry( "hmtx", nOfs, nHmtxSize, &rBuffer[0], pFakeEntry ); nOfs += nHmtxSize; if( nMaxpSize != pMacFont->GetFontTable( "maxp", &rBuffer[nOfs])) return false; + FakeDirEntry( "maxp", nOfs, nMaxpSize, &rBuffer[0], pFakeEntry ); nOfs += nMaxpSize; if( nNameSize != pMacFont->GetFontTable( "name", &rBuffer[nOfs])) return false; + FakeDirEntry( "name", nOfs, nNameSize, &rBuffer[0], pFakeEntry ); nOfs += nNameSize; - if( nPrepSize ) { + if( nPrepSize ) + { if( nPrepSize != pMacFont->GetFontTable( "prep", &rBuffer[nOfs])) return false; + FakeDirEntry( "prep", nOfs, nPrepSize, &rBuffer[0], pFakeEntry ); nOfs += nPrepSize; } @@ -662,80 +694,91 @@ void AquaSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFontData, bool bV rGlyphWidths.clear(); rUnicodeEnc.clear(); - if( pFontData->IsSubsettable() ) + if( !pFontData->IsSubsettable() ) { - ByteVector aBuffer; - if( !GetRawFontData( pFontData, aBuffer, NULL ) ) - return; - - // TODO: modernize psprint's horrible fontsubset C-API - // this probably only makes sense after the switch to another SCM - // that can preserve change history after file renames - - // use the font subsetter to get the widths - TrueTypeFont* pSftFont = NULL; - int nRC = ::OpenTTFontBuffer( static_cast<void*>(&aBuffer[0]), aBuffer.size(), 0, &pSftFont); - if( nRC != SF_OK ) - return; - - const int nGlyphCount = ::GetTTGlyphCount( pSftFont ); - if( nGlyphCount > 0 ) + if( pFontData->IsEmbeddable() ) { - // get glyph metrics - rGlyphWidths.resize(nGlyphCount); - std::vector<sal_uInt16> aGlyphIds(nGlyphCount); - for( int i = 0; i < nGlyphCount; i++ ) - aGlyphIds[i] = static_cast<sal_uInt16>(i); - const TTSimpleGlyphMetrics* pGlyphMetrics = ::GetTTSimpleGlyphMetrics( - pSftFont, &aGlyphIds[0], nGlyphCount, bVertical ); - if( pGlyphMetrics ) + // get individual character widths + OSL_FAIL("not implemented for non-subsettable fonts!\n"); + } + return; + } + + ByteVector aBuffer; + if( !GetRawFontData( pFontData, aBuffer, NULL ) ) + return; + + // TODO: modernize psprint's horrible fontsubset C-API + // this probably only makes sense after the switch to another SCM + // that can preserve change history after file renames + + // use the font subsetter to get the widths + TrueTypeFont* pSftFont = NULL; + int nRC = ::OpenTTFontBuffer( static_cast<void*>(&aBuffer[0]), aBuffer.size(), 0, &pSftFont); + if( nRC != SF_OK ) + return; + + const int nGlyphCount = ::GetTTGlyphCount( pSftFont ); + if( nGlyphCount > 0 ) + { + // get glyph metrics + rGlyphWidths.resize(nGlyphCount); + std::vector<sal_uInt16> aGlyphIds(nGlyphCount); + for( int i = 0; i < nGlyphCount; i++ ) + { + aGlyphIds[i] = static_cast<sal_uInt16>(i); + } + + const TTSimpleGlyphMetrics* pGlyphMetrics = ::GetTTSimpleGlyphMetrics( pSftFont, &aGlyphIds[0], + nGlyphCount, bVertical ); + if( pGlyphMetrics ) + { + for( int i = 0; i < nGlyphCount; ++i ) { - for( int i = 0; i < nGlyphCount; ++i ) - rGlyphWidths[i] = pGlyphMetrics[i].adv; - free( const_cast<TTSimpleGlyphMetrics *>(pGlyphMetrics) ); + rGlyphWidths[i] = pGlyphMetrics[i].adv; } + free( const_cast<TTSimpleGlyphMetrics *>(pGlyphMetrics) ); + } + + FontCharMapPtr pMap = mpFontData->GetFontCharMap(); + DBG_ASSERT( pMap && pMap->GetCharCount(), "no charmap" ); - FontCharMapPtr pMap = mpFontData->GetFontCharMap(); - DBG_ASSERT( pMap && pMap->GetCharCount(), "no charmap" ); + // 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 ) ) + { + if( nChar > 0xFFFF ) // TODO: allow UTF-32 chars + break; - // 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 ) ) + sal_Ucs nUcsChar = static_cast<sal_Ucs>(nChar); + sal_uInt32 nGlyph = ::MapChar( pSftFont, nUcsChar, bVertical ); + if( nGlyph > 0 ) { - if( nChar > 0xFFFF ) // TODO: allow UTF-32 chars - break; - sal_Ucs nUcsChar = static_cast<sal_Ucs>(nChar); - sal_uInt32 nGlyph = ::MapChar( pSftFont, nUcsChar, bVertical ); - if( nGlyph > 0 ) - rUnicodeEnc[ nUcsChar ] = nGlyph; + rUnicodeEnc[ nUcsChar ] = nGlyph; } - - pMap = 0; } - ::CloseTTFont( pSftFont ); - } - else if( pFontData->IsEmbeddable() ) - { - // get individual character widths - OSL_FAIL("not implemented for non-subsettable fonts!\n"); + pMap = 0; } + + ::CloseTTFont( pSftFont ); } -const Ucs2SIntMap* AquaSalGraphics::GetFontEncodingVector( - const PhysicalFontFace*, const Ucs2OStrMap** /*ppNonEncoded*/, std::set<sal_Unicode> const** ) +const Ucs2SIntMap* AquaSalGraphics::GetFontEncodingVector( const PhysicalFontFace*, + const Ucs2OStrMap** /*ppNonEncoded*/, + std::set<sal_Unicode> const** ) { return NULL; } const void* AquaSalGraphics::GetEmbedFontData( const PhysicalFontFace*, - const sal_Ucs* /*pUnicodes*/, - sal_Int32* /*pWidths*/, - size_t /*nLen*/, - FontSubsetInfo&, - long* /*pDataLen*/ ) + const sal_Ucs* /*pUnicodes*/, + sal_Int32* /*pWidths*/, + size_t /*nLen*/, + FontSubsetInfo&, + long* /*pDataLen*/ ) { return NULL; } @@ -771,9 +814,9 @@ void AquaSalGraphics::RefreshRect(float lX, float lY, float lWidth, float lHeigh // The decrementing of x, the rounding error and the antialiasing border // require that the width and the height need to be increased by four const Rectangle aVclRect(Point(static_cast<long int>(lX-1), - static_cast<long int>(lY-1) ), - Size( static_cast<long int>(lWidth+4), - static_cast<long int>(lHeight+4) ) ); + static_cast<long int>(lY-1) ), + Size( static_cast<long int>(lWidth+4), + static_cast<long int>(lHeight+4) ) ); mpFrame->maInvalidRect.Union( aVclRect ); } #else diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx index 01fac7f..6a6efb5 100644 --- a/vcl/quartz/salgdicommon.cxx +++ b/vcl/quartz/salgdicommon.cxx @@ -17,27 +17,29 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "sal/config.h" +#include <sal/config.h> +#include <cassert> #include <cstring> -#include <sal/types.h> +#include <basegfx/polygon/b2dpolygon.hxx> #include <osl/endian.h> #include <osl/file.hxx> +#include <sal/types.h> -#include <basegfx/polygon/b2dpolygon.hxx> +#include <vcl/sysdata.hxx> +#include "fontsubset.hxx" #include "quartz/salbmp.h" +#ifdef MACOSX #include "quartz/salgdi.h" +#endif #include "quartz/utils.h" - -#include "fontsubset.hxx" -#include "sft.hxx" - #ifdef IOS #include "saldatabasic.hxx" -#include <vcl/sysdata.hxx> #endif +#include "sft.hxx" + #if defined(IOS) && defined(DBG_UTIL) @@ -120,7 +122,7 @@ static void AddPolygonToPath( CGMutablePathRef xPath, if( !nPointIdx ) { // first point => just move there - CG_TRACE("CGPathMoveToPoint(" << xPath << ",NULL," << aPoint.getX() << "," << aPoint.getY() << ")"); + SAL_INFO( "vcl.cg", "CGPathMoveToPoint(" << xPath << ",NULL," << aPoint.getX() << "," << aPoint.getY() << ")"); CGPathMoveToPoint( xPath, NULL, aPoint.getX(), aPoint.getY() ); continue; } @@ -134,7 +136,7 @@ static void AddPolygonToPath( CGMutablePathRef xPath, if( !bPendingCurve ) // line segment { - CG_TRACE("CGPathAddLineToPoint(" << xPath << ",NULL," << aPoint.getX() << "," << aPoint.getY() << ")"); + SAL_INFO( "vcl.cg", "CGPathAddLineToPoint(" << xPath << ",NULL," << aPoint.getX() << "," << aPoint.getY() << ")"); CGPathAddLineToPoint( xPath, NULL, aPoint.getX(), aPoint.getY() ); } else // cubic bezier segment @@ -146,7 +148,7 @@ static void AddPolygonToPath( CGMutablePathRef xPath, aCP1 += aHalfPointOfs; aCP2 += aHalfPointOfs; } - CG_TRACE( "CGPathAddCurveToPoint(" << xPath << ",NULL," << aCP1.getX() << "," << aCP1.getY() << "," << + SAL_INFO( "vcl.cg", "CGPathAddCurveToPoint(" << xPath << ",NULL," << aCP1.getX() << "," << aCP1.getY() << "," << aCP2.getX() << "," << aCP2.getY() << "," << aPoint.getX() << "," << aPoint.getY() << ")" ); CGPathAddCurveToPoint( xPath, NULL, aCP1.getX(), aCP1.getY(), aCP2.getX(), aCP2.getY(), aPoint.getX(), aPoint.getY() ); @@ -155,7 +157,7 @@ static void AddPolygonToPath( CGMutablePathRef xPath, if( bClosePath ) { - CG_TRACE( "CGPathCloseSubpath(" << xPath << ")" ); + SAL_INFO( "vcl.cg", "CGPathCloseSubpath(" << xPath << ")" ); CGPathCloseSubpath( xPath ); } } @@ -188,15 +190,19 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile, // prepare the requested file name for writing the font-subset file OUString aSysPath; if( osl_File_E_None != osl_getSystemPathFromFileURL( rToFile.pData, &aSysPath.pData ) ) + { return false; - const rtl_TextEncoding aThreadEncoding = osl_getThreadTextEncoding(); - const OString aToFile( OUStringToOString( aSysPath, aThreadEncoding ) ); + } // get the raw-bytes from the font to be subset ByteVector aBuffer; bool bCffOnly = false; if( !GetRawFontData( pFontData, aBuffer, &bCffOnly ) ) + { return false; + } + const OString aToFile( OUStringToOString( aSysPath, + osl_getThreadTextEncoding())); // handle CFF-subsetting if( bCffOnly ) @@ -210,7 +216,7 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile, // make the subsetter provide the requested subset FILE* pOutFile = fopen( aToFile.getStr(), "wb" ); bool bRC = rInfo.CreateFontSubset( FontSubsetInfo::TYPE1_PFB, pOutFile, NULL, - pGlyphIds, pEncoding, nGlyphCount, pGlyphWidths ); + pGlyphIds, pEncoding, nGlyphCount, pGlyphWidths ); fclose( pOutFile ); return bRC; } @@ -223,40 +229,52 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile, TrueTypeFont* pSftFont = NULL; int nRC = ::OpenTTFontBuffer( static_cast<void*>(&aBuffer[0]), aBuffer.size(), 0, &pSftFont); if( nRC != SF_OK ) + { return false; - + } // get details about the subsetted font TTGlobalFontInfo aTTInfo; ::GetTTGlobalFontInfo( pSftFont, &aTTInfo ); - rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; - rInfo.m_aPSName = OUString( - aTTInfo.psname, std::strlen(aTTInfo.psname), RTL_TEXTENCODING_UTF8 ); - rInfo.m_aFontBBox = Rectangle( Point( aTTInfo.xMin, aTTInfo.yMin ), - Point( aTTInfo.xMax, aTTInfo.yMax ) ); - rInfo.m_nCapHeight = aTTInfo.yMax; // Well ... - rInfo.m_nAscent = aTTInfo.winAscent; - rInfo.m_nDescent = aTTInfo.winDescent; + rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; + rInfo.m_aPSName = OUString( aTTInfo.psname, std::strlen(aTTInfo.psname), + RTL_TEXTENCODING_UTF8 ); + rInfo.m_aFontBBox = Rectangle( Point( aTTInfo.xMin, aTTInfo.yMin ), + Point( aTTInfo.xMax, aTTInfo.yMax ) ); + rInfo.m_nCapHeight = aTTInfo.yMax; // Well ... + rInfo.m_nAscent = aTTInfo.winAscent; + rInfo.m_nDescent = aTTInfo.winDescent; // mac fonts usually do not have an OS2-table // => get valid ascent/descent values from other tables if( !rInfo.m_nAscent ) + { rInfo.m_nAscent = +aTTInfo.typoAscender; + } if( !rInfo.m_nAscent ) + { rInfo.m_nAscent = +aTTInfo.ascender; + } if( !rInfo.m_nDescent ) + { rInfo.m_nDescent = +aTTInfo.typoDescender; + } if( !rInfo.m_nDescent ) + { rInfo.m_nDescent = -aTTInfo.descender; + } // subset glyphs and get their properties // take care that subset fonts require the NotDef glyph in pos 0 int nOrigCount = nGlyphCount; - sal_uInt16 aShortIDs[ 256 ]; - sal_uInt8 aTempEncs[ 256 ]; - + sal_uInt16 aShortIDs[ 257 ]; + sal_uInt8 aTempEncs[ 257 ]; int nNotDef = -1; + + assert( (nGlyphCount <= 256 && "too many glyphs for subsetting" )); + for( int i = 0; i < nGlyphCount; ++i ) { aTempEncs[i] = pEncoding[i]; + sal_GlyphId aGlyphId(pGlyphIds[i] & GF_IDXMASK); if( pGlyphIds[i] & GF_ISCHAR ) { @@ -271,44 +289,50 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile, } } aShortIDs[i] = static_cast<sal_uInt16>( aGlyphId ); - if( !aGlyphId ) - if( nNotDef < 0 ) - nNotDef = i; // first NotDef glyph found + if( !aGlyphId && nNotDef < 0 ) + { + nNotDef = i; // first NotDef glyph found + } } if( nNotDef != 0 ) { // add fake NotDef glyph if needed if( nNotDef < 0 ) + { nNotDef = nGlyphCount++; - + } // NotDef glyph must be in pos 0 => swap glyphids aShortIDs[ nNotDef ] = aShortIDs[0]; aTempEncs[ nNotDef ] = aTempEncs[0]; aShortIDs[0] = 0; aTempEncs[0] = 0; } - DBG_ASSERT( nGlyphCount < 257, "too many glyphs for subsetting" ); // TODO: where to get bVertical? const bool bVertical = false; // fill the pGlyphWidths array // while making sure that the NotDef glyph is at index==0 - TTSimpleGlyphMetrics* pGlyphMetrics = - ::GetTTSimpleGlyphMetrics( pSftFont, aShortIDs, nGlyphCount, bVertical ); + TTSimpleGlyphMetrics* pGlyphMetrics = ::GetTTSimpleGlyphMetrics( pSftFont, aShortIDs, + nGlyphCount, bVertical ); if( !pGlyphMetrics ) + { return false; - sal_uInt16 nNotDefAdv = pGlyphMetrics[0].adv; - pGlyphMetrics[0].adv = pGlyphMetrics[nNotDef].adv; + } + + sal_uInt16 nNotDefAdv = pGlyphMetrics[0].adv; + pGlyphMetrics[0].adv = pGlyphMetrics[nNotDef].adv; pGlyphMetrics[nNotDef].adv = nNotDefAdv; for( int i = 0; i < nOrigCount; ++i ) + { pGlyphWidths[i] = pGlyphMetrics[i].adv; + } free( pGlyphMetrics ); // write subset into destination file nRC = ::CreateTTFromTTGlyphs( pSftFont, aToFile.getStr(), aShortIDs, - aTempEncs, nGlyphCount, 0, NULL, 0 ); + aTempEncs, nGlyphCount, 0, NULL, 0 ); ::CloseTTFont(pSftFont); return (nRC == SF_OK); } @@ -328,10 +352,10 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap } //from unix salgdi2.cxx //[FIXME] find a better way to prevent calc from crashing when width and height are negative - if( rPosAry.mnSrcWidth <= 0 - || rPosAry.mnSrcHeight <= 0 - || rPosAry.mnDestWidth <= 0 - || rPosAry.mnDestHeight <= 0 ) + if( rPosAry.mnSrcWidth <= 0 || + rPosAry.mnSrcHeight <= 0 || + rPosAry.mnDestWidth <= 0 || + rPosAry.mnDestHeight <= 0 ) { return; } @@ -349,24 +373,28 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap || (mbWindow && mpFrame && pSrc->mbWindow && (mpFrame == pSrc->mpFrame)) #endif ; - if( bSameGraphics - && (rPosAry.mnSrcWidth == rPosAry.mnDestWidth) - && (rPosAry.mnSrcHeight == rPosAry.mnDestHeight)) + + if( bSameGraphics && + (rPosAry.mnSrcWidth == rPosAry.mnDestWidth) && + (rPosAry.mnSrcHeight == rPosAry.mnDestHeight)) { // short circuit if there is nothing to do - if( (rPosAry.mnSrcX == rPosAry.mnDestX) - && (rPosAry.mnSrcY == rPosAry.mnDestY)) + if( (rPosAry.mnSrcX == rPosAry.mnDestX) && + (rPosAry.mnSrcY == rPosAry.mnDestY)) + { return; + } // use copyArea() if source and destination context are identical copyArea( rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnSrcX, rPosAry.mnSrcY, - rPosAry.mnSrcWidth, rPosAry.mnSrcHeight, 0 ); + rPosAry.mnSrcWidth, rPosAry.mnSrcHeight, 0 ); return; } ApplyXorContext(); pSrc->ApplyXorContext(); - SAL_WARN_IF( !pSrc->mxLayer, "vcl.quartz", "AquaSalGraphics::copyBits() from non-layered graphics this=" << this ); + SAL_WARN_IF( !pSrc->mxLayer, "vcl.quartz", + "AquaSalGraphics::copyBits() from non-layered graphics this=" << this ); const CGPoint aDstPoint = CGPointMake(+rPosAry.mnDestX - rPosAry.mnSrcX, rPosAry.mnDestY - rPosAry.mnSrcY); if( (rPosAry.mnSrcWidth == rPosAry.mnDestWidth && @@ -384,25 +412,28 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap xCopyContext = mpXorEmulation->GetTargetContext(); } } - CG_TRACE( "CGContextSaveGState(" << xCopyContext << ")" ); + SAL_INFO( "vcl.cg", "CGContextSaveGState(" << xCopyContext << ")" ); CGContextSaveGState( xCopyContext ); + const CGRect aDstRect = CGRectMake(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); - CG_TRACE( "CGContextClipToRect(" << xCopyContext << "," << aDstRect << ")" ); + SAL_INFO( "vcl.cg", "CGContextClipToRect(" << xCopyContext << "," << aDstRect << ")" ); CGContextClipToRect( xCopyContext, aDstRect ); // draw at new destination // NOTE: flipped drawing gets disabled for this, else the subimage would be drawn upside down if( pSrc->IsFlipped() ) { - CG_TRACE( "CGContextTranslateCTM(" << xCopyContext << ",0," << mnHeight << ")" ); + SAL_INFO( "vcl.cg", "CGContextTranslateCTM(" << xCopyContext << ",0," << mnHeight << ")" ); CGContextTranslateCTM( xCopyContext, 0, +mnHeight ); - CG_TRACE( "CGContextScaleCTM(" << xCopyContext << ",+1,-1)" ); + SAL_INFO( "vcl.cg", "CGContextScaleCTM(" << xCopyContext << ",+1,-1)" ); CGContextScaleCTM( xCopyContext, +1, -1 ); } + // TODO: pSrc->size() != this->size() - CG_TRACE( "CGContextDrawLayerAtPoint(" << xCopyContext << "," << aDstPoint << "," << pSrc->mxLayer << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xCopyContext << "," << aDstPoint << "," << pSrc->mxLayer << ")" ); CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, pSrc->mxLayer ); - CG_TRACE( "CGContextRestoreGState(" << xCopyContext << ")" ); + + SAL_INFO( "vcl.cg", "CGContextRestoreGState(" << xCopyContext << ")" ); CGContextRestoreGState( xCopyContext ); // mark the destination rectangle as updated RefreshRect( aDstRect ); @@ -411,7 +442,6 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap { SalBitmap* pBitmap = pSrc->getBitmap( rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight ); - if( pBitmap ) { SalTwoRect aPosAry( rPosAry ); @@ -426,18 +456,20 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap static void DrawPattern50( void*, CGContextRef rContext ) { static const CGRect aRects[2] = { { {0,0}, { 2, 2 } }, { { 2, 2 }, { 2, 2 } } }; - CG_TRACE( "CGContextAddRects(" << rContext << ",aRects,2 )" ); + SAL_INFO( "vcl.cg", "CGContextAddRects(" << rContext << ",aRects,2 )" ); CGContextAddRects( rContext, aRects, 2 ); - CG_TRACE( "CGContextFillPath(" << rContext << ")" ); + SAL_INFO( "vcl.cg", "CGContextFillPath(" << rContext << ")" ); CGContextFillPath( rContext ); } -static void getBoundRect( sal_uInt32 nPoints, const SalPoint *pPtAry, long &rX, long& rY, long& rWidth, long& rHeight ) +static void getBoundRect( sal_uInt32 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( sal_uInt32 n = 1; n < nPoints; n++ ) { if( pPtAry[n].mnX < nX1 ) @@ -493,7 +525,8 @@ void AquaSalGraphics::ApplyXorContext() void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, sal_uInt16 /*nFlags*/ ) { - SAL_WARN_IF( !mxLayer, "vcl.quartz", "AquaSalGraphics::copyArea() for non-layered graphics this=" << this ); + SAL_WARN_IF( !mxLayer, "vcl.quartz", + "AquaSalGraphics::copyArea() for non-layered graphics this=" << this ); #ifdef IOS if( !mxLayer ) @@ -513,36 +546,39 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, // TODO: is it possible to get rid of this unneeded copy more often? // e.g. on OSX>=10.5 only this situation causes problems: // mnBitmapDepth && (aDstPoint.x + pSrc->mnWidth) > mnWidth + CGLayerRef xSrcLayer = mxLayer; // TODO: if( mnBitmapDepth > 0 ) { const CGSize aSrcSize = CGSizeMake(nSrcWidth, nSrcHeight); xSrcLayer = CGLayerCreateWithContext( xCopyContext, aSrcSize, NULL ); - CG_TRACE( "CGLayerCreateWithContext(" << xCopyContext << "," << aSrcSize << ",NULL) = " << xSrcLayer ); + SAL_INFO( "vcl.cg", "CGLayerCreateWithContext(" << xCopyContext << "," << aSrcSize << ",NULL) = " << xSrcLayer ); + const CGContextRef xSrcContext = CGLayerGetContext( xSrcLayer ); - CG_TRACE( "CGLayerGetContext(" << xSrcLayer << ") = " << xSrcContext ); + SAL_INFO( "vcl.cg", "CGLayerGetContext(" << xSrcLayer << ") = " << xSrcContext ); + CGPoint aSrcPoint = CGPointMake(-nSrcX, -nSrcY); if( IsFlipped() ) { - CG_TRACE( "CGContextTranslateCTM(" << xSrcContext << ",0," << nSrcHeight << ")" ); + SAL_INFO( "vcl.cg", "CGContextTranslateCTM(" << xSrcContext << ",0," << nSrcHeight << ")" ); CGContextTranslateCTM( xSrcContext, 0, +nSrcHeight ); - CG_TRACE( "CGContextScaleCTM(" << xSrcContext << ",+1,-1)" ); + SAL_INFO( "vcl.cg", "CGContextScaleCTM(" << xSrcContext << ",+1,-1)" ); CGContextScaleCTM( xSrcContext, +1, -1 ); aSrcPoint.y = (nSrcY + nSrcHeight) - mnHeight; } - CG_TRACE( "CGContextDrawLayerAtPoint(" << xSrcContext << "," << aSrcPoint << "," << mxLayer << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xSrcContext << "," << aSrcPoint << "," << mxLayer << ")" ); CGContextDrawLayerAtPoint( xSrcContext, aSrcPoint, mxLayer ); } // draw at new destination const CGPoint aDstPoint = CGPointMake(+nDstX, +nDstY); - CG_TRACE( "CGContextDrawLayerAtPoint(" << xCopyContext << "," << aDstPoint << "," << xSrcLayer << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xCopyContext << "," << aDstPoint << "," << xSrcLayer << ")" ); CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, xSrcLayer ); // cleanup if( xSrcLayer != mxLayer ) { - CG_TRACE( "CGLayerRelease(" << xSrcLayer << ")" ); + SAL_INFO( "vcl.cg", "CGLayerRelease(" << xSrcLayer << ")" ); CGLayerRelease( xSrcLayer ); } // mark the destination rectangle as updated @@ -618,12 +654,12 @@ bool AquaSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, if ( CheckContext() ) { const CGRect aDstRect = CGRectMake( rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight); - CG_TRACE( "CGContextDrawImage(" << mrContext << "," << aDstRect << "," << xMaskedImage << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawImage(" << mrContext << "," << aDstRect << "," << xMaskedImage << ")" ); CGContextDrawImage( mrContext, aDstRect, xMaskedImage ); RefreshRect( aDstRect ); } - CG_TRACE("CGImageRelease(" << xMaskedImage << ")"); + SAL_INFO( "vcl.cg", "CGImageRelease(" << xMaskedImage << ")"); CGImageRelease(xMaskedImage); DBG_DRAW_OPERATION_EXIT("drawAlphaBitmap"); @@ -647,6 +683,7 @@ bool AquaSalGraphics::drawTransformedBitmap( const Size aSize = rSrcBitmap.GetSize(); const QuartzSalBitmap& rSrcSalBmp = static_cast<const QuartzSalBitmap&>(rSrcBitmap); const QuartzSalBitmap* pMaskSalBmp = static_cast<const QuartzSalBitmap*>(pAlphaBmp); + if( !pMaskSalBmp) xImage = rSrcSalBmp.CreateCroppedImage( 0, 0, (int)aSize.Width(), (int)aSize.Height() ); else @@ -659,7 +696,7 @@ bool AquaSalGraphics::drawTransformedBitmap( // setup the image transformation // using the rNull,rX,rY points as destinations for the (0,0),(0,Width),(Height,0) source points - CG_TRACE( "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); + SAL_INFO( "vcl.cg", "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); CGContextSaveGState( mrContext ); const basegfx::B2DVector aXRel = rX - rNull; const basegfx::B2DVector aYRel = rY - rNull; @@ -667,17 +704,19 @@ bool AquaSalGraphics::drawTransformedBitmap( aXRel.getX()/aSize.Width(), aXRel.getY()/aSize.Width(), aYRel.getX()/aSize.Height(), aYRel.getY()/aSize.Height(), rNull.getX(), rNull.getY()); - CG_TRACE( "CGContextConcatCTM(" << mrContext << "," << aCGMat << ")" ); + + SAL_INFO( "vcl.cg", "CGContextConcatCTM(" << mrContext << "," << aCGMat << ")" ); CGContextConcatCTM( mrContext, aCGMat ); // draw the transformed image const CGRect aSrcRect = CGRectMake(0, 0, aSize.Width(), aSize.Height()); - CG_TRACE( "CGContextDrawImage(" << mrContext << "," << aSrcRect << "," << xImage << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawImage(" << mrContext << "," << aSrcRect << "," << xImage << ")" ); CGContextDrawImage( mrContext, aSrcRect, xImage ); - CG_TRACE( "CGImageRelease(" << xImage << ")" ); + + SAL_INFO( "vcl.cg", "CGImageRelease(" << xImage << ")" ); CGImageRelease( xImage ); // restore the Quartz graphics state - CG_TRACE("CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth--); + SAL_INFO( "vcl.cg", "CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth--); CGContextRestoreGState(mrContext); // mark the destination as painted @@ -700,9 +739,9 @@ bool AquaSalGraphics::drawAlphaRect( long nX, long nY, long nWidth, } // save the current state - CG_TRACE( "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); + SAL_INFO( "vcl.cg", "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); CGContextSaveGState( mrContext ); - CG_TRACE( "CGContextSetAlpha(" << mrContext << "," << (100-nTransparency) * (1.0/100) << ")" ); + SAL_INFO( "vcl.cg", "CGContextSetAlpha(" << mrContext << "," << (100-nTransparency) * (1.0/100) << ")" ); CGContextSetAlpha( mrContext, (100-nTransparency) * (1.0/100) ); CGRect aRect = CGRectMake(nX, nY, nWidth-1, nHeight-1); @@ -712,15 +751,15 @@ bool AquaSalGraphics::drawAlphaRect( long nX, long nY, long nWidth, aRect.origin.y += 0.5; } - CG_TRACE( "CGContextBeginPath(" << mrContext << ")" ); + SAL_INFO( "vcl.cg", "CGContextBeginPath(" << mrContext << ")" ); CGContextBeginPath( mrContext ); - CG_TRACE( "CGContextAddRect(" << mrContext << "," << aRect << ")" ); + SAL_INFO( "vcl.cg", "CGContextAddRect(" << mrContext << "," << aRect << ")" ); CGContextAddRect( mrContext, aRect ); - CG_TRACE( "CGContextDrawPath(" << mrContext << ",kCGPathFill)" ); + SAL_INFO( "vcl.cg", "CGContextDrawPath(" << mrContext << ",kCGPathFill)" ); CGContextDrawPath( mrContext, kCGPathFill ); // restore state - CG_TRACE("CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth--); + SAL_INFO( "vcl.cg", "CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth--); CGContextRestoreGState(mrContext); RefreshRect( aRect ); @@ -748,9 +787,10 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS } const CGRect aDstRect = CGRectMake(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); - CG_TRACE( "CGContextDrawImage(" << mrContext << "," << aDstRect << "," << xImage << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawImage(" << mrContext << "," << aDstRect << "," << xImage << ")" ); CGContextDrawImage( mrContext, aDstRect, xImage ); - CG_TRACE( "CGImageRelease(" << xImage << ")" ); + + SAL_INFO( "vcl.cg", "CGImageRelease(" << xImage << ")" ); CGImageRelease( xImage ); RefreshRect( aDstRect ); @@ -779,9 +819,9 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS } const CGRect aDstRect = CGRectMake(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); - CG_TRACE( "CGContextDrawImage(" << mrContext << "," << aDstRect << "," << xMaskedImage << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawImage(" << mrContext << "," << aDstRect << "," << xMaskedImage << ")" ); CGContextDrawImage( mrContext, aDstRect, xMaskedImage ); - CG_TRACE( "CGImageRelease(" << xMaskedImage << ")" ); + SAL_INFO( "vcl.cg", "CGImageRelease(" << xMaskedImage << ")" ); CGImageRelease( xMaskedImage ); RefreshRect( aDstRect ); @@ -806,10 +846,10 @@ bool AquaSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, return false; } // NOTE: flip drawing, else the nsimage would be drawn upside down - CG_TRACE( "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); + SAL_INFO( "vcl.cg", "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); CGContextSaveGState( mrContext ); // CGContextTranslateCTM( mrContext, 0, +mnHeight ); - CG_TRACE( "CGContextScaleCTM(" << mrContext << ",+1,-1)" ); + SAL_INFO( "vcl.cg", "CGContextScaleCTM(" << mrContext << ",+1,-1)" ); CGContextScaleCTM( mrContext, +1, -1 ); nY = /*mnHeight*/ - (nY + nHeight); @@ -830,7 +870,7 @@ bool AquaSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, [NSGraphicsContext setCurrentContext: pOrigNSCtx]; [pOrigNSCtx release]; // restore the original retain count - CG_TRACE("CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth--); + SAL_INFO( "vcl.cg", "CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth--); CGContextRestoreGState( mrContext ); // mark the destination rectangle as updated RefreshRect( aDstRect ); @@ -859,13 +899,13 @@ void AquaSalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) return; } - CG_TRACE( "CGContextBeginPath(" << mrContext << ")" ); + SAL_INFO( "vcl.cg", "CGContextBeginPath(" << mrContext << ")" ); CGContextBeginPath( mrContext ); - CG_TRACE( "CGContextMoveToPoint(" << mrContext << "," << static_cast<float>(nX1)+0.5 << "," << static_cast<float>(nY1)+0.5 << ")" ); + SAL_INFO( "vcl.cg", "CGContextMoveToPoint(" << mrContext << "," << static_cast<float>(nX1)+0.5 << "," << static_cast<float>(nY1)+0.5 << ")" ); CGContextMoveToPoint( mrContext, static_cast<float>(nX1)+0.5, static_cast<float>(nY1)+0.5 ); - CG_TRACE( "CGContextAddLineToPoint(" << mrContext << "," << static_cast<float>(nX2)+0.5 << "," << static_cast<float>(nY2)+0.5 << ")" ); + SAL_INFO( "vcl.cg", "CGContextAddLineToPoint(" << mrContext << "," << static_cast<float>(nX2)+0.5 << "," << static_cast<float>(nY2)+0.5 << ")" ); CGContextAddLineToPoint( mrContext, static_cast<float>(nX2)+0.5, static_cast<float>(nY2)+0.5 ); - CG_TRACE( "CGContextDrawPath(" << mrContext << ",kCGPathStroke)" ); + SAL_INFO( "vcl.cg", "CGContextDrawPath(" << mrContext << ",kCGPathStroke)" ); CGContextDrawPath( mrContext, kCGPathStroke ); Rectangle aRefreshRect( nX1, nY1, nX2, nY2 ); @@ -896,9 +936,9 @@ void AquaSalGraphics::drawMask( const SalTwoRect& rPosAry, const SalBitmap& rSal } const CGRect aDstRect = CGRectMake(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); - CG_TRACE( "CGContextDrawImage(" << mrContext << "," << aDstRect << "," << xImage << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawImage(" << mrContext << "," << aDstRect << "," << xImage << ")" ); CGContextDrawImage( mrContext, aDstRect, xImage ); - CG_TRACE( "CGImageRelease(" << xImage << ")" ); + SAL_INFO( "vcl.cg", "CGImageRelease(" << xImage << ")" ); CGImageRelease( xImage ); RefreshRect( aDstRect ); @@ -917,12 +957,11 @@ void AquaSalGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) ImplDrawPixel( nX, nY, aPixelColor ); } -bool AquaSalGraphics::drawPolyLine( - const ::basegfx::B2DPolygon& rPolyLine, - double fTransparency, - const ::basegfx::B2DVector& rLineWidths, - basegfx::B2DLineJoin eLineJoin, - com::sun::star::drawing::LineCap eLineCap) +bool AquaSalGraphics::drawPolyLine( const ::basegfx::B2DPolygon& rPolyLine, + double fTransparency, + const ::basegfx::B2DVector& rLineWidths, + basegfx::B2DLineJoin eLineJoin, + css::drawing::LineCap eLineCap) { DBG_DRAW_OPERATION("drawPolyLine", true); @@ -963,11 +1002,11 @@ bool AquaSalGraphics::drawPolyLine( CGLineJoin aCGLineJoin = kCGLineJoinMiter; switch( eLineJoin ) { - case ::basegfx::B2DLineJoin::NONE: aCGLineJoin = /*TODO?*/kCGLineJoinMiter; break; - case ::basegfx::B2DLineJoin::Middle: aCGLineJoin = /*TODO?*/kCGLineJoinMiter; break; - case ::basegfx::B2DLineJoin::Bevel: aCGLineJoin = kCGLineJoinBevel; break; - case ::basegfx::B2DLineJoin::Miter: aCGLineJoin = kCGLineJoinMiter; break; - case ::basegfx::B2DLineJoin::Round: aCGLineJoin = kCGLineJoinRound; break; + case basegfx::B2DLineJoin::NONE: aCGLineJoin = /*TODO?*/kCGLineJoinMiter; break; + case basegfx::B2DLineJoin::Middle: aCGLineJoin = /*TODO?*/kCGLineJoinMiter; break; + case basegfx::B2DLineJoin::Bevel: aCGLineJoin = kCGLineJoinBevel; break; + case basegfx::B2DLineJoin::Miter: aCGLineJoin = kCGLineJoinMiter; break; + case basegfx::B2DLineJoin::Round: aCGLineJoin = kCGLineJoinRound; break; } // setup cap attribute @@ -980,12 +1019,12 @@ bool AquaSalGraphics::drawPolyLine( aCGLineCap = kCGLineCapButt; break; } - case com::sun::star::drawing::LineCap_ROUND: + case css::drawing::LineCap_ROUND: { aCGLineCap = kCGLineCapRound; break; } - case com::sun::star::drawing::LineCap_SQUARE: + case css::drawing::LineCap_SQUARE: { aCGLineCap = kCGLineCapSquare; break; @@ -994,38 +1033,38 @@ bool AquaSalGraphics::drawPolyLine( // setup poly-polygon path CGMutablePathRef xPath = CGPathCreateMutable(); - CG_TRACE( "CGPathCreateMutable() = " << xPath ); + SAL_INFO( "vcl.cg", "CGPathCreateMutable() = " << xPath ); AddPolygonToPath( xPath, rPolyLine, rPolyLine.isClosed(), !getAntiAliasB2DDraw(), true ); const CGRect aRefreshRect = CGPathGetBoundingBox( xPath ); - CG_TRACE( "CGPathGetBoundingBox(" << xPath << ") = " << aRefreshRect ); + SAL_INFO( "vcl.cg", "CGPathGetBoundingBox(" << xPath << ") = " << aRefreshRect ); // #i97317# workaround for Quartz having problems with drawing small polygons if( ! ((aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125)) ) { // use the path to prepare the graphics context - CG_TRACE( "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); + SAL_INFO( "vcl.cg", "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); CGContextSaveGState( mrContext ); - CG_TRACE( "CGContextBeginPath(" << mrContext << ")" ); + SAL_INFO( "vcl.cg", "CGContextBeginPath(" << mrContext << ")" ); CGContextBeginPath( mrContext ); - CG_TRACE( "CGContextAddPath(" << mrContext << "," << xPath << ")" ); + SAL_INFO( "vcl.cg", "CGContextAddPath(" << mrContext << "," << xPath << ")" ); CGContextAddPath( mrContext, xPath ); // draw path with antialiased line CGContextSetShouldAntialias( mrContext, true ); - CG_TRACE( "CGContextSetAlpha(" << mrContext << "," << 1.0 - fTransparency << ")" ); + SAL_INFO( "vcl.cg", "CGContextSetAlpha(" << mrContext << "," << 1.0 - fTransparency << ")" ); CGContextSetAlpha( mrContext, 1.0 - fTransparency ); CGContextSetLineJoin( mrContext, aCGLineJoin ); CGContextSetLineCap( mrContext, aCGLineCap ); CGContextSetLineWidth( mrContext, rLineWidths.getX() ); - CG_TRACE( "CGContextDrawPath(" << mrContext << ",kCGPathStroke)" ); + SAL_INFO( "vcl.cg", "CGContextDrawPath(" << mrContext << ",kCGPathStroke)" ); CGContextDrawPath( mrContext, kCGPathStroke ); - CG_TRACE( "CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth-- ); + SAL_INFO( "vcl.cg", "CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth-- ); CGContextRestoreGState( mrContext ); // mark modified rectangle as updated RefreshRect( aRefreshRect ); } - CG_TRACE( "CGPathRelease(" << xPath << ")" ); + SAL_INFO( "vcl.cg", "CGPathRelease(" << xPath << ")" ); CGPathRelease( xPath ); DBG_DRAW_OPERATION_EXIT("drawPolyLine"); @@ -1037,8 +1076,8 @@ bool AquaSalGraphics::drawPolyLineBezier( sal_uInt32, const SalPoint*, const sal return false; } -bool AquaSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly, - double fTransparency ) +bool AquaSalGraphics::drawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPoly, + double fTransparency ) { DBG_DRAW_OPERATION("drawPolyPolygon", true); @@ -1059,15 +1098,15 @@ bool AquaSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPol // setup poly-polygon path CGMutablePathRef xPath = CGPathCreateMutable(); - CG_TRACE( "CGPathCreateMutable() = " << xPath ); + SAL_INFO( "vcl.cg", "CGPathCreateMutable() = " << xPath ); for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx ) { - const ::basegfx::B2DPolygon rPolygon = rPolyPoly.getB2DPolygon( nPolyIdx ); + const basegfx::B2DPolygon rPolygon = rPolyPoly.getB2DPolygon( nPolyIdx ); AddPolygonToPath( xPath, rPolygon, true, !getAntiAliasB2DDraw(), IsPenVisible() ); } const CGRect aRefreshRect = CGPathGetBoundingBox( xPath ); - CG_TRACE( "CGPathGetBoundingBox(" << xPath << ") = " << aRefreshRect ); + SAL_INFO( "vcl.cg", "CGPathGetBoundingBox(" << xPath << ") = " << aRefreshRect ); // #i97317# workaround for Quartz having problems with drawing small polygons if( ! ((aRefreshRect.size.width <= 0.125) && (aRefreshRect.size.height <= 0.125)) ) { @@ -1088,34 +1127,34 @@ bool AquaSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPol else { SAL_WARN( "vcl.quartz", "Neither pen nor brush visible" ); - CG_TRACE( "CGPathRelease(" << xPath << ")" ); + SAL_INFO( "vcl.cg", "CGPathRelease(" << xPath << ")" ); CGPathRelease( xPath ); DBG_DRAW_OPERATION_EXIT_EARLY("drawPolyPolygon"); return true; } // use the path to prepare the graphics context - CG_TRACE( "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); + SAL_INFO( "vcl.cg", "CGContextSaveGState(" << mrContext << ") " << ++mnContextStackDepth ); CGContextSaveGState( mrContext ); - CG_TRACE( "CGContextBeginPath(" << mrContext << ")" ); + SAL_INFO( "vcl.cg", "CGContextBeginPath(" << mrContext << ")" ); CGContextBeginPath( mrContext ); - CG_TRACE( "CGContextAddPath(" << mrContext << "," << xPath << ")" ); + SAL_INFO( "vcl.cg", "CGContextAddPath(" << mrContext << "," << xPath << ")" ); CGContextAddPath( mrContext, xPath ); // draw path with antialiased polygon CGContextSetShouldAntialias( mrContext, true ); - CG_TRACE( "CGContextSetAlpha(" << mrContext << "," << 1.0 - fTransparency << ")" ); + SAL_INFO( "vcl.cg", "CGContextSetAlpha(" << mrContext << "," << 1.0 - fTransparency << ")" ); CGContextSetAlpha( mrContext, 1.0 - fTransparency ); - CG_TRACE( "CGContextDrawPath(" << mrContext << "," << eMode << ")" ); + SAL_INFO( "vcl.cg", "CGContextDrawPath(" << mrContext << "," << eMode << ")" ); CGContextDrawPath( mrContext, eMode ); - CG_TRACE( "CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth-- ); + SAL_INFO( "vcl.cg", "CGContextRestoreGState(" << mrContext << ") " << mnContextStackDepth-- ); CGContextRestoreGState( mrContext ); // mark modified rectangle as updated RefreshRect( aRefreshRect ); } - CG_TRACE( "CGPathRelease(" << xPath << ")" ); + SAL_INFO( "vcl.cg", "CGPathRelease(" << xPath << ")" ); CGPathRelease( xPath ); DBG_DRAW_OPERATION_EXIT("drawPolyPolygon"); @@ -1141,6 +1180,7 @@ void AquaSalGraphics::drawPolyPolygon( sal_uInt32 nPolyCount, const sal_uInt32 * // find bound rect long leftX = 0, topY = 0, maxWidth = 0, maxHeight = 0; getBoundRect( pPoints[0], ppPtAry[0], leftX, topY, maxWidth, maxHeight ); + for( sal_uInt32 n = 1; n < nPolyCount; n++ ) { long nX = leftX, nY = topY, nW = maxWidth, nH = maxHeight; @@ -1187,7 +1227,7 @@ void AquaSalGraphics::drawPolyPolygon( sal_uInt32 nPolyCount, const sal_uInt32 * } // convert to CGPath - CG_TRACE( "CGContextBeginPath(" << mrContext << ")" ); + SAL_INFO( "vcl.cg", "CGContextBeginPath(" << mrContext << ")" ); CGContextBeginPath( mrContext ); if( IsPenVisible() ) { @@ -1198,17 +1238,19 @@ void AquaSalGraphics::drawPolyPolygon( sal_uInt32 nPolyCount, const sal_uInt32 * { const SalPoint *pPtAry = ppPtAry[nPoly]; float fX, fY; + alignLinePoint( pPtAry, fX, fY ); - CG_TRACE( "CGContextMoveToPoint(" << mrContext << "," << fX << "," << fY << ")" ); + SAL_INFO( "vcl.cg", "CGContextMoveToPoint(" << mrContext << "," << fX << "," << fY << ")" ); CGContextMoveToPoint( mrContext, fX, fY ); pPtAry++; + for( sal_uInt32 nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) { alignLinePoint( pPtAry, fX, fY ); - CG_TRACE( "CGContextAddLineToPoint(" << mrContext << "," << fX << "," << fY << ")" ); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
