Kaydet (Commit) e262c072 authored tarafından Herbert Dürr's avatar Herbert Dürr Kaydeden (comit) Caolán McNamara

Related: #i123840# use CoreGraphic helper methods for primitives

C++11 says that narrowing conversions in array initializers are illegal.
This often happened for signed/unsigned and 32bit/64bit mismatches when
initializing CoreGraphics elementary types. Using CoreGraphic helper
methods for primitives is recommended.

(cherry picked from commit 5e7c8cd9)

Conflicts:
	vcl/aqua/source/gdi/salgdi.cxx

Change-Id: I5927790d97decea57ff236b0a52561e08f017163
üst c0c37983
...@@ -328,7 +328,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap ...@@ -328,7 +328,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap
DBG_ASSERT( pSrc->mxLayer!=NULL, "AquaSalGraphics::copyBits() from non-layered graphics" ); DBG_ASSERT( pSrc->mxLayer!=NULL, "AquaSalGraphics::copyBits() from non-layered graphics" );
const CGPoint aDstPoint = { static_cast<CGFloat>(+rPosAry.mnDestX - rPosAry.mnSrcX), static_cast<CGFloat>(rPosAry.mnDestY - rPosAry.mnSrcY) }; 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) && rPosAry.mnSrcHeight == rPosAry.mnDestHeight) &&
(!mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth) ) // workaround a Quartz crasher (!mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth) ) // workaround a Quartz crasher
...@@ -344,7 +344,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap ...@@ -344,7 +344,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap
} }
} }
CGContextSaveGState( xCopyContext ); CGContextSaveGState( xCopyContext );
const CGRect aDstRect = { { static_cast<CGFloat>(rPosAry.mnDestX), static_cast<CGFloat>(rPosAry.mnDestY) }, { static_cast<CGFloat>(rPosAry.mnDestWidth), static_cast<CGFloat>(rPosAry.mnDestHeight) } }; const CGRect aDstRect = CGRectMake(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
CGContextClipToRect( xCopyContext, aDstRect ); CGContextClipToRect( xCopyContext, aDstRect );
// draw at new destination // draw at new destination
...@@ -461,10 +461,10 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, ...@@ -461,10 +461,10 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY,
CGLayerRef xSrcLayer = mxLayer; CGLayerRef xSrcLayer = mxLayer;
// TODO: if( mnBitmapDepth > 0 ) // TODO: if( mnBitmapDepth > 0 )
{ {
const CGSize aSrcSize = { static_cast<CGFloat>(nSrcWidth), static_cast<CGFloat>(nSrcHeight) }; const CGSize aSrcSize = CGSizeMake(nSrcWidth, nSrcHeight);
xSrcLayer = ::CGLayerCreateWithContext( xCopyContext, aSrcSize, NULL ); xSrcLayer = ::CGLayerCreateWithContext( xCopyContext, aSrcSize, NULL );
const CGContextRef xSrcContext = CGLayerGetContext( xSrcLayer ); const CGContextRef xSrcContext = CGLayerGetContext( xSrcLayer );
CGPoint aSrcPoint = { static_cast<CGFloat>(-nSrcX), static_cast<CGFloat>(-nSrcY) }; CGPoint aSrcPoint = CGPointMake(-nSrcX, -nSrcY);
if( IsFlipped() ) if( IsFlipped() )
{ {
::CGContextTranslateCTM( xSrcContext, 0, +nSrcHeight ); ::CGContextTranslateCTM( xSrcContext, 0, +nSrcHeight );
...@@ -475,7 +475,7 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, ...@@ -475,7 +475,7 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY,
} }
// draw at new destination // draw at new destination
const CGPoint aDstPoint = { static_cast<CGFloat>(+nDstX), static_cast<CGFloat>(+nDstY) }; const CGPoint aDstPoint = CGPointMake(+nDstX, +nDstY);
::CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, xSrcLayer ); ::CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, xSrcLayer );
// cleanup // cleanup
...@@ -526,7 +526,7 @@ bool AquaSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, ...@@ -526,7 +526,7 @@ bool AquaSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
} }
if ( CheckContext() ) if ( CheckContext() )
{ {
const CGRect aDstRect = { { static_cast<CGFloat>(rTR.mnDestX), static_cast<CGFloat>(rTR.mnDestY) }, { static_cast<CGFloat>(rTR.mnDestWidth), static_cast<CGFloat>(rTR.mnDestHeight) } }; const CGRect aDstRect = CGRectMake( rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight);
CGContextDrawImage( mrContext, aDstRect, xMaskedImage ); CGContextDrawImage( mrContext, aDstRect, xMaskedImage );
RefreshRect( aDstRect ); RefreshRect( aDstRect );
} }
...@@ -566,7 +566,7 @@ bool AquaSalGraphics::drawTransformedBitmap( ...@@ -566,7 +566,7 @@ bool AquaSalGraphics::drawTransformedBitmap(
CGContextConcatCTM( mrContext, aCGMat ); CGContextConcatCTM( mrContext, aCGMat );
// draw the transformed image // draw the transformed image
const CGRect aSrcRect = {{0,0}, {static_cast<CGFloat>(aSize.Width()), static_cast<CGFloat>(aSize.Height())}}; const CGRect aSrcRect = CGRectMake(0, 0, aSize.Width(), aSize.Height());
CGContextDrawImage( mrContext, aSrcRect, xImage ); CGContextDrawImage( mrContext, aSrcRect, xImage );
CGImageRelease( xImage ); CGImageRelease( xImage );
// restore the Quartz graphics state // restore the Quartz graphics state
...@@ -590,7 +590,7 @@ bool AquaSalGraphics::drawAlphaRect( long nX, long nY, long nWidth, ...@@ -590,7 +590,7 @@ bool AquaSalGraphics::drawAlphaRect( long nX, long nY, long nWidth,
CGContextSaveGState( mrContext ); CGContextSaveGState( mrContext );
CGContextSetAlpha( mrContext, (100-nTransparency) * (1.0/100) ); CGContextSetAlpha( mrContext, (100-nTransparency) * (1.0/100) );
CGRect aRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { static_cast<CGFloat>(nWidth-1), static_cast<CGFloat>(nHeight-1) } }; CGRect aRect = CGRectMake(nX, nY, nWidth-1, nHeight-1);
if( IsPenVisible() ) if( IsPenVisible() )
{ {
aRect.origin.x += 0.5; aRect.origin.x += 0.5;
...@@ -620,8 +620,8 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS ...@@ -620,8 +620,8 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS
{ {
return; return;
} }
const CGRect aDstRect = { { static_cast<CGFloat>(rPosAry.mnDestX), static_cast<CGFloat>(rPosAry.mnDestY) },
{ static_cast<CGFloat>(rPosAry.mnDestWidth), static_cast<CGFloat>(rPosAry.mnDestHeight) } }; const CGRect aDstRect = CGRectMake(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
CGContextDrawImage( mrContext, aDstRect, xImage ); CGContextDrawImage( mrContext, aDstRect, xImage );
CGImageRelease( xImage ); CGImageRelease( xImage );
RefreshRect( aDstRect ); RefreshRect( aDstRect );
...@@ -648,8 +648,8 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS ...@@ -648,8 +648,8 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS
{ {
return; return;
} }
const CGRect aDstRect = { { static_cast<CGFloat>(rPosAry.mnDestX), static_cast<CGFloat>(rPosAry.mnDestY)},
{ static_cast<CGFloat>(rPosAry.mnDestWidth), static_cast<CGFloat>(rPosAry.mnDestHeight) } }; const CGRect aDstRect = CGRectMake(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
CGContextDrawImage( mrContext, aDstRect, xMaskedImage ); CGContextDrawImage( mrContext, aDstRect, xMaskedImage );
CGImageRelease( xMaskedImage ); CGImageRelease( xMaskedImage );
RefreshRect( aDstRect ); RefreshRect( aDstRect );
...@@ -686,7 +686,7 @@ sal_Bool AquaSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, ...@@ -686,7 +686,7 @@ sal_Bool AquaSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight,
[NSGraphicsContext setCurrentContext: pDrawNSCtx]; [NSGraphicsContext setCurrentContext: pDrawNSCtx];
// draw the EPS // draw the EPS
const NSRect aDstRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { static_cast<CGFloat>(nWidth), static_cast<CGFloat>(nHeight) } }; const NSRect aDstRect = NSMakeRect( nX, nY, nWidth, nHeight);
const BOOL bOK = [xEpsImage drawInRect: aDstRect]; const BOOL bOK = [xEpsImage drawInRect: aDstRect];
// restore the NSGraphicsContext // restore the NSGraphicsContext
...@@ -736,8 +736,8 @@ void AquaSalGraphics::drawMask( const SalTwoRect& rPosAry, const SalBitmap& rSal ...@@ -736,8 +736,8 @@ void AquaSalGraphics::drawMask( const SalTwoRect& rPosAry, const SalBitmap& rSal
{ {
return; return;
} }
const CGRect aDstRect = { { static_cast<CGFloat>(rPosAry.mnDestX), static_cast<CGFloat>(rPosAry.mnDestY) },
{ static_cast<CGFloat>(rPosAry.mnDestWidth), static_cast<CGFloat>(rPosAry.mnDestHeight) } }; const CGRect aDstRect = CGRectMake(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
CGContextDrawImage( mrContext, aDstRect, xImage ); CGContextDrawImage( mrContext, aDstRect, xImage );
CGImageRelease( xImage ); CGImageRelease( xImage );
RefreshRect( aDstRect ); RefreshRect( aDstRect );
...@@ -1195,7 +1195,7 @@ SalColor AquaSalGraphics::getPixel( long nX, long nY ) ...@@ -1195,7 +1195,7 @@ SalColor AquaSalGraphics::getPixel( long nX, long nY )
{ {
nY = mnHeight - nY; nY = mnHeight - nY;
} }
const CGPoint aCGPoint = { static_cast<CGFloat>(-nX), static_cast<CGFloat>(-nY) }; const CGPoint aCGPoint = CGPointMake(-nX, -nY);
CGContextDrawLayerAtPoint( xOnePixelContext, aCGPoint, mxLayer ); CGContextDrawLayerAtPoint( xOnePixelContext, aCGPoint, mxLayer );
CGContextRelease( xOnePixelContext ); CGContextRelease( xOnePixelContext );
...@@ -1223,7 +1223,7 @@ void AquaSalGraphics::ImplDrawPixel( long nX, long nY, const RGBAColor& rColor ) ...@@ -1223,7 +1223,7 @@ void AquaSalGraphics::ImplDrawPixel( long nX, long nY, const RGBAColor& rColor )
// overwrite the fill color // overwrite the fill color
CGContextSetFillColor( mrContext, rColor.AsArray() ); CGContextSetFillColor( mrContext, rColor.AsArray() );
// draw 1x1 rect, there is no pixel drawing in Quartz // draw 1x1 rect, there is no pixel drawing in Quartz
CGRect aDstRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, {1,1}}; const CGRect aDstRect = CGRectMake(nX, nY, 1, 1);
CGContextFillRect( mrContext, aDstRect ); CGContextFillRect( mrContext, aDstRect );
RefreshRect( aDstRect ); RefreshRect( aDstRect );
// reset the fill color // reset the fill color
...@@ -1509,7 +1509,7 @@ bool AquaSalGraphics::setClipRegion( const Region& i_rClip ) ...@@ -1509,7 +1509,7 @@ bool AquaSalGraphics::setClipRegion( const Region& i_rClip )
if(nH) if(nH)
{ {
CGRect aRect = {{ (CGFloat) aRectIter->Left(), (CGFloat) aRectIter->Top() }, { (CGFloat) nW, (CGFloat) nH }}; const CGRect aRect = CGRectMake( aRectIter->Left(), aRectIter->Top(), nW, nH);
CGPathAddRect( mxClipPath, NULL, aRect ); CGPathAddRect( mxClipPath, NULL, aRect );
} }
} }
...@@ -1739,7 +1739,7 @@ bool XorEmulation::UpdateTarget() ...@@ -1739,7 +1739,7 @@ bool XorEmulation::UpdateTarget()
const int nWidth = (int)CGImageGetWidth( xXorImage ); const int nWidth = (int)CGImageGetWidth( xXorImage );
const int nHeight = (int)CGImageGetHeight( xXorImage ); const int nHeight = (int)CGImageGetHeight( xXorImage );
// TODO: update minimal changerect // TODO: update minimal changerect
const CGRect aFullRect = { {0, 0}, { static_cast<CGFloat>(nWidth), static_cast<CGFloat>(nHeight) } }; const CGRect aFullRect = CGRectMake(0, 0, nWidth, nHeight);
CGContextDrawImage( m_xTargetContext, aFullRect, xXorImage ); CGContextDrawImage( m_xTargetContext, aFullRect, xXorImage );
CGImageRelease( xXorImage ); CGImageRelease( xXorImage );
} }
......
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