Kaydet (Commit) 45a8eaf9 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i121534# Adapted rotated bitmap paints to use own transformer...

due to bad quality of GraphicManager paints

(cherry picked from commit f4887567)

Conflicts:
	drawinglayer/source/processor2d/vclhelperbitmaprender.cxx

Change-Id: Ie4b5873cdfb8bc7f1f4b288e1f983672343d8847
üst b0f10dd3
...@@ -57,7 +57,7 @@ namespace drawinglayer ...@@ -57,7 +57,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2); const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maTopLeft = getBitmapEx(); const_cast< DiscreteShadow* >(this)->maTopLeft = getBitmapEx();
const_cast< DiscreteShadow* >(this)->maTopLeft.Crop( const_cast< DiscreteShadow* >(this)->maTopLeft.Crop(
Rectangle(Point(0,0),Size(nQuarter*2+1,nQuarter*2+1))); Rectangle(Point(0, 0), Size((nQuarter * 2) + 1, (nQuarter * 2) + 1)));
} }
return maTopLeft; return maTopLeft;
...@@ -70,7 +70,7 @@ namespace drawinglayer ...@@ -70,7 +70,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2); const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maTop = getBitmapEx(); const_cast< DiscreteShadow* >(this)->maTop = getBitmapEx();
const_cast< DiscreteShadow* >(this)->maTop.Crop( const_cast< DiscreteShadow* >(this)->maTop.Crop(
Rectangle(Point(nQuarter*2+1,0),Size(1,nQuarter+1))); Rectangle(Point((nQuarter * 2) + 1, 0), Size(1, nQuarter)));
} }
return maTop; return maTop;
...@@ -83,7 +83,7 @@ namespace drawinglayer ...@@ -83,7 +83,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2); const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maTopRight = getBitmapEx(); const_cast< DiscreteShadow* >(this)->maTopRight = getBitmapEx();
const_cast< DiscreteShadow* >(this)->maTopRight.Crop( const_cast< DiscreteShadow* >(this)->maTopRight.Crop(
Rectangle(Point(nQuarter*2+2,0),Size(nQuarter*2+1,nQuarter*2+1))); Rectangle(Point((nQuarter * 2) + 2, 0), Size((nQuarter * 2) + 1, (nQuarter * 2) + 1)));
} }
return maTopRight; return maTopRight;
...@@ -96,7 +96,7 @@ namespace drawinglayer ...@@ -96,7 +96,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2); const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maRight = getBitmapEx(); const_cast< DiscreteShadow* >(this)->maRight = getBitmapEx();
const_cast< DiscreteShadow* >(this)->maRight.Crop( const_cast< DiscreteShadow* >(this)->maRight.Crop(
Rectangle(Point(nQuarter*3+2,nQuarter*2+1),Size(nQuarter+1,1))); Rectangle(Point((nQuarter * 3) + 3, (nQuarter * 2) + 1), Size(nQuarter, 1)));
} }
return maRight; return maRight;
...@@ -109,7 +109,7 @@ namespace drawinglayer ...@@ -109,7 +109,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2); const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maBottomRight = getBitmapEx(); const_cast< DiscreteShadow* >(this)->maBottomRight = getBitmapEx();
const_cast< DiscreteShadow* >(this)->maBottomRight.Crop( const_cast< DiscreteShadow* >(this)->maBottomRight.Crop(
Rectangle(Point(nQuarter*2+2,nQuarter*2+2),Size(nQuarter*2+1,nQuarter*2+1))); Rectangle(Point((nQuarter * 2) + 2, (nQuarter * 2) + 2), Size((nQuarter * 2) + 1, (nQuarter * 2) + 1)));
} }
return maBottomRight; return maBottomRight;
...@@ -122,7 +122,7 @@ namespace drawinglayer ...@@ -122,7 +122,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2); const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maBottom = getBitmapEx(); const_cast< DiscreteShadow* >(this)->maBottom = getBitmapEx();
const_cast< DiscreteShadow* >(this)->maBottom.Crop( const_cast< DiscreteShadow* >(this)->maBottom.Crop(
Rectangle(Point(nQuarter*2+1,nQuarter*3+2),Size(1,nQuarter+1))); Rectangle(Point((nQuarter * 2) + 1, (nQuarter * 3) + 3), Size(1, nQuarter)));
} }
return maBottom; return maBottom;
...@@ -135,7 +135,7 @@ namespace drawinglayer ...@@ -135,7 +135,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2); const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maBottomLeft = getBitmapEx(); const_cast< DiscreteShadow* >(this)->maBottomLeft = getBitmapEx();
const_cast< DiscreteShadow* >(this)->maBottomLeft.Crop( const_cast< DiscreteShadow* >(this)->maBottomLeft.Crop(
Rectangle(Point(0,nQuarter*2+2),Size(nQuarter*2+1,nQuarter*2+1))); Rectangle(Point(0, (nQuarter * 2) + 2), Size((nQuarter * 2) + 1, (nQuarter * 2) + 1)));
} }
return maBottomLeft; return maBottomLeft;
...@@ -148,7 +148,7 @@ namespace drawinglayer ...@@ -148,7 +148,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2); const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maLeft = getBitmapEx(); const_cast< DiscreteShadow* >(this)->maLeft = getBitmapEx();
const_cast< DiscreteShadow* >(this)->maLeft.Crop( const_cast< DiscreteShadow* >(this)->maLeft.Crop(
Rectangle(Point(0,nQuarter*2+1),Size(nQuarter+1,1))); Rectangle(Point(0, (nQuarter * 2) + 1), Size(nQuarter, 1)));
} }
return maLeft; return maLeft;
...@@ -195,8 +195,8 @@ namespace drawinglayer ...@@ -195,8 +195,8 @@ namespace drawinglayer
new BitmapPrimitive2D( new BitmapPrimitive2D(
getDiscreteShadow().getTop(), getDiscreteShadow().getTop(),
basegfx::tools::createScaleTranslateB2DHomMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
1.0 - (2.0 * fBorderX) - fSingleX, 1.0 - (2.0 * (fBorderX + fSingleX)) + fSingleX,
fBorderY + fSingleY, fBorderY,
fBorderX + fSingleX, fBorderX + fSingleX,
-fBorderY))); -fBorderY)));
...@@ -215,9 +215,9 @@ namespace drawinglayer ...@@ -215,9 +215,9 @@ namespace drawinglayer
new BitmapPrimitive2D( new BitmapPrimitive2D(
getDiscreteShadow().getRight(), getDiscreteShadow().getRight(),
basegfx::tools::createScaleTranslateB2DHomMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
fBorderX + fSingleX, fBorderX,
1.0 - (2.0 * fBorderY) - fSingleY, 1.0 - (2.0 * (fBorderY + fSingleY)) + fSingleY,
1.0, 1.0 + fSingleX,
fBorderY + fSingleY))); fBorderY + fSingleY)));
// BottomRight // BottomRight
...@@ -227,18 +227,18 @@ namespace drawinglayer ...@@ -227,18 +227,18 @@ namespace drawinglayer
basegfx::tools::createScaleTranslateB2DHomMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
fBigLenX, fBigLenX,
fBigLenY, fBigLenY,
1.0 - fBorderX, 1.0 - (fBorderX + fSingleX) + fSingleX,
1.0 - fBorderY))); 1.0 - (fBorderY + fSingleY) + fSingleY)));
// Bottom // Bottom
xRetval[5] = Primitive2DReference( xRetval[5] = Primitive2DReference(
new BitmapPrimitive2D( new BitmapPrimitive2D(
getDiscreteShadow().getBottom(), getDiscreteShadow().getBottom(),
basegfx::tools::createScaleTranslateB2DHomMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
1.0 - (2.0 * fBorderX) - fSingleX, 1.0 - (2.0 * (fBorderX + fSingleX)) + fSingleX,
fBorderY + fSingleY, fBorderY,
fBorderX + fSingleX, fBorderX + fSingleX,
1.0))); 1.0 + fSingleY)));
// BottomLeft // BottomLeft
xRetval[6] = Primitive2DReference( xRetval[6] = Primitive2DReference(
...@@ -255,8 +255,8 @@ namespace drawinglayer ...@@ -255,8 +255,8 @@ namespace drawinglayer
new BitmapPrimitive2D( new BitmapPrimitive2D(
getDiscreteShadow().getLeft(), getDiscreteShadow().getLeft(),
basegfx::tools::createScaleTranslateB2DHomMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
fBorderX + fSingleX, fBorderX,
1.0 - (2.0 * fBorderY) - fSingleY, 1.0 - (2.0 * (fBorderY + fSingleY)) + fSingleY,
-fBorderX, -fBorderX,
fBorderY + fSingleY))); fBorderY + fSingleY)));
......
...@@ -18,95 +18,19 @@ ...@@ -18,95 +18,19 @@
*/ */
#include <vclhelperbitmaprender.hxx> #include <vclhelperbitmaprender.hxx>
#include <svtools/grfmgr.hxx>
#include <basegfx/vector/b2dvector.hxx> #include <basegfx/vector/b2dvector.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/range/b2drange.hxx> #include <basegfx/range/b2drange.hxx>
#include <vcl/outdev.hxx> #include <vcl/outdev.hxx>
#include <vclhelperbitmaptransform.hxx> #include <vclhelperbitmaptransform.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <vcl/gdimtf.hxx>
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// support for different kinds of bitmap rendering using vcl // support for different kinds of bitmap rendering using vcl
namespace drawinglayer namespace drawinglayer
{ {
void RenderBitmapPrimitive2D_GraphicManager(
OutputDevice& rOutDev,
const BitmapEx& rBitmapEx,
const basegfx::B2DHomMatrix& rTransform)
{
// prepare attributes
GraphicAttr aAttributes;
// decompose matrix to check for shear, rotate and mirroring
basegfx::B2DVector aScale, aTranslate;
double fRotate, fShearX;
rTransform.decompose(aScale, aTranslate, fRotate, fShearX);
// mirror flags
const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
aAttributes.SetMirrorFlags((bMirrorX ? BMP_MIRROR_HORZ : 0)|(bMirrorY ? BMP_MIRROR_VERT : 0));
// rotation
if(!basegfx::fTools::equalZero(fRotate))
{
double fRotation(fmod(3600.0 - (fRotate * (10.0 / F_PI180)), 3600.0));
aAttributes.SetRotation((sal_uInt16)(fRotation));
}
// prepare Bitmap
basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0);
if(basegfx::fTools::equalZero(fRotate))
{
aOutlineRange.transform(rTransform);
}
else
{
// if rotated, create the unrotated output rectangle for the GraphicManager paint
// #118824# Caution! When mirrored, adapt transformation accordingly
// #i121387# Also need to adapt position when mirror and rotation is combined
if(bMirrorX || bMirrorY)
{
const basegfx::B2DHomMatrix aRot(basegfx::tools::createRotateB2DHomMatrix(fRotate));
if(bMirrorX)
{
aTranslate += aRot * basegfx::B2DVector(aScale.getX(), 0.0);
}
if(bMirrorY)
{
aTranslate += aRot * basegfx::B2DVector(0.0, aScale.getY());
}
}
const basegfx::B2DHomMatrix aSimpleObjectMatrix(
basegfx::tools::createScaleTranslateB2DHomMatrix(
fabs(aScale.getX()),
fabs(aScale.getY()),
aTranslate.getX(),
aTranslate.getY()));
aOutlineRange.transform(aSimpleObjectMatrix);
}
// prepare dest coordinates
const Point aPoint(
basegfx::fround(aOutlineRange.getMinX()),
basegfx::fround(aOutlineRange.getMinY()));
const Size aSize(
basegfx::fround(aOutlineRange.getWidth()),
basegfx::fround(aOutlineRange.getHeight()));
// paint it using GraphicManager
Graphic aGraphic(rBitmapEx);
GraphicObject aGraphicObject(aGraphic);
aGraphicObject.Draw(&rOutDev, aPoint, aSize, &aAttributes);
}
void RenderBitmapPrimitive2D_BitmapEx( void RenderBitmapPrimitive2D_BitmapEx(
OutputDevice& rOutDev, OutputDevice& rOutDev,
const BitmapEx& rBitmapEx, const BitmapEx& rBitmapEx,
......
...@@ -34,11 +34,6 @@ namespace basegfx { class B2DHomMatrix; } ...@@ -34,11 +34,6 @@ namespace basegfx { class B2DHomMatrix; }
namespace drawinglayer namespace drawinglayer
{ {
void RenderBitmapPrimitive2D_GraphicManager(
OutputDevice& rOutDev,
const BitmapEx& rBitmapEx,
const basegfx::B2DHomMatrix& rTransform);
void RenderBitmapPrimitive2D_BitmapEx( void RenderBitmapPrimitive2D_BitmapEx(
OutputDevice& rOutDev, OutputDevice& rOutDev,
const BitmapEx& rBitmapEx, const BitmapEx& rBitmapEx,
......
...@@ -442,7 +442,6 @@ namespace drawinglayer ...@@ -442,7 +442,6 @@ namespace drawinglayer
if(!bPainted) if(!bPainted)
{ {
static bool bForceUseOfOwnTransformer(false); static bool bForceUseOfOwnTransformer(false);
static bool bUseGraphicManager(true);
// decompose matrix to check for shear, rotate and mirroring // decompose matrix to check for shear, rotate and mirroring
basegfx::B2DVector aScale, aTranslate; basegfx::B2DVector aScale, aTranslate;
...@@ -452,19 +451,12 @@ namespace drawinglayer ...@@ -452,19 +451,12 @@ namespace drawinglayer
// #i121387# when mirrored and rotated, avoid the GraphicManager output which has low quality // #i121387# when mirrored and rotated, avoid the GraphicManager output which has low quality
const bool bRotated(!basegfx::fTools::equalZero(fRotate)); const bool bRotated(!basegfx::fTools::equalZero(fRotate));
const bool bSheared(!basegfx::fTools::equalZero(fShearX)); const bool bSheared(!basegfx::fTools::equalZero(fShearX));
const bool bMirrored(aScale.getX() < 0.0 || aScale.getY() < 0.0); //const bool bMirrored(aScale.getX() < 0.0 || aScale.getY() < 0.0);
const bool bMirroredAndRotated(bRotated && bMirrored); // const bool bMirroredAndRotated(bRotated && bMirrored);
if(!bForceUseOfOwnTransformer && !bSheared && !bMirroredAndRotated) if(!bForceUseOfOwnTransformer && !bRotated && !bSheared) // && !bMirrored)
{ {
if(!bUseGraphicManager && !bRotated) RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform);
{
RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform);
}
else
{
RenderBitmapPrimitive2D_GraphicManager(*mpOutputDevice, aBitmapEx, aLocalTransform);
}
} }
else else
{ {
......
...@@ -155,18 +155,23 @@ namespace sdr ...@@ -155,18 +155,23 @@ namespace sdr
} }
else else
{ {
static vcl::DeleteOnDeinit<drawinglayer::primitive2d::DiscreteShadow> static vcl::DeleteOnDeinit< drawinglayer::primitive2d::DiscreteShadow > aDiscreteShadow(
aDiscreteShadow(new drawinglayer::primitive2d::DiscreteShadow( new drawinglayer::primitive2d::DiscreteShadow(
BitmapEx(ResId(SIP_SA_PAGESHADOW35X35, *ImpGetResMgr())))); BitmapEx(
if (aDiscreteShadow.get() != NULL) ResId(
SIP_SA_PAGESHADOW35X35,
*ImpGetResMgr()))));
if(aDiscreteShadow.get())
{ {
const drawinglayer::primitive2d::Primitive2DReference xReference( const drawinglayer::primitive2d::Primitive2DReference xReference(
new drawinglayer::primitive2d::DiscreteShadowPrimitive2D( new drawinglayer::primitive2d::DiscreteShadowPrimitive2D(
aPageMatrix, aPageMatrix,
*aDiscreteShadow.get())); *aDiscreteShadow.get()));
return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
} }
return drawinglayer::primitive2d::Primitive2DSequence(); return drawinglayer::primitive2d::Primitive2DSequence();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment