summaryrefslogtreecommitdiff
path: root/basegfx/source
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-10-02 11:08:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-11 10:32:54 +0100
commit5e39bc0937940e8d0f78668366e9de447269f0df (patch)
tree98c01dcc4374557ecc6e531ffd803d4ddcb53fce /basegfx/source
parent385bb4547359027bca6d5158e00e541f094b277e (diff)
Related: #i120604# Adapted back texture mapper for gradients for 3D usage
(cherry picked from commit 4152ce982bc8c1aca6859d9b803cefd16ba11de0) Change-Id: I712494bb166518c2ba9aa2ef529b4ac3e9fe8951
Diffstat (limited to 'basegfx/source')
-rw-r--r--basegfx/source/tools/gradienttools.cxx65
1 files changed, 51 insertions, 14 deletions
diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx
index f3e254098182..83b6e21e0f32 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -354,42 +354,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;
@@ -404,9 +435,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;
}
@@ -414,9 +451,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;