This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch AOO50X in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 7fc4b7f2c45774b3698a201b2e7a3f3cd28195be Author: Jim Jagielski <[email protected]> AuthorDate: Mon Nov 16 12:52:49 2026 -0500 vcl: do the macOS XOR emulation in layer pixels Turning XOR mode off left a 2x window or virtual device resampled to 1x. In flipped (window) targets the XORed shape also landed mirrored top to bottom, at 1x as well. This more closely aligns with Apple's published guidelines and recommendations regarding HIDPI, which we are now in a better situation to follow. --- main/vcl/aqua/source/gdi/salgdi.cxx | 21 +++++++++++++++------ main/vcl/aqua/source/gdi/salgdiutils.cxx | 4 ++-- main/vcl/inc/aqua/salgdi.h | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/main/vcl/aqua/source/gdi/salgdi.cxx b/main/vcl/aqua/source/gdi/salgdi.cxx index 3a807fe765..68ea3900cf 100644 --- a/main/vcl/aqua/source/gdi/salgdi.cxx +++ b/main/vcl/aqua/source/gdi/salgdi.cxx @@ -2370,7 +2370,7 @@ void AquaSalGraphics::SetXORMode( bool bSet, bool bInvertOnly ) if( !mpXorEmulation ) { mpXorEmulation = new XorEmulation(); - mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer, mfScale ); + mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer ); } // change the XOR mode @@ -2424,7 +2424,7 @@ XorEmulation::~XorEmulation() // ----------------------------------------------------------------------- void XorEmulation::SetTarget( int nWidth, int nHeight, int nTargetDepth, - CGContextRef xTargetContext, CGLayerRef xTargetLayer, float fScale ) + CGContextRef xTargetContext, CGLayerRef xTargetLayer ) { // prepare to replace old mask+temp context if( mxMaskContext ) @@ -2453,6 +2453,14 @@ void XorEmulation::SetTarget( int nWidth, int nHeight, int nTargetDepth, mxTargetLayer = xTargetLayer; mxTargetContext = xTargetContext; + // XOR per layer pixel, which is more than one per point on a HiDPI layer + if( xTargetLayer ) + { + const CGSize aPixels = CGLayerGetSize( xTargetLayer ); + nWidth = static_cast<int>(aPixels.width); + nHeight = static_cast<int>(aPixels.height); + } + // prepare creation of matching CGBitmaps CGColorSpaceRef aCGColorSpace = GetSalData()->mxRGBSpace; CGBitmapInfo aCGBmpInfo = kCGImageAlphaNoneSkipFirst; @@ -2502,11 +2510,9 @@ void XorEmulation::SetTarget( int nWidth, int nHeight, int nTargetDepth, CGContextSetBlendMode( mxMaskContext, kCGBlendModeDifference ); // initialize the transformation matrix to the drawing target - const CGAffineTransform aCTM = CGAffineTransformConcat( CGContextGetCTM( xTargetContext ), - CGAffineTransformMakeScale( 1.0 / fScale, 1.0 / fScale ) ); + // the temp context keeps identity: it copies target pixels 1:1 + const CGAffineTransform aCTM = CGContextGetCTM( xTargetContext ); CGContextConcatCTM( mxMaskContext, aCTM ); - if( mxTempContext ) - CGContextConcatCTM( mxTempContext, aCTM ); // initialize the default XorMask graphics state CGContextSaveGState( mxMaskContext ); @@ -2540,7 +2546,10 @@ bool XorEmulation::UpdateTarget() const int nHeight = (int)CGImageGetHeight( xXorImage ); // TODO: update minimal changerect const CGRect aFullRect = CGRectMake( 0, 0, nWidth, nHeight); + CGContextSaveGState( mxTargetContext ); + CGContextConcatCTM( mxTargetContext, CGAffineTransformInvert( CGContextGetCTM( mxTargetContext ) ) ); CGContextDrawImage( mxTargetContext, aFullRect, xXorImage ); + CGContextRestoreGState( mxTargetContext ); CGImageRelease( xXorImage ); } diff --git a/main/vcl/aqua/source/gdi/salgdiutils.cxx b/main/vcl/aqua/source/gdi/salgdiutils.cxx index f1f83e7cf3..1d927cb97a 100644 --- a/main/vcl/aqua/source/gdi/salgdiutils.cxx +++ b/main/vcl/aqua/source/gdi/salgdiutils.cxx @@ -118,7 +118,7 @@ void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContex // re-enable XorEmulation for the new context if( mpXorEmulation ) { - mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer, mfScale ); + mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer ); if( mpXorEmulation->IsEnabled() ) mrContext = mpXorEmulation->GetMaskContext(); } @@ -226,7 +226,7 @@ bool AquaSalGraphics::CheckContext() // re-enable XOR emulation for the new context if( mpXorEmulation ) - mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer, mfScale ); + mpXorEmulation->SetTarget( mnWidth, mnHeight, mnBitmapDepth, mrContext, mxLayer ); } } diff --git a/main/vcl/inc/aqua/salgdi.h b/main/vcl/inc/aqua/salgdi.h index cb45c43da5..6d880d8d31 100644 --- a/main/vcl/inc/aqua/salgdi.h +++ b/main/vcl/inc/aqua/salgdi.h @@ -423,7 +423,7 @@ public: XorEmulation(); /*final*/ ~XorEmulation(); - void SetTarget( int nWidth, int nHeight, int nBitmapDepth, CGContextRef, CGLayerRef, float fScale = 1.0f ); + void SetTarget( int nWidth, int nHeight, int nBitmapDepth, CGContextRef, CGLayerRef ); bool UpdateTarget(); void Enable() { mbIsEnabled = true; } void Disable() { mbIsEnabled = false; }
