summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-12-17 21:28:43 +0100
committerLuboš Luňák <l.lunak@collabora.com>2021-02-09 10:36:22 +0100
commit5177c672bb1eb848cc1da5d96c5871e8da6adb0f (patch)
tree5a7eb48ce9c5cd3ad1175cba4106f5c31fbd69ac /canvas
parent61404bca5af9072b99c69a605077f0f4f6b54661 (diff)
simply use DrawTransformedBitmapEx()
And leave the work to the function instead of trying to handle it manually. Change-Id: Ia1ede2378d461a57e5c338ab5cabe908c320b2b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110599 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/vcl/spritehelper.cxx83
1 files changed, 11 insertions, 72 deletions
diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx
index 53116fa9d53d..31d16032e576 100644
--- a/canvas/source/vcl/spritehelper.cxx
+++ b/canvas/source/vcl/spritehelper.cxx
@@ -175,67 +175,6 @@ namespace vclcanvas
::basegfx::B2DHomMatrix aTransform( getTransformation() );
- // check whether matrix is "easy" to handle - pure
- // translations or scales are handled by OutputDevice
- // alone
- const bool bIdentityTransform( aTransform.isIdentity() );
-
- // make transformation absolute (put sprite to final
- // output position). Need to happen here, as we also have
- // to translate the clip polygon
- aTransform.translate( aOutPos.X(),
- aOutPos.Y() );
-
- if( !bIdentityTransform )
- {
- if (!::basegfx::fTools::equalZero( aTransform.get(0,1) ) ||
- !::basegfx::fTools::equalZero( aTransform.get(1,0) ))
- {
- // "complex" transformation, employ affine
- // transformator
-
- // modify output position, to account for the fact
- // that transformBitmap() always normalizes its output
- // bitmap into the smallest enclosing box.
- ::basegfx::B2DRectangle aDestRect;
- ::canvas::tools::calcTransformedRectBounds( aDestRect,
- ::basegfx::B2DRectangle(0,
- 0,
- rOrigOutputSize.getX(),
- rOrigOutputSize.getY()),
- aTransform );
-
- aOutPos.setX( ::basegfx::fround( aDestRect.getMinX() ) );
- aOutPos.setY( ::basegfx::fround( aDestRect.getMinY() ) );
-
- // TODO(P3): Use optimized bitmap transformation here.
-
- // actually re-create the bitmap ONLY if necessary
- if( bNeedBitmapUpdate )
- maContent = tools::transformBitmap( *maContent,
- aTransform );
-
- aOutputSize = maContent->GetSizePixel();
- }
- else
- {
- // relatively 'simplistic' transformation -
- // retrieve scale and translational offset
- aOutputSize.setWidth (
- ::basegfx::fround( rOrigOutputSize.getX() * aTransform.get(0,0) ) );
- aOutputSize.setHeight(
- ::basegfx::fround( rOrigOutputSize.getY() * aTransform.get(1,1) ) );
-
- aOutPos.setX( ::basegfx::fround( aTransform.get(0,2) ) );
- aOutPos.setY( ::basegfx::fround( aTransform.get(1,2) ) );
- }
- }
-
- // transformBitmap() might return empty bitmaps, for tiny
- // scales.
- if( !(*maContent) )
- return;
-
rTargetSurface.Push( PushFlags::CLIPREGION );
// apply clip (if any)
@@ -247,10 +186,10 @@ namespace vclcanvas
if( aClipPoly.count() )
{
- // aTransform already contains the
- // translational component, moving the clip to
- // the final sprite output position.
- aClipPoly.transform( aTransform );
+ // Move the clip to the final sprite output position.
+ ::basegfx::B2DHomMatrix aClipTransform( aTransform );
+ aClipTransform.translate( aOutPos.X(), aOutPos.Y() );
+ aClipPoly.transform( aClipTransform );
if( mbShowSpriteBounds )
{
@@ -266,13 +205,15 @@ namespace vclcanvas
}
}
+ ::basegfx::B2DHomMatrix aSizeTransform, aMoveTransform;
+ aSizeTransform.scale( aOutputSize.Width(), aOutputSize.Height() );
+ aMoveTransform.translate( aOutPos.X(), aOutPos.Y() );
+ aTransform = aMoveTransform * aTransform * aSizeTransform;
+
if( ::rtl::math::approxEqual(fAlpha, 1.0) )
{
// no alpha modulation -> just copy to output
- if( maContent->IsTransparent() )
- rTargetSurface.DrawBitmapEx( aOutPos, aOutputSize, *maContent );
- else
- rTargetSurface.DrawBitmap( aOutPos, aOutputSize, maContent->GetBitmap() );
+ rTargetSurface.DrawTransformedBitmapEx( aTransform, *maContent );
}
else
{
@@ -289,9 +230,7 @@ namespace vclcanvas
aAlpha.Replace( maContent->GetMask(), 255 );
// alpha-blend to output
- rTargetSurface.DrawBitmapEx( aOutPos, aOutputSize,
- BitmapEx( maContent->GetBitmap(),
- aAlpha ) );
+ rTargetSurface.DrawTransformedBitmapEx( aTransform, BitmapEx( maContent->GetBitmap(), aAlpha ) );
}
rTargetSurface.Pop();