[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/quartz
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sat May 18 06:50:22 UTC 2019
vcl/inc/quartz/CGHelpers.hxx | 34 ++++++++++++++++++
vcl/inc/quartz/salbmp.h | 2 -
vcl/inc/quartz/salgdi.h | 12 +++---
vcl/inc/quartz/salvd.h | 4 +-
vcl/quartz/salbmp.cxx | 13 +++---
vcl/quartz/salgdi.cxx | 15 +++-----
vcl/quartz/salgdicommon.cxx | 74 +++++++++++++++++++--------------------
vcl/quartz/salgdiutils.cxx | 28 +++++++--------
vcl/quartz/salvd.cxx | 80 ++++++++++++++++++++-----------------------
9 files changed, 147 insertions(+), 115 deletions(-)
New commits:
commit 368eb33bf21e2537410bf45171f56ad1dc668b99
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu May 16 15:21:08 2019 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat May 18 08:49:30 2019 +0200
use CGContextHolder in AquaVirtualDevice
Change-Id: If5e27ea4049a76e560dd9823f335b86e2599d4cc
Reviewed-on: https://gerrit.libreoffice.org/72440
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/inc/quartz/salvd.h b/vcl/inc/quartz/salvd.h
index bda6dc87e7cc..9c2d707981cc 100644
--- a/vcl/inc/quartz/salvd.h
+++ b/vcl/inc/quartz/salvd.h
@@ -39,7 +39,7 @@ class AquaSalVirtualDevice : public SalVirtualDevice
private:
bool mbGraphicsUsed; // is Graphics used
bool mbForeignContext; // is mxContext from outside VCL
- CGContextRef mxBitmapContext;
+ CGContextHolder maBitmapContext;
int mnBitmapDepth;
CGLayerHolder maLayer; // Quartz layer
AquaSalGraphics* mpGraphics; // current VirDev graphics
diff --git a/vcl/quartz/salvd.cxx b/vcl/quartz/salvd.cxx
index 84e6c7cf992f..c438f5245eba 100644
--- a/vcl/quartz/salvd.cxx
+++ b/vcl/quartz/salvd.cxx
@@ -65,7 +65,6 @@ std::unique_ptr<SalVirtualDevice> AquaSalInstance::CreateVirtualDevice( SalGraph
AquaSalVirtualDevice::AquaSalVirtualDevice( AquaSalGraphics* pGraphic, long &nDX, long &nDY,
DeviceFormat eFormat, const SystemGraphicsData *pData )
: mbGraphicsUsed( false )
- , mxBitmapContext( nullptr )
, mnBitmapDepth( 0 )
, mnWidth(0)
, mnHeight(0)
@@ -180,13 +179,13 @@ void AquaSalVirtualDevice::Destroy()
maLayer.set(nullptr);
}
- if( mxBitmapContext )
+ if (maBitmapContext.isSet())
{
- void* pRawData = CGBitmapContextGetData( mxBitmapContext );
- std::free( pRawData );
- SAL_INFO( "vcl.cg", "CGContextRelease(" << mxBitmapContext << ")" );
- CGContextRelease( mxBitmapContext );
- mxBitmapContext = nullptr;
+ void* pRawData = CGBitmapContextGetData(maBitmapContext.get());
+ std::free(pRawData);
+ SAL_INFO( "vcl.cg", "CGContextRelease(" << maBitmapContext.get() << ")" );
+ CGContextRelease(maBitmapContext.get());
+ maBitmapContext.set(nullptr);
}
}
@@ -233,18 +232,18 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY )
mnHeight = nDY;
// create a Quartz layer matching to the intended virdev usage
- CGContextRef xCGContext = nullptr;
+ CGContextHolder xCGContextHolder;
if( mnBitmapDepth && (mnBitmapDepth < 16) )
{
mnBitmapDepth = 8; // TODO: are 1bit vdevs worth it?
const int nBytesPerRow = (mnBitmapDepth * nDX + 7) / 8;
void* pRawData = std::malloc( nBytesPerRow * nDY );
- mxBitmapContext = CGBitmapContextCreate( pRawData, nDX, nDY,
+ maBitmapContext.set(CGBitmapContextCreate( pRawData, nDX, nDY,
mnBitmapDepth, nBytesPerRow,
- GetSalData()->mxGraySpace, kCGImageAlphaNone );
- SAL_INFO( "vcl.cg", "CGBitmapContextCreate(" << nDX << "x" << nDY << "x" << mnBitmapDepth << ") = " << mxBitmapContext );
- xCGContext = mxBitmapContext;
+ GetSalData()->mxGraySpace, kCGImageAlphaNone));
+ SAL_INFO("vcl.cg", "CGBitmapContextCreate(" << nDX << "x" << nDY << "x" << mnBitmapDepth << ") = " << maBitmapContext.get());
+ xCGContextHolder = maBitmapContext;
}
else
{
@@ -267,13 +266,13 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY )
NSGraphicsContext* pNSContext = [NSGraphicsContext graphicsContextWithWindow: pNSWindow];
if( pNSContext )
{
- xCGContext = [pNSContext CGContext];
+ xCGContextHolder.set([pNSContext CGContext]);
}
}
}
#endif
- if (!xCGContext)
+ if (!xCGContextHolder.isSet())
{
// assert(Application::IsBitmapRendering());
mnBitmapDepth = 32;
@@ -285,18 +284,18 @@ bool AquaSalVirtualDevice::SetSize( long nDX, long nDY )
#else
const int nFlags = kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little;
#endif
- mxBitmapContext = CGBitmapContextCreate(pRawData, nDX, nDY, 8, nBytesPerRow,
- GetSalData()->mxRGBSpace, nFlags);
- SAL_INFO( "vcl.cg", "CGBitmapContextCreate(" << nDX << "x" << nDY << "x32) = " << mxBitmapContext );
- xCGContext = mxBitmapContext;
+ maBitmapContext.set(CGBitmapContextCreate(pRawData, nDX, nDY, 8, nBytesPerRow,
+ GetSalData()->mxRGBSpace, nFlags));
+ SAL_INFO("vcl.cg", "CGBitmapContextCreate(" << nDX << "x" << nDY << "x32) = " << maBitmapContext.get());
+ xCGContextHolder = maBitmapContext;
}
}
- SAL_WARN_IF( !xCGContext, "vcl.quartz", "No context" );
+ SAL_WARN_IF(!xCGContextHolder.isSet(), "vcl.quartz", "No context");
const CGSize aNewSize = { static_cast<CGFloat>(nDX), static_cast<CGFloat>(nDY) };
- maLayer.set(CGLayerCreateWithContext(xCGContext, aNewSize, nullptr));
- SAL_INFO("vcl.cg", "CGLayerCreateWithContext(" << xCGContext << "," << aNewSize << ",NULL) = " << maLayer.get());
+ maLayer.set(CGLayerCreateWithContext(xCGContextHolder.get(), aNewSize, nullptr));
+ SAL_INFO("vcl.cg", "CGLayerCreateWithContext(" << xCGContextHolder.get() << "," << aNewSize << ",NULL) = " << maLayer.get());
if (maLayer.isSet() && mpGraphics)
{
commit ca2aa30771039bc0dc5cec9050f4e70a3b629e19
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 15 16:48:20 2019 +0900
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat May 18 08:49:17 2019 +0200
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 at gmail.com>
diff --git a/vcl/inc/quartz/CGHelpers.hxx b/vcl/inc/quartz/CGHelpers.hxx
index cbd13d76fcf4..9ec892175aee 100644
--- a/vcl/inc/quartz/CGHelpers.hxx
+++ b/vcl/inc/quartz/CGHelpers.hxx
@@ -15,8 +15,34 @@
#include <CoreGraphics/CoreGraphics.h>
#include <postmac.h>
+#include <quartz/utils.h>
+
+class CGLayerHolder
+{
+private:
+ CGLayerRef mpLayer;
+
+public:
+ CGLayerHolder()
+ : mpLayer(nullptr)
+ {
+ }
+
+ CGLayerHolder(CGLayerRef pLayer)
+ : mpLayer(pLayer)
+ {
+ }
+
+ CGLayerRef get() const { return mpLayer; }
+
+ bool isSet() const { return mpLayer != nullptr; }
+
+ void set(CGLayerRef const& pLayer) { mpLayer = pLayer; }
+};
+
class CGContextHolder
{
+private:
CGContextRef mpContext;
#if OSL_DEBUG_LEVEL > 0
int mnContextStackDepth;
@@ -31,6 +57,14 @@ public:
{
}
+ CGContextHolder(CGContextRef pContext)
+ : mpContext(pContext)
+#if OSL_DEBUG_LEVEL > 0
+ , mnContextStackDepth(0)
+#endif
+ {
+ }
+
CGContextRef get() const { return mpContext; }
bool isSet() const { return mpContext != nullptr; }
diff --git a/vcl/inc/quartz/salbmp.h b/vcl/inc/quartz/salbmp.h
index d2799add6847..cd9cfb43a549 100644
--- a/vcl/inc/quartz/salbmp.h
+++ b/vcl/inc/quartz/salbmp.h
@@ -89,7 +89,7 @@ private:
sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData );
public:
- bool Create( CGLayerRef xLayer, int nBitCount, int nX, int nY, int nWidth, int nHeight, bool bFlipped );
+ bool Create(CGLayerHolder const & rLayerHolder, int nBitCount, int nX, int nY, int nWidth, int nHeight, bool bFlipped);
public:
CGImageRef CreateWithMask( const QuartzSalBitmap& rMask, int nX, int nY, int nWidth, int nHeight ) const;
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index bde5167f55f5..e3c2b8e7b553 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -132,11 +132,9 @@ private:
class AquaSalGraphics : public SalGraphics
{
- CGLayerRef mxLayer; // Quartz graphics layer
+ CGLayerHolder maLayer; // Quartz graphics layer
CGContextHolder maContextHolder; // Quartz drawing context
-#ifdef MACOSX
- AquaSalFrame* mpFrame;
-#endif
+
XorEmulation* mpXorEmulation;
int mnXorMode; // 0: off 1: on 2: invert only
int mnWidth;
@@ -161,6 +159,10 @@ class AquaSalGraphics : public SalGraphics
/// allows text to be rendered without antialiasing
bool mbNonAntialiasedText;
+#ifdef MACOSX
+ AquaSalFrame* mpFrame;
+#endif
+
// Graphics types
/// is this a printer graphics
@@ -187,7 +189,7 @@ public:
void SetWindowGraphics( AquaSalFrame* pFrame );
void SetPrinterGraphics( CGContextRef, long nRealDPIX, long nRealDPIY );
- void SetVirDevGraphics( CGLayerRef, CGContextRef, int nBitDepth = 0 );
+ void SetVirDevGraphics(CGLayerHolder const & rLayer, CGContextRef, int nBitDepth = 0);
#ifdef MACOSX
void initResolution( NSWindow* );
void copyResolution( AquaSalGraphics& );
diff --git a/vcl/inc/quartz/salvd.h b/vcl/inc/quartz/salvd.h
index f5fc6e38b7bb..bda6dc87e7cc 100644
--- a/vcl/inc/quartz/salvd.h
+++ b/vcl/inc/quartz/salvd.h
@@ -41,7 +41,7 @@ private:
bool mbForeignContext; // is mxContext from outside VCL
CGContextRef mxBitmapContext;
int mnBitmapDepth;
- CGLayerRef mxLayer; // Quartz layer
+ CGLayerHolder maLayer; // Quartz layer
AquaSalGraphics* mpGraphics; // current VirDev graphics
long mnWidth;
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: */
More information about the Libreoffice-commits
mailing list