34 #define GRADIENT_DEFAULT_STEPCOUNT 0
57 if ( rPolyPoly.
Count() && rPolyPoly[ 0 ].GetSize() )
91 if ( !aRect.IsEmpty() )
129 aRect.AdjustLeft( -1 );
130 aRect.AdjustTop( -1 );
131 aRect.AdjustRight( 1 );
132 aRect.AdjustBottom( 1 );
137 if( aGradient.
GetStyle() == GradientStyle::Linear || rGradient.
GetStyle() == GradientStyle::Axial )
183 if ( !(rPolyPoly.
Count() && rPolyPoly[ 0 ].GetSize()) )
188 if (aBoundRect.IsEmpty())
217 else if ( nValue > 0xFF )
237 bool bLinear = (rGradient.
GetStyle() == GradientStyle::Linear);
261 nStartRed = (nStartRed * nFactor) / 100;
262 nStartGreen = (nStartGreen * nFactor) / 100;
263 nStartBlue = (nStartBlue * nFactor) / 100;
265 nEndRed = (nEndRed * nFactor) / 100;
266 nEndGreen = (nEndGreen * nFactor) / 100;
267 nEndBlue = (nEndBlue * nFactor) / 100;
274 nEndRed = nTempColor;
275 nTempColor = nStartGreen;
276 nStartGreen = nEndGreen;
277 nEndGreen = nTempColor;
278 nTempColor = nStartBlue;
279 nStartBlue = nEndBlue;
280 nEndBlue = nTempColor;
292 nRed =
static_cast<sal_uInt8>(nStartRed);
293 nGreen =
static_cast<sal_uInt8>(nStartGreen);
294 nBlue =
static_cast<sal_uInt8>(nStartBlue);
298 aBorderRect.
SetBottom( static_cast<tools::Long>( aBorderRect.
Top() + fBorder ) );
300 aPoly[0] = aBorderRect.
TopLeft();
304 aPoly.
Rotate( aCenter, nAngle );
310 aBorderRect = aMirrorRect;
311 aBorderRect.
SetTop( static_cast<tools::Long>( aBorderRect.
Bottom() - fBorder ) );
313 aPoly[0] = aBorderRect.
TopLeft();
317 aPoly.
Rotate( aCenter, nAngle );
327 tools::Long nAbsRedSteps = std::abs( nEndRed - nStartRed );
328 tools::Long nAbsGreenSteps = std::abs( nEndGreen - nStartGreen );
329 tools::Long nAbsBlueSteps = std::abs( nEndBlue - nStartBlue );
330 tools::Long nMaxColorSteps = std::max( nAbsRedSteps , nAbsGreenSteps );
331 nMaxColorSteps = std::max( nMaxColorSteps, nAbsBlueSteps );
332 tools::Long nSteps = std::min( nStepCount, nMaxColorSteps );
338 double fScanInc =
static_cast<double>(aRect.
GetHeight()) / static_cast<double>(nSteps);
339 double fGradientLine =
static_cast<double>(aRect.
Top());
340 double fMirrorGradientLine =
static_cast<double>(aMirrorRect.
Bottom());
342 const double fStepsMinus1 =
static_cast<double>(nSteps) - 1.0;
351 const double fAlpha =
static_cast<double>(
i) / fStepsMinus1;
352 double fTempColor =
static_cast<double>(nStartRed) * (1.0-fAlpha) +
static_cast<double>(nEndRed) * fAlpha;
354 fTempColor =
static_cast<double>(nStartGreen) * (1.0-fAlpha) +
static_cast<double>(nEndGreen) * fAlpha;
356 fTempColor =
static_cast<double>(nStartBlue) * (1.0-fAlpha) +
static_cast<double>(nEndBlue) * fAlpha;
362 aRect.
SetTop( static_cast<tools::Long>( fGradientLine + static_cast<double>(
i) * fScanInc ) );
363 aRect.
SetBottom( static_cast<tools::Long>( fGradientLine + ( static_cast<double>(
i) + 1.0 ) * fScanInc ) );
368 aPoly.
Rotate( aCenter, nAngle );
374 aMirrorRect.
SetBottom( static_cast<tools::Long>( fMirrorGradientLine - static_cast<double>(
i) * fScanInc ) );
375 aMirrorRect.
SetTop( static_cast<tools::Long>( fMirrorGradientLine - (static_cast<double>(
i) + 1.0)* fScanInc ) );
376 aPoly[0] = aMirrorRect.
TopLeft();
380 aPoly.
Rotate( aCenter, nAngle );
395 aRect.
SetTop( static_cast<tools::Long>( fGradientLine + static_cast<double>(nSteps) * fScanInc ) );
396 aRect.
SetBottom( static_cast<tools::Long>( fMirrorGradientLine - static_cast<double>(nSteps) * fScanInc ) );
401 aPoly.
Rotate( aCenter, nAngle );
410 return pOwnerWindow && pOwnerWindow->SupportsDoubleBuffering();
425 std::optional<tools::PolyPolygon> xPolyPoly;
452 if ( nTempSteps > nCalcSteps )
453 nCalcSteps = nTempSteps;
454 nTempSteps = std::abs( nBlueSteps );
455 if ( nTempSteps > nCalcSteps )
456 nCalcSteps = nTempSteps;
457 if ( nCalcSteps < nSteps )
464 double fScanLeft = aRect.
Left();
465 double fScanTop = aRect.
Top();
466 double fScanRight = aRect.
Right();
467 double fScanBottom = aRect.
Bottom();
468 double fScanIncX =
static_cast<double>(aRect.
GetWidth()) / static_cast<double>(nSteps) * 0.5;
469 double fScanIncY =
static_cast<double>(aRect.
GetHeight()) / static_cast<double>(nSteps) * 0.5;
474 if( rGradient.
GetStyle() != GradientStyle::Square )
476 fScanIncY = std::min( fScanIncY, fScanIncX );
477 fScanIncX = fScanIncY;
479 sal_uInt8 nRed =
static_cast<sal_uInt8>(nStartRed), nGreen = static_cast<sal_uInt8>(nStartGreen), nBlue =
static_cast<sal_uInt8>(nStartBlue);
480 bool bPaintLastPolygon(
false );
487 xPolyPoly->Insert( aPoly );
488 xPolyPoly->Insert( aPoly );
508 fScanLeft += fScanIncX;
509 aRect.
SetLeft( static_cast<tools::Long>( fScanLeft ) );
510 fScanTop += fScanIncY;
511 aRect.
SetTop( static_cast<tools::Long>( fScanTop ) );
512 fScanRight -= fScanIncX;
513 aRect.
SetRight( static_cast<tools::Long>( fScanRight ) );
514 fScanBottom -= fScanIncY;
515 aRect.
SetBottom( static_cast<tools::Long>( fScanBottom ) );
520 if( rGradient.
GetStyle() == GradientStyle::Radial || rGradient.
GetStyle() == GradientStyle::Elliptical )
525 aPoly.
Rotate( aCenter, nAngle );
528 const tools::Long nStepIndex = ( xPolyPoly ?
i : (
i + 1 ) );
536 bPaintLastPolygon =
true;
538 xPolyPoly->Replace( xPolyPoly->GetObject( 1 ), 0 );
539 xPolyPoly->Replace( aPoly, 1 );
573 if( bPaintLastPolygon )
601 if (rGradient.
GetStyle() == GradientStyle::Linear || rGradient.
GetStyle() == GradientStyle::Axial)
611 return nMinRect / nInc;
void EnableOutput(bool bEnable=true)
virtual tools::Long GetGradientStepCount(tools::Long nMinRect)
GradientStyle GetStyle() const
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
virtual bool UsePolyPolygonForComplexGradient()=0
SAL_DLLPRIVATE void DrawComplexGradient(const tools::Rectangle &rRect, const Gradient &rGradient, const tools::PolyPolygon *pClipPolyPoly)
const StyleSettings & GetStyleSettings() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
bool IsOutputEnabled() const
sal_uInt16 GetBorder() const
SAL_DLLPRIVATE bool is_double_buffered_window() const
void IntersectClipRegion(const tools::Rectangle &rRect)
SAL_DLLPRIVATE Color GetSingleColorGradientFill()
#define GRADIENT_DEFAULT_STEPCOUNT
SAL_DLLPRIVATE void DrawGradientToMetafile(const tools::PolyPolygon &rPolyPoly, const Gradient &rGradient)
bool DrawGradient(const tools::PolyPolygon &rPolyPoly, const Gradient &rGradient, const OutputDevice &rOutDev)
void SetSteps(sal_uInt16 nSteps)
SAL_DLLPRIVATE void DrawLinearGradient(const tools::Rectangle &rRect, const Gradient &rGradient, const tools::PolyPolygon *pClipPolyPoly)
sal_uInt8 GetBlue() const
static sal_uInt8 GetGradientColorValue(tools::Long nValue)
SalGraphics * mpGraphics
Graphics context to draw on.
virtual void SetFillColor()=0
void GetBoundRect(const tools::Rectangle &rRect, tools::Rectangle &rBoundRect, Point &rCenter) const
virtual void SetLineColor()=0
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
Size GetOutputSize() const
sal_uInt16 GetEndIntensity() const
const AllSettings & GetSettings() const
sal_uInt16 GetSteps() const
const Color & GetStartColor() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
sal_uInt8 GetGreen() const
VclPtr< VirtualDevice > mpAlphaVDev
Degree10 GetAngle() const
SAL_DLLPRIVATE void ImplDrawPolyPolygon(const tools::PolyPolygon &rPolyPoly, const tools::PolyPolygon *pClipPolyPoly)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
const Color & GetEndColor() const
void SetRasterOp(RasterOp eRasterOp)
SAL_DLLPRIVATE tools::Long GetGradientSteps(Gradient const &rGradient, tools::Rectangle const &rRect)
void DrawPolyPolygon(const tools::PolyPolygon &rPolyPoly)
Render the given poly-polygon.
virtual void InitClipRegion()
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
const Color & GetWindowColor() const
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel(const tools::Rectangle &rLogicRect) const
Convert a logical rectangle to a rectangle in physical device pixel units.
bool IsDeviceOutputNecessary() const
void DrawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
virtual vcl::Window * GetOwnerWindow() const
Get the vcl::Window that this OutputDevice belongs to, if any.
sal_uInt16 GetStartIntensity() const
virtual void ClipAndDrawGradientMetafile(const Gradient &rGradient, const tools::PolyPolygon &rPolyPoly)
const Color & GetFillColor() const
SAL_DLLPRIVATE void ImplDrawPolygon(const tools::Polygon &rPoly, const tools::PolyPolygon *pClipPolyPoly=nullptr)