Resolves: #i121534# Adapted rotated bitmap paints to use own transformer...
due to bad quality of GraphicManager paints
(cherry picked from commit f4887567cc71dca520d57cb6ff2b40eb49142cda)
Conflicts:
drawinglayer/source/processor2d/vclhelperbitmaprender.cxx
Change-Id: Ie4b5873cdfb8bc7f1f4b288e1f983672343d8847
diff --git a/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx b/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
index 5acebe6..a325690 100644
--- a/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/discreteshadowprimitive2d.cxx
@@ -57,7 +57,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maTopLeft = getBitmapEx();
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;
@@ -70,7 +70,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maTop = getBitmapEx();
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;
@@ -83,7 +83,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maTopRight = getBitmapEx();
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;
@@ -96,7 +96,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maRight = getBitmapEx();
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;
@@ -109,7 +109,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maBottomRight = getBitmapEx();
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;
@@ -122,7 +122,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maBottom = getBitmapEx();
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;
@@ -135,7 +135,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maBottomLeft = getBitmapEx();
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;
@@ -148,7 +148,7 @@ namespace drawinglayer
const sal_Int32 nQuarter((getBitmapEx().GetSizePixel().Width() - 3) >> 2);
const_cast< DiscreteShadow* >(this)->maLeft = getBitmapEx();
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;
@@ -195,8 +195,8 @@ namespace drawinglayer
new BitmapPrimitive2D(
getDiscreteShadow().getTop(),
basegfx::tools::createScaleTranslateB2DHomMatrix(
1.0 - (2.0 * fBorderX) - fSingleX,
fBorderY + fSingleY,
1.0 - (2.0 * (fBorderX + fSingleX)) + fSingleX,
fBorderY,
fBorderX + fSingleX,
-fBorderY)));
@@ -215,9 +215,9 @@ namespace drawinglayer
new BitmapPrimitive2D(
getDiscreteShadow().getRight(),
basegfx::tools::createScaleTranslateB2DHomMatrix(
fBorderX + fSingleX,
1.0 - (2.0 * fBorderY) - fSingleY,
1.0,
fBorderX,
1.0 - (2.0 * (fBorderY + fSingleY)) + fSingleY,
1.0 + fSingleX,
fBorderY + fSingleY)));
// BottomRight
@@ -227,18 +227,18 @@ namespace drawinglayer
basegfx::tools::createScaleTranslateB2DHomMatrix(
fBigLenX,
fBigLenY,
1.0 - fBorderX,
1.0 - fBorderY)));
1.0 - (fBorderX + fSingleX) + fSingleX,
1.0 - (fBorderY + fSingleY) + fSingleY)));
// Bottom
xRetval[5] = Primitive2DReference(
new BitmapPrimitive2D(
getDiscreteShadow().getBottom(),
basegfx::tools::createScaleTranslateB2DHomMatrix(
1.0 - (2.0 * fBorderX) - fSingleX,
fBorderY + fSingleY,
1.0 - (2.0 * (fBorderX + fSingleX)) + fSingleX,
fBorderY,
fBorderX + fSingleX,
1.0)));
1.0 + fSingleY)));
// BottomLeft
xRetval[6] = Primitive2DReference(
@@ -255,8 +255,8 @@ namespace drawinglayer
new BitmapPrimitive2D(
getDiscreteShadow().getLeft(),
basegfx::tools::createScaleTranslateB2DHomMatrix(
fBorderX + fSingleX,
1.0 - (2.0 * fBorderY) - fSingleY,
fBorderX,
1.0 - (2.0 * (fBorderY + fSingleY)) + fSingleY,
-fBorderX,
fBorderY + fSingleY)));
diff --git a/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx b/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx
index f1aa08c..598b7d18 100644
--- a/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx
+++ b/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx
@@ -18,95 +18,19 @@
*/
#include <vclhelperbitmaprender.hxx>
#include <svtools/grfmgr.hxx>
#include <basegfx/vector/b2dvector.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/range/b2drange.hxx>
#include <vcl/outdev.hxx>
#include <vclhelperbitmaptransform.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <vcl/gdimtf.hxx>
//////////////////////////////////////////////////////////////////////////////
// support for different kinds of bitmap rendering using vcl
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(
OutputDevice& rOutDev,
const BitmapEx& rBitmapEx,
diff --git a/drawinglayer/source/processor2d/vclhelperbitmaprender.hxx b/drawinglayer/source/processor2d/vclhelperbitmaprender.hxx
index 8f3f3e6..3130742 100644
--- a/drawinglayer/source/processor2d/vclhelperbitmaprender.hxx
+++ b/drawinglayer/source/processor2d/vclhelperbitmaprender.hxx
@@ -34,11 +34,6 @@ namespace basegfx { class B2DHomMatrix; }
namespace drawinglayer
{
void RenderBitmapPrimitive2D_GraphicManager(
OutputDevice& rOutDev,
const BitmapEx& rBitmapEx,
const basegfx::B2DHomMatrix& rTransform);
void RenderBitmapPrimitive2D_BitmapEx(
OutputDevice& rOutDev,
const BitmapEx& rBitmapEx,
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index f67b982..533f2c2 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -442,7 +442,6 @@ namespace drawinglayer
if(!bPainted)
{
static bool bForceUseOfOwnTransformer(false);
static bool bUseGraphicManager(true);
// decompose matrix to check for shear, rotate and mirroring
basegfx::B2DVector aScale, aTranslate;
@@ -452,19 +451,12 @@ namespace drawinglayer
// #i121387# when mirrored and rotated, avoid the GraphicManager output which has low quality
const bool bRotated(!basegfx::fTools::equalZero(fRotate));
const bool bSheared(!basegfx::fTools::equalZero(fShearX));
const bool bMirrored(aScale.getX() < 0.0 || aScale.getY() < 0.0);
const bool bMirroredAndRotated(bRotated && bMirrored);
//const bool bMirrored(aScale.getX() < 0.0 || aScale.getY() < 0.0);
// const bool bMirroredAndRotated(bRotated && bMirrored);
if(!bForceUseOfOwnTransformer && !bSheared && !bMirroredAndRotated)
if(!bForceUseOfOwnTransformer && !bRotated && !bSheared) // && !bMirrored)
{
if(!bUseGraphicManager && !bRotated)
{
RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform);
}
else
{
RenderBitmapPrimitive2D_GraphicManager(*mpOutputDevice, aBitmapEx, aLocalTransform);
}
RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform);
}
else
{
diff --git a/svx/source/sdr/contact/viewcontactofsdrpage.cxx b/svx/source/sdr/contact/viewcontactofsdrpage.cxx
index 04d1322..525eff3 100644
--- a/svx/source/sdr/contact/viewcontactofsdrpage.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrpage.cxx
@@ -155,18 +155,23 @@ namespace sdr
}
else
{
static vcl::DeleteOnDeinit<drawinglayer::primitive2d::DiscreteShadow>
aDiscreteShadow(new drawinglayer::primitive2d::DiscreteShadow(
BitmapEx(ResId(SIP_SA_PAGESHADOW35X35, *ImpGetResMgr()))));
if (aDiscreteShadow.get() != NULL)
static vcl::DeleteOnDeinit< drawinglayer::primitive2d::DiscreteShadow > aDiscreteShadow(
new drawinglayer::primitive2d::DiscreteShadow(
BitmapEx(
ResId(
SIP_SA_PAGESHADOW35X35,
*ImpGetResMgr()))));
if(aDiscreteShadow.get())
{
const drawinglayer::primitive2d::Primitive2DReference xReference(
new drawinglayer::primitive2d::DiscreteShadowPrimitive2D(
aPageMatrix,
*aDiscreteShadow.get()));
*aDiscreteShadow.get()));
return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
}
return drawinglayer::primitive2d::Primitive2DSequence();
}
}