summaryrefslogtreecommitdiff
path: root/vcl/aqua/source/gdi
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2013-01-23 14:58:58 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-14 17:20:38 +0100
commit9b4c604e1eb790d7f86097653d6ae4f19bd6fe14 (patch)
tree45ce1417e0fa021bee6a03007d6c7146cc2b1966 /vcl/aqua/source/gdi
parentf1f6ac03aa41efce53d08ac16dc33f6f6bb3e8a7 (diff)
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
Diffstat (limited to 'vcl/aqua/source/gdi')
-rw-r--r--vcl/aqua/source/gdi/salgdicommon.cxx47
1 files changed, 39 insertions, 8 deletions
diff --git a/vcl/aqua/source/gdi/salgdicommon.cxx b/vcl/aqua/source/gdi/salgdicommon.cxx
index a7b3f32e63c3..e75616846e0e 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;
}