diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-05-15 16:48:20 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-05-18 08:49:17 +0200 |
commit | ca2aa30771039bc0dc5cec9050f4e70a3b629e19 (patch) | |
tree | cecf042c0942b6086f9813c82912bc8281d8f899 /vcl/quartz | |
parent | 1b1c750146b07bb760603a8d1d2ef0a3ae5d98c2 (diff) |
Wrap CGLayer into a CGLayerHolder class and move code to use it
Change-Id: I52539f6582d099ef80048d9a25266c88e1f6d783
Reviewed-on: https://gerrit.libreoffice.org/72439
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/quartz')
-rw-r--r-- | vcl/quartz/salbmp.cxx | 13 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 15 | ||||
-rw-r--r-- | vcl/quartz/salgdicommon.cxx | 74 | ||||
-rw-r--r-- | vcl/quartz/salgdiutils.cxx | 28 | ||||
-rw-r--r-- | vcl/quartz/salvd.cxx | 43 |
5 files changed, 85 insertions, 88 deletions
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index 12daa7567f42..745b57bd82a9 100644 --- a/vcl/quartz/salbmp.cxx +++ b/vcl/quartz/salbmp.cxx @@ -69,10 +69,9 @@ QuartzSalBitmap::~QuartzSalBitmap() Destroy(); } -bool QuartzSalBitmap::Create( CGLayerRef xLayer, int nBitmapBits, - int nX, int nY, int nWidth, int nHeight, bool bFlipped ) +bool QuartzSalBitmap::Create(CGLayerHolder const & rLayerHolder, int nBitmapBits, int nX, int nY, int nWidth, int nHeight, bool bFlipped) { - SAL_WARN_IF( !xLayer, "vcl", "QuartzSalBitmap::Create() from non-layered context" ); + SAL_WARN_IF(!rLayerHolder.isSet(), "vcl", "QuartzSalBitmap::Create() from non-layered context"); // sanitize input parameters if( nX < 0 ) { @@ -85,8 +84,8 @@ bool QuartzSalBitmap::Create( CGLayerRef xLayer, int nBitmapBits, nY = 0; } - const CGSize aLayerSize = CGLayerGetSize( xLayer ); - SAL_INFO("vcl.cg", "CGLayerGetSize(" << xLayer << ") = " << aLayerSize ); + const CGSize aLayerSize = CGLayerGetSize(rLayerHolder.get()); + SAL_INFO("vcl.cg", "CGLayerGetSize(" << rLayerHolder.get() << ") = " << aLayerSize ); if( nWidth >= static_cast<int>(aLayerSize.width) - nX ) nWidth = static_cast<int>(aLayerSize.width) - nX; @@ -108,7 +107,7 @@ bool QuartzSalBitmap::Create( CGLayerRef xLayer, int nBitmapBits, const CGPoint aSrcPoint = { static_cast<CGFloat>(-nX), static_cast<CGFloat>(-nY) }; if(mxGraphicContext) // remove warning { - SAL_INFO("vcl.cg", "CGContextDrawLayerAtPoint(" << mxGraphicContext << "," << aSrcPoint << "," << xLayer << ")" ); + SAL_INFO("vcl.cg", "CGContextDrawLayerAtPoint(" << mxGraphicContext << "," << aSrcPoint << "," << rLayerHolder.get() << ")" ); if( bFlipped ) { SAL_INFO( "vcl.cg", "CGContextTranslateCTM(" << mxGraphicContext << ",0," << mnHeight << ")" ); @@ -117,7 +116,7 @@ bool QuartzSalBitmap::Create( CGLayerRef xLayer, int nBitmapBits, CGContextScaleCTM( mxGraphicContext, +1, -1 ); } - CGContextDrawLayerAtPoint( mxGraphicContext, aSrcPoint, xLayer ); + CGContextDrawLayerAtPoint( mxGraphicContext, aSrcPoint, rLayerHolder.get() ); } return true; } diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index a68f9e9736ef..846b7abbbc49 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -181,11 +181,7 @@ bool CoreTextFontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilit } AquaSalGraphics::AquaSalGraphics() - : mxLayer( nullptr ) -#ifdef MACOSX - , mpFrame( nullptr ) -#endif - , mpXorEmulation( nullptr ) + : mpXorEmulation( nullptr ) , mnXorMode( 0 ) , mnWidth( 0 ) , mnHeight( 0 ) @@ -197,6 +193,9 @@ AquaSalGraphics::AquaSalGraphics() , maFillColor( COL_BLACK ) , maTextColor( COL_BLACK ) , mbNonAntialiasedText( false ) +#ifdef MACOSX + , mpFrame( nullptr ) +#endif , mbPrinter( false ) , mbVirDev( false ) #ifdef MACOSX @@ -238,10 +237,10 @@ AquaSalGraphics::~AquaSalGraphics() if (mbForeignContext) return; #endif - if( mxLayer ) + if (maLayer.isSet()) { - SAL_INFO("vcl.cg", "CGLayerRelease(" << mxLayer << ")" ); - CGLayerRelease( mxLayer ); + SAL_INFO("vcl.cg", "CGLayerRelease(" << maLayer.get() << ")" ); + CGLayerRelease(maLayer.get()); } else if (maContextHolder.isSet() #ifdef MACOSX diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx index dc73d3c95b28..11fc42fc6cfc 100644 --- a/vcl/quartz/salgdicommon.cxx +++ b/vcl/quartz/salgdicommon.cxx @@ -347,14 +347,14 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap ApplyXorContext(); pSrc->ApplyXorContext(); - SAL_WARN_IF( !pSrc->mxLayer, "vcl.quartz", - "AquaSalGraphics::copyBits() from non-layered graphics this=" << this ); + SAL_WARN_IF (!pSrc->maLayer.isSet(), "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 && + if ((rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight == rPosAry.mnDestHeight) && (!mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth) - && pSrc->mxLayer ) // workaround for a Quartz crash + && pSrc->maLayer.isSet()) // workaround for a Quartz crash { // in XOR mode the drawing context is redirected to the XOR mask // if source and target are identical then copyBits() paints onto the target context though @@ -384,8 +384,8 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap } // TODO: pSrc->size() != this->size() - SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xCopyContext << "," << aDstPoint << "," << pSrc->mxLayer << ")" ); - CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, pSrc->mxLayer ); + SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xCopyContext << "," << aDstPoint << "," << pSrc->maLayer.get() << ")"); + CGContextDrawLayerAtPoint(xCopyContext, aDstPoint, pSrc->maLayer.get()); SAL_INFO( "vcl.cg", "CGContextRestoreGState(" << xCopyContext << ")" ); CGContextRestoreGState( xCopyContext ); @@ -478,11 +478,11 @@ void AquaSalGraphics::ApplyXorContext() void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, bool /*bWindowInvalidate*/ ) { - SAL_WARN_IF( !mxLayer, "vcl.quartz", - "AquaSalGraphics::copyArea() for non-layered graphics this=" << this ); + SAL_WARN_IF (!maLayer.isSet(), "vcl.quartz", + "AquaSalGraphics::copyArea() for non-layered graphics this=" << this); #ifdef IOS - if( !mxLayer ) + if (!maLayer.isSet()) return; #endif @@ -500,15 +500,15 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, // e.g. on OSX>=10.5 only this situation causes problems: // mnBitmapDepth && (aDstPoint.x + pSrc->mnWidth) > mnWidth - CGLayerRef xSrcLayer = mxLayer; + CGLayerHolder sSourceLayerHolder(maLayer.get()); // TODO: if( mnBitmapDepth > 0 ) { const CGSize aSrcSize = CGSizeMake(nSrcWidth, nSrcHeight); - xSrcLayer = CGLayerCreateWithContext( xCopyContext, aSrcSize, nullptr ); - SAL_INFO( "vcl.cg", "CGLayerCreateWithContext(" << xCopyContext << "," << aSrcSize << ",NULL) = " << xSrcLayer ); + sSourceLayerHolder.set(CGLayerCreateWithContext(xCopyContext, aSrcSize, nullptr)); + SAL_INFO( "vcl.cg", "CGLayerCreateWithContext(" << xCopyContext << "," << aSrcSize << ",NULL) = " << sSourceLayerHolder.get()); - const CGContextRef xSrcContext = CGLayerGetContext( xSrcLayer ); - SAL_INFO( "vcl.cg", "CGLayerGetContext(" << xSrcLayer << ") = " << xSrcContext ); + const CGContextRef xSrcContext = CGLayerGetContext(sSourceLayerHolder.get()); + SAL_INFO( "vcl.cg", "CGLayerGetContext(" << sSourceLayerHolder.get() << ") = " << xSrcContext); CGPoint aSrcPoint = CGPointMake(-nSrcX, -nSrcY); if( IsFlipped() ) @@ -519,20 +519,20 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, CGContextScaleCTM( xSrcContext, +1, -1 ); aSrcPoint.y = (nSrcY + nSrcHeight) - mnHeight; } - SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xSrcContext << "," << aSrcPoint << "," << mxLayer << ")" ); - CGContextDrawLayerAtPoint( xSrcContext, aSrcPoint, mxLayer ); + SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xSrcContext << "," << aSrcPoint << "," << maLayer.get() << ")" ); + CGContextDrawLayerAtPoint(xSrcContext, aSrcPoint, maLayer.get()); } // draw at new destination const CGPoint aDstPoint = CGPointMake(+nDstX, +nDstY); - SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xCopyContext << "," << aDstPoint << "," << xSrcLayer << ")" ); - CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, xSrcLayer ); + SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << xCopyContext << "," << aDstPoint << "," << sSourceLayerHolder.get() << ")" ); + CGContextDrawLayerAtPoint(xCopyContext, aDstPoint, sSourceLayerHolder.get()); // cleanup - if( xSrcLayer != mxLayer ) + if (sSourceLayerHolder.get() != maLayer.get()) { - SAL_INFO( "vcl.cg", "CGLayerRelease(" << xSrcLayer << ")" ); - CGLayerRelease( xSrcLayer ); + SAL_INFO( "vcl.cg", "CGLayerRelease(" << sSourceLayerHolder.get() << ")" ); + CGLayerRelease(sSourceLayerHolder.get()); } // mark the destination rectangle as updated RefreshRect( nDstX, nDstY, nSrcWidth, nSrcHeight ); @@ -1298,12 +1298,12 @@ sal_uInt16 AquaSalGraphics::GetBitCount() const std::shared_ptr<SalBitmap> AquaSalGraphics::getBitmap( long nX, long nY, long nDX, long nDY ) { - SAL_WARN_IF( !mxLayer, "vcl.quartz", "AquaSalGraphics::getBitmap() with no layer this=" << this ); + SAL_WARN_IF(!maLayer.isSet(), "vcl.quartz", "AquaSalGraphics::getBitmap() with no layer this=" << this); ApplyXorContext(); std::shared_ptr<QuartzSalBitmap> pBitmap = std::make_shared<QuartzSalBitmap>(); - if( !pBitmap->Create( mxLayer, mnBitmapDepth, nX, nY, nDX, nDY, IsFlipped()) ) + if (!pBitmap->Create(maLayer, mnBitmapDepth, nX, nY, nDX, nDY, IsFlipped())) { pBitmap = nullptr; } @@ -1345,7 +1345,7 @@ long AquaSalGraphics::GetGraphicsWidth() const Color AquaSalGraphics::getPixel( long nX, long nY ) { // return default value on printers or when out of bounds - if( !mxLayer || (nX < 0) || (nX >= mnWidth) || + if (!maLayer.isSet() || (nX < 0) || (nX >= mnWidth) || (nY < 0) || (nY >= mnHeight)) { return sal_uInt32(COL_BLACK); @@ -1375,9 +1375,9 @@ Color AquaSalGraphics::getPixel( long nX, long nY ) nY = mnHeight - nY; } const CGPoint aCGPoint = CGPointMake(-nX, -nY); - SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << - xOnePixelContext << "," << aCGPoint << "," << mxLayer << ")" ); - CGContextDrawLayerAtPoint( xOnePixelContext, aCGPoint, mxLayer ); + SAL_INFO("vcl.cg", "CGContextDrawLayerAtPoint(" << + xOnePixelContext << "," << aCGPoint << "," << maLayer.get() << ")"); + CGContextDrawLayerAtPoint(xOnePixelContext, aCGPoint, maLayer.get()); SAL_INFO( "vcl.cg", "CGContextRelease(" << xOnePixelContext << ")" ); CGContextRelease( xOnePixelContext ); @@ -1851,7 +1851,7 @@ void AquaSalGraphics::SetXORMode( bool bSet, bool bInvertOnly ) if( !mpXorEmulation ) { mpXorEmulation = new XorEmulation(); - mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, maContextHolder.get(), mxLayer ); + mpXorEmulation->SetTarget(mnWidth, mnHeight, mnBitmapDepth, maContextHolder.get(), maLayer.get()); } // change the XOR mode @@ -2056,10 +2056,10 @@ bool XorEmulation::UpdateTarget() return true; } -void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContext, - int nBitmapDepth ) +void AquaSalGraphics::SetVirDevGraphics(CGLayerHolder const & rLayer, CGContextRef xContext, + int nBitmapDepth) { - SAL_INFO( "vcl.quartz", "SetVirDevGraphics() this=" << this << " layer=" << xLayer << " context=" << xContext ); + SAL_INFO( "vcl.quartz", "SetVirDevGraphics() this=" << this << " layer=" << rLayer.get() << " context=" << xContext ); #ifndef IOS mbWindow = false; @@ -2070,7 +2070,7 @@ void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContex #ifdef IOS (void) nBitmapDepth; - if( !xContext ) + if (!xContext) { // We will return early a few lines lower. // Undo the "stack initialization" done at the initial call of @@ -2080,7 +2080,7 @@ void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContex #endif // set graphics properties - mxLayer = xLayer; + maLayer = rLayer; maContextHolder.set(xContext); #ifndef IOS @@ -2096,7 +2096,7 @@ void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContex return; // get new graphics properties - if( !mxLayer ) + if (!maLayer.isSet()) { mnWidth = CGBitmapContextGetWidth( maContextHolder.get() ); mnHeight = CGBitmapContextGetHeight( maContextHolder.get() ); @@ -2105,10 +2105,10 @@ void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContex } else { - const CGSize aSize = CGLayerGetSize( mxLayer ); + const CGSize aSize = CGLayerGetSize(maLayer.get()); mnWidth = static_cast<int>(aSize.width); mnHeight = static_cast<int>(aSize.height); - SAL_INFO( "vcl.cg", "CGLayerGetSize(" << mxLayer << ") = " << aSize ); + SAL_INFO("vcl.cg", "CGLayerGetSize(" << maLayer.get() << ") = " << aSize); } // prepare graphics for drawing @@ -2119,7 +2119,7 @@ void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContex // re-enable XorEmulation for the new context if( mpXorEmulation ) { - mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, maContextHolder.get(), mxLayer ); + mpXorEmulation->SetTarget(mnWidth, mnHeight, mnBitmapDepth, maContextHolder.get(), maLayer.get()); if( mpXorEmulation->IsEnabled() ) { maContextHolder.set(mpXorEmulation->GetMaskContext()); diff --git a/vcl/quartz/salgdiutils.cxx b/vcl/quartz/salgdiutils.cxx index 98213b7c3344..4c13ad788183 100644 --- a/vcl/quartz/salgdiutils.cxx +++ b/vcl/quartz/salgdiutils.cxx @@ -88,7 +88,7 @@ void AquaSalGraphics::UnsetState() } /** - * (re-)create the off-screen mxLayer we render everything to if + * (re-)create the off-screen maLayer we render everything to if * necessary: eg. not initialized yet, or it has an incorrect size. */ bool AquaSalGraphics::CheckContext() @@ -106,15 +106,15 @@ bool AquaSalGraphics::CheckContext() mnWidth = nWidth; mnHeight = nHeight; // prepare to release the corresponding resources - if (mxLayer) - rReleaseLayer = mxLayer; + if (maLayer.isSet()) + rReleaseLayer = maLayer.get(); else if (maContextHolder.isSet()) { SAL_INFO("vcl.cg", "CGContextRelease(" << maContextHolder.get() << ")"); CGContextRelease(maContextHolder.get()); } maContextHolder.set(nullptr); - mxLayer = nullptr; + maLayer.set(nullptr); } if (!maContextHolder.isSet()) @@ -124,12 +124,12 @@ bool AquaSalGraphics::CheckContext() const CGSize aLayerSize = { static_cast<CGFloat>(nWidth), static_cast<CGFloat>(nHeight) }; NSGraphicsContext* pNSGContext = [NSGraphicsContext graphicsContextWithWindow: mpFrame->getNSWindow()]; CGContextRef xCGContext = [pNSGContext CGContext]; - mxLayer = CGLayerCreateWithContext(xCGContext, aLayerSize, nullptr); - SAL_INFO("vcl.cg", "CGLayerCreateWithContext(" << xCGContext << "," << aLayerSize << ",NULL) = " << mxLayer); - if (mxLayer) + maLayer.set(CGLayerCreateWithContext(xCGContext, aLayerSize, nullptr)); + SAL_INFO("vcl.cg", "CGLayerCreateWithContext(" << xCGContext << "," << aLayerSize << ",NULL) = " << maLayer.get()); + if (maLayer.isSet()) { - maContextHolder.set(CGLayerGetContext(mxLayer)); - SAL_INFO( "vcl.cg", "CGLayerGetContext(" << mxLayer << ") = " << maContextHolder.get() ); + maContextHolder.set(CGLayerGetContext(maLayer.get())); + SAL_INFO( "vcl.cg", "CGLayerGetContext(" << maLayer.get() << ") = " << maContextHolder.get() ); } if (rReleaseLayer) @@ -168,7 +168,7 @@ bool AquaSalGraphics::CheckContext() // re-enable XOR emulation for the new context if (mpXorEmulation) - mpXorEmulation->SetTarget(mnWidth, mnHeight, mnBitmapDepth, maContextHolder.get(), mxLayer); + mpXorEmulation->SetTarget(mnWidth, mnHeight, mnBitmapDepth, maContextHolder.get(), maLayer.get()); } } } @@ -187,7 +187,7 @@ CGContextRef AquaSalGraphics::GetContext() } /** - * Blit the contents of our internal mxLayer state to the + * Blit the contents of our internal maLayer state to the * associated window, if any; cf. drawRect event handling * on the frame. */ @@ -199,7 +199,7 @@ void AquaSalGraphics::UpdateWindow( NSRect& ) } NSGraphicsContext* pContext = [NSGraphicsContext currentContext]; - if( (mxLayer != nullptr) && (pContext != nullptr) ) + if (maLayer.isSet() && pContext != nullptr) { CGContextRef rCGContext = [pContext CGContext]; SAL_INFO( "vcl.cg", "[[NSGraphicsContext currentContext] CGContext] = " << rCGContext ); @@ -217,8 +217,8 @@ void AquaSalGraphics::UpdateWindow( NSRect& ) } ApplyXorContext(); - SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << rCGContext << "," << CGPointZero << "," << mxLayer << ")" ); - CGContextDrawLayerAtPoint( rCGContext, CGPointZero, mxLayer ); + SAL_INFO( "vcl.cg", "CGContextDrawLayerAtPoint(" << rCGContext << "," << CGPointZero << "," << maLayer.get() << ")" ); + CGContextDrawLayerAtPoint( rCGContext, CGPointZero, maLayer.get() ); if( rClip ) // cleanup clipping { CGContextRestoreGState( rCGContext ); diff --git a/vcl/quartz/salvd.cxx b/vcl/quartz/salvd.cxx index a08345dfd1c1..84e6c7cf992f 100644 --- a/vcl/quartz/salvd.cxx +++ b/vcl/quartz/salvd.cxx @@ -67,7 +67,6 @@ AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX : mbGraphicsUsed( false ) , mxBitmapContext( nullptr ) , mnBitmapDepth( 0 ) - , mxLayer( nullptr ) , mnWidth(0) , mnHeight(0) { @@ -90,11 +89,11 @@ AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX { nDY = 1; } - mxLayer = CGLayerCreateWithContext( pData->rCGContext, CGSizeMake( nDX, nDY), nullptr ); + maLayer.set(CGLayerCreateWithContext(pData->rCGContext, CGSizeMake(nDX, nDY), nullptr)); // Interrogate the context as to its real size - if (mxLayer) + if (maLayer.isSet()) { - const CGSize aSize = CGLayerGetSize( mxLayer ); + const CGSize aSize = CGLayerGetSize(maLayer.get()); nDX = static_cast<long>(aSize.width); nDY = static_cast<long>(aSize.height); } @@ -104,8 +103,8 @@ AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX nDY = 0; } SAL_INFO( "vcl.cg", "CGLayerCreateWithContext(" << pData->rCGContext << - "," << CGSizeMake( nDX, nDY) << ",NULL) = " << mxLayer ); - mpGraphics->SetVirDevGraphics( mxLayer, pData->rCGContext ); + "," << CGSizeMake( nDX, nDY) << ",NULL) = " << maLayer.get()); + mpGraphics->SetVirDevGraphics(maLayer, pData->rCGContext); } else { @@ -166,19 +165,19 @@ void AquaSalVirtualDevice::Destroy() if( mbForeignContext ) { // Do not delete mxContext that we have received from outside VCL - mxLayer = nullptr; + maLayer.set(nullptr); return; } - if( mxLayer ) + if (maLayer.isSet()) { if( mpGraphics ) { - mpGraphics->SetVirDevGraphics( nullptr, nullptr ); + mpGraphics->SetVirDevGraphics(nullptr, nullptr); } - SAL_INFO( "vcl.cg", "CGLayerRelease(" << mxLayer << ")" ); - CGLayerRelease( mxLayer ); - mxLayer = nullptr; + SAL_INFO("vcl.cg", "CGLayerRelease(" << maLayer.get() << ")"); + CGLayerRelease(maLayer.get()); + maLayer.set(nullptr); } if( mxBitmapContext ) @@ -217,10 +216,10 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY ) return true; } - if( mxLayer ) + if (maLayer.isSet()) { - const CGSize aSize = CGLayerGetSize( mxLayer ); - SAL_INFO( "vcl.cg", "CGlayerGetSize(" << mxLayer << ") = " << aSize ); + const CGSize aSize = CGLayerGetSize(maLayer.get()); + SAL_INFO( "vcl.cg", "CGlayerGetSize(" << maLayer.get() << ") = " << aSize ); if( (nDX == aSize.width) && (nDY == aSize.height) ) { // Yay, we do not have to do anything :) @@ -296,18 +295,18 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY ) SAL_WARN_IF( !xCGContext, "vcl.quartz", "No context" ); const CGSize aNewSize = { static_cast<CGFloat>(nDX), static_cast<CGFloat>(nDY) }; - mxLayer = CGLayerCreateWithContext( xCGContext, aNewSize, nullptr ); - SAL_INFO( "vcl.cg", "CGLayerCreateWithContext(" << xCGContext << "," << aNewSize << ",NULL) = " << mxLayer ); + maLayer.set(CGLayerCreateWithContext(xCGContext, aNewSize, nullptr)); + SAL_INFO("vcl.cg", "CGLayerCreateWithContext(" << xCGContext << "," << aNewSize << ",NULL) = " << maLayer.get()); - if( mxLayer && mpGraphics ) + if (maLayer.isSet() && mpGraphics) { // get the matching Quartz context - CGContextRef xDrawContext = CGLayerGetContext( mxLayer ); - SAL_INFO( "vcl.cg", "CGLayerGetContext(" << mxLayer << ") = " << xDrawContext ); - mpGraphics->SetVirDevGraphics( mxLayer, xDrawContext, mnBitmapDepth ); + CGContextRef xDrawContext = CGLayerGetContext( maLayer.get() ); + SAL_INFO( "vcl.cg", "CGLayerGetContext(" << maLayer.get() << ") = " << xDrawContext ); + mpGraphics->SetVirDevGraphics(maLayer.get(), xDrawContext, mnBitmapDepth); } - return (mxLayer != nullptr); + return maLayer.isSet(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |