summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2014-03-14 21:31:59 +1100
committerCaolán McNamara <caolanm@redhat.com>2014-03-19 10:39:51 +0000
commitc16186f1b96ecf0933a16f4c9fb196c5be18d7d9 (patch)
tree8734af9f01b0fbfa2a836fdcd3a41e41d01e9b0b /vcl
parent3fa4b0a00f78e940b32d546bac410890719502fd (diff)
fdo#74702 Move gradient steps logic into OutputDevice or Printer classes
Currently we work out the number of gradient steps based on the type of class that is being used. We calculate the number differntly for printers. However, we should let the Printers class work this out. Also, the function is very long - I have moved most of the calculation logic to it's own function. Made some very small formatting changes to outdev.hxx. Change-Id: I91b8787d885c1c8d2aa2205f25e5c7f82607c0ea Reviewed-on: https://gerrit.libreoffice.org/8586 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/outdev4.cxx46
-rw-r--r--vcl/source/gdi/print.cxx7
2 files changed, 36 insertions, 17 deletions
diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx
index 8df71b8e3ed9..c3873b6adcb4 100644
--- a/vcl/source/gdi/outdev4.cxx
+++ b/vcl/source/gdi/outdev4.cxx
@@ -140,6 +140,34 @@ inline sal_uInt8 ImplGetGradientColorValue( long nValue )
return (sal_uInt8)nValue;
}
+long OutputDevice::ImplGetGradientStepCount( long nMinRect )
+{
+ long nInc = (nMinRect < 50) ? 2 : 4;
+
+ return nInc;
+}
+
+long OutputDevice::ImplGetGradientSteps( const Gradient& rGradient, const Rectangle& rRect, bool bMtf )
+{
+ // calculate step count
+ long nStepCount = rGradient.GetSteps();
+
+ // generate nStepCount, if not passed
+ long nMinRect = rRect.GetHeight();
+
+ if ( !nStepCount )
+ {
+ long nInc;
+
+ nInc = ImplGetGradientStepCount (nMinRect);
+ if ( !nInc || bMtf )
+ nInc = 1;
+ nStepCount = nMinRect / nInc;
+ }
+
+ return nStepCount;
+}
+
void OutputDevice::ImplDrawLinearGradient( const Rectangle& rRect,
const Gradient& rGradient,
bool bMtf, const PolyPolygon* pClipPolyPoly )
@@ -243,23 +271,7 @@ void OutputDevice::ImplDrawLinearGradient( const Rectangle& rRect,
}
// calculate step count
- long nStepCount = rGradient.GetSteps();
- // generate nStepCount, if not passed
- long nMinRect = aRect.GetHeight();
- if ( !nStepCount )
- {
- long nInc = 1;
- if ( meOutDevType != OUTDEV_PRINTER && !bMtf )
- {
- nInc = (nMinRect < 50) ? 2 : 4;
- }
- else
- {
- // Use display-equivalent step size calculation
- nInc = (nMinRect < 800) ? 10 : 20;
- }
- nStepCount = nMinRect / nInc;
- }
+ long nStepCount = ImplGetGradientSteps( rGradient, aRect, bMtf );
// minimal three steps and maximal as max color steps
long nAbsRedSteps = std::abs( nEndRed - nStartRed );
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 92a7d3d7f486..8e97d4bc62c2 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -663,6 +663,13 @@ void Printer::ImplUpdateFontList()
ImplUpdateFontData( true );
}
+long Printer::ImplGetGradientStepCount( long nMinRect )
+{
+ // use display-equivalent step size calculation
+ long nInc = (nMinRect < 800) ? 10 : 20;
+
+ return nInc;
+}
Printer::Printer()
{