Kaydet (Commit) 5e7c8cd9 authored tarafından Herbert Dürr's avatar Herbert Dürr

#i123840# fix narrowing conversions in CoreGraphic's array initializers

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 solves these problems and is recommended anyway.
üst 0801e9b4
...@@ -592,7 +592,7 @@ bool AquaSalGraphics::setClipRegion( const Region& i_rClip ) ...@@ -592,7 +592,7 @@ bool AquaSalGraphics::setClipRegion( const Region& i_rClip )
if(nH) if(nH)
{ {
CGRect aRect = {{ aRectIter->Left(), aRectIter->Top() }, { nW, nH }}; const CGRect aRect = CGRectMake( aRectIter->Left(), aRectIter->Top(), nW, nH);
CGPathAddRect( mxClipPath, NULL, aRect ); CGPathAddRect( mxClipPath, NULL, aRect );
} }
} }
...@@ -676,7 +676,7 @@ void AquaSalGraphics::ImplDrawPixel( long nX, long nY, const RGBAColor& rColor ) ...@@ -676,7 +676,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 = {{nX,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
...@@ -1133,7 +1133,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap ...@@ -1133,7 +1133,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 = { +rPosAry.mnDestX - rPosAry.mnSrcX, rPosAry.mnDestY - rPosAry.mnSrcY }; const CGPoint aDstPoint = CGPointMake( +rPosAry.mnDestX - rPosAry.mnSrcX, rPosAry.mnDestY - rPosAry.mnSrcY);
if( (rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight == rPosAry.mnDestHeight) && if( (rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight == rPosAry.mnDestHeight) &&
(!mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth) ) // workaround a Quartz crasher (!mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth) ) // workaround a Quartz crasher
{ {
...@@ -1145,7 +1145,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap ...@@ -1145,7 +1145,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap
xCopyContext = mpXorEmulation->GetTargetContext(); xCopyContext = mpXorEmulation->GetTargetContext();
CGContextSaveGState( xCopyContext ); CGContextSaveGState( xCopyContext );
const CGRect aDstRect = { {rPosAry.mnDestX, rPosAry.mnDestY}, {rPosAry.mnDestWidth, 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
...@@ -1211,10 +1211,10 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, l ...@@ -1211,10 +1211,10 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, l
CGLayerRef xSrcLayer = mxLayer; CGLayerRef xSrcLayer = mxLayer;
// TODO: if( mnBitmapDepth > 0 ) // TODO: if( mnBitmapDepth > 0 )
{ {
const CGSize aSrcSize = { nSrcWidth, 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 = { -nSrcX, -nSrcY }; CGPoint aSrcPoint = CGPointMake( -nSrcX, -nSrcY);
if( IsFlipped() ) if( IsFlipped() )
{ {
::CGContextTranslateCTM( xSrcContext, 0, +nSrcHeight ); ::CGContextTranslateCTM( xSrcContext, 0, +nSrcHeight );
...@@ -1225,7 +1225,7 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, l ...@@ -1225,7 +1225,7 @@ void AquaSalGraphics::copyArea( long nDstX, long nDstY,long nSrcX, long nSrcY, l
} }
// draw at new destination // draw at new destination
const CGPoint aDstPoint = { +nDstX, +nDstY }; const CGPoint aDstPoint = CGPointMake( +nDstX, +nDstY);
::CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, xSrcLayer ); ::CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, xSrcLayer );
// cleanup // cleanup
...@@ -1249,7 +1249,7 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS ...@@ -1249,7 +1249,7 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS
if( !xImage ) if( !xImage )
return; return;
const CGRect aDstRect = {{rPosAry.mnDestX, rPosAry.mnDestY}, {rPosAry.mnDestWidth, 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 );
...@@ -1259,7 +1259,7 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS ...@@ -1259,7 +1259,7 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS
void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,SalColor ) void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,SalColor )
{ {
DBG_ERROR("not implemented for color masking!"); DBG_ERROR( "not implemented for color masking!");
drawBitmap( rPosAry, rSalBitmap ); drawBitmap( rPosAry, rSalBitmap );
} }
...@@ -1276,7 +1276,7 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS ...@@ -1276,7 +1276,7 @@ void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rS
if( !xMaskedImage ) if( !xMaskedImage )
return; return;
const CGRect aDstRect = {{rPosAry.mnDestX, rPosAry.mnDestY}, {rPosAry.mnDestWidth, 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 );
...@@ -1294,7 +1294,7 @@ void AquaSalGraphics::drawMask( const SalTwoRect& rPosAry, const SalBitmap& rSal ...@@ -1294,7 +1294,7 @@ void AquaSalGraphics::drawMask( const SalTwoRect& rPosAry, const SalBitmap& rSal
if( !xImage ) if( !xImage )
return; return;
const CGRect aDstRect = {{rPosAry.mnDestX, rPosAry.mnDestY}, {rPosAry.mnDestWidth, 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 );
...@@ -1348,7 +1348,7 @@ SalColor AquaSalGraphics::getPixel( long nX, long nY ) ...@@ -1348,7 +1348,7 @@ SalColor AquaSalGraphics::getPixel( long nX, long nY )
// copy the requested pixel into the bitmap context // copy the requested pixel into the bitmap context
if( IsFlipped() ) if( IsFlipped() )
nY = mnHeight - nY; nY = mnHeight - nY;
const CGPoint aCGPoint = {-nX, -nY}; const CGPoint aCGPoint = CGPointMake( -nX, -nY);
CGContextDrawLayerAtPoint( xOnePixelContext, aCGPoint, mxLayer ); CGContextDrawLayerAtPoint( xOnePixelContext, aCGPoint, mxLayer );
CGContextRelease( xOnePixelContext ); CGContextRelease( xOnePixelContext );
...@@ -1485,7 +1485,7 @@ sal_Bool AquaSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, ...@@ -1485,7 +1485,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 = {{nX,nY},{nWidth,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
...@@ -1521,7 +1521,7 @@ bool AquaSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, ...@@ -1521,7 +1521,7 @@ bool AquaSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
if ( CheckContext() ) if ( CheckContext() )
{ {
const CGRect aDstRect = {{rTR.mnDestX, rTR.mnDestY}, {rTR.mnDestWidth, 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 );
} }
...@@ -1562,7 +1562,7 @@ bool AquaSalGraphics::drawTransformedBitmap( ...@@ -1562,7 +1562,7 @@ bool AquaSalGraphics::drawTransformedBitmap(
CGContextConcatCTM( mrContext, aCGMat ); CGContextConcatCTM( mrContext, aCGMat );
// draw the transformed image // draw the transformed image
const CGRect aSrcRect = {{0,0}, {aSize.Width(), 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
...@@ -1585,7 +1585,7 @@ bool AquaSalGraphics::drawAlphaRect( long nX, long nY, long nWidth, ...@@ -1585,7 +1585,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 = {{nX,nY},{nWidth-1,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;
...@@ -2739,7 +2739,7 @@ bool XorEmulation::UpdateTarget() ...@@ -2739,7 +2739,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},{nWidth,nHeight}}; const CGRect aFullRect = CGRectMake( 0, 0, nWidth, nHeight);
CGContextDrawImage( mxTargetContext, aFullRect, xXorImage ); CGContextDrawImage( mxTargetContext, 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