From af1514abf26b2070bd342ce449f209a42f3989e5 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Tue, 6 Mar 2012 19:01:56 +0100 Subject: Performance: avoid scaling just-generated bitmap 2nd time We're creating the bitmap to exactly match our output size - so why rounding off total transformation again, incurring another expensive bitmap scale down in the canvas? --- .../source/mtfrenderer/transparencygroupaction.cxx | 38 ++++++++++------------ 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'cppcanvas') diff --git a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx index ec80e8f43897..543ec6c975d8 100644 --- a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx +++ b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx @@ -279,6 +279,22 @@ namespace cppcanvas aTotalTransform.set( 0, 2, 0.0 ); aTotalTransform.set( 1, 2, 0.0 ); + // determine total scaling factor of the + // transformation matrix - need to make the bitmap + // large enough + ::basegfx::B2DTuple aScale; + ::basegfx::B2DTuple aTranslate; + double nRotate; + double nShearX; + if( !aTotalTransform.decompose( aScale, + aTranslate, + nRotate, + nShearX ) ) + { + OSL_FAIL( "TransparencyGroupAction::render(): non-decomposable transformation" ); + return false; + } + // if there's no buffer bitmap, or as soon as the // total transformation changes, we've got to // re-render the bitmap @@ -289,22 +305,6 @@ namespace cppcanvas { DBG_TESTSOLARMUTEX(); - // determine total scaling factor of the - // transformation matrix - need to make the bitmap - // large enough - ::basegfx::B2DTuple aScale; - ::basegfx::B2DTuple aTranslate; - double nRotate; - double nShearX; - if( !aTotalTransform.decompose( aScale, - aTranslate, - nRotate, - nShearX ) ) - { - OSL_FAIL( "TransparencyGroupAction::render(): non-decomposable transformation" ); - return false; - } - // output size of metafile ::Size aOutputSizePixel( ::basegfx::fround( aScale.getX() * maDstSize.getX() ), ::basegfx::fround( aScale.getY() * maDstSize.getY() ) ); @@ -452,12 +452,8 @@ namespace cppcanvas // Translation*Rotation*Shear*Scale. Thus, to neutralize // the contained scaling, we've got to right-multiply with // the inverse. - ::basegfx::B2ISize aBmpSize( - ::basegfx::unotools::b2ISizeFromIntegerSize2D( mxBufferBitmap->getSize() ) ); - ::basegfx::B2DHomMatrix aScaleCorrection; - aScaleCorrection.scale( (double)maDstSize.getX() / aBmpSize.getX(), - (double)maDstSize.getY() / aBmpSize.getY() ); + aScaleCorrection.scale( 1/aScale.getX(), 1/aScale.getY() ); aTransform = aTransform * aScaleCorrection; rendering::RenderState aLocalState( maState ); -- cgit