canvas: simplify calcTransformedRectBounds
Change-Id: Ia0314a985ae2183727587ad254faec12ee49b66c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176769 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
parent
b20156432f
commit
d991795635
14 changed files with 27 additions and 62 deletions
|
@ -70,8 +70,7 @@ namespace canvas
|
||||||
|
|
||||||
// rectangular area which is actually covered by the sprite.
|
// rectangular area which is actually covered by the sprite.
|
||||||
// coordinates are relative to the sprite origin.
|
// coordinates are relative to the sprite origin.
|
||||||
::basegfx::B2DRectangle aSpriteRectPixel;
|
::basegfx::B2DRectangle aSpriteRectPixel = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aSpriteRectPixel,
|
|
||||||
aBounds,
|
aBounds,
|
||||||
maTransform );
|
maTransform );
|
||||||
|
|
||||||
|
@ -413,8 +412,7 @@ namespace canvas
|
||||||
|
|
||||||
// transform bounds at origin, as the sprite transformation is
|
// transform bounds at origin, as the sprite transformation is
|
||||||
// formulated that way
|
// formulated that way
|
||||||
::basegfx::B2DRectangle aTransformedBounds;
|
return ::canvas::tools::calcTransformedRectBounds(
|
||||||
return ::canvas::tools::calcTransformedRectBounds( aTransformedBounds,
|
|
||||||
rBounds,
|
rBounds,
|
||||||
aTransform );
|
aTransform );
|
||||||
}
|
}
|
||||||
|
|
|
@ -821,9 +821,7 @@ namespace canvas::tools
|
||||||
}
|
}
|
||||||
|
|
||||||
// transform by given transformation
|
// transform by given transformation
|
||||||
::basegfx::B2DRectangle aTransformedRect;
|
::basegfx::B2DRectangle aTransformedRect = calcTransformedRectBounds(
|
||||||
|
|
||||||
calcTransformedRectBounds( aTransformedRect,
|
|
||||||
i_srcRect,
|
i_srcRect,
|
||||||
i_transformation );
|
i_transformation );
|
||||||
|
|
||||||
|
@ -837,11 +835,10 @@ namespace canvas::tools
|
||||||
return o_transform;
|
return o_transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
::basegfx::B2DRange& calcTransformedRectBounds( ::basegfx::B2DRange& outRect,
|
::basegfx::B2DRange calcTransformedRectBounds( const ::basegfx::B2DRange& inRect,
|
||||||
const ::basegfx::B2DRange& inRect,
|
|
||||||
const ::basegfx::B2DHomMatrix& transformation )
|
const ::basegfx::B2DHomMatrix& transformation )
|
||||||
{
|
{
|
||||||
outRect.reset();
|
::basegfx::B2DRange outRect;
|
||||||
|
|
||||||
if( inRect.isEmpty() )
|
if( inRect.isEmpty() )
|
||||||
return outRect;
|
return outRect;
|
||||||
|
|
|
@ -795,8 +795,7 @@ namespace vclcanvas
|
||||||
// modify output position, to account for the fact
|
// modify output position, to account for the fact
|
||||||
// that transformBitmap() always normalizes its output
|
// that transformBitmap() always normalizes its output
|
||||||
// bitmap into the smallest enclosing box.
|
// bitmap into the smallest enclosing box.
|
||||||
::basegfx::B2DRectangle aDestRect;
|
::basegfx::B2DRectangle aDestRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aDestRect,
|
|
||||||
::basegfx::B2DRectangle(0,
|
::basegfx::B2DRectangle(0,
|
||||||
0,
|
0,
|
||||||
aBmpSize.Width(),
|
aBmpSize.Width(),
|
||||||
|
|
|
@ -574,9 +574,8 @@ namespace vclcanvas
|
||||||
// extra-verbosity
|
// extra-verbosity
|
||||||
{
|
{
|
||||||
::basegfx::B2DRectangle aRect(0.0, 0.0, 1.0, 1.0);
|
::basegfx::B2DRectangle aRect(0.0, 0.0, 1.0, 1.0);
|
||||||
::basegfx::B2DRectangle aTextureDeviceRect;
|
|
||||||
::basegfx::B2DHomMatrix aTextureTransform;
|
::basegfx::B2DHomMatrix aTextureTransform;
|
||||||
::canvas::tools::calcTransformedRectBounds( aTextureDeviceRect,
|
::basegfx::B2DRectangle aTextureDeviceRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
aRect,
|
aRect,
|
||||||
aTextureTransform );
|
aTextureTransform );
|
||||||
rOutDev.SetLineColor( COL_RED );
|
rOutDev.SetLineColor( COL_RED );
|
||||||
|
@ -699,8 +698,7 @@ namespace vclcanvas
|
||||||
aTotalTransform *= aTextureTransform;
|
aTotalTransform *= aTextureTransform;
|
||||||
|
|
||||||
const ::basegfx::B2DRectangle aRect(0.0, 0.0, 1.0, 1.0);
|
const ::basegfx::B2DRectangle aRect(0.0, 0.0, 1.0, 1.0);
|
||||||
::basegfx::B2DRectangle aTextureDeviceRect;
|
::basegfx::B2DRectangle aTextureDeviceRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aTextureDeviceRect,
|
|
||||||
aRect,
|
aRect,
|
||||||
aTotalTransform );
|
aTotalTransform );
|
||||||
|
|
||||||
|
@ -806,8 +804,7 @@ namespace vclcanvas
|
||||||
// modify output position, to account for the fact
|
// modify output position, to account for the fact
|
||||||
// that transformBitmap() always normalizes its output
|
// that transformBitmap() always normalizes its output
|
||||||
// bitmap into the smallest enclosing box.
|
// bitmap into the smallest enclosing box.
|
||||||
::basegfx::B2DRectangle aDestRect;
|
::basegfx::B2DRectangle aDestRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aDestRect,
|
|
||||||
::basegfx::B2DRectangle(0,
|
::basegfx::B2DRectangle(0,
|
||||||
0,
|
0,
|
||||||
aBmpSize.Width,
|
aBmpSize.Width,
|
||||||
|
@ -867,8 +864,7 @@ namespace vclcanvas
|
||||||
// Finally, the bound rect is transformed back to
|
// Finally, the bound rect is transformed back to
|
||||||
// device coordinate space, were we determine the
|
// device coordinate space, were we determine the
|
||||||
// start point from it.
|
// start point from it.
|
||||||
::basegfx::B2DRectangle aTextureSpacePolygonRect;
|
::basegfx::B2DRectangle aTextureSpacePolygonRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aTextureSpacePolygonRect,
|
|
||||||
vcl::unotools::b2DRectangleFromRectangle(aPolygonDeviceRect),
|
vcl::unotools::b2DRectangleFromRectangle(aPolygonDeviceRect),
|
||||||
aInverseTextureTransform );
|
aInverseTextureTransform );
|
||||||
|
|
||||||
|
@ -891,8 +887,7 @@ namespace vclcanvas
|
||||||
nY1 + 1.0 );
|
nY1 + 1.0 );
|
||||||
|
|
||||||
// and convert back to device space
|
// and convert back to device space
|
||||||
::basegfx::B2DRectangle aSingleDeviceTextureRect;
|
::basegfx::B2DRectangle aSingleDeviceTextureRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aSingleDeviceTextureRect,
|
|
||||||
aSingleTextureRect,
|
aSingleTextureRect,
|
||||||
aPureTotalTransform );
|
aPureTotalTransform );
|
||||||
|
|
||||||
|
|
|
@ -223,13 +223,12 @@ namespace vclcanvas::tools
|
||||||
// deleted from the transformation; this can be handled by
|
// deleted from the transformation; this can be handled by
|
||||||
// an offset when painting the bitmap
|
// an offset when painting the bitmap
|
||||||
const Size aBmpSize( rBitmap.GetSizePixel() );
|
const Size aBmpSize( rBitmap.GetSizePixel() );
|
||||||
::basegfx::B2DRectangle aDestRect;
|
|
||||||
|
|
||||||
// calc effective transformation for bitmap
|
// calc effective transformation for bitmap
|
||||||
const ::basegfx::B2DRectangle aSrcRect( 0, 0,
|
const ::basegfx::B2DRectangle aSrcRect( 0, 0,
|
||||||
aBmpSize.Width(),
|
aBmpSize.Width(),
|
||||||
aBmpSize.Height() );
|
aBmpSize.Height() );
|
||||||
::canvas::tools::calcTransformedRectBounds( aDestRect,
|
::basegfx::B2DRectangle aDestRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
aSrcRect,
|
aSrcRect,
|
||||||
rTransform );
|
rTransform );
|
||||||
|
|
||||||
|
|
|
@ -634,9 +634,7 @@ namespace cppcanvas::tools
|
||||||
viewState,
|
viewState,
|
||||||
renderState );
|
renderState );
|
||||||
|
|
||||||
::basegfx::B2DRange aTransformedBounds;
|
return ::canvas::tools::calcTransformedRectBounds(rBounds,
|
||||||
return ::canvas::tools::calcTransformedRectBounds( aTransformedBounds,
|
|
||||||
rBounds,
|
|
||||||
aTransform );
|
aTransform );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,18 +176,15 @@ namespace canvas
|
||||||
specified input rectangle, and returns the bounding box of
|
specified input rectangle, and returns the bounding box of
|
||||||
the resulting output area.
|
the resulting output area.
|
||||||
|
|
||||||
@param o_Rect
|
|
||||||
Output rectangle
|
|
||||||
|
|
||||||
@param i_Rect
|
@param i_Rect
|
||||||
Input rectangle
|
Input rectangle
|
||||||
|
|
||||||
@param i_Transformation
|
@param i_Transformation
|
||||||
Transformation to apply to the input rectangle
|
Transformation to apply to the input rectangle
|
||||||
|
|
||||||
@return a reference to the resulting rectangle
|
@return the resulting rectangle
|
||||||
*/
|
*/
|
||||||
CANVASTOOLS_DLLPUBLIC ::basegfx::B2DRange& calcTransformedRectBounds( ::basegfx::B2DRange& o_Rect,
|
CANVASTOOLS_DLLPUBLIC ::basegfx::B2DRange calcTransformedRectBounds(
|
||||||
const ::basegfx::B2DRange& i_Rect,
|
const ::basegfx::B2DRange& i_Rect,
|
||||||
const ::basegfx::B2DHomMatrix& i_Transformation );
|
const ::basegfx::B2DHomMatrix& i_Transformation );
|
||||||
|
|
||||||
|
|
|
@ -164,8 +164,7 @@ namespace slideshow::internal
|
||||||
// resize surrounding window and applet to current shape size
|
// resize surrounding window and applet to current shape size
|
||||||
// ==========================================================
|
// ==========================================================
|
||||||
|
|
||||||
::basegfx::B2DRange aTmpRange;
|
::basegfx::B2DRange aTmpRange = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aTmpRange,
|
|
||||||
rBounds,
|
rBounds,
|
||||||
mpViewLayer->getTransformation() );
|
mpViewLayer->getTransformation() );
|
||||||
const ::basegfx::B2IRange aPixelBounds(
|
const ::basegfx::B2IRange aPixelBounds(
|
||||||
|
@ -230,8 +229,7 @@ namespace slideshow::internal
|
||||||
if( !mxFrame.is() )
|
if( !mxFrame.is() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
::basegfx::B2DRange aTmpRange;
|
::basegfx::B2DRange aTmpRange = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aTmpRange,
|
|
||||||
rBounds,
|
rBounds,
|
||||||
mpViewLayer->getTransformation() );
|
mpViewLayer->getTransformation() );
|
||||||
const ::basegfx::B2IRange aPixelBounds(
|
const ::basegfx::B2IRange aPixelBounds(
|
||||||
|
|
|
@ -61,8 +61,7 @@ namespace slideshow::internal
|
||||||
// buffered bitmap is invalid, re-create
|
// buffered bitmap is invalid, re-create
|
||||||
|
|
||||||
// determine transformed page bounds
|
// determine transformed page bounds
|
||||||
::basegfx::B2DRectangle aTmpRect;
|
::basegfx::B2DRectangle aTmpRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aTmpRect,
|
|
||||||
maBounds,
|
maBounds,
|
||||||
aCanvasTransform );
|
aCanvasTransform );
|
||||||
|
|
||||||
|
|
|
@ -228,8 +228,7 @@ namespace slideshow::internal
|
||||||
maWindowOffset.Y = aRect.Y;
|
maWindowOffset.Y = aRect.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
::basegfx::B2DRange aTmpRange;
|
::basegfx::B2DRange aTmpRange = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aTmpRange,
|
|
||||||
rNewBounds,
|
rNewBounds,
|
||||||
mpViewLayer->getTransformation() );
|
mpViewLayer->getTransformation() );
|
||||||
const ::basegfx::B2IRange aRangePix(
|
const ::basegfx::B2IRange aRangePix(
|
||||||
|
@ -422,9 +421,7 @@ namespace slideshow::internal
|
||||||
|
|
||||||
if( pWindow )
|
if( pWindow )
|
||||||
{
|
{
|
||||||
::basegfx::B2DRange aTmpRange;
|
::basegfx::B2DRange aTmpRange = ::canvas::tools::calcTransformedRectBounds( rBounds,
|
||||||
::canvas::tools::calcTransformedRectBounds( aTmpRange,
|
|
||||||
rBounds,
|
|
||||||
mpViewLayer->getTransformation() );
|
mpViewLayer->getTransformation() );
|
||||||
const ::basegfx::B2IRange aRangePix(
|
const ::basegfx::B2IRange aRangePix(
|
||||||
::basegfx::unotools::b2ISurroundingRangeFromB2DRange( aTmpRange ));
|
::basegfx::unotools::b2ISurroundingRangeFromB2DRange( aTmpRange ));
|
||||||
|
|
|
@ -248,8 +248,7 @@ namespace slideshow::internal
|
||||||
// transformation might result in smaller
|
// transformation might result in smaller
|
||||||
// overall bounds.
|
// overall bounds.
|
||||||
|
|
||||||
::basegfx::B2DRectangle aBoundsPixel;
|
::basegfx::B2DRectangle aBoundsPixel = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aBoundsPixel,
|
|
||||||
rUntransformedArea,
|
rUntransformedArea,
|
||||||
rCanvasTransformation );
|
rCanvasTransformation );
|
||||||
|
|
||||||
|
@ -339,11 +338,9 @@ namespace slideshow::internal
|
||||||
// char scaling). NOTE: to cancel the shape translation,
|
// char scaling). NOTE: to cancel the shape translation,
|
||||||
// contained in rSpriteBoundsPixel, this is _without_ any
|
// contained in rSpriteBoundsPixel, this is _without_ any
|
||||||
// translational component.
|
// translational component.
|
||||||
::basegfx::B2DRectangle aLogShapeBounds;
|
|
||||||
const ::basegfx::B2DRectangle aNominalShapeBoundsPixel(
|
const ::basegfx::B2DRectangle aNominalShapeBoundsPixel(
|
||||||
shapeArea2AreaPixel( aCanvasTransform,
|
shapeArea2AreaPixel( aCanvasTransform,
|
||||||
::canvas::tools::calcTransformedRectBounds(
|
::canvas::tools::calcTransformedRectBounds(
|
||||||
aLogShapeBounds,
|
|
||||||
::basegfx::B2DRectangle(0.0,0.0,1.0,1.0),
|
::basegfx::B2DRectangle(0.0,0.0,1.0,1.0),
|
||||||
aNonTranslationalShapeTransformation ) ) );
|
aNonTranslationalShapeTransformation ) ) );
|
||||||
|
|
||||||
|
@ -582,8 +579,7 @@ namespace slideshow::internal
|
||||||
// area_ in device pixel
|
// area_ in device pixel
|
||||||
const ::basegfx::B2DHomMatrix aCanvasTransform(
|
const ::basegfx::B2DHomMatrix aCanvasTransform(
|
||||||
rDestinationCanvas->getTransformation() );
|
rDestinationCanvas->getTransformation() );
|
||||||
::basegfx::B2DRectangle aTmpRect;
|
::basegfx::B2DRectangle aTmpRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aTmpRect,
|
|
||||||
rUpdateBounds,
|
rUpdateBounds,
|
||||||
aCanvasTransform );
|
aCanvasTransform );
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,7 @@ basegfx::B2IVector getSlideSizePixel(const basegfx::B2DVector& rSlideSize,
|
||||||
{
|
{
|
||||||
const basegfx::B2DRange aRect(0, 0, rSlideSize.getX(), rSlideSize.getY());
|
const basegfx::B2DRange aRect(0, 0, rSlideSize.getX(), rSlideSize.getY());
|
||||||
|
|
||||||
basegfx::B2DRange aTmpRect;
|
basegfx::B2DRange aTmpRect = canvas::tools::calcTransformedRectBounds(aRect, rTransformation);
|
||||||
canvas::tools::calcTransformedRectBounds(aTmpRect, aRect, rTransformation);
|
|
||||||
|
|
||||||
// #i42440# Returned slide size is one pixel too small, as
|
// #i42440# Returned slide size is one pixel too small, as
|
||||||
// rendering happens one pixel to the right and below the
|
// rendering happens one pixel to the right and below the
|
||||||
|
|
|
@ -213,8 +213,7 @@ void clearRect( ::cppcanvas::CanvasSharedPtr const& pCanvas,
|
||||||
basegfx::B2IRange getLayerBoundsPixel( basegfx::B2DRange const& rLayerBounds,
|
basegfx::B2IRange getLayerBoundsPixel( basegfx::B2DRange const& rLayerBounds,
|
||||||
basegfx::B2DHomMatrix const& rTransformation )
|
basegfx::B2DHomMatrix const& rTransformation )
|
||||||
{
|
{
|
||||||
::basegfx::B2DRange aTmpRect;
|
::basegfx::B2DRange aTmpRect = ::canvas::tools::calcTransformedRectBounds(
|
||||||
::canvas::tools::calcTransformedRectBounds( aTmpRect,
|
|
||||||
rLayerBounds,
|
rLayerBounds,
|
||||||
rTransformation );
|
rTransformation );
|
||||||
|
|
||||||
|
@ -464,8 +463,7 @@ public:
|
||||||
|
|
||||||
virtual css::geometry::IntegerSize2D getTranslationOffset() const override
|
virtual css::geometry::IntegerSize2D getTranslationOffset() const override
|
||||||
{
|
{
|
||||||
basegfx::B2DRectangle aTmpRect;
|
basegfx::B2DRectangle aTmpRect = canvas::tools::calcTransformedRectBounds(
|
||||||
canvas::tools::calcTransformedRectBounds( aTmpRect,
|
|
||||||
maLayerBounds,
|
maLayerBounds,
|
||||||
maTransformation );
|
maTransformation );
|
||||||
geometry::IntegerSize2D offset(0, 0);
|
geometry::IntegerSize2D offset(0, 0);
|
||||||
|
@ -514,8 +512,7 @@ private:
|
||||||
{
|
{
|
||||||
// Offset given transformation by left, top border of given
|
// Offset given transformation by left, top border of given
|
||||||
// range (after transformation through given transformation)
|
// range (after transformation through given transformation)
|
||||||
basegfx::B2DRectangle aTmpRect;
|
basegfx::B2DRectangle aTmpRect = canvas::tools::calcTransformedRectBounds(
|
||||||
canvas::tools::calcTransformedRectBounds( aTmpRect,
|
|
||||||
maLayerBounds,
|
maLayerBounds,
|
||||||
maTransformation );
|
maTransformation );
|
||||||
|
|
||||||
|
|
|
@ -561,11 +561,8 @@ namespace slideshow::internal
|
||||||
|
|
||||||
aTransform *= rShapeTransform;
|
aTransform *= rShapeTransform;
|
||||||
|
|
||||||
::basegfx::B2DRectangle aRes;
|
|
||||||
|
|
||||||
// apply shape transformation to unit rect
|
// apply shape transformation to unit rect
|
||||||
return ::canvas::tools::calcTransformedRectBounds(
|
return ::canvas::tools::calcTransformedRectBounds(
|
||||||
aRes,
|
|
||||||
rUnitBounds,
|
rUnitBounds,
|
||||||
aTransform );
|
aTransform );
|
||||||
}
|
}
|
||||||
|
@ -764,8 +761,7 @@ namespace slideshow::internal
|
||||||
const basegfx::B2DRange aRect( 0,0,
|
const basegfx::B2DRange aRect( 0,0,
|
||||||
rSlideSize.getX(),
|
rSlideSize.getX(),
|
||||||
rSlideSize.getY() );
|
rSlideSize.getY() );
|
||||||
basegfx::B2DRange aTmpRect;
|
basegfx::B2DRange aTmpRect = canvas::tools::calcTransformedRectBounds(
|
||||||
canvas::tools::calcTransformedRectBounds( aTmpRect,
|
|
||||||
aRect,
|
aRect,
|
||||||
pView->getTransformation() );
|
pView->getTransformation() );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue