summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-02-15 10:45:10 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-02-15 14:46:11 +0000
commitea1d3d11ca113042a99effc168da834894005370 (patch)
tree60aafa53ee15614b39b329c3510bbca913305f67 /basegfx
parentd88fa033f02b70e28dbef6b42a4e73abc24c3a60 (diff)
MCGR: Add GradientSteps to GeoTexSvxGradient
Move GradientSteps data to GeoTexSvxGradient and adapt interfaces. Also move tooling to more isolated place in gradienttools in basegfx. Keep everything still compatible, the work will be now to adapt all six different derivations of GeoTexSvxGradient to make use of the evtl. given GradientSteps. Change-Id: Iaa212763c603d46de0a94b1b203b979bb7ce359d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147050 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/tools/gradienttools.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx
index c6e716510432..3f2480c82e84 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -29,7 +29,7 @@ namespace basegfx
{
return getTextureTransform() == rODFGradientInfo.getTextureTransform()
&& getAspectRatio() == rODFGradientInfo.getAspectRatio()
- && getSteps() == rODFGradientInfo.getSteps();
+ && getRequestedSteps() == rODFGradientInfo.getRequestedSteps();
}
const B2DHomMatrix& ODFGradientInfo::getBackTextureTransform() const
@@ -261,6 +261,26 @@ namespace basegfx
namespace utils
{
+ sal_uInt32 calculateNumberOfSteps(
+ sal_uInt32 nRequestedSteps,
+ const BColor& rStart,
+ const BColor& rEnd)
+ {
+ const sal_uInt32 nMaxSteps(sal_uInt32((rStart.getMaximumDistance(rEnd) * 127.5) + 0.5));
+
+ if (0 == nRequestedSteps)
+ {
+ nRequestedSteps = nMaxSteps;
+ }
+
+ if(nRequestedSteps > nMaxSteps)
+ {
+ nRequestedSteps = nMaxSteps;
+ }
+
+ return std::max(sal_uInt32(1), nRequestedSteps);
+ }
+
ODFGradientInfo createLinearODFGradientInfo(
const B2DRange& rTargetArea,
sal_uInt32 nSteps,
@@ -372,7 +392,7 @@ namespace basegfx
return 1.0; // end value for outside
}
- const sal_uInt32 nSteps(rGradInfo.getSteps());
+ const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
if(nSteps)
{
@@ -399,7 +419,7 @@ namespace basegfx
return 1.0; // use end value when outside in Y
}
- const sal_uInt32 nSteps(rGradInfo.getSteps());
+ const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
if(nSteps)
{
@@ -419,7 +439,7 @@ namespace basegfx
}
const double t(1.0 - std::hypot(aCoor.getX(), aCoor.getY()));
- const sal_uInt32 nSteps(rGradInfo.getSteps());
+ const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
if(nSteps && t < 1.0)
{
@@ -452,7 +472,7 @@ namespace basegfx
}
const double t(1.0 - std::max(fAbsX, fAbsY));
- const sal_uInt32 nSteps(rGradInfo.getSteps());
+ const sal_uInt32 nSteps(rGradInfo.getRequestedSteps());
if(nSteps && t < 1.0)
{