[Libreoffice-commits] core.git: vcl/aqua
Herbert Dürr
hdu at apache.org
Fri Jun 14 09:21:12 PDT 2013
vcl/aqua/source/gdi/salgdicommon.cxx | 47 +++++++++++++++++++++++++++++------
1 file changed, 39 insertions(+), 8 deletions(-)
New commits:
commit 9b4c604e1eb790d7f86097653d6ae4f19bd6fe14
Author: Herbert Dürr <hdu at apache.org>
Date: Wed Jan 23 14:58:58 2013 +0000
Related: #i121534# support native drawing of affinely-transformed images...
on Mac
(cherry picked from commit 947f7594c18a01eb070fac3b01d48d22f6bfb040)
Conflicts:
vcl/aqua/source/gdi/salgdi.cxx
Change-Id: I7e38ed34caf4f0e841f95ef5c4de52e241d561db
diff --git a/vcl/aqua/source/gdi/salgdicommon.cxx b/vcl/aqua/source/gdi/salgdicommon.cxx
index a7b3f32..e756168 100644
--- a/vcl/aqua/source/gdi/salgdicommon.cxx
+++ b/vcl/aqua/source/gdi/salgdicommon.cxx
@@ -531,15 +531,46 @@ bool AquaSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
}
bool AquaSalGraphics::drawTransformedBitmap(
- const basegfx::B2DPoint& rNull,
- const basegfx::B2DPoint& rX,
- const basegfx::B2DPoint& rY,
- const SalBitmap& rSourceBitmap,
- const SalBitmap* pAlphaBitmap)
+ const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, const basegfx::B2DPoint& rY,
+ const SalBitmap& rSrcBitmap, const SalBitmap* pAlphaBmp )
{
- // here direct support for transformed bitmaps can be impemented
- (void)rNull; (void)rX; (void)rY; (void)rSourceBitmap; (void)pAlphaBitmap;
- return false;
+ if( !CheckContext() )
+ return true;
+
+ // get the Quartz image
+ CGImageRef xImage = NULL;
+ const Size aSize = rSrcBitmap.GetSize();
+ const QuartzSalBitmap& rSrcSalBmp = static_cast<const QuartzSalBitmap&>(rSrcBitmap);
+ const QuartzSalBitmap* pMaskSalBmp = static_cast<const QuartzSalBitmap*>(pAlphaBmp);
+ if( !pMaskSalBmp)
+ xImage = rSrcSalBmp.CreateCroppedImage( 0, 0, (int)aSize.Width(), (int)aSize.Height() );
+ else
+ xImage = rSrcSalBmp.CreateWithMask( *pMaskSalBmp, 0, 0, (int)aSize.Width(), (int)aSize.Height() );
+ if( !xImage )
+ return false;
+
+ // setup the image transformation
+ // using the rNull,rX,rY points as destinations for the (0,0),(0,Width),(Height,0) source points
+ CGContextSaveGState( mrContext );
+ const basegfx::B2DVector aXRel = rX - rNull;
+ const basegfx::B2DVector aYRel = rY - rNull;
+ const CGAffineTransform aCGMat = CGAffineTransformMake(
+ aXRel.getX()/aSize.Width(), aXRel.getY()/aSize.Width(),
+ aYRel.getX()/aSize.Height(), aYRel.getY()/aSize.Height(),
+ rNull.getX(), rNull.getY());
+ CGContextConcatCTM( mrContext, aCGMat );
+
+ // draw the transformed image
+ const CGRect aSrcRect = {{0,0}, {static_cast<CGFloat>(aSize.Width()), static_cast<CGFloat>(aSize.Height())}};
+ CGContextDrawImage( mrContext, aSrcRect, xImage );
+ CGImageRelease( xImage );
+ // restore the Quartz graphics state
+ CGContextRestoreGState(mrContext);
+
+ // mark the destination as painted
+ const CGRect aDstRect = CGRectApplyAffineTransform( aSrcRect, aCGMat );
+ RefreshRect( aDstRect );
+ return true;
}
More information about the Libreoffice-commits
mailing list