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()) )
241 if( aGradient.
GetStyle() == GradientStyle::Linear || rGradient.
GetStyle() == GradientStyle::Axial )
253 else if ( nValue > 0xFF )
273 bool bLinear = (rGradient.
GetStyle() == GradientStyle::Linear);
297 nStartRed = (nStartRed * nFactor) / 100;
298 nStartGreen = (nStartGreen * nFactor) / 100;
299 nStartBlue = (nStartBlue * nFactor) / 100;
301 nEndRed = (nEndRed * nFactor) / 100;
302 nEndGreen = (nEndGreen * nFactor) / 100;
303 nEndBlue = (nEndBlue * nFactor) / 100;
310 nEndRed = nTempColor;
311 nTempColor = nStartGreen;
312 nStartGreen = nEndGreen;
313 nEndGreen = nTempColor;
314 nTempColor = nStartBlue;
315 nStartBlue = nEndBlue;
316 nEndBlue = nTempColor;
328 nRed =
static_cast<sal_uInt8>(nStartRed);
329 nGreen =
static_cast<sal_uInt8>(nStartGreen);
330 nBlue =
static_cast<sal_uInt8>(nStartBlue);
334 aBorderRect.
SetBottom( static_cast<tools::Long>( aBorderRect.
Top() + fBorder ) );
336 aPoly[0] = aBorderRect.
TopLeft();
340 aPoly.
Rotate( aCenter, nAngle );
346 aBorderRect = aMirrorRect;
347 aBorderRect.
SetTop( static_cast<tools::Long>( aBorderRect.
Bottom() - fBorder ) );
349 aPoly[0] = aBorderRect.
TopLeft();
353 aPoly.
Rotate( aCenter, nAngle );
363 tools::Long nAbsRedSteps = std::abs( nEndRed - nStartRed );
364 tools::Long nAbsGreenSteps = std::abs( nEndGreen - nStartGreen );
365 tools::Long nAbsBlueSteps = std::abs( nEndBlue - nStartBlue );
366 tools::Long nMaxColorSteps = std::max( nAbsRedSteps , nAbsGreenSteps );
367 nMaxColorSteps = std::max( nMaxColorSteps, nAbsBlueSteps );
368 tools::Long nSteps = std::min( nStepCount, nMaxColorSteps );
374 double fScanInc =
static_cast<double>(aRect.
GetHeight()) / static_cast<double>(nSteps);
375 double fGradientLine =
static_cast<double>(aRect.
Top());
376 double fMirrorGradientLine =
static_cast<double>(aMirrorRect.
Bottom());
378 const double fStepsMinus1 =
static_cast<double>(nSteps) - 1.0;
386 const double fAlpha =
static_cast<double>(
i) / fStepsMinus1;
387 double fTempColor =
static_cast<double>(nStartRed) * (1.0-fAlpha) +
static_cast<double>(nEndRed) * fAlpha;
388 nRed = GetGradientColorValue(static_cast<tools::Long>(fTempColor));
389 fTempColor =
static_cast<double>(nStartGreen) * (1.0-fAlpha) +
static_cast<double>(nEndGreen) * fAlpha;
390 nGreen = GetGradientColorValue(static_cast<tools::Long>(fTempColor));
391 fTempColor =
static_cast<double>(nStartBlue) * (1.0-fAlpha) +
static_cast<double>(nEndBlue) * fAlpha;
392 nBlue = GetGradientColorValue(static_cast<tools::Long>(fTempColor));
397 aRect.
SetTop( static_cast<tools::Long>( fGradientLine + static_cast<double>(
i) * fScanInc ) );
398 aRect.
SetBottom( static_cast<tools::Long>( fGradientLine + ( static_cast<double>(
i) + 1.0 ) * fScanInc ) );
403 aPoly.
Rotate( aCenter, nAngle );
409 aMirrorRect.
SetBottom( static_cast<tools::Long>( fMirrorGradientLine - static_cast<double>(
i) * fScanInc ) );
410 aMirrorRect.
SetTop( static_cast<tools::Long>( fMirrorGradientLine - (static_cast<double>(
i) + 1.0)* fScanInc ) );
411 aPoly[0] = aMirrorRect.
TopLeft();
415 aPoly.
Rotate( aCenter, nAngle );
424 nRed = GetGradientColorValue(nEndRed);
425 nGreen = GetGradientColorValue(nEndGreen);
426 nBlue = GetGradientColorValue(nEndBlue);
430 aRect.
SetTop( static_cast<tools::Long>( fGradientLine + static_cast<double>(nSteps) * fScanInc ) );
431 aRect.
SetBottom( static_cast<tools::Long>( fMirrorGradientLine - static_cast<double>(nSteps) * fScanInc ) );
436 aPoly.
Rotate( aCenter, nAngle );
460 std::unique_ptr<tools::PolyPolygon> xPolyPoly;
487 if ( nTempSteps > nCalcSteps )
488 nCalcSteps = nTempSteps;
489 nTempSteps = std::abs( nBlueSteps );
490 if ( nTempSteps > nCalcSteps )
491 nCalcSteps = nTempSteps;
492 if ( nCalcSteps < nSteps )
499 double fScanLeft = aRect.
Left();
500 double fScanTop = aRect.
Top();
501 double fScanRight = aRect.
Right();
502 double fScanBottom = aRect.
Bottom();
503 double fScanIncX =
static_cast<double>(aRect.
GetWidth()) / static_cast<double>(nSteps) * 0.5;
504 double fScanIncY =
static_cast<double>(aRect.
GetHeight()) / static_cast<double>(nSteps) * 0.5;
509 if( rGradient.
GetStyle() != GradientStyle::Square )
511 fScanIncY = std::min( fScanIncY, fScanIncX );
512 fScanIncX = fScanIncY;
514 sal_uInt8 nRed =
static_cast<sal_uInt8>(nStartRed), nGreen = static_cast<sal_uInt8>(nStartGreen), nBlue =
static_cast<sal_uInt8>(nStartBlue);
515 bool bPaintLastPolygon(
false );
522 xPolyPoly->Insert( aPoly );
523 xPolyPoly->Insert( aPoly );
543 fScanLeft += fScanIncX;
544 aRect.
SetLeft( static_cast<tools::Long>( fScanLeft ) );
545 fScanTop += fScanIncY;
546 aRect.
SetTop( static_cast<tools::Long>( fScanTop ) );
547 fScanRight -= fScanIncX;
548 aRect.
SetRight( static_cast<tools::Long>( fScanRight ) );
549 fScanBottom -= fScanIncY;
550 aRect.
SetBottom( static_cast<tools::Long>( fScanBottom ) );
555 if( rGradient.
GetStyle() == GradientStyle::Radial || rGradient.
GetStyle() == GradientStyle::Elliptical )
560 aPoly.
Rotate( aCenter, nAngle );
563 const tools::Long nStepIndex = ( xPolyPoly ?
i : (
i + 1 ) );
564 nRed = GetGradientColorValue( nStartRed + ( ( nRedSteps * nStepIndex ) / nSteps ) );
565 nGreen = GetGradientColorValue( nStartGreen + ( ( nGreenSteps * nStepIndex ) / nSteps ) );
566 nBlue = GetGradientColorValue( nStartBlue + ( ( nBlueSteps * nStepIndex ) / nSteps ) );
571 bPaintLastPolygon =
true;
573 xPolyPoly->Replace( xPolyPoly->GetObject( 1 ), 0 );
574 xPolyPoly->Replace( aPoly, 1 );
608 if( bPaintLastPolygon )
610 nRed = GetGradientColorValue( nEndRed );
611 nGreen = GetGradientColorValue( nEndGreen );
612 nBlue = GetGradientColorValue( nEndBlue );
631 bool bLinear = (rGradient.
GetStyle() == GradientStyle::Linear);
655 nStartRed = (nStartRed * nFactor) / 100;
656 nStartGreen = (nStartGreen * nFactor) / 100;
657 nStartBlue = (nStartBlue * nFactor) / 100;
659 nEndRed = (nEndRed * nFactor) / 100;
660 nEndGreen = (nEndGreen * nFactor) / 100;
661 nEndBlue = (nEndBlue * nFactor) / 100;
668 nEndRed = nTempColor;
669 nTempColor = nStartGreen;
670 nStartGreen = nEndGreen;
671 nEndGreen = nTempColor;
672 nTempColor = nStartBlue;
673 nStartBlue = nEndBlue;
674 nEndBlue = nTempColor;
686 nRed =
static_cast<sal_uInt8>(nStartRed);
687 nGreen =
static_cast<sal_uInt8>(nStartGreen);
688 nBlue =
static_cast<sal_uInt8>(nStartBlue);
692 aBorderRect.
SetBottom( static_cast<tools::Long>( aBorderRect.
Top() + fBorder ) );
694 aPoly[0] = aBorderRect.
TopLeft();
698 aPoly.
Rotate( aCenter, nAngle );
704 aBorderRect = aMirrorRect;
705 aBorderRect.
SetTop( static_cast<tools::Long>( aBorderRect.
Bottom() - fBorder ) );
707 aPoly[0] = aBorderRect.
TopLeft();
711 aPoly.
Rotate( aCenter, nAngle );
720 tools::Long nAbsRedSteps = std::abs( nEndRed - nStartRed );
721 tools::Long nAbsGreenSteps = std::abs( nEndGreen - nStartGreen );
722 tools::Long nAbsBlueSteps = std::abs( nEndBlue - nStartBlue );
723 tools::Long nMaxColorSteps = std::max( nAbsRedSteps , nAbsGreenSteps );
724 nMaxColorSteps = std::max( nMaxColorSteps, nAbsBlueSteps );
725 tools::Long nSteps = std::min( nStepCount, nMaxColorSteps );
731 double fScanInc =
static_cast<double>(aRect.
GetHeight()) / static_cast<double>(nSteps);
732 double fGradientLine =
static_cast<double>(aRect.
Top());
733 double fMirrorGradientLine =
static_cast<double>(aMirrorRect.
Bottom());
735 const double fStepsMinus1 =
static_cast<double>(nSteps) - 1.0;
743 double fAlpha =
static_cast<double>(
i) / fStepsMinus1;
744 double fTempColor =
static_cast<double>(nStartRed) * (1.0-fAlpha) +
static_cast<double>(nEndRed) * fAlpha;
745 nRed = GetGradientColorValue(static_cast<tools::Long>(fTempColor));
746 fTempColor =
static_cast<double>(nStartGreen) * (1.0-fAlpha) +
static_cast<double>(nEndGreen) * fAlpha;
747 nGreen = GetGradientColorValue(static_cast<tools::Long>(fTempColor));
748 fTempColor =
static_cast<double>(nStartBlue) * (1.0-fAlpha) +
static_cast<double>(nEndBlue) * fAlpha;
749 nBlue = GetGradientColorValue(static_cast<tools::Long>(fTempColor));
754 aRect.
SetTop( static_cast<tools::Long>( fGradientLine + static_cast<double>(
i) * fScanInc ) );
755 aRect.
SetBottom( static_cast<tools::Long>( fGradientLine + ( static_cast<double>(
i) + 1.0 ) * fScanInc ) );
760 aPoly.
Rotate( aCenter, nAngle );
766 aMirrorRect.
SetBottom( static_cast<tools::Long>( fMirrorGradientLine - static_cast<double>(
i) * fScanInc ) );
767 aMirrorRect.
SetTop( static_cast<tools::Long>( fMirrorGradientLine - (static_cast<double>(
i) + 1.0)* fScanInc ) );
768 aPoly[0] = aMirrorRect.
TopLeft();
772 aPoly.
Rotate( aCenter, nAngle );
781 nRed = GetGradientColorValue(nEndRed);
782 nGreen = GetGradientColorValue(nEndGreen);
783 nBlue = GetGradientColorValue(nEndBlue);
787 aRect.
SetTop( static_cast<tools::Long>( fGradientLine + static_cast<double>(nSteps) * fScanInc ) );
788 aRect.
SetBottom( static_cast<tools::Long>( fMirrorGradientLine - static_cast<double>(nSteps) * fScanInc ) );
793 aPoly.
Rotate( aCenter, nAngle );
810 std::unique_ptr<tools::PolyPolygon> xPolyPoly;
837 if ( nTempSteps > nCalcSteps )
838 nCalcSteps = nTempSteps;
839 nTempSteps = std::abs( nBlueSteps );
840 if ( nTempSteps > nCalcSteps )
841 nCalcSteps = nTempSteps;
842 if ( nCalcSteps < nSteps )
849 double fScanLeft = aRect.
Left();
850 double fScanTop = aRect.
Top();
851 double fScanRight = aRect.
Right();
852 double fScanBottom = aRect.
Bottom();
853 double fScanIncX =
static_cast<double>(aRect.
GetWidth()) / static_cast<double>(nSteps) * 0.5;
854 double fScanIncY =
static_cast<double>(aRect.
GetHeight()) / static_cast<double>(nSteps) * 0.5;
859 if( rGradient.
GetStyle() != GradientStyle::Square )
861 fScanIncY = std::min( fScanIncY, fScanIncX );
862 fScanIncX = fScanIncY;
864 sal_uInt8 nRed =
static_cast<sal_uInt8>(nStartRed), nGreen = static_cast<sal_uInt8>(nStartGreen), nBlue =
static_cast<sal_uInt8>(nStartBlue);
865 bool bPaintLastPolygon(
false );
870 xPolyPoly->Insert( aPoly );
871 xPolyPoly->Insert( aPoly );
877 fScanLeft += fScanIncX;
878 aRect.
SetLeft( static_cast<tools::Long>( fScanLeft ) );
879 fScanTop += fScanIncY;
880 aRect.
SetTop( static_cast<tools::Long>( fScanTop ) );
881 fScanRight -= fScanIncX;
882 aRect.
SetRight( static_cast<tools::Long>( fScanRight ) );
883 fScanBottom -= fScanIncY;
884 aRect.
SetBottom( static_cast<tools::Long>( fScanBottom ) );
889 if( rGradient.
GetStyle() == GradientStyle::Radial || rGradient.
GetStyle() == GradientStyle::Elliptical )
894 aPoly.
Rotate( aCenter, nAngle );
897 const tools::Long nStepIndex = ( xPolyPoly ?
i : (
i + 1 ) );
898 nRed = GetGradientColorValue( nStartRed + ( ( nRedSteps * nStepIndex ) / nSteps ) );
899 nGreen = GetGradientColorValue( nStartGreen + ( ( nGreenSteps * nStepIndex ) / nSteps ) );
900 nBlue = GetGradientColorValue( nStartBlue + ( ( nBlueSteps * nStepIndex ) / nSteps ) );
902 bPaintLastPolygon =
true;
904 xPolyPoly->Replace( xPolyPoly->GetObject( 1 ), 0 );
905 xPolyPoly->Replace( aPoly, 1 );
927 if( bPaintLastPolygon )
929 nRed = GetGradientColorValue( nEndRed );
930 nGreen = GetGradientColorValue( nEndGreen );
931 nBlue = GetGradientColorValue( nEndBlue );
964 nStepCount = nMinRect / nInc;
1018 if( aGradient.
GetStyle() == GradientStyle::Linear || aGradient.
GetStyle() == GradientStyle::Axial )
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)
SAL_DLLPRIVATE tools::Long GetGradientSteps(const Gradient &rGradient, const tools::Rectangle &rRect, bool bMtf, bool bComplex=false)
const StyleSettings & GetStyleSettings() const
bool IsOutputEnabled() const
sal_uInt16 GetBorder() const
SAL_DLLPRIVATE bool is_double_buffered_window() const
SAL_DLLPRIVATE void DrawLinearGradientToMetafile(const tools::Rectangle &rRect, const Gradient &rGradient)
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)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_uInt8 GetBlue() const
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
void AddGradientActions(const tools::Rectangle &rRect, const Gradient &rGradient, GDIMetaFile &rMtf)
const AllSettings & GetSettings() const
sal_uInt16 GetSteps() const
const Color & GetStartColor() const
Point PixelToLogic(const Point &rDevicePt) const
sal_uInt8 GetGreen() const
VclPtr< VirtualDevice > mpAlphaVDev
Degree10 GetAngle() const
SAL_DLLPRIVATE void DrawComplexGradientToMetafile(const tools::Rectangle &rRect, const Gradient &rGradient)
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)
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 Push(PushFlags nFlags=PushFlags::ALL)
void DrawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly...
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)