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?
This commit is contained in:
@@ -279,6 +279,22 @@ namespace cppcanvas
|
|||||||
aTotalTransform.set( 0, 2, 0.0 );
|
aTotalTransform.set( 0, 2, 0.0 );
|
||||||
aTotalTransform.set( 1, 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
|
// if there's no buffer bitmap, or as soon as the
|
||||||
// total transformation changes, we've got to
|
// total transformation changes, we've got to
|
||||||
// re-render the bitmap
|
// re-render the bitmap
|
||||||
@@ -289,22 +305,6 @@ namespace cppcanvas
|
|||||||
{
|
{
|
||||||
DBG_TESTSOLARMUTEX();
|
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
|
// output size of metafile
|
||||||
::Size aOutputSizePixel( ::basegfx::fround( aScale.getX() * maDstSize.getX() ),
|
::Size aOutputSizePixel( ::basegfx::fround( aScale.getX() * maDstSize.getX() ),
|
||||||
::basegfx::fround( aScale.getY() * maDstSize.getY() ) );
|
::basegfx::fround( aScale.getY() * maDstSize.getY() ) );
|
||||||
@@ -452,12 +452,8 @@ namespace cppcanvas
|
|||||||
// Translation*Rotation*Shear*Scale. Thus, to neutralize
|
// Translation*Rotation*Shear*Scale. Thus, to neutralize
|
||||||
// the contained scaling, we've got to right-multiply with
|
// the contained scaling, we've got to right-multiply with
|
||||||
// the inverse.
|
// the inverse.
|
||||||
::basegfx::B2ISize aBmpSize(
|
|
||||||
::basegfx::unotools::b2ISizeFromIntegerSize2D( mxBufferBitmap->getSize() ) );
|
|
||||||
|
|
||||||
::basegfx::B2DHomMatrix aScaleCorrection;
|
::basegfx::B2DHomMatrix aScaleCorrection;
|
||||||
aScaleCorrection.scale( (double)maDstSize.getX() / aBmpSize.getX(),
|
aScaleCorrection.scale( 1/aScale.getX(), 1/aScale.getY() );
|
||||||
(double)maDstSize.getY() / aBmpSize.getY() );
|
|
||||||
aTransform = aTransform * aScaleCorrection;
|
aTransform = aTransform * aScaleCorrection;
|
||||||
|
|
||||||
rendering::RenderState aLocalState( maState );
|
rendering::RenderState aLocalState( maState );
|
||||||
|
Reference in New Issue
Block a user