Kaydet (Commit) 8bc28541 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

More CoreGraphics tracing

Change-Id: I2fbdb95637ee77b444e1947405d64cdd2e0338af
üst 6f86b9d0
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "vcl/salbtype.hxx" #include "vcl/salbtype.hxx"
#include "quartz/salbmp.h" #include "quartz/salbmp.h"
#include "quartz/utils.h"
#ifdef MACOSX #ifdef MACOSX
#include "osx/saldata.hxx" #include "osx/saldata.hxx"
...@@ -103,7 +104,10 @@ bool QuartzSalBitmap::Create( CGLayerRef xLayer, int nBitmapBits, ...@@ -103,7 +104,10 @@ bool QuartzSalBitmap::Create( CGLayerRef xLayer, int nBitmapBits,
// copy layer content into the bitmap buffer // copy layer content into the bitmap buffer
const CGPoint aSrcPoint = { static_cast<CGFloat>(-nX), static_cast<CGFloat>(-nY) }; const CGPoint aSrcPoint = { static_cast<CGFloat>(-nX), static_cast<CGFloat>(-nY) };
if(mxGraphicContext) // remove warning if(mxGraphicContext) // remove warning
{
CG_TRACE( "CGContextDrawLayerAtPoint(" << mxGraphicContext << "," << aSrcPoint << "," << xLayer << ")" );
CGContextDrawLayerAtPoint( mxGraphicContext, aSrcPoint, xLayer ); CGContextDrawLayerAtPoint( mxGraphicContext, aSrcPoint, xLayer );
}
return true; return true;
} }
...@@ -173,11 +177,16 @@ void QuartzSalBitmap::Destroy() ...@@ -173,11 +177,16 @@ void QuartzSalBitmap::Destroy()
void QuartzSalBitmap::DestroyContext() void QuartzSalBitmap::DestroyContext()
{ {
CGImageRelease( mxCachedImage ); if( mxCachedImage )
mxCachedImage = NULL; {
CG_TRACE( "CGImageRelease(" << mxCachedImage << ")" );
CGImageRelease( mxCachedImage );
mxCachedImage = NULL;
}
if( mxGraphicContext ) if( mxGraphicContext )
{ {
CG_TRACE( "CGContextRelease(" << mxGraphicContext << ")" );
CGContextRelease( mxGraphicContext ); CGContextRelease( mxGraphicContext );
mxGraphicContext = NULL; mxGraphicContext = NULL;
maContextBuffer.reset(); maContextBuffer.reset();
...@@ -739,6 +748,7 @@ CGImageRef QuartzSalBitmap::CreateCroppedImage( int nX, int nY, int nNewWidth, i ...@@ -739,6 +748,7 @@ CGImageRef QuartzSalBitmap::CreateCroppedImage( int nX, int nY, int nNewWidth, i
return NULL; return NULL;
mxCachedImage = CGBitmapContextCreateImage( mxGraphicContext ); mxCachedImage = CGBitmapContextCreateImage( mxGraphicContext );
CG_TRACE( "CGBitmapContextCreateImage(" << mxGraphicContext << ") = " << mxCachedImage );
} }
CGImageRef xCroppedImage = NULL; CGImageRef xCroppedImage = NULL;
...@@ -753,6 +763,7 @@ CGImageRef QuartzSalBitmap::CreateCroppedImage( int nX, int nY, int nNewWidth, i ...@@ -753,6 +763,7 @@ CGImageRef QuartzSalBitmap::CreateCroppedImage( int nX, int nY, int nNewWidth, i
nY = mnHeight - (nY + nNewHeight); // adjust for y-mirrored context 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) } }; const CGRect aCropRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { static_cast<CGFloat>(nNewWidth), static_cast<CGFloat>(nNewHeight) } };
xCroppedImage = CGImageCreateWithImageInRect( mxCachedImage, aCropRect ); xCroppedImage = CGImageCreateWithImageInRect( mxCachedImage, aCropRect );
CG_TRACE( "CGImageCreateWithImageInRect(" << mxCachedImage << "," << aCropRect << ") = " << xCroppedImage );
} }
return xCroppedImage; return xCroppedImage;
...@@ -788,13 +799,18 @@ CGImageRef QuartzSalBitmap::CreateWithMask( const QuartzSalBitmap& rMask, ...@@ -788,13 +799,18 @@ CGImageRef QuartzSalBitmap::CreateWithMask( const QuartzSalBitmap& rMask,
void* pMaskMem = rtl_allocateMemory( nMaskBytesPerRow * nHeight ); void* pMaskMem = rtl_allocateMemory( nMaskBytesPerRow * nHeight );
CGContextRef xMaskContext = CGBitmapContextCreate( pMaskMem, CGContextRef xMaskContext = CGBitmapContextCreate( pMaskMem,
nWidth, nHeight, 8, nMaskBytesPerRow, GetSalData()->mxGraySpace, kCGImageAlphaNone ); nWidth, nHeight, 8, nMaskBytesPerRow, GetSalData()->mxGraySpace, kCGImageAlphaNone );
CG_TRACE( "CGBitmapContextCreate(" << nWidth << "x" << nHeight << "x8) = " << xMaskContext );
CG_TRACE( "CGContextDrawImage(" << xMaskContext << "," << xImageRect << "," << xMask << ")" );
CGContextDrawImage( xMaskContext, xImageRect, xMask ); CGContextDrawImage( xMaskContext, xImageRect, xMask );
CG_TRACE( "CFRelease(" << xMask << ")" );
CFRelease( xMask ); CFRelease( xMask );
CGDataProviderRef xDataProvider( CGDataProviderCreateWithData( NULL, CGDataProviderRef xDataProvider( CGDataProviderCreateWithData( NULL,
pMaskMem, nHeight * nMaskBytesPerRow, &CFRTLFree ) ); pMaskMem, nHeight * nMaskBytesPerRow, &CFRTLFree ) );
static const CGFloat* pDecode = NULL; static const CGFloat* pDecode = NULL;
xMask = CGImageMaskCreate( nWidth, nHeight, 8, 8, nMaskBytesPerRow, xDataProvider, pDecode, false ); xMask = CGImageMaskCreate( nWidth, nHeight, 8, 8, nMaskBytesPerRow, xDataProvider, pDecode, false );
CG_TRACE( "CGImageMaskCreate(" << nWidth << "," << nHeight << ",8,8) = " << xMask );
CFRelease( xDataProvider ); CFRelease( xDataProvider );
CG_TRACE( "CFRelease(" << xMaskContext << ")" );
CFRelease( xMaskContext ); CFRelease( xMaskContext );
} }
...@@ -803,7 +819,10 @@ CGImageRef QuartzSalBitmap::CreateWithMask( const QuartzSalBitmap& rMask, ...@@ -803,7 +819,10 @@ CGImageRef QuartzSalBitmap::CreateWithMask( const QuartzSalBitmap& rMask,
// combine image and alpha mask // combine image and alpha mask
CGImageRef xMaskedImage = CGImageCreateWithMask( xImage, xMask ); CGImageRef xMaskedImage = CGImageCreateWithMask( xImage, xMask );
CG_TRACE( "CGImageCreateWithMask(" << xImage << "," << xMask << ") = " << xMaskedImage );
CG_TRACE( "CFRelease(" << xMask << ")" );
CFRelease( xMask ); CFRelease( xMask );
CG_TRACE( "CFRelease(" << xImage << ")" );
CFRelease( xImage ); CFRelease( xImage );
return xMaskedImage; return xMaskedImage;
} }
......
...@@ -484,6 +484,7 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, ...@@ -484,6 +484,7 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY,
xSrcLayer = CGLayerCreateWithContext( xCopyContext, aSrcSize, NULL ); xSrcLayer = CGLayerCreateWithContext( xCopyContext, aSrcSize, NULL );
CG_TRACE( "CGLayerCreateWithContext(" << xCopyContext << "," << aSrcSize << ",NULL) = " << xSrcLayer ); CG_TRACE( "CGLayerCreateWithContext(" << xCopyContext << "," << aSrcSize << ",NULL) = " << xSrcLayer );
const CGContextRef xSrcContext = CGLayerGetContext( xSrcLayer ); const CGContextRef xSrcContext = CGLayerGetContext( xSrcLayer );
CG_TRACE( "CGLayerGetContext(" << xSrcLayer << ") = " << xSrcContext );
CGPoint aSrcPoint = CGPointMake(-nSrcX, -nSrcY); CGPoint aSrcPoint = CGPointMake(-nSrcX, -nSrcY);
if( IsFlipped() ) if( IsFlipped() )
{ {
......
...@@ -32,8 +32,7 @@ ...@@ -32,8 +32,7 @@
#include "headless/svpvd.hxx" #include "headless/svpvd.hxx"
#endif #endif
#include "quartz/salgdi.h" #include "quartz/salgdi.h"
#include "quartz/utils.h"
SalVirtualDevice* AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, SalVirtualDevice* AquaSalInstance::CreateVirtualDevice( SalGraphics* pGraphics,
long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData ) long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData )
...@@ -74,6 +73,7 @@ AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long nDX, ...@@ -74,6 +73,7 @@ AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long nDX,
if (nDY == 0) if (nDY == 0)
nDY = 1; nDY = 1;
mxLayer = CGLayerCreateWithContext( pData->rCGContext, CGSizeMake( nDX, nDY), NULL ); mxLayer = CGLayerCreateWithContext( pData->rCGContext, CGSizeMake( nDX, nDY), NULL );
CG_TRACE( "CGLayerCreateWithContext(" << pData->rCGContext << "," << CGSizeMake( nDX, nDY) << ",NULL) = " << mxLayer );
mpGraphics->SetVirDevGraphics( mxLayer, pData->rCGContext ); mpGraphics->SetVirDevGraphics( mxLayer, pData->rCGContext );
} }
else else
...@@ -131,6 +131,7 @@ void AquaSalVirtualDevice::Destroy() ...@@ -131,6 +131,7 @@ void AquaSalVirtualDevice::Destroy()
{ {
if( mpGraphics ) if( mpGraphics )
mpGraphics->SetVirDevGraphics( NULL, NULL ); mpGraphics->SetVirDevGraphics( NULL, NULL );
CG_TRACE( "CGLayerRelease(" << mxLayer << ")" );
CGLayerRelease( mxLayer ); CGLayerRelease( mxLayer );
mxLayer = NULL; mxLayer = NULL;
} }
...@@ -139,6 +140,7 @@ void AquaSalVirtualDevice::Destroy() ...@@ -139,6 +140,7 @@ void AquaSalVirtualDevice::Destroy()
{ {
void* pRawData = CGBitmapContextGetData( mxBitmapContext ); void* pRawData = CGBitmapContextGetData( mxBitmapContext );
rtl_freeMemory( pRawData ); rtl_freeMemory( pRawData );
CG_TRACE( "CGContextRelease(" << mxBitmapContext << ")" );
CGContextRelease( mxBitmapContext ); CGContextRelease( mxBitmapContext );
mxBitmapContext = NULL; mxBitmapContext = NULL;
} }
...@@ -198,6 +200,7 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY ) ...@@ -198,6 +200,7 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY )
void* pRawData = rtl_allocateMemory( nBytesPerRow * nDY ); void* pRawData = rtl_allocateMemory( nBytesPerRow * nDY );
mxBitmapContext = CGBitmapContextCreate( pRawData, nDX, nDY, mxBitmapContext = CGBitmapContextCreate( pRawData, nDX, nDY,
mnBitmapDepth, nBytesPerRow, aCGColorSpace, aCGBmpInfo ); mnBitmapDepth, nBytesPerRow, aCGColorSpace, aCGBmpInfo );
CG_TRACE( "CGBitmapContextCreate(" << nDX << "x" << nDY << "x" << mnBitmapDepth << ") = " << mxBitmapContext );
xCGContext = mxBitmapContext; xCGContext = mxBitmapContext;
} }
else else
...@@ -254,6 +257,7 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY ) ...@@ -254,6 +257,7 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY )
void* pRawData = rtl_allocateMemory( nBytesPerRow * nDY ); void* pRawData = rtl_allocateMemory( nBytesPerRow * nDY );
mxBitmapContext = CGBitmapContextCreate( pRawData, nDX, nDY, mxBitmapContext = CGBitmapContextCreate( pRawData, nDX, nDY,
8, nBytesPerRow, aCGColorSpace, aCGBmpInfo ); 8, nBytesPerRow, aCGColorSpace, aCGBmpInfo );
CG_TRACE( "CGBitmapContextCreate(" << nDX << "x" << nDY << "x8) = " << mxBitmapContext );
xCGContext = mxBitmapContext; xCGContext = mxBitmapContext;
#endif #endif
} }
...@@ -262,11 +266,13 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY ) ...@@ -262,11 +266,13 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY )
const CGSize aNewSize = { static_cast<CGFloat>(nDX), static_cast<CGFloat>(nDY) }; const CGSize aNewSize = { static_cast<CGFloat>(nDX), static_cast<CGFloat>(nDY) };
mxLayer = CGLayerCreateWithContext( xCGContext, aNewSize, NULL ); mxLayer = CGLayerCreateWithContext( xCGContext, aNewSize, NULL );
CG_TRACE( "CGLayerCreateWithContext(" << xCGContext << "," << aNewSize << ",NULL) = " << mxLayer );
if( mxLayer && mpGraphics ) if( mxLayer && mpGraphics )
{ {
// get the matching Quartz context // get the matching Quartz context
CGContextRef xDrawContext = CGLayerGetContext( mxLayer ); CGContextRef xDrawContext = CGLayerGetContext( mxLayer );
CG_TRACE( "CGLayerGetContext(" << mxLayer << ") = " << xDrawContext );
mpGraphics->SetVirDevGraphics( mxLayer, xDrawContext, mnBitmapDepth ); mpGraphics->SetVirDevGraphics( mxLayer, xDrawContext, mnBitmapDepth );
} }
...@@ -282,6 +288,7 @@ void AquaSalVirtualDevice::GetSize( long& rWidth, long& rHeight ) ...@@ -282,6 +288,7 @@ void AquaSalVirtualDevice::GetSize( long& rWidth, long& rHeight )
const CGSize aSize = CGLayerGetSize( mxLayer ); const CGSize aSize = CGLayerGetSize( mxLayer );
rWidth = static_cast<long>(aSize.width); rWidth = static_cast<long>(aSize.width);
rHeight = static_cast<long>(aSize.height); rHeight = static_cast<long>(aSize.height);
CG_TRACE( "CGLayerGetSize(" << mxLayer << ") = " << aSize << "(" << rWidth << "x" << rHeight << ")" );
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment