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,16 +279,6 @@ namespace cppcanvas
|
||||
aTotalTransform.set( 0, 2, 0.0 );
|
||||
aTotalTransform.set( 1, 2, 0.0 );
|
||||
|
||||
// if there's no buffer bitmap, or as soon as the
|
||||
// total transformation changes, we've got to
|
||||
// re-render the bitmap
|
||||
if( !mxBufferBitmap.is() ||
|
||||
aTotalTransform != maLastTransformation ||
|
||||
rSubset.mnSubsetBegin != maLastSubset.mnSubsetBegin ||
|
||||
rSubset.mnSubsetEnd != maLastSubset.mnSubsetEnd )
|
||||
{
|
||||
DBG_TESTSOLARMUTEX();
|
||||
|
||||
// determine total scaling factor of the
|
||||
// transformation matrix - need to make the bitmap
|
||||
// large enough
|
||||
@@ -305,6 +295,16 @@ namespace cppcanvas
|
||||
return false;
|
||||
}
|
||||
|
||||
// if there's no buffer bitmap, or as soon as the
|
||||
// total transformation changes, we've got to
|
||||
// re-render the bitmap
|
||||
if( !mxBufferBitmap.is() ||
|
||||
aTotalTransform != maLastTransformation ||
|
||||
rSubset.mnSubsetBegin != maLastSubset.mnSubsetBegin ||
|
||||
rSubset.mnSubsetEnd != maLastSubset.mnSubsetEnd )
|
||||
{
|
||||
DBG_TESTSOLARMUTEX();
|
||||
|
||||
// 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 );
|
||||
|
Reference in New Issue
Block a user