incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1392807 [2/2] - in /incubator/ooo/trunk/main: basegfx/inc/basegfx/tools/ basegfx/source/tools/ cppcanvas/source/mtfrenderer/ drawinglayer/inc/drawinglayer/primitive2d/ drawinglayer/inc/drawinglayer/texture/ drawinglayer/source/primitive2d/...
Date Tue, 02 Oct 2012 09:23:26 GMT
Modified: incubator/ooo/trunk/main/drawinglayer/source/texture/texture.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/texture/texture.cxx?rev=1392807&r1=1392806&r2=1392807&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/texture/texture.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/texture/texture.cxx Tue Oct  2 09:23:25 2012
@@ -49,11 +49,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)
@@ -76,41 +71,21 @@ namespace drawinglayer
 
 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),
+    namespace texture
+    {
+		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()
@@ -120,11 +95,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
+
+            return (pCompare
+				&& maGradientInfo == pCompare->maGradientInfo
 				&& maTargetRange == pCompare->maTargetRange
-				&& maGradientInfo.mnSteps == pCompare->maGradientInfo.mnSteps
-				&& maGradientInfo.mfAspectRatio == pCompare->maGradientInfo.mfAspectRatio
 				&& mfBorder == pCompare->mfBorder);
 		}
 	} // end of namespace texture
@@ -136,45 +110,55 @@ 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)
-		{
-			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);
-				}
-			}
-		}
-
-		void GeoTexSvxGradientLinear::appendColors(::std::vector< basegfx::BColor >&
rColors)
-		{
-			if(maGradientInfo.mnSteps)
-			{
-				rColors.push_back(maStart);
-
-				for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
-				{
-					rColors.push_back(interpolate(maStart, maEnd, (double)a / (double)(maGradientInfo.mnSteps
+ 1L)));
-				}
-			}
-		}
+        void GeoTexSvxGradientLinear::appendTransformationsAndColors(
+            std::vector< B2DHomMatrixAndBColor >& rEntries, 
+            basegfx::BColor& rOutmostColor)
+        {
+            rOutmostColor = maStart;
+
+            if(maGradientInfo.getSteps())
+            {
+                const double fStripeWidth(1.0 / maGradientInfo.getSteps());
+                B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
+
+                for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
+                {
+                    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);
+                }
+            }
+        }
 
 		void GeoTexSvxGradientLinear::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor&
rBColor, double& /*rfOpacity*/) const
 		{
@@ -191,44 +175,52 @@ 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)
-		{
-			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);
-				}
-			}
-		}
-
-		void GeoTexSvxGradientAxial::appendColors(::std::vector< basegfx::BColor >& rColors)
-		{
-			if(maGradientInfo.mnSteps)
-			{
-				rColors.push_back(maEnd);
-
-				for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
-				{
-					rColors.push_back(interpolate(maEnd, maStart, (double)a / (double)maGradientInfo.mnSteps));
-				}
-			}
+        void GeoTexSvxGradientAxial::appendTransformationsAndColors(
+            std::vector< B2DHomMatrixAndBColor >& rEntries, 
+            basegfx::BColor& rOutmostColor)
+        {
+            rOutmostColor = maEnd;
+
+            if(maGradientInfo.getSteps())
+            {
+                const double fStripeWidth(1.0 / maGradientInfo.getSteps());
+                B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
+
+                for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
+                {
+                    // 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);
+                }
+            }
 		}
 
 		void GeoTexSvxGradientAxial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor&
rBColor, double& /*rfOpacity*/) const
@@ -246,37 +238,47 @@ 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)
-		{
-			if(maGradientInfo.mnSteps)
-			{
-				const double fStepSize=1.0 / maGradientInfo.mnSteps;
-				for(sal_uInt32 a(maGradientInfo.mnSteps-1L); a > 0; a--)
-				{
-					const basegfx::B2DRange aRect(0, 0, fStepSize*a, fStepSize*a);
-					impAppendMatrix(rMatrices, aRect);
-				}
-			}
-		}
-
-		void GeoTexSvxGradientRadial::appendColors(::std::vector< basegfx::BColor >&
rColors)
-		{
-			impAppendColorsRadial(rColors);
-		}
+		void GeoTexSvxGradientRadial::appendTransformationsAndColors(
+            std::vector< B2DHomMatrixAndBColor >& rEntries, 
+            basegfx::BColor& rOutmostColor)
+		{
+            rOutmostColor = maStart;
+
+            if(maGradientInfo.getSteps())
+            {
+                const double fStepSize(1.0 / maGradientInfo.getSteps());
+                B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
+
+                for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
+                {
+                    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::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor&
rBColor, double& /*rfOpacity*/) const
 		{
@@ -293,56 +295,66 @@ 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)
-		{
-			if(maGradientInfo.mnSteps)
-			{
-				double fWidth(1);
-				double fHeight(1);
-				double fIncrementX, fIncrementY;
-
-				if(maGradientInfo.mfAspectRatio > 1.0)
-				{
-					fIncrementY = fHeight / maGradientInfo.mnSteps;
-					fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio;
-				}
-				else
-				{
-					fIncrementX = fWidth / maGradientInfo.mnSteps;
-					fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio;
-				}
-
-				for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
-				{
-					// next step
-					fWidth  -= fIncrementX;
-					fHeight -= fIncrementY;
-
-					// create matrix
-					const basegfx::B2DRange aRect(0, 0, fWidth, fHeight);
-					impAppendMatrix(rMatrices, aRect);
-				}
-			}
-		}
-
-		void GeoTexSvxGradientElliptical::appendColors(::std::vector< basegfx::BColor >&
rColors)
-		{
-			impAppendColorsRadial(rColors);
+		void GeoTexSvxGradientElliptical::appendTransformationsAndColors(
+            std::vector< B2DHomMatrixAndBColor >& rEntries, 
+            basegfx::BColor& rOutmostColor)
+		{
+            rOutmostColor = maStart;
+
+            if(maGradientInfo.getSteps())
+            {
+                double fWidth(1.0);
+                double fHeight(1.0);
+                double fIncrementX(0.0);
+                double fIncrementY(0.0);
+
+                if(maGradientInfo.getAspectRatio() > 1.0)
+                {
+                    fIncrementY = fHeight / maGradientInfo.getSteps();
+                    fIncrementX = fIncrementY / maGradientInfo.getAspectRatio();
+                }
+                else
+                {
+                    fIncrementX = fWidth / maGradientInfo.getSteps();
+                    fIncrementY = fIncrementX * maGradientInfo.getAspectRatio();
+                }
+
+                B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
+
+                for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
+                {
+                    // next step
+                    fWidth -= fIncrementX;
+                    fHeight -= fIncrementY;
+
+                    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::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor&
rBColor, double& /*rfOpacity*/) const
@@ -360,37 +372,48 @@ 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)
-		{
-			if(maGradientInfo.mnSteps)
-			{
-				const double fStepSize=1.0 / maGradientInfo.mnSteps;
-				for(sal_uInt32 a(maGradientInfo.mnSteps-1L); a > 0; a--)
-				{
-					const basegfx::B2DRange aRect(0, 0, fStepSize*a, fStepSize*a);
-					impAppendMatrix(rMatrices, aRect);
-				}
-			}
-		}
-
-		void GeoTexSvxGradientSquare::appendColors(::std::vector< basegfx::BColor >&
rColors)
-		{
-			impAppendColorsRadial(rColors);
+		void GeoTexSvxGradientSquare::appendTransformationsAndColors(
+            std::vector< B2DHomMatrixAndBColor >& rEntries, 
+            basegfx::BColor& rOutmostColor)
+		{
+            rOutmostColor = maStart;
+
+            if(maGradientInfo.getSteps())
+            {
+                const double fStepSize(1.0 / maGradientInfo.getSteps());
+                B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
+
+                for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
+                {
+                    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::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor&
rBColor, double& /*rfOpacity*/) const
@@ -408,56 +431,66 @@ 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)
-		{
-			if(maGradientInfo.mnSteps)
-			{
-				double fWidth(1);
-				double fHeight(1);
-				double fIncrementX, fIncrementY;
-
-				if(maGradientInfo.mfAspectRatio > 1.0)
-				{
-					fIncrementY = fHeight / maGradientInfo.mnSteps;
-					fIncrementX = fIncrementY / maGradientInfo.mfAspectRatio;
-				}
-				else
-				{
-					fIncrementX = fWidth / maGradientInfo.mnSteps;
-					fIncrementY = fIncrementX * maGradientInfo.mfAspectRatio;
-				}
-
-				for(sal_uInt32 a(1L); a < maGradientInfo.mnSteps; a++)
-				{
-					// next step
-					fWidth  -= fIncrementX;
-					fHeight -= fIncrementY;
-
-					// create matrix
-					const basegfx::B2DRange aRect(0, 0, fWidth, fHeight);
-					impAppendMatrix(rMatrices, aRect);
-				}
-			}
-		}
-
-		void GeoTexSvxGradientRect::appendColors(::std::vector< basegfx::BColor >& rColors)
-		{
-			impAppendColorsRadial(rColors);
+		void GeoTexSvxGradientRect::appendTransformationsAndColors(
+            std::vector< B2DHomMatrixAndBColor >& rEntries, 
+            basegfx::BColor& rOutmostColor)
+		{
+            rOutmostColor = maStart;
+
+            if(maGradientInfo.getSteps())
+            {
+                double fWidth(1.0);
+                double fHeight(1.0);
+                double fIncrementX(0.0);
+                double fIncrementY(0.0);
+
+                if(maGradientInfo.getAspectRatio() > 1.0)
+                {
+                    fIncrementY = fHeight / maGradientInfo.getSteps();
+                    fIncrementX = fIncrementY / maGradientInfo.getAspectRatio();
+                }
+                else
+                {
+                    fIncrementX = fWidth / maGradientInfo.getSteps();
+                    fIncrementY = fIncrementX * maGradientInfo.getAspectRatio();
+                }
+
+                B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
+
+                for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
+                {
+                    // next step
+                    fWidth -= fIncrementX;
+                    fHeight -= fIncrementY;
+
+                    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::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor&
rBColor, double& /*rfOpacity*/) const
@@ -475,7 +508,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)
@@ -520,10 +556,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()
@@ -554,9 +586,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
 
@@ -566,7 +609,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)
 		{



Mime
View raw message