You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/10/02 14:08:18 UTC

svn commit: r1392873 - /incubator/ooo/trunk/main/basegfx/source/tools/gradienttools.cxx

Author: alg
Date: Tue Oct  2 12:08:18 2012
New Revision: 1392873

URL: http://svn.apache.org/viewvc?rev=1392873&view=rev
Log:
#120604# Adapted back texture mapper for gradients for 3D usage

Modified:
    incubator/ooo/trunk/main/basegfx/source/tools/gradienttools.cxx

Modified: incubator/ooo/trunk/main/basegfx/source/tools/gradienttools.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/basegfx/source/tools/gradienttools.cxx?rev=1392873&r1=1392872&r2=1392873&view=diff
==============================================================================
--- incubator/ooo/trunk/main/basegfx/source/tools/gradienttools.cxx (original)
+++ incubator/ooo/trunk/main/basegfx/source/tools/gradienttools.cxx Tue Oct  2 12:08:18 2012
@@ -361,42 +361,73 @@ namespace basegfx
         double getLinearGradientAlpha(const B2DPoint& rUV, const ODFGradientInfo& rGradInfo)
         {
             const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
-            const double t(clamp(aCoor.getY(), 0.0, 1.0));
+
+            if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
+            {
+                return 0.0;
+            }
+
+            if(aCoor.getY() <= 0.0)
+            {
+                return 0.0;
+            }
+
+            if(aCoor.getY() >= 1.0)
+            {
+                return 1.0;
+            }
+
             const sal_uInt32 nSteps(rGradInfo.getSteps());
 
             if(nSteps)
             {
-                return floor(t * nSteps) / double(nSteps + 1L);
+                return floor(aCoor.getY() * nSteps) / double(nSteps - 1);
             }
 
-            return t;
+            return aCoor.getY();
         }
 
         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));
+
+            if(aCoor.getX() < 0.0 || aCoor.getX() > 1.0)
+            {
+                return 0.0;
+            }
+
+            const double fAbsY(fabs(aCoor.getY()));
+
+            if(fAbsY >= 1.0)
+            {
+                return 0.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 floor(fAbsY * nSteps) / double(nSteps - 1);
             }
 
-            return t;
+            return fAbsY;
         }
 
         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));
+
+            if(aCoor.getX() < -1.0 || aCoor.getX() > 1.0 || aCoor.getY() < -1.0 || aCoor.getY() > 1.0)
+            {
+                return 0.0;
+            }
+
+            const double t(1.0 - sqrt(aCoor.getX() * aCoor.getX() + aCoor.getY() * aCoor.getY()));
             const sal_uInt32 nSteps(rGradInfo.getSteps());
 
-            if(nSteps)
+            if(nSteps && t < 1.0)
             {
-                return floor(t * nSteps) / double(nSteps - 1L);
+                return floor(t * nSteps) / double(nSteps - 1);
             }
 
             return t;
@@ -411,9 +442,15 @@ namespace basegfx
         {
             const B2DPoint aCoor(rGradInfo.getBackTextureTransform() * rUV);
             const double fAbsX(fabs(aCoor.getX()));
+
+            if(fAbsX >= 1.0)
+            {
+                return 0.0;
+            }
+
             const double fAbsY(fabs(aCoor.getY()));
 
-            if(fTools::moreOrEqual(fAbsX, 1.0) || fTools::moreOrEqual(fAbsY, 1.0))
+            if(fAbsY >= 1.0)
             {
                 return 0.0;
             }
@@ -421,9 +458,9 @@ namespace basegfx
             const double t(1.0 - std::max(fAbsX, fAbsY));
             const sal_uInt32 nSteps(rGradInfo.getSteps());
 
-            if(nSteps)
+            if(nSteps && t < 1.0)
             {
-                return floor(t * nSteps) / double(nSteps - 1L);
+                return floor(t * nSteps) / double(nSteps - 1);
             }
 
             return t;