diff options
author | Armin Le Grand <alg@apache.org> | 2012-10-02 08:23:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-11 10:32:54 +0100 |
commit | 385bb4547359027bca6d5158e00e541f094b277e (patch) | |
tree | a160b457cc7f649669e5eaddf9b8731ebe64e910 | |
parent | Revert "fix fdo#60533, Set TEXT_LAYOUT_BIDI_STRONG flag." (diff) | |
download | core-385bb4547359027bca6d5158e00e541f094b277e.tar.gz core-385bb4547359027bca6d5158e00e541f094b277e.zip |
Resolves: #i120604# unified and secured gradient tooling for primitives
(cherry picked from commit 05785d283e718aab182a5ea848de72e4a4b2efe3)
Conflicts:
basegfx/inc/basegfx/tools/gradienttools.hxx
basegfx/source/tools/gradienttools.cxx
cppcanvas/source/mtfrenderer/implrenderer.cxx
drawinglayer/inc/drawinglayer/primitive2d/fillgradientprimitive2d.hxx
drawinglayer/inc/drawinglayer/texture/texture.hxx
drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx
drawinglayer/source/processor2d/vclhelpergradient.cxx
Change-Id: I21f94e7b4eede094171a83a009ae19213e77f22c
Unname unused argument to prevent warnings.
(cherry picked from commit f7d4af835cf308bc9ece6fd84cbd14ba5be0adcd)
Change-Id: I44381f1e417c39dfbd1d4051079bbd09f0c61848
-rw-r--r-- | basegfx/source/tools/gradienttools.cxx | 394 | ||||
-rw-r--r-- | cppcanvas/source/mtfrenderer/emfplus.cxx | 8 | ||||
-rw-r--r-- | cppcanvas/source/mtfrenderer/implrenderer.cxx | 24 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx | 170 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/vclhelpergradient.cxx | 116 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/vclprocessor2d.cxx | 4 | ||||
-rw-r--r-- | drawinglayer/source/texture/texture.cxx | 403 | ||||
-rw-r--r-- | include/basegfx/tools/gradienttools.hxx | 217 | ||||
-rw-r--r-- | include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx | 13 | ||||
-rw-r--r-- | include/drawinglayer/texture/texture.hxx | 127 |
10 files changed, 832 insertions, 644 deletions
diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 7bdc07d1441c..f3e254098182 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -24,19 +24,35 @@ namespace basegfx { + bool ODFGradientInfo::operator==(const ODFGradientInfo& rODFGradientInfo) const + { + return getTextureTransform() == rODFGradientInfo.getTextureTransform() + && getAspectRatio() == rODFGradientInfo.getAspectRatio() + && getSteps() == rODFGradientInfo.getSteps(); + } + + const B2DHomMatrix& ODFGradientInfo::getBackTextureTransform() const + { + if(maBackTextureTransform.isIdentity()) + { + const_cast< ODFGradientInfo* >(this)->maBackTextureTransform = getTextureTransform(); + const_cast< ODFGradientInfo* >(this)->maBackTextureTransform.invert(); + } + + return maBackTextureTransform; + } + /** Most of the setup for linear & axial gradient is the same, except for the border treatment. Factored out here. */ - static void init1DGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetRange, - sal_uInt32 nSteps, - double fBorder, - double fAngle, - bool bAxial) + ODFGradientInfo init1DGradientInfo( + const B2DRange& rTargetRange, + sal_uInt32 nSteps, + double fBorder, + double fAngle, + bool bAxial) { - o_rGradientInfo.maTextureTransform.identity(); - o_rGradientInfo.maBackTextureTransform.identity(); - o_rGradientInfo.mnSteps = nSteps; + B2DHomMatrix aTextureTransform; fAngle = -fAngle; @@ -46,69 +62,68 @@ namespace basegfx double fTargetOffsetY(rTargetRange.getMinY()); // add object expansion - if(0.0 != fAngle) + const bool bAngleUsed(!fTools::equalZero(fAngle)); + + if(bAngleUsed) { const double fAbsCos(fabs(cos(fAngle))); const double fAbsSin(fabs(sin(fAngle))); const double fNewX(fTargetSizeX * fAbsCos + fTargetSizeY * fAbsSin); const double fNewY(fTargetSizeY * fAbsCos + fTargetSizeX * fAbsSin); + fTargetOffsetX -= (fNewX - fTargetSizeX) / 2.0; fTargetOffsetY -= (fNewY - fTargetSizeY) / 2.0; fTargetSizeX = fNewX; fTargetSizeY = fNewY; } - const double fSizeWithoutBorder=1.0 - fBorder; - if( bAxial ) + const double fSizeWithoutBorder(1.0 - fBorder); + + if(bAxial) { - o_rGradientInfo.maTextureTransform.scale(1.0, fSizeWithoutBorder * .5); - o_rGradientInfo.maTextureTransform.translate(0.0, 0.5); + aTextureTransform.scale(1.0, fSizeWithoutBorder * 0.5); + aTextureTransform.translate(0.0, 0.5); } else { if(!fTools::equal(fSizeWithoutBorder, 1.0)) { - o_rGradientInfo.maTextureTransform.scale(1.0, fSizeWithoutBorder); - o_rGradientInfo.maTextureTransform.translate(0.0, fBorder); + aTextureTransform.scale(1.0, fSizeWithoutBorder); + aTextureTransform.translate(0.0, fBorder); } } - o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY); + aTextureTransform.scale(fTargetSizeX, fTargetSizeY); // add texture rotate after scale to keep perpendicular angles - if(0.0 != fAngle) + if(bAngleUsed) { - const B2DPoint aCenter(0.5*fTargetSizeX, - 0.5*fTargetSizeY); - o_rGradientInfo.maTextureTransform *= - basegfx::tools::createRotateAroundPoint(aCenter, fAngle); + const B2DPoint aCenter(0.5 * fTargetSizeX, 0.5 * fTargetSizeY); + + aTextureTransform *= basegfx::tools::createRotateAroundPoint(aCenter, fAngle); } // add object translate - o_rGradientInfo.maTextureTransform.translate(fTargetOffsetX, fTargetOffsetY); + aTextureTransform.translate(fTargetOffsetX, fTargetOffsetY); // prepare aspect for texture - o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0; + const double fAspectRatio(fTools::equalZero(fTargetSizeY) ? 1.0 : fTargetSizeX / fTargetSizeY); - // build transform from u,v to [0.0 .. 1.0]. - o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform; - o_rGradientInfo.maBackTextureTransform.invert(); + return ODFGradientInfo(aTextureTransform, fAspectRatio, nSteps); } /** Most of the setup for radial & ellipsoidal gradient is the same, except for the border treatment. Factored out here. */ - static void initEllipticalGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetRange, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder, - double fAngle, - bool bCircular) + ODFGradientInfo initEllipticalGradientInfo( + const B2DRange& rTargetRange, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder, + double fAngle, + bool bCircular) { - o_rGradientInfo.maTextureTransform.identity(); - o_rGradientInfo.maBackTextureTransform.identity(); - o_rGradientInfo.mnSteps = nSteps; + B2DHomMatrix aTextureTransform; fAngle = -fAngle; @@ -118,9 +133,10 @@ namespace basegfx double fTargetOffsetY(rTargetRange.getMinY()); // add object expansion - if( bCircular ) + if(bCircular) { const double fOriginalDiag(sqrt((fTargetSizeX * fTargetSizeX) + (fTargetSizeY * fTargetSizeY))); + fTargetOffsetX -= (fOriginalDiag - fTargetSizeX) / 2.0; fTargetOffsetY -= (fOriginalDiag - fTargetSizeY) / 2.0; fTargetSizeX = fOriginalDiag; @@ -135,22 +151,21 @@ namespace basegfx } const double fHalfBorder((1.0 - fBorder) * 0.5); - o_rGradientInfo.maTextureTransform.scale(fHalfBorder, fHalfBorder); - o_rGradientInfo.maTextureTransform.translate(0.5, 0.5); - o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY); + aTextureTransform.scale(fHalfBorder, fHalfBorder); + aTextureTransform.translate(0.5, 0.5); + aTextureTransform.scale(fTargetSizeX, fTargetSizeY); // add texture rotate after scale to keep perpendicular angles - if( !bCircular && 0.0 != fAngle) + if(!bCircular && !fTools::equalZero(fAngle)) { - const B2DPoint aCenter(0.5*fTargetSizeX, - 0.5*fTargetSizeY); - o_rGradientInfo.maTextureTransform *= - basegfx::tools::createRotateAroundPoint(aCenter, fAngle); + const B2DPoint aCenter(0.5 * fTargetSizeX, 0.5 * fTargetSizeY); + + aTextureTransform *= basegfx::tools::createRotateAroundPoint(aCenter, fAngle); } // add defined offsets after rotation - if(0.5 != rOffset.getX() || 0.5 != rOffset.getY()) + if(!fTools::equal(0.5, rOffset.getX()) || !fTools::equal(0.5, rOffset.getY())) { // use original target size fTargetOffsetX += (rOffset.getX() - 0.5) * rTargetRange.getWidth(); @@ -158,30 +173,26 @@ namespace basegfx } // add object translate - o_rGradientInfo.maTextureTransform.translate(fTargetOffsetX, fTargetOffsetY); + aTextureTransform.translate(fTargetOffsetX, fTargetOffsetY); // prepare aspect for texture - o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0; + const double fAspectRatio((0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0); - // build transform from u,v to [0.0 .. 1.0]. - o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform; - o_rGradientInfo.maBackTextureTransform.invert(); + return ODFGradientInfo(aTextureTransform, fAspectRatio, nSteps); } /** Setup for rect & square gradient is exactly the same. Factored out here. */ - static void initRectGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetRange, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder, - double fAngle, - bool bSquare) + ODFGradientInfo initRectGradientInfo( + const B2DRange& rTargetRange, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder, + double fAngle, + bool bSquare) { - o_rGradientInfo.maTextureTransform.identity(); - o_rGradientInfo.maBackTextureTransform.identity(); - o_rGradientInfo.mnSteps = nSteps; + B2DHomMatrix aTextureTransform; fAngle = -fAngle; @@ -194,18 +205,22 @@ namespace basegfx if(bSquare) { const double fSquareWidth(std::max(fTargetSizeX, fTargetSizeY)); + fTargetOffsetX -= (fSquareWidth - fTargetSizeX) / 2.0; fTargetOffsetY -= (fSquareWidth - fTargetSizeY) / 2.0; fTargetSizeX = fTargetSizeY = fSquareWidth; } // add object expansion - if(0.0 != fAngle) + const bool bAngleUsed(!fTools::equalZero(fAngle)); + + if(bAngleUsed) { const double fAbsCos(fabs(cos(fAngle))); const double fAbsSin(fabs(sin(fAngle))); const double fNewX(fTargetSizeX * fAbsCos + fTargetSizeY * fAbsSin); const double fNewY(fTargetSizeY * fAbsCos + fTargetSizeX * fAbsSin); + fTargetOffsetX -= (fNewX - fTargetSizeX) / 2.0; fTargetOffsetY -= (fNewY - fTargetSizeY) / 2.0; fTargetSizeX = fNewX; @@ -213,22 +228,21 @@ namespace basegfx } const double fHalfBorder((1.0 - fBorder) * 0.5); - o_rGradientInfo.maTextureTransform.scale(fHalfBorder, fHalfBorder); - o_rGradientInfo.maTextureTransform.translate(0.5, 0.5); - o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY); + aTextureTransform.scale(fHalfBorder, fHalfBorder); + aTextureTransform.translate(0.5, 0.5); + aTextureTransform.scale(fTargetSizeX, fTargetSizeY); // add texture rotate after scale to keep perpendicular angles - if(0.0 != fAngle) + if(bAngleUsed) { - const B2DPoint aCenter(0.5*fTargetSizeX, - 0.5*fTargetSizeY); - o_rGradientInfo.maTextureTransform *= - basegfx::tools::createRotateAroundPoint(aCenter, fAngle); + const B2DPoint aCenter(0.5 * fTargetSizeX, 0.5 * fTargetSizeY); + + aTextureTransform *= basegfx::tools::createRotateAroundPoint(aCenter, fAngle); } // add defined offsets after rotation - if(0.5 != rOffset.getX() || 0.5 != rOffset.getY()) + if(!fTools::equal(0.5, rOffset.getX()) || !fTools::equal(0.5, rOffset.getY())) { // use scaled target size fTargetOffsetX += (rOffset.getX() - 0.5) * fTargetSizeX; @@ -236,117 +250,183 @@ namespace basegfx } // add object translate - o_rGradientInfo.maTextureTransform.translate(fTargetOffsetX, fTargetOffsetY); + aTextureTransform.translate(fTargetOffsetX, fTargetOffsetY); // prepare aspect for texture - o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0; + const double fAspectRatio((0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0); - // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform - o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform; - o_rGradientInfo.maBackTextureTransform.invert(); + return ODFGradientInfo(aTextureTransform, fAspectRatio, nSteps); } namespace tools { - ODFGradientInfo& createLinearODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - sal_uInt32 nSteps, - double fBorder, - double fAngle) + ODFGradientInfo createLinearODFGradientInfo( + const B2DRange& rTargetArea, + sal_uInt32 nSteps, + double fBorder, + double fAngle) { - init1DGradientInfo(o_rGradientInfo, - rTargetArea, - nSteps, - fBorder, - fAngle, - false); - return o_rGradientInfo; + return init1DGradientInfo( + rTargetArea, + nSteps, + fBorder, + fAngle, + false); } - ODFGradientInfo& createAxialODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - sal_uInt32 nSteps, - double fBorder, - double fAngle) + ODFGradientInfo createAxialODFGradientInfo( + const B2DRange& rTargetArea, + sal_uInt32 nSteps, + double fBorder, + double fAngle) { - init1DGradientInfo(o_rGradientInfo, - rTargetArea, - nSteps, - fBorder, - fAngle, - true); - return o_rGradientInfo; + return init1DGradientInfo( + rTargetArea, + nSteps, + fBorder, + fAngle, + true); } - ODFGradientInfo& createRadialODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder) + ODFGradientInfo createRadialODFGradientInfo( + const B2DRange& rTargetArea, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder) { - initEllipticalGradientInfo(o_rGradientInfo, - rTargetArea, - rOffset, - nSteps, - fBorder, - 0.0, - true); - return o_rGradientInfo; + return initEllipticalGradientInfo( + rTargetArea, + rOffset, + nSteps, + fBorder, + 0.0, + true); } - ODFGradientInfo& createEllipticalODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder, - double fAngle) + ODFGradientInfo createEllipticalODFGradientInfo( + const B2DRange& rTargetArea, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder, + double fAngle) { - initEllipticalGradientInfo(o_rGradientInfo, - rTargetArea, - rOffset, - nSteps, - fBorder, - fAngle, - false); - return o_rGradientInfo; + return initEllipticalGradientInfo( + rTargetArea, + rOffset, + nSteps, + fBorder, + fAngle, + false); } - ODFGradientInfo& createSquareODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder, - double fAngle) + ODFGradientInfo createSquareODFGradientInfo( + const B2DRange& rTargetArea, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder, + double fAngle) { - initRectGradientInfo(o_rGradientInfo, - rTargetArea, - rOffset, - nSteps, - fBorder, - fAngle, - true); - return o_rGradientInfo; + return initRectGradientInfo( + rTargetArea, + rOffset, + nSteps, + fBorder, + fAngle, + true); } - ODFGradientInfo& createRectangularODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder, - double fAngle) + ODFGradientInfo createRectangularODFGradientInfo( + const B2DRange& rTargetArea, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder, + double fAngle) { - initRectGradientInfo(o_rGradientInfo, - rTargetArea, - rOffset, - nSteps, - fBorder, - fAngle, - false); - return o_rGradientInfo; + return initRectGradientInfo( + rTargetArea, + rOffset, + nSteps, + fBorder, + fAngle, + false); } - } // namespace tools + double getLinearGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) + { + const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); + const double t(clamp(aCoor.getY(), 0.0, 1.0)); + const sal_uInt32 nSteps(rGradInfo.getSteps()); + + if(nSteps) + { + return floor(t * nSteps) / double(nSteps + 1L); + } + + return t; + } + double getAxialGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) + { + const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); + const double t(clamp(fabs(aCoor.getY()), 0.0, 1.0)); + const sal_uInt32 nSteps(rGradInfo.getSteps()); + const double fInternalSteps((nSteps * 2) - 1); + + if(nSteps) + { + return floor(((t * fInternalSteps) + 1.0) / 2.0) / double(nSteps - 1L); + } + + return t; + } + + double getRadialGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) + { + const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); + const double fDist(clamp(aCoor.getX() * aCoor.getX() + aCoor.getY() * aCoor.getY(), 0.0, 1.0)); + const double t(1.0 - sqrt(fDist)); + const sal_uInt32 nSteps(rGradInfo.getSteps()); + + if(nSteps) + { + return floor(t * nSteps) / double(nSteps - 1L); + } + + return t; + } + + double getEllipticalGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) + { + return getRadialGradientAlpha(rUV, rGradInfo); // only matrix setup differs + } + + double getSquareGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) + { + const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV); + const double fAbsX(fabs(aCoor.getX())); + const double fAbsY(fabs(aCoor.getY())); + + if(fTools::moreOrEqual(fAbsX, 1.0) || fTools::moreOrEqual(fAbsY, 1.0)) + { + return 0.0; + } + + const double t(1.0 - std::max(fAbsX, fAbsY)); + const sal_uInt32 nSteps(rGradInfo.getSteps()); + + if(nSteps) + { + return floor(t * nSteps) / double(nSteps - 1L); + } + + return t; + } + + double getRectangularGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo) + { + return getSquareGradientAlpha(rUV, rGradInfo); // only matrix setup differs + } + } // namespace tools } // namespace basegfx /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx index 47b98bb72875..111c1e2268fa 100644 --- a/cppcanvas/source/mtfrenderer/emfplus.cxx +++ b/cppcanvas/source/mtfrenderer/emfplus.cxx @@ -1030,20 +1030,20 @@ namespace cppcanvas basegfx::B2DRange aBoundsRectangle (0, 0, 1, 1); if (brush->type == 4) { aGradientService = "LinearGradient"; - basegfx::tools::createLinearODFGradientInfo( aGradInfo, + aGradInfo = basegfx::tools::createLinearODFGradientInfo( aBoundsRectangle, aStops.getLength(), 0, - 0 ); + 0); } else { aGradientService = "EllipticalGradient"; - basegfx::tools::createEllipticalODFGradientInfo( aGradInfo, + aGradInfo = basegfx::tools::createEllipticalODFGradientInfo( aBoundsRectangle, ::basegfx::B2DVector( 0, 0 ), aStops.getLength(), 0, - 0 ); + 0); } uno::Reference< lang::XMultiServiceFactory > xFactory( diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 769df3df5ee4..85a5cef24b38 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -676,14 +676,14 @@ namespace cppcanvas switch( rGradient.GetStyle() ) { case GradientStyle_LINEAR: - basegfx::tools::createLinearODFGradientInfo(aGradInfo, + aGradInfo = basegfx::tools::createLinearODFGradientInfo( aBounds, nSteps, fBorder, fRotation); // map ODF to svg gradient orientation - x // instead of y direction - aGradInfo.maTextureTransform = aGradInfo.maTextureTransform * aRot90; + aGradInfo.setTextureTransform(aGradInfo.getTextureTransform() * aRot90); aGradientService = "LinearGradient"; break; @@ -702,27 +702,27 @@ namespace cppcanvas // border value, hence the second (left // most 1-... const double fAxialBorder (1-2*(1-fBorder)); - basegfx::tools::createAxialODFGradientInfo(aGradInfo, + aGradInfo = basegfx::tools::createAxialODFGradientInfo( aBounds, nSteps, fAxialBorder, fRotation); // map ODF to svg gradient orientation - x // instead of y direction - aGradInfo.maTextureTransform = aGradInfo.maTextureTransform * aRot90; + aGradInfo.setTextureTransform(aGradInfo.getTextureTransform() * aRot90); // map ODF axial gradient to 3-stop linear // gradient - shift left by 0.5 basegfx::B2DHomMatrix aShift; - aShift.translate(-0.5,0); - aGradInfo.maTextureTransform = aGradInfo.maTextureTransform * aShift; + aShift.translate(-0.5,0); + aGradInfo.setTextureTransform(aGradInfo.getTextureTransform() * aShift); aGradientService = "LinearGradient"; break; } case GradientStyle_RADIAL: - basegfx::tools::createRadialODFGradientInfo(aGradInfo, + aGradInfo = basegfx::tools::createRadialODFGradientInfo( aBounds, aOffset, nSteps, @@ -731,7 +731,7 @@ namespace cppcanvas break; case GradientStyle_ELLIPTICAL: - basegfx::tools::createEllipticalODFGradientInfo(aGradInfo, + aGradInfo = basegfx::tools::createEllipticalODFGradientInfo( aBounds, aOffset, nSteps, @@ -741,7 +741,7 @@ namespace cppcanvas break; case GradientStyle_SQUARE: - basegfx::tools::createSquareODFGradientInfo(aGradInfo, + aGradInfo = basegfx::tools::createSquareODFGradientInfo( aBounds, aOffset, nSteps, @@ -751,7 +751,7 @@ namespace cppcanvas break; case GradientStyle_RECT: - basegfx::tools::createRectangularODFGradientInfo(aGradInfo, + aGradInfo = basegfx::tools::createRectangularODFGradientInfo( aBounds, aOffset, nSteps, @@ -767,7 +767,7 @@ namespace cppcanvas } ::basegfx::unotools::affineMatrixFromHomMatrix( aTexture.AffineTransform, - aGradInfo.maTextureTransform ); + aGradInfo.getTextureTransform() ); uno::Sequence<uno::Any> args(3); beans::PropertyValue aProp; @@ -778,7 +778,7 @@ namespace cppcanvas aProp.Value <<= aStops; args[1] <<= aProp; aProp.Name = "AspectRatio"; - aProp.Value <<= aGradInfo.mfAspectRatio; + aProp.Value <<= aGradInfo.getAspectRatio(); args[2] <<= aProp; aTexture.Gradient.set( diff --git a/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx b/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx index fef92a97950b..751108279019 100644 --- a/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx @@ -36,11 +36,10 @@ namespace drawinglayer namespace primitive2d { void FillGradientPrimitive2D::generateMatricesAndColors( - std::vector< basegfx::B2DHomMatrix >& rMatrices, - std::vector< basegfx::BColor >& rColors) const + std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) const { - rMatrices.clear(); - rColors.clear(); + rEntries.clear(); // make sure steps is not too high/low const basegfx::BColor aStart(getFillGradient().getStartColor()); @@ -70,127 +69,131 @@ namespace drawinglayer case attribute::GRADIENTSTYLE_LINEAR: { texture::GeoTexSvxGradientLinear aGradient(getObjectRange(), aStart, aEnd, nSteps, getFillGradient().getBorder(), getFillGradient().getAngle()); - aGradient.appendTransformations(rMatrices); - aGradient.appendColors(rColors); + aGradient.appendTransformationsAndColors(rEntries, rOutmostColor); break; } case attribute::GRADIENTSTYLE_AXIAL: { texture::GeoTexSvxGradientAxial aGradient(getObjectRange(), aStart, aEnd, nSteps, getFillGradient().getBorder(), getFillGradient().getAngle()); - aGradient.appendTransformations(rMatrices); - aGradient.appendColors(rColors); + aGradient.appendTransformationsAndColors(rEntries, rOutmostColor); break; } case attribute::GRADIENTSTYLE_RADIAL: { texture::GeoTexSvxGradientRadial aGradient(getObjectRange(), aStart, aEnd, nSteps, getFillGradient().getBorder(), getFillGradient().getOffsetX(), getFillGradient().getOffsetY()); - aGradient.appendTransformations(rMatrices); - aGradient.appendColors(rColors); + aGradient.appendTransformationsAndColors(rEntries, rOutmostColor); break; } case attribute::GRADIENTSTYLE_ELLIPTICAL: { texture::GeoTexSvxGradientElliptical aGradient(getObjectRange(), aStart, aEnd, nSteps, getFillGradient().getBorder(), getFillGradient().getOffsetX(), getFillGradient().getOffsetY(), getFillGradient().getAngle()); - aGradient.appendTransformations(rMatrices); - aGradient.appendColors(rColors); + aGradient.appendTransformationsAndColors(rEntries, rOutmostColor); break; } case attribute::GRADIENTSTYLE_SQUARE: { texture::GeoTexSvxGradientSquare aGradient(getObjectRange(), aStart, aEnd, nSteps, getFillGradient().getBorder(), getFillGradient().getOffsetX(), getFillGradient().getOffsetY(), getFillGradient().getAngle()); - aGradient.appendTransformations(rMatrices); - aGradient.appendColors(rColors); + aGradient.appendTransformationsAndColors(rEntries, rOutmostColor); break; } case attribute::GRADIENTSTYLE_RECT: { texture::GeoTexSvxGradientRect aGradient(getObjectRange(), aStart, aEnd, nSteps, getFillGradient().getBorder(), getFillGradient().getOffsetX(), getFillGradient().getOffsetY(), getFillGradient().getAngle()); - aGradient.appendTransformations(rMatrices); - aGradient.appendColors(rColors); + aGradient.appendTransformationsAndColors(rEntries, rOutmostColor); break; } } } Primitive2DSequence FillGradientPrimitive2D::createOverlappingFill( - const std::vector< basegfx::B2DHomMatrix >& rMatrices, - const std::vector< basegfx::BColor >& rColors, + const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + const basegfx::BColor& rOutmostColor, const basegfx::B2DPolygon& rUnitPolygon) const { // prepare return value - Primitive2DSequence aRetval(rColors.size() ? rMatrices.size() + 1 : rMatrices.size()); + Primitive2DSequence aRetval(rEntries.size() + 1); - // create solid fill with start color - if(!rColors.empty()) - { - // create primitive - const Primitive2DReference xRef( - new PolyPolygonColorPrimitive2D( - basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(getObjectRange())), - rColors[0])); - aRetval[0] = xRef; - } + // create solid fill with outmost color + aRetval[0] = Primitive2DReference( + new PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(getObjectRange())), + rOutmostColor)); // create solid fill steps - for(sal_uInt32 a(0); a < rMatrices.size(); a++) + for(sal_uInt32 a(0); a < rEntries.size(); a++) { // create part polygon basegfx::B2DPolygon aNewPoly(rUnitPolygon); - aNewPoly.transform(rMatrices[a]); + + aNewPoly.transform(rEntries[a].maB2DHomMatrix); // create solid fill - const Primitive2DReference xRef( + aRetval[a + 1] = Primitive2DReference( new PolyPolygonColorPrimitive2D( basegfx::B2DPolyPolygon(aNewPoly), - rColors[a + 1])); - aRetval[a + 1] = xRef; + rEntries[a].maBColor)); } return aRetval; } Primitive2DSequence FillGradientPrimitive2D::createNonOverlappingFill( - const std::vector< basegfx::B2DHomMatrix >& rMatrices, - const std::vector< basegfx::BColor >& rColors, + const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + const basegfx::BColor& rOutmostColor, const basegfx::B2DPolygon& rUnitPolygon) const { // prepare return value - Primitive2DSequence aRetval; - const sal_uInt32 nMatricesSize(rMatrices.size()); + Primitive2DSequence aRetval(rEntries.size() + 1); - if(nMatricesSize) + // get outmost range from object + basegfx::B2DRange aOutmostRange(getObjectRange()); + basegfx::B2DPolyPolygon aCombinedPolyPoly; + + if(rEntries.size()) { - basegfx::B2DPolygon aOuterPoly(rUnitPolygon); - aOuterPoly.transform(rMatrices[0]); - basegfx::B2DPolyPolygon aCombinedPolyPoly(aOuterPoly); - const sal_uInt32 nEntryCount(rColors.size() ? rMatrices.size() + 1 : rMatrices.size()); - sal_uInt32 nIndex(0); + // extend aOutmostRange with first polygon + basegfx::B2DPolygon aFirstPoly(rUnitPolygon); - aRetval.realloc(nEntryCount); + aFirstPoly.transform(rEntries[0].maB2DHomMatrix); + aCombinedPolyPoly.append(aFirstPoly); + aOutmostRange.expand(aFirstPoly.getB2DRange()); + } - if(!rColors.empty()) - { - basegfx::B2DRange aOuterPolyRange(aOuterPoly.getB2DRange()); - aOuterPolyRange.expand(getObjectRange()); - aCombinedPolyPoly.append(basegfx::tools::createPolygonFromRect(aOuterPolyRange)); - aRetval[nIndex++] = Primitive2DReference(new PolyPolygonColorPrimitive2D(aCombinedPolyPoly, rColors[0])); - aCombinedPolyPoly = basegfx::B2DPolyPolygon(aOuterPoly); - } + // add outmost range to combined polypolygon (in 1st place), create first primitive + aCombinedPolyPoly.insert(0, basegfx::tools::createPolygonFromRect(aOutmostRange)); + aRetval[0] = Primitive2DReference( + new PolyPolygonColorPrimitive2D( + aCombinedPolyPoly, + rOutmostColor)); - for(sal_uInt32 a(1); a < nMatricesSize - 1; a++) - { - basegfx::B2DPolygon aInnerPoly(rUnitPolygon); - aInnerPoly.transform(rMatrices[a]); - aCombinedPolyPoly.append(aInnerPoly); - aRetval[nIndex++] = Primitive2DReference(new PolyPolygonColorPrimitive2D(aCombinedPolyPoly, rColors[a])); - aCombinedPolyPoly = basegfx::B2DPolyPolygon(aInnerPoly); - } + if(rEntries.size()) + { + // reuse first polygon, it's the second one + aCombinedPolyPoly.remove(0); - if(!rColors.empty()) + for(sal_uInt32 a(0); a < rEntries.size() - 1; a++) { - aRetval[nIndex] = Primitive2DReference(new PolyPolygonColorPrimitive2D( - aCombinedPolyPoly, rColors[rColors.size() - 1])); + // create next inner polygon, combinbe with last one + basegfx::B2DPolygon aNextPoly(rUnitPolygon); + + aNextPoly.transform(rEntries[a + 1].maB2DHomMatrix); + aCombinedPolyPoly.append(aNextPoly); + + // create primitive with correct color + aRetval[a + 1] = Primitive2DReference( + new PolyPolygonColorPrimitive2D( + aCombinedPolyPoly, + rEntries[a].maBColor)); + + // reuse inner polygon, it's the 2nd one + aCombinedPolyPoly.remove(0); } + + // add last inner polygon with last color + aRetval[rEntries.size()] = Primitive2DReference( + new PolyPolygonColorPrimitive2D( + aCombinedPolyPoly, + rEntries[rEntries.size() - 1].maBColor)); } return aRetval; @@ -201,34 +204,35 @@ namespace drawinglayer // prepare shape of the Unit Polygon basegfx::B2DPolygon aUnitPolygon; - if(attribute::GRADIENTSTYLE_RADIAL == getFillGradient().getStyle() - || attribute::GRADIENTSTYLE_ELLIPTICAL == getFillGradient().getStyle()) - { - aUnitPolygon = basegfx::tools::createPolygonFromCircle( - basegfx::B2DPoint(0,0), 1); - } - else if(attribute::GRADIENTSTYLE_LINEAR == maFillGradient.getStyle()) - { - aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0, 0, 1, 1)); - } - else + switch(getFillGradient().getStyle()) { - aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); + case attribute::GRADIENTSTYLE_RADIAL: + case attribute::GRADIENTSTYLE_ELLIPTICAL: + { + aUnitPolygon = basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), 1.0); + break; + } + default: // GRADIENTSTYLE_LINEAR, attribute::GRADIENTSTYLE_AXIAL, attribute::GRADIENTSTYLE_SQUARE, attribute::GRADIENTSTYLE_RECT + { + aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1.0, -1.0, 1.0, 1.0)); + break; + } } // get the transform matrices and colors (where colors // will have one more entry that matrices) - std::vector< basegfx::B2DHomMatrix > aMatrices; - std::vector< basegfx::BColor > aColors; - generateMatricesAndColors(aMatrices, aColors); + std::vector< drawinglayer::texture::B2DHomMatrixAndBColor > aEntries; + basegfx::BColor aOutmostColor; + + generateMatricesAndColors(aEntries, aOutmostColor); if(bOverlapping) { - return createOverlappingFill(aMatrices, aColors, aUnitPolygon); + return createOverlappingFill(aEntries, aOutmostColor, aUnitPolygon); } else { - return createNonOverlappingFill(aMatrices, aColors, aUnitPolygon); + return createNonOverlappingFill(aEntries, aOutmostColor, aUnitPolygon); } } @@ -243,7 +247,9 @@ namespace drawinglayer if(!getFillGradient().isDefault()) { - return createFill(true); + static bool bOverlapping(true); // allow to test non-overlapping in the debugger + + return createFill(bOverlapping); } else { diff --git a/drawinglayer/source/processor2d/vclhelpergradient.cxx b/drawinglayer/source/processor2d/vclhelpergradient.cxx index 71c263d7ef5e..245e85084fcd 100644 --- a/drawinglayer/source/processor2d/vclhelpergradient.cxx +++ b/drawinglayer/source/processor2d/vclhelpergradient.cxx @@ -56,86 +56,78 @@ namespace drawinglayer void impDrawGradientToOutDevSimple( OutputDevice& rOutDev, const basegfx::B2DPolyPolygon& rTargetForm, - const ::std::vector< basegfx::B2DHomMatrix >& rMatrices, - const ::std::vector< basegfx::BColor >& rColors, + const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + const basegfx::BColor& rOutmostColor, const basegfx::B2DPolygon& rUnitPolygon) { rOutDev.SetLineColor(); + rOutDev.SetFillColor(Color(rOutmostColor)); + rOutDev.DrawPolyPolygon(rTargetForm); + const sal_uInt32 nCount(rEntries.size()); - for(sal_uInt32 a(0L); a < rColors.size(); a++) + for(sal_uInt32 a(0); a < nCount; a++) { - // set correct color - const basegfx::BColor aFillColor(rColors[a]); - rOutDev.SetFillColor(Color(aFillColor)); + // create part polygon + basegfx::B2DPolygon aNewPoly(rUnitPolygon); - if(a) - { - if(a - 1L < static_cast< sal_uInt32 >(rMatrices.size())) - { - basegfx::B2DPolygon aNewPoly(rUnitPolygon); - aNewPoly.transform(rMatrices[a - 1L]); - rOutDev.DrawPolygon(aNewPoly); - } - } - else - { - rOutDev.DrawPolyPolygon(rTargetForm); - } + aNewPoly.transform(rEntries[a].maB2DHomMatrix); + + // create solid fill + rOutDev.SetFillColor(Color(rEntries[a].maBColor)); + rOutDev.DrawPolygon(aNewPoly); } } void impDrawGradientToOutDevComplex( OutputDevice& rOutDev, const basegfx::B2DPolyPolygon& rTargetForm, - const ::std::vector< basegfx::B2DHomMatrix >& rMatrices, - const ::std::vector< basegfx::BColor >& rColors, + const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + const basegfx::BColor& rOutmostColor, const basegfx::B2DPolygon& rUnitPolygon) { PolyPolygon aVclTargetForm(rTargetForm); ::std::vector< Polygon > aVclPolygons; + const sal_uInt32 nCount(rEntries.size()); sal_uInt32 a; + // reserve when possible + aVclPolygons.reserve(nCount); + // remember and set to XOR rOutDev.SetLineColor(); rOutDev.Push(PUSH_RASTEROP); rOutDev.SetRasterOp(ROP_XOR); // draw gradient PolyPolygons - for(a = 0L; a < rMatrices.size(); a++) + for(a = 0; a < nCount; a++) { // create polygon and remember basegfx::B2DPolygon aNewPoly(rUnitPolygon); - aNewPoly.transform(rMatrices[a]); + aNewPoly.transform(rEntries[a].maB2DHomMatrix); aVclPolygons.push_back(Polygon(aNewPoly)); - // set correct color - if(rColors.size() > a) - { - const basegfx::BColor aFillColor(rColors[a]); - rOutDev.SetFillColor(Color(aFillColor)); - } - // create vcl PolyPolygon and draw it if(a) { - PolyPolygon aVclPolyPoly(aVclPolygons[a - 1L]); + rOutDev.SetFillColor(Color(rEntries[a - 1].maBColor)); + PolyPolygon aVclPolyPoly(aVclPolygons[a - 1]); aVclPolyPoly.Insert(aVclPolygons[a]); rOutDev.DrawPolyPolygon(aVclPolyPoly); } else { + rOutDev.SetFillColor(Color(rOutmostColor)); PolyPolygon aVclPolyPoly(aVclTargetForm); - aVclPolyPoly.Insert(aVclPolygons[0L]); + aVclPolyPoly.Insert(aVclPolygons[0]); rOutDev.DrawPolyPolygon(aVclPolyPoly); } } // draw last poly in last color - if(!rColors.empty()) + if(nCount) { - const basegfx::BColor aFillColor(rColors[rColors.size() - 1L]); - rOutDev.SetFillColor(Color(aFillColor)); - rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1L]); + rOutDev.SetFillColor(Color(rEntries[nCount - 1].maBColor)); + rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1]); } // draw object form in black and go back to XOR @@ -145,36 +137,30 @@ namespace drawinglayer rOutDev.SetRasterOp(ROP_XOR); // draw gradient PolyPolygons again - for(a = 0L; a < rMatrices.size(); a++) + for(a = 0; a < nCount; a++) { - // set correct color - if(rColors.size() > a) - { - const basegfx::BColor aFillColor(rColors[a]); - rOutDev.SetFillColor(Color(aFillColor)); - } - // create vcl PolyPolygon and draw it if(a) { - PolyPolygon aVclPolyPoly(aVclPolygons[a - 1L]); + rOutDev.SetFillColor(Color(rEntries[a - 1].maBColor)); + PolyPolygon aVclPolyPoly(aVclPolygons[a - 1]); aVclPolyPoly.Insert(aVclPolygons[a]); rOutDev.DrawPolyPolygon(aVclPolyPoly); } else { + rOutDev.SetFillColor(Color(rOutmostColor)); PolyPolygon aVclPolyPoly(aVclTargetForm); - aVclPolyPoly.Insert(aVclPolygons[0L]); + aVclPolyPoly.Insert(aVclPolygons[0]); rOutDev.DrawPolyPolygon(aVclPolyPoly); } } // draw last poly in last color - if(!rColors.empty()) + if(nCount) { - const basegfx::BColor aFillColor(rColors[rColors.size() - 1L]); - rOutDev.SetFillColor(Color(aFillColor)); - rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1L]); + rOutDev.SetFillColor(Color(rEntries[nCount - 1].maBColor)); + rOutDev.DrawPolygon(aVclPolygons[aVclPolygons.size() - 1]); } // reset drawmode @@ -195,8 +181,8 @@ namespace drawinglayer double fBorder, double fAngle, double fOffsetX, double fOffsetY, bool bSimple) { const basegfx::B2DRange aOutlineRange(basegfx::tools::getRange(rTargetForm)); - ::std::vector< basegfx::B2DHomMatrix > aMatrices; - ::std::vector< basegfx::BColor > aColors; + std::vector< drawinglayer::texture::B2DHomMatrixAndBColor > aEntries; + basegfx::BColor aOutmostColor; basegfx::B2DPolygon aUnitPolygon; // make sure steps is not too high/low @@ -208,63 +194,57 @@ namespace drawinglayer case attribute::GRADIENTSTYLE_LINEAR: { texture::GeoTexSvxGradientLinear aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); - aUnitPolygon = basegfx::tools::createUnitPolygon(); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); + aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); break; } case attribute::GRADIENTSTYLE_AXIAL: { texture::GeoTexSvxGradientAxial aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); break; } case attribute::GRADIENTSTYLE_RADIAL: { texture::GeoTexSvxGradientRadial aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetY); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0,0), 1); break; } case attribute::GRADIENTSTYLE_ELLIPTICAL: { texture::GeoTexSvxGradientElliptical aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0,0), 1); break; } case attribute::GRADIENTSTYLE_SQUARE: { texture::GeoTexSvxGradientSquare aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); break; } case attribute::GRADIENTSTYLE_RECT: { texture::GeoTexSvxGradientRect aGradient(aOutlineRange, rStart, rEnd, nSteps, fBorder, fOffsetX, fOffsetX, fAngle); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformationsAndColors(aEntries, aOutmostColor); aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(-1, -1, 1, 1)); break; } } // paint them with mask using the XOR method - if(!aMatrices.empty()) + if(aEntries.size()) { if(bSimple) { - impDrawGradientToOutDevSimple(rOutDev, rTargetForm, aMatrices, aColors, aUnitPolygon); + impDrawGradientToOutDevSimple(rOutDev, rTargetForm, aEntries, aOutmostColor, aUnitPolygon); } else { - impDrawGradientToOutDevComplex(rOutDev, rTargetForm, aMatrices, aColors, aUnitPolygon); + impDrawGradientToOutDevComplex(rOutDev, rTargetForm, aEntries, aOutmostColor, aUnitPolygon); } } } diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index cd7bd574ab17..cced61242c17 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -631,10 +631,12 @@ namespace drawinglayer } else { + static bool bSimple = false; // allow testing simple paint in debugger + impDrawGradientToOutDev( *mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(), aStartColor, aEndColor, rGradient.getBorder(), - rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), false); + rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), bSimple); } } } diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index 502427436e45..c42f75c22c03 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -42,11 +42,6 @@ namespace drawinglayer return true; } - void GeoTexSvx::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& /*rMatrices*/) - { - // default implementation does nothing - } - void GeoTexSvx::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { // base implementation creates random color (for testing only, may also be pure virtual) @@ -71,39 +66,19 @@ namespace drawinglayer { namespace texture { - void GeoTexSvxGradient::impAppendMatrix(::std::vector< basegfx::B2DHomMatrix >& rMatrices, const basegfx::B2DRange& rRange) - { - basegfx::B2DHomMatrix aNew; - aNew.set(0, 0, rRange.getWidth()); - aNew.set(1, 1, rRange.getHeight()); - aNew.set(0, 2, rRange.getMinX()); - aNew.set(1, 2, rRange.getMinY()); - rMatrices.push_back(maGradientInfo.maTextureTransform * aNew); - } - - void GeoTexSvxGradient::impAppendColorsRadial(::std::vector< basegfx::BColor >& rColors) - { - if(maGradientInfo.mnSteps) - { - rColors.push_back(maStart); - - for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps - 1L; a++) - { - rColors.push_back(interpolate(maStart, maEnd, (double)a / (double)maGradientInfo.mnSteps)); - } - - rColors.push_back(maEnd); - } - } - - GeoTexSvxGradient::GeoTexSvxGradient(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder) - : maTargetRange(rTargetRange), + GeoTexSvxGradient::GeoTexSvxGradient( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 /* nSteps */, + double fBorder) + : GeoTexSvx(), + maGradientInfo(), + maTargetRange(rTargetRange), maStart(rStart), maEnd(rEnd), mfBorder(fBorder) { - maGradientInfo.mnSteps = nSteps; - maGradientInfo.mfAspectRatio = 1.0; } GeoTexSvxGradient::~GeoTexSvxGradient() @@ -113,11 +88,10 @@ namespace drawinglayer bool GeoTexSvxGradient::operator==(const GeoTexSvx& rGeoTexSvx) const { const GeoTexSvxGradient* pCompare = dynamic_cast< const GeoTexSvxGradient* >(&rGeoTexSvx); + return (pCompare - && maGradientInfo.maTextureTransform == pCompare->maGradientInfo.maTextureTransform + && maGradientInfo == pCompare->maGradientInfo && maTargetRange == pCompare->maTargetRange - && maGradientInfo.mnSteps == pCompare->maGradientInfo.mnSteps - && maGradientInfo.mfAspectRatio == pCompare->maGradientInfo.mfAspectRatio && mfBorder == pCompare->mfBorder); } } // end of namespace texture @@ -129,42 +103,52 @@ namespace drawinglayer { namespace texture { - GeoTexSvxGradientLinear::GeoTexSvxGradientLinear(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle) + GeoTexSvxGradientLinear::GeoTexSvxGradientLinear( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fAngle) : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { - basegfx::tools::createLinearODFGradientInfo(maGradientInfo, - rTargetRange, - nSteps, - fBorder, - fAngle); + maGradientInfo = basegfx::tools::createLinearODFGradientInfo( + rTargetRange, + nSteps, + fBorder, + fAngle); } GeoTexSvxGradientLinear::~GeoTexSvxGradientLinear() { } - void GeoTexSvxGradientLinear::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientLinear::appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) { - if(maGradientInfo.mnSteps) - { - const double fStripeWidth(1.0 / maGradientInfo.mnSteps); - for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) - { - const basegfx::B2DRange aRect(0.0, fStripeWidth * a, 1.0, 1.0); - impAppendMatrix(rMatrices, aRect); - } - } - } + rOutmostColor = maStart; - void GeoTexSvxGradientLinear::appendColors(::std::vector< basegfx::BColor >& rColors) - { - if(maGradientInfo.mnSteps) + if(maGradientInfo.getSteps()) { - rColors.push_back(maStart); + const double fStripeWidth(1.0 / maGradientInfo.getSteps()); + B2DHomMatrixAndBColor aB2DHomMatrixAndBColor; - for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) + for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++) { - rColors.push_back(interpolate(maStart, maEnd, (double)a / (double)(maGradientInfo.mnSteps + 1L))); + const double fPos(fStripeWidth * a); + // optimized below... + // + // basegfx::B2DHomMatrix aNew; + // aNew.scale(0.5, 0.5); + // aNew.translate(0.5, 0.5); + // aNew.scale(1.0, (1.0 - fPos)); + // aNew.translate(0.0, fPos); + // aNew = maGradientInfo.getTextureTransform() * aNew; + aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * + basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 0.5 * (1.0 - fPos), 0.5, 0.5 * (1.0 + fPos)); + aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1)); + rEntries.push_back(aB2DHomMatrixAndBColor); } } } @@ -184,42 +168,50 @@ namespace drawinglayer { namespace texture { - GeoTexSvxGradientAxial::GeoTexSvxGradientAxial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle) + GeoTexSvxGradientAxial::GeoTexSvxGradientAxial( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fAngle) : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { - basegfx::tools::createAxialODFGradientInfo(maGradientInfo, - rTargetRange, - nSteps, - fBorder, - fAngle); + maGradientInfo = basegfx::tools::createAxialODFGradientInfo( + rTargetRange, + nSteps, + fBorder, + fAngle); } GeoTexSvxGradientAxial::~GeoTexSvxGradientAxial() { } - void GeoTexSvxGradientAxial::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientAxial::appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) { - if(maGradientInfo.mnSteps) - { - const double fStripeWidth=1.0 / (maGradientInfo.mnSteps - 1L); - for(sal_uInt32 a(maGradientInfo.mnSteps-1L); a != 0; a--) - { - const basegfx::B2DRange aRect(0, 0, 1.0, fStripeWidth * a); - impAppendMatrix(rMatrices, aRect); - } - } - } + rOutmostColor = maEnd; - void GeoTexSvxGradientAxial::appendColors(::std::vector< basegfx::BColor >& rColors) - { - if(maGradientInfo.mnSteps) + if(maGradientInfo.getSteps()) { - rColors.push_back(maEnd); + const double fStripeWidth(1.0 / maGradientInfo.getSteps()); + B2DHomMatrixAndBColor aB2DHomMatrixAndBColor; - for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) + for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++) { - rColors.push_back(interpolate(maEnd, maStart, (double)a / (double)maGradientInfo.mnSteps)); + // const double fPos(fStripeWidth * a); + // optimized below... + // + // basegfx::B2DHomMatrix aNew; + // aNew.scale(0.50, (1.0 - fPos)); + // aNew.translate(0.5, 0.0); + // aNew = maGradientInfo.getTextureTransform() * aNew; + aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * + basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 1.0 - (fStripeWidth * a), 0.5, 0.0); + aB2DHomMatrixAndBColor.maBColor = interpolate(maEnd, maStart, double(a) / double(maGradientInfo.getSteps() - 1)); + rEntries.push_back(aB2DHomMatrixAndBColor); } } } @@ -239,38 +231,48 @@ namespace drawinglayer { namespace texture { - GeoTexSvxGradientRadial::GeoTexSvxGradientRadial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY) + GeoTexSvxGradientRadial::GeoTexSvxGradientRadial( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY) : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { - basegfx::tools::createRadialODFGradientInfo(maGradientInfo, - rTargetRange, - basegfx::B2DVector(fOffsetX,fOffsetY), - nSteps, - fBorder); + maGradientInfo = basegfx::tools::createRadialODFGradientInfo( + rTargetRange, + basegfx::B2DVector(fOffsetX,fOffsetY), + nSteps, + fBorder); } GeoTexSvxGradientRadial::~GeoTexSvxGradientRadial() { } - void GeoTexSvxGradientRadial::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientRadial::appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) { - if(maGradientInfo.mnSteps) + rOutmostColor = maStart; + + if(maGradientInfo.getSteps()) { - const double fStepSize=1.0 / maGradientInfo.mnSteps; - for(sal_uInt32 a(maGradientInfo.mnSteps-1L); a > 0; a--) + const double fStepSize(1.0 / maGradientInfo.getSteps()); + B2DHomMatrixAndBColor aB2DHomMatrixAndBColor; + + for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++) { - const basegfx::B2DRange aRect(0, 0, fStepSize*a, fStepSize*a); - impAppendMatrix(rMatrices, aRect); + const double fSize(1.0 - (fStepSize * a)); + aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fSize, fSize); + aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1)); + rEntries.push_back(aB2DHomMatrixAndBColor); } } } - void GeoTexSvxGradientRadial::appendColors(::std::vector< basegfx::BColor >& rColors) - { - impAppendColorsRadial(rColors); - } - void GeoTexSvxGradientRadial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const double fScaler(basegfx::tools::getRadialGradientAlpha(rUV, maGradientInfo)); @@ -286,58 +288,68 @@ namespace drawinglayer { namespace texture { - GeoTexSvxGradientElliptical::GeoTexSvxGradientElliptical(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) + GeoTexSvxGradientElliptical::GeoTexSvxGradientElliptical( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle) : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { - basegfx::tools::createEllipticalODFGradientInfo(maGradientInfo, - rTargetRange, - basegfx::B2DVector(fOffsetX,fOffsetY), - nSteps, - fBorder, - fAngle); + maGradientInfo = basegfx::tools::createEllipticalODFGradientInfo( + rTargetRange, + basegfx::B2DVector(fOffsetX,fOffsetY), + nSteps, + fBorder, + fAngle); } GeoTexSvxGradientElliptical::~GeoTexSvxGradientElliptical() { } - void GeoTexSvxGradientElliptical::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientElliptical::appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) { - if(maGradientInfo.mnSteps) + rOutmostColor = maStart; + + if(maGradientInfo.getSteps()) { - double fWidth(1); - double fHeight(1); - double fIncrementX, fIncrementY; + double fWidth(1.0); + double fHeight(1.0); + double fIncrementX(0.0); + double fIncrementY(0.0); - if(maGradientInfo.mfAspectRatio > 1.0) + if(maGradientInfo.getAspectRatio() > 1.0) { - fIncrementY = fHeight / maGradientInfo.mnSteps; - fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio; + fIncrementY = fHeight / maGradientInfo.getSteps(); + fIncrementX = fIncrementY / maGradientInfo.getAspectRatio(); } else { - fIncrementX = fWidth / maGradientInfo.mnSteps; - fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio; + fIncrementX = fWidth / maGradientInfo.getSteps(); + fIncrementY = fIncrementX * maGradientInfo.getAspectRatio(); } - for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) + B2DHomMatrixAndBColor aB2DHomMatrixAndBColor; + + for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++) { // next step - fWidth -= fIncrementX; + fWidth -= fIncrementX; fHeight -= fIncrementY; - // create matrix - const basegfx::B2DRange aRect(0, 0, fWidth, fHeight); - impAppendMatrix(rMatrices, aRect); + aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fWidth, fHeight); + aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1)); + rEntries.push_back(aB2DHomMatrixAndBColor); } } } - void GeoTexSvxGradientElliptical::appendColors(::std::vector< basegfx::BColor >& rColors) - { - impAppendColorsRadial(rColors); - } - void GeoTexSvxGradientElliptical::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const double fScaler(basegfx::tools::getEllipticalGradientAlpha(rUV, maGradientInfo)); @@ -353,39 +365,50 @@ namespace drawinglayer { namespace texture { - GeoTexSvxGradientSquare::GeoTexSvxGradientSquare(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) + GeoTexSvxGradientSquare::GeoTexSvxGradientSquare( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle) : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { - basegfx::tools::createSquareODFGradientInfo(maGradientInfo, - rTargetRange, - basegfx::B2DVector(fOffsetX,fOffsetY), - nSteps, - fBorder, - fAngle); + maGradientInfo = basegfx::tools::createSquareODFGradientInfo( + rTargetRange, + basegfx::B2DVector(fOffsetX,fOffsetY), + nSteps, + fBorder, + fAngle); } GeoTexSvxGradientSquare::~GeoTexSvxGradientSquare() { } - void GeoTexSvxGradientSquare::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientSquare::appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) { - if(maGradientInfo.mnSteps) + rOutmostColor = maStart; + + if(maGradientInfo.getSteps()) { - const double fStepSize=1.0 / maGradientInfo.mnSteps; - for(sal_uInt32 a(maGradientInfo.mnSteps-1L); a > 0; a--) + const double fStepSize(1.0 / maGradientInfo.getSteps()); + B2DHomMatrixAndBColor aB2DHomMatrixAndBColor; + + for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++) { - const basegfx::B2DRange aRect(0, 0, fStepSize*a, fStepSize*a); - impAppendMatrix(rMatrices, aRect); + const double fSize(1.0 - (fStepSize * a)); + aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fSize, fSize); + aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1)); + rEntries.push_back(aB2DHomMatrixAndBColor); } } } - void GeoTexSvxGradientSquare::appendColors(::std::vector< basegfx::BColor >& rColors) - { - impAppendColorsRadial(rColors); - } - void GeoTexSvxGradientSquare::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const double fScaler(basegfx::tools::getSquareGradientAlpha(rUV, maGradientInfo)); @@ -401,58 +424,68 @@ namespace drawinglayer { namespace texture { - GeoTexSvxGradientRect::GeoTexSvxGradientRect(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle) + GeoTexSvxGradientRect::GeoTexSvxGradientRect( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle) : GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder) { - basegfx::tools::createRectangularODFGradientInfo(maGradientInfo, - rTargetRange, - basegfx::B2DVector(fOffsetX,fOffsetY), - nSteps, - fBorder, - fAngle); + maGradientInfo = basegfx::tools::createRectangularODFGradientInfo( + rTargetRange, + basegfx::B2DVector(fOffsetX,fOffsetY), + nSteps, + fBorder, + fAngle); } GeoTexSvxGradientRect::~GeoTexSvxGradientRect() { } - void GeoTexSvxGradientRect::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) + void GeoTexSvxGradientRect::appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) { - if(maGradientInfo.mnSteps) + rOutmostColor = maStart; + + if(maGradientInfo.getSteps()) { - double fWidth(1); - double fHeight(1); - double fIncrementX, fIncrementY; + double fWidth(1.0); + double fHeight(1.0); + double fIncrementX(0.0); + double fIncrementY(0.0); - if(maGradientInfo.mfAspectRatio > 1.0) + if(maGradientInfo.getAspectRatio() > 1.0) { - fIncrementY = fHeight / maGradientInfo.mnSteps; - fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio; + fIncrementY = fHeight / maGradientInfo.getSteps(); + fIncrementX = fIncrementY / maGradientInfo.getAspectRatio(); } else { - fIncrementX = fWidth / maGradientInfo.mnSteps; - fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio; + fIncrementX = fWidth / maGradientInfo.getSteps(); + fIncrementY = fIncrementX * maGradientInfo.getAspectRatio(); } - for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++) + B2DHomMatrixAndBColor aB2DHomMatrixAndBColor; + + for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++) { // next step - fWidth -= fIncrementX; + fWidth -= fIncrementX; fHeight -= fIncrementY; - // create matrix - const basegfx::B2DRange aRect(0, 0, fWidth, fHeight); - impAppendMatrix(rMatrices, aRect); + aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fWidth, fHeight); + aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1)); + rEntries.push_back(aB2DHomMatrixAndBColor); } } } - void GeoTexSvxGradientRect::appendColors(::std::vector< basegfx::BColor >& rColors) - { - impAppendColorsRadial(rColors); - } - void GeoTexSvxGradientRect::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const { const double fScaler(basegfx::tools::getRectangularGradientAlpha(rUV, maGradientInfo)); @@ -468,7 +501,10 @@ namespace drawinglayer { namespace texture { - GeoTexSvxHatch::GeoTexSvxHatch(const basegfx::B2DRange& rTargetRange, double fDistance, double fAngle) + GeoTexSvxHatch::GeoTexSvxHatch( + const basegfx::B2DRange& rTargetRange, + double fDistance, + double fAngle) : mfDistance(0.1), mfAngle(fAngle), mnSteps(10L) @@ -513,10 +549,6 @@ namespace drawinglayer const double fSteps((0.0 != fDistance) ? fTargetSizeY / fDistance : 10.0); mnSteps = basegfx::fround(fSteps + 0.5); mfDistance = 1.0 / fSteps; - - // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform - maBackTextureTransform = maTextureTransform; - maBackTextureTransform.invert(); } GeoTexSvxHatch::~GeoTexSvxHatch() @@ -547,9 +579,20 @@ namespace drawinglayer double GeoTexSvxHatch::getDistanceToHatch(const basegfx::B2DPoint& rUV) const { - const basegfx::B2DPoint aCoor(maBackTextureTransform * rUV); + const basegfx::B2DPoint aCoor(getBackTextureTransform() * rUV); return fmod(aCoor.getY(), mfDistance); } + + const basegfx::B2DHomMatrix& GeoTexSvxHatch::getBackTextureTransform() const + { + if(maBackTextureTransform.isIdentity()) + { + const_cast< GeoTexSvxHatch* >(this)->maBackTextureTransform = maTextureTransform; + const_cast< GeoTexSvxHatch* >(this)->maBackTextureTransform.invert(); + } + + return maBackTextureTransform; + } } // end of namespace texture } // end of namespace drawinglayer @@ -559,7 +602,9 @@ namespace drawinglayer { namespace texture { - GeoTexSvxTiled::GeoTexSvxTiled(const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize) + GeoTexSvxTiled::GeoTexSvxTiled( + const basegfx::B2DPoint& rTopLeft, + const basegfx::B2DVector& rSize) : maTopLeft(rTopLeft), maSize(rSize) { diff --git a/include/basegfx/tools/gradienttools.hxx b/include/basegfx/tools/gradienttools.hxx index aa7479d2c369..db4894e795c2 100644 --- a/include/basegfx/tools/gradienttools.hxx +++ b/include/basegfx/tools/gradienttools.hxx @@ -38,12 +38,13 @@ namespace basegfx 1.2-compatible gradients. Use the createXXXODFGradientInfo() methods below for initializing from ODF attributes. */ - struct BASEGFX_DLLPUBLIC ODFGradientInfo + class BASEGFX_DLLPUBLIC ODFGradientInfo { + private: /** transformation mapping from [0,1]^2 texture coordinate space to [0,1]^2 shape coordinate space */ - B2DHomMatrix maTextureTransform; + B2DHomMatrix maTextureTransform; /** transformation mapping from [0,1]^2 shape coordinate space to [0,1]^2 texture coordinate space. This is the @@ -51,20 +52,72 @@ namespace basegfx scanline rasterizer (put shape u/v coordinates into it, get texture s/t coordinates out of it) */ - B2DHomMatrix maBackTextureTransform; + B2DHomMatrix maBackTextureTransform; /** Aspect ratio of the gradient. Only used in drawinglayer for generating nested gradient polygons currently. Already catered for in the transformations above. */ - double mfAspectRatio; + double mfAspectRatio; /** Requested gradient steps to render. See the implementations of the getXXXGradientAlpha() methods below, the semantic differs slightly for the different gradient types. */ - sal_uInt32 mnSteps; + sal_uInt32 mnSteps; + + public: + ODFGradientInfo() + : maTextureTransform(), + maBackTextureTransform(), + mfAspectRatio(1.0), + mnSteps(0) + { + } + + ODFGradientInfo( + const B2DHomMatrix& rTextureTransform, + double fAspectRatio, + sal_uInt32 nSteps) + : maTextureTransform(rTextureTransform), + maBackTextureTransform(), + mfAspectRatio(fAspectRatio), + mnSteps(nSteps) + { + } + + ODFGradientInfo(const ODFGradientInfo& rODFGradientInfo) + : maTextureTransform(rODFGradientInfo.getTextureTransform()), + maBackTextureTransform(rODFGradientInfo.maBackTextureTransform), + mfAspectRatio(rODFGradientInfo.getAspectRatio()), + mnSteps(rODFGradientInfo.getSteps()) + { + } + + ODFGradientInfo& operator=(const ODFGradientInfo& rODFGradientInfo) + { + maTextureTransform = rODFGradientInfo.getTextureTransform(); + maBackTextureTransform = rODFGradientInfo.maBackTextureTransform; + mfAspectRatio = rODFGradientInfo.getAspectRatio(); + mnSteps = rODFGradientInfo.getSteps(); + + return *this; + } + + // compare operator + bool operator==(const ODFGradientInfo& rGeoTexSvx) const; + + const B2DHomMatrix& getTextureTransform() const { return maTextureTransform; } + const B2DHomMatrix& getBackTextureTransform() const; + double getAspectRatio() const { return mfAspectRatio; } + sal_uInt32 getSteps() const { return mnSteps; } + + void setTextureTransform(const B2DHomMatrix& rNew) + { + maTextureTransform = rNew; + maBackTextureTransform.identity(); + } }; namespace tools @@ -90,11 +143,12 @@ namespace basegfx @param fAngle Gradient angle (from ODF) */ - BASEGFX_DLLPUBLIC ODFGradientInfo& createLinearODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - sal_uInt32 nSteps, - double fBorder, - double fAngle); + BASEGFX_DLLPUBLIC ODFGradientInfo createLinearODFGradientInfo( + const B2DRange& rTargetArea, + sal_uInt32 nSteps, + double fBorder, + double fAngle); + /** Calculate linear gradient blend value @@ -109,18 +163,8 @@ namespace basegfx @param rGradInfo Gradient info, for transformation and number of steps */ - inline double getLinearGradientAlpha(const B2DPoint& rUV, - const ODFGradientInfo& rGradInfo ) - { - const B2DPoint aCoor(rGradInfo.maBackTextureTransform * rUV); - const double t(clamp(aCoor.getY(), 0.0, 1.0)); - const sal_uInt32 nSteps(rGradInfo.mnSteps); - - if(nSteps > 2L && nSteps < 128L) - return floor(t * nSteps) / double(nSteps + 1L); - - return t; - } + BASEGFX_DLLPUBLIC double getLinearGradientAlpha(const B2DPoint& rUV, + const ODFGradientInfo& rGradInfo); /** Create matrix for ODF's axial gradient definition @@ -149,11 +193,12 @@ namespace basegfx @param fAngle Gradient angle (from ODF) */ - BASEGFX_DLLPUBLIC ODFGradientInfo& createAxialODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - sal_uInt32 nSteps, - double fBorder, - double fAngle); + BASEGFX_DLLPUBLIC ODFGradientInfo createAxialODFGradientInfo( + const B2DRange& rTargetArea, + sal_uInt32 nSteps, + double fBorder, + double fAngle); + /** Calculate axial gradient blend value @@ -168,19 +213,8 @@ namespace basegfx @param rGradInfo Gradient info, for transformation and number of steps */ - inline double getAxialGradientAlpha(const B2DPoint& rUV, - const ODFGradientInfo& rGradInfo ) - { - const B2DPoint aCoor(rGradInfo.maBackTextureTransform * rUV); - const double t(clamp(fabs(aCoor.getY()), 0.0, 1.0)); - const sal_uInt32 nSteps(rGradInfo.mnSteps); - const double fInternalSteps((nSteps * 2L) - 1L); - - if(nSteps > 2L && nSteps < 128L) - return floor(((t * fInternalSteps) + 1.0) / 2.0) / double(nSteps - 1L); - - return t; - } + BASEGFX_DLLPUBLIC double getAxialGradientAlpha(const B2DPoint& rUV, + const ODFGradientInfo& rGradInfo); /** Create matrix for ODF's radial gradient definition @@ -204,11 +238,12 @@ namespace basegfx @param fAngle Gradient angle (from ODF) */ - BASEGFX_DLLPUBLIC ODFGradientInfo& createRadialODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder); + BASEGFX_DLLPUBLIC ODFGradientInfo createRadialODFGradientInfo( + const B2DRange& rTargetArea, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder); + /** Calculate radial gradient blend value @@ -223,23 +258,8 @@ namespace basegfx @param rGradInfo Gradient info, for transformation and number of steps */ - inline double getRadialGradientAlpha(const B2DPoint& rUV, - const ODFGradientInfo& rGradInfo ) - { - const B2DPoint aCoor(rGradInfo.maBackTextureTransform * rUV); - const double fDist( - clamp(aCoor.getX() * aCoor.getX() + aCoor.getY() * aCoor.getY(), - 0.0, - 1.0)); - - const double t(1.0 - sqrt(fDist)); - const sal_uInt32 nSteps(rGradInfo.mnSteps); - - if(nSteps > 2L && nSteps < 128L) - return floor(t * nSteps) / double(nSteps - 1L); - - return t; - } + BASEGFX_DLLPUBLIC double getRadialGradientAlpha(const B2DPoint& rUV, + const ODFGradientInfo& rGradInfo); /** Create matrix for ODF's elliptical gradient definition @@ -263,12 +283,13 @@ namespace basegfx @param fAngle Gradient angle (from ODF) */ - BASEGFX_DLLPUBLIC ODFGradientInfo& createEllipticalODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder, - double fAngle); + BASEGFX_DLLPUBLIC ODFGradientInfo createEllipticalODFGradientInfo( + const B2DRange& rTargetArea, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder, + double fAngle); + /** Calculate elliptical gradient blend value @@ -283,11 +304,8 @@ namespace basegfx @param rGradInfo Gradient info, for transformation and number of steps */ - inline double getEllipticalGradientAlpha(const B2DPoint& rUV, - const ODFGradientInfo& rGradInfo ) - { - return getRadialGradientAlpha(rUV,rGradInfo); // only matrix setup differs - } + BASEGFX_DLLPUBLIC double getEllipticalGradientAlpha(const B2DPoint& rUV, + const ODFGradientInfo& rGradInfo); /** Create matrix for ODF's square gradient definition @@ -311,12 +329,13 @@ namespace basegfx @param fAngle Gradient angle (from ODF) */ - BASEGFX_DLLPUBLIC ODFGradientInfo& createSquareODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder, - double fAngle); + BASEGFX_DLLPUBLIC ODFGradientInfo createSquareODFGradientInfo( + const B2DRange& rTargetArea, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder, + double fAngle); + /** Calculate square gradient blend value @@ -331,24 +350,8 @@ namespace basegfx @param rGradInfo Gradient info, for transformation and number of steps */ - inline double getSquareGradientAlpha(const B2DPoint& rUV, - const ODFGradientInfo& rGradInfo ) - { - const B2DPoint aCoor(rGradInfo.maBackTextureTransform * rUV); - const double fAbsX(fabs(aCoor.getX())); - const double fAbsY(fabs(aCoor.getY())); - - if(fTools::moreOrEqual(fAbsX, 1.0) || fTools::moreOrEqual(fAbsY, 1.0)) - return 0.0; - - const double t(1.0 - (fAbsX > fAbsY ? fAbsX : fAbsY)); - const sal_uInt32 nSteps(rGradInfo.mnSteps); - - if(nSteps > 2L && nSteps < 128L) - return floor(t * nSteps) / double(nSteps - 1L); - - return t; - } + BASEGFX_DLLPUBLIC double getSquareGradientAlpha(const B2DPoint& rUV, + const ODFGradientInfo& rGradInfo); /** Create matrix for ODF's rectangular gradient definition @@ -372,12 +375,13 @@ namespace basegfx @param fAngle Gradient angle (from ODF) */ - BASEGFX_DLLPUBLIC ODFGradientInfo& createRectangularODFGradientInfo(ODFGradientInfo& o_rGradientInfo, - const B2DRange& rTargetArea, - const B2DVector& rOffset, - sal_uInt32 nSteps, - double fBorder, - double fAngle); + BASEGFX_DLLPUBLIC ODFGradientInfo createRectangularODFGradientInfo( + const B2DRange& rTargetArea, + const B2DVector& rOffset, + sal_uInt32 nSteps, + double fBorder, + double fAngle); + /** Calculate rectangular gradient blend value @@ -392,11 +396,8 @@ namespace basegfx @param rGradInfo Gradient info, for transformation and number of steps */ - inline double getRectangularGradientAlpha(const B2DPoint& rUV, - const ODFGradientInfo& rGradInfo ) - { - return getSquareGradientAlpha(rUV, rGradInfo); // only matrix setup differs - } + BASEGFX_DLLPUBLIC double getRectangularGradientAlpha(const B2DPoint& rUV, + const ODFGradientInfo& rGradInfo); } } diff --git a/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx b/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx index f953f9c01507..a15e4547bcda 100644 --- a/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx @@ -24,6 +24,7 @@ #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/attribute/fillgradientattribute.hxx> +#include <drawinglayer/texture/texture.hxx> ////////////////////////////////////////////////////////////////////////////// // predefines @@ -62,15 +63,15 @@ namespace drawinglayer /// local helpers void generateMatricesAndColors( - std::vector< basegfx::B2DHomMatrix >& rMatrices, - std::vector< basegfx::BColor >& rColors) const; + std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) const; Primitive2DSequence createOverlappingFill( - const std::vector< basegfx::B2DHomMatrix >& rMatrices, - const std::vector< basegfx::BColor >& rColors, + const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + const basegfx::BColor& rOutmostColor, const basegfx::B2DPolygon& rUnitPolygon) const; Primitive2DSequence createNonOverlappingFill( - const std::vector< basegfx::B2DHomMatrix >& rMatrices, - const std::vector< basegfx::BColor >& rColors, + const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, + const basegfx::BColor& rOutmostColor, const basegfx::B2DPolygon& rUnitPolygon) const; protected: diff --git a/include/drawinglayer/texture/texture.hxx b/include/drawinglayer/texture/texture.hxx index 5d1751d70889..b22e61d12be8 100644 --- a/include/drawinglayer/texture/texture.hxx +++ b/include/drawinglayer/texture/texture.hxx @@ -44,7 +44,6 @@ namespace drawinglayer bool operator!=(const GeoTexSvx& rGeoTexSvx) const { return !operator==(rGeoTexSvx); } // virtual base methods - virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const; }; @@ -57,6 +56,22 @@ namespace drawinglayer { namespace texture { + /// helper class for processing equal number of matrices and colors + /// for texture processing + struct B2DHomMatrixAndBColor + { + basegfx::B2DHomMatrix maB2DHomMatrix; + basegfx::BColor maBColor; + }; + } // end of namespace texture +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace texture + { class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradient : public GeoTexSvx { protected: @@ -66,19 +81,22 @@ namespace drawinglayer basegfx::BColor maEnd; double mfBorder; - // helpers - void impAppendMatrix(::std::vector< basegfx::B2DHomMatrix >& rMatrices, const basegfx::B2DRange& rRange); - void impAppendColorsRadial(::std::vector< basegfx::BColor >& rColors); - public: - GeoTexSvxGradient(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder); + GeoTexSvxGradient( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder); virtual ~GeoTexSvxGradient(); // compare operator virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const; // virtual base methods - virtual void appendColors(::std::vector< basegfx::BColor >& rColors) = 0; + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor) = 0; // data access const basegfx::BColor& getStart() const { return maStart; } @@ -96,11 +114,18 @@ namespace drawinglayer class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientLinear : public GeoTexSvxGradient { public: - GeoTexSvxGradientLinear(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle); + GeoTexSvxGradientLinear( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fAngle); virtual ~GeoTexSvxGradientLinear(); - virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); - virtual void appendColors(::std::vector< basegfx::BColor >& rColors); + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; }; } // end of namespace texture @@ -115,11 +140,18 @@ namespace drawinglayer class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientAxial : public GeoTexSvxGradient { public: - GeoTexSvxGradientAxial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fAngle); + GeoTexSvxGradientAxial( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fAngle); virtual ~GeoTexSvxGradientAxial(); - virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); - virtual void appendColors(::std::vector< basegfx::BColor >& rColors); + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; }; } // end of namespace texture @@ -134,11 +166,19 @@ namespace drawinglayer class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRadial : public GeoTexSvxGradient { public: - GeoTexSvxGradientRadial(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY); + GeoTexSvxGradientRadial( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY); virtual ~GeoTexSvxGradientRadial(); - virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); - virtual void appendColors(::std::vector< basegfx::BColor >& rColors); + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; }; } // end of namespace texture @@ -153,11 +193,20 @@ namespace drawinglayer class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientElliptical : public GeoTexSvxGradient { public: - GeoTexSvxGradientElliptical(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle); + GeoTexSvxGradientElliptical( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle); virtual ~GeoTexSvxGradientElliptical(); - virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); - virtual void appendColors(::std::vector< basegfx::BColor >& rColors); + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; }; } // end of namespace texture @@ -172,11 +221,20 @@ namespace drawinglayer class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientSquare : public GeoTexSvxGradient { public: - GeoTexSvxGradientSquare(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle); + GeoTexSvxGradientSquare( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle); virtual ~GeoTexSvxGradientSquare(); - virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); - virtual void appendColors(::std::vector< basegfx::BColor >& rColors); + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; }; } // end of namespace texture @@ -191,11 +249,20 @@ namespace drawinglayer class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRect : public GeoTexSvxGradient { public: - GeoTexSvxGradientRect(const basegfx::B2DRange& rTargetRange, const basegfx::BColor& rStart, const basegfx::BColor& rEnd, sal_uInt32 nSteps, double fBorder, double fOffsetX, double fOffsetY, double fAngle); + GeoTexSvxGradientRect( + const basegfx::B2DRange& rTargetRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle); virtual ~GeoTexSvxGradientRect(); - virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); - virtual void appendColors(::std::vector< basegfx::BColor >& rColors); + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOutmostColor); virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; }; } // end of namespace texture @@ -217,7 +284,10 @@ namespace drawinglayer sal_uInt32 mnSteps; public: - GeoTexSvxHatch(const basegfx::B2DRange& rTargetRange, double fDistance, double fAngle); + GeoTexSvxHatch( + const basegfx::B2DRange& rTargetRange, + double fDistance, + double fAngle); virtual ~GeoTexSvxHatch(); // compare operator @@ -225,6 +295,7 @@ namespace drawinglayer virtual void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); double getDistanceToHatch(const basegfx::B2DPoint& rUV) const; + const basegfx::B2DHomMatrix& getBackTextureTransform() const; }; } // end of namespace texture } // end of namespace drawinglayer @@ -242,7 +313,9 @@ namespace drawinglayer basegfx::B2DVector maSize; public: - GeoTexSvxTiled(const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize); + GeoTexSvxTiled( + const basegfx::B2DPoint& rTopLeft, + const basegfx::B2DVector& rSize); virtual ~GeoTexSvxTiled(); // compare operator |