summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/outdev4.cxx
diff options
context:
space:
mode:
authorTakeshi Kurosawa <taken.spc@gmail.com>2011-02-01 14:40:58 +0900
committerThorsten Behrens <tbehrens@novell.com>2011-02-08 11:29:47 +0100
commit5e5abcdd6fcc2d87160baddc83c8c324ed211450 (patch)
treebed8e5acdfb6047bae5aec0b63475a97bf0c3cad /vcl/source/gdi/outdev4.cxx
parent5c7c8cd6ef60a77cdc37816734383229fbea75fc (diff)
Encapsulate calculation of gradient bounding box to Gradient::GetBoundRect
Export filters need to get gradient bounding box. Signed-off-by: Thorsten Behrens <tbehrens@novell.com>
Diffstat (limited to 'vcl/source/gdi/outdev4.cxx')
-rw-r--r--vcl/source/gdi/outdev4.cxx91
1 files changed, 11 insertions, 80 deletions
diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx
index 3a1644ebf7aa..2fd02378c9b0 100644
--- a/vcl/source/gdi/outdev4.cxx
+++ b/vcl/source/gdi/outdev4.cxx
@@ -175,42 +175,25 @@ void OutputDevice::ImplDrawLinearGradient( const Rectangle& rRect,
BOOL bMtf, const PolyPolygon* pClipPolyPoly )
{
// rotiertes BoundRect ausrechnen
- Rectangle aRect = rRect;
- aRect.Left()--;
- aRect.Top()--;
- aRect.Right()++;
- aRect.Bottom()++;
- USHORT nAngle = rGradient.GetAngle() % 3600;
- double fAngle = nAngle * F_PI1800;
- double fWidth = aRect.GetWidth();
- double fHeight = aRect.GetHeight();
- double fDX = fWidth * fabs( cos( fAngle ) ) +
- fHeight * fabs( sin( fAngle ) );
- double fDY = fHeight * fabs( cos( fAngle ) ) +
- fWidth * fabs( sin( fAngle ) );
- fDX = (fDX - fWidth) * 0.5 + 0.5;
- fDY = (fDY - fHeight) * 0.5 + 0.5;
- aRect.Left() -= (long)fDX;
- aRect.Right() += (long)fDX;
- aRect.Top() -= (long)fDY;
- aRect.Bottom() += (long)fDY;
+ Rectangle aRect;
+ Point aCenter;
+ USHORT nAngle = rGradient.GetAngle() % 3600;
+
+ rGradient.GetBoundRect( rRect, aRect, aCenter );
// Rand berechnen und Rechteck neu setzen
- Point aCenter = rRect.Center();
Rectangle aFullRect = aRect;
long nBorder = (long)rGradient.GetBorder() * aRect.GetHeight() / 100;
- BOOL bLinear;
// Rand berechnen und Rechteck neu setzen fuer linearen Farbverlauf
- if ( rGradient.GetStyle() == GRADIENT_LINEAR )
+ bool bLinear = (rGradient.GetStyle() == GRADIENT_LINEAR);
+ if ( bLinear )
{
- bLinear = TRUE;
aRect.Top() += nBorder;
}
// Rand berechnen und Rechteck neu setzen fuer axiale Farbverlauf
else
{
- bLinear = FALSE;
nBorder >>= 1;
aRect.Top() += nBorder;
@@ -430,7 +413,8 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect,
// Virtuelle Device werden auch ausgeklammert, da einige Treiber
// ansonsten zu langsam sind
PolyPolygon* pPolyPoly;
- Rectangle aRect( rRect );
+ Rectangle aRect;
+ Point aCenter;
Color aStartCol( rGradient.GetStartColor() );
Color aEndCol( rGradient.GetEndColor() );
long nStartRed = ( (long) aStartCol.GetRed() * rGradient.GetStartIntensity() ) / 100;
@@ -445,66 +429,13 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect,
long nStepCount = rGradient.GetSteps();
USHORT nAngle = rGradient.GetAngle() % 3600;
+ rGradient.GetBoundRect( rRect, aRect, aCenter );
+
if( (meRasterOp != ROP_OVERPAINT) || (meOutDevType != OUTDEV_WINDOW) || bMtf )
pPolyPoly = new PolyPolygon( 2 );
else
pPolyPoly = NULL;
- if( rGradient.GetStyle() == GRADIENT_SQUARE || rGradient.GetStyle() == GRADIENT_RECT )
- {
- const double fAngle = nAngle * F_PI1800;
- const double fWidth = aRect.GetWidth();
- const double fHeight = aRect.GetHeight();
- double fDX = fWidth * fabs( cos( fAngle ) ) + fHeight * fabs( sin( fAngle ) );
- double fDY = fHeight * fabs( cos( fAngle ) ) + fWidth * fabs( sin( fAngle ) );
-
- fDX = ( fDX - fWidth ) * 0.5 + 0.5;
- fDY = ( fDY - fHeight ) * 0.5 + 0.5;
-
- aRect.Left() -= (long) fDX;
- aRect.Right() += (long) fDX;
- aRect.Top() -= (long) fDY;
- aRect.Bottom() += (long) fDY;
- }
-
- Size aSize( aRect.GetSize() );
-
- if( rGradient.GetStyle() == GRADIENT_RADIAL )
- {
- // Radien-Berechnung fuer Kreis
- aSize.Width() = (long)(0.5 + sqrt((double)aSize.Width()*(double)aSize.Width() + (double)aSize.Height()*(double)aSize.Height()));
- aSize.Height() = aSize.Width();
- }
- else if( rGradient.GetStyle() == GRADIENT_ELLIPTICAL )
- {
- // Radien-Berechnung fuer Ellipse
- aSize.Width() = (long)( 0.5 + (double) aSize.Width() * 1.4142 );
- aSize.Height() = (long)( 0.5 + (double) aSize.Height() * 1.4142 );
- }
- else if( rGradient.GetStyle() == GRADIENT_SQUARE )
- {
- if ( aSize.Width() > aSize.Height() )
- aSize.Height() = aSize.Width();
- else
- aSize.Width() = aSize.Height();
- }
-
- // neue Mittelpunkte berechnen
- long nZWidth = aRect.GetWidth() * (long) rGradient.GetOfsX() / 100;
- long nZHeight = aRect.GetHeight() * (long) rGradient.GetOfsY() / 100;
- long nBorderX = (long) rGradient.GetBorder() * aSize.Width() / 100;
- long nBorderY = (long) rGradient.GetBorder() * aSize.Height() / 100;
- Point aCenter( aRect.Left() + nZWidth, aRect.Top() + nZHeight );
-
- // Rand beruecksichtigen
- aSize.Width() -= nBorderX;
- aSize.Height() -= nBorderY;
-
- // Ausgaberechteck neu setzen
- aRect.Left() = aCenter.X() - ( aSize.Width() >> 1 );
- aRect.Top() = aCenter.Y() - ( aSize.Height() >> 1 );
-
- aRect.SetSize( aSize );
long nMinRect = Min( aRect.GetWidth(), aRect.GetHeight() );
// Anzahl der Schritte berechnen, falls nichts uebergeben wurde