[Libreoffice-commits] .: 2 commits - basebmp/inc vcl/inc vcl/source
Thorsten Behrens
thorsten at kemper.freedesktop.org
Tue Feb 8 02:32:27 PST 2011
basebmp/inc/basebmp/accessortraits.hxx | 2
basebmp/inc/basebmp/metafunctions.hxx | 10 +++
basebmp/inc/basebmp/paletteformats.hxx | 2
vcl/inc/vcl/gradient.hxx | 3 +
vcl/source/gdi/gradient.cxx | 93 +++++++++++++++++++++++++++++++++
vcl/source/gdi/outdev4.cxx | 91 +++-----------------------------
6 files changed, 118 insertions(+), 83 deletions(-)
New commits:
commit 0f4b5e19fcc872bc7a452edc66cbcb6ce413b5d7
Author: Thorsten Behrens <tbehrens at novell.com>
Date: Tue Feb 8 11:28:22 2011 +0100
Remove last remaining SGI-ism from basebmp
Get rid of std::project2nd, which is an SGI extension to STL.
Permits build against compiler-provided stl, no need for stlport
anymore.
diff --git a/basebmp/inc/basebmp/accessortraits.hxx b/basebmp/inc/basebmp/accessortraits.hxx
index 15a5a04..d3f2e00 100644
--- a/basebmp/inc/basebmp/accessortraits.hxx
+++ b/basebmp/inc/basebmp/accessortraits.hxx
@@ -91,7 +91,7 @@ template< class Accessor > struct AccessorTraits
typedef typename Accessor::value_type value_type;
/// Retrieve stand-alone color lookup function for given Accessor type
- typedef std::project2nd< Accessor, value_type > color_lookup;
+ typedef project2nd< Accessor, value_type > color_lookup;
/// Retrieve raw pixel data accessor for given Accessor type
typedef Accessor raw_accessor;
diff --git a/basebmp/inc/basebmp/metafunctions.hxx b/basebmp/inc/basebmp/metafunctions.hxx
index bdd6b66..6d67aba 100644
--- a/basebmp/inc/basebmp/metafunctions.hxx
+++ b/basebmp/inc/basebmp/metafunctions.hxx
@@ -33,6 +33,8 @@
#include <vigra/metaprogramming.hxx>
#include <vigra/numerictraits.hxx>
+#include <functional>
+
namespace basebmp
{
@@ -217,6 +219,14 @@ template< typename T > inline T shiftRight( T v, int shift )
return shift > 0 ? v >> shift : v << (-shift);
}
+//--------------------------------------------------------------
+
+/// Replace non-std project2nd from SGI extensions
+template< typename T1, typename T2 >
+struct project2nd : public std::binary_function<T1, T2, T2>
+{
+ T2 operator() (const T1&, const T2& v) const { return v; }
+};
} // namespace basebmp
diff --git a/basebmp/inc/basebmp/paletteformats.hxx b/basebmp/inc/basebmp/paletteformats.hxx
index 0ba8cbb..d161d90 100644
--- a/basebmp/inc/basebmp/paletteformats.hxx
+++ b/basebmp/inc/basebmp/paletteformats.hxx
@@ -41,8 +41,6 @@
#include <vigra/numerictraits.hxx>
#include <vigra/metaprogramming.hxx>
-#include <functional>
-
namespace basebmp
{
commit cc7391712b64f0b805eaeeed6bc5b548003ca2d4
Author: Takeshi Kurosawa <taken.spc at gmail.com>
Date: Tue Feb 1 14:40:58 2011 +0900
Encapsulate calculation of gradient bounding box to Gradient::GetBoundRect
Export filters need to get gradient bounding box.
Signed-off-by: Thorsten Behrens <tbehrens at novell.com>
diff --git a/vcl/inc/vcl/gradient.hxx b/vcl/inc/vcl/gradient.hxx
index 46abd8d..f24ec95 100644
--- a/vcl/inc/vcl/gradient.hxx
+++ b/vcl/inc/vcl/gradient.hxx
@@ -31,6 +31,7 @@
#include <vcl/dllapi.h>
#include <tools/color.hxx>
+#include <tools/gen.hxx>
#include <vcl/vclenum.hxx>
@@ -119,6 +120,8 @@ public:
void SetSteps( USHORT nSteps );
USHORT GetSteps() const { return mpImplGradient->mnStepCount; }
+ void GetBoundRect( const Rectangle& rRect, Rectangle &rBoundRect, Point& rCenter ) const;
+
Gradient& operator=( const Gradient& rGradient );
BOOL operator==( const Gradient& rGradient ) const;
BOOL operator!=( const Gradient& rGradient ) const
diff --git a/vcl/source/gdi/gradient.cxx b/vcl/source/gdi/gradient.cxx
index d11d62e..297f30d 100644
--- a/vcl/source/gdi/gradient.cxx
+++ b/vcl/source/gdi/gradient.cxx
@@ -245,6 +245,99 @@ void Gradient::SetSteps( USHORT nSteps )
// -----------------------------------------------------------------------
+void Gradient::GetBoundRect( const Rectangle& rRect, Rectangle& rBoundRect, Point& rCenter ) const
+{
+ Rectangle aRect( rRect );
+ USHORT nAngle = GetAngle() % 3600;
+
+ if( GetStyle() == GRADIENT_LINEAR || GetStyle() == GRADIENT_AXIAL )
+ {
+ aRect.Left()--;
+ aRect.Top()--;
+ aRect.Right()++;
+ aRect.Bottom()++;
+
+ 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;
+
+ rBoundRect = aRect;
+ rCenter = rRect.Center();
+ }
+ else
+ {
+
+ if( GetStyle() == GRADIENT_SQUARE || 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( 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( 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( 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) GetOfsX() / 100;
+ long nZHeight = aRect.GetHeight() * (long) GetOfsY() / 100;
+ long nBorderX = (long) GetBorder() * aSize.Width() / 100;
+ long nBorderY = (long) GetBorder() * aSize.Height() / 100;
+ rCenter = Point( aRect.Left() + nZWidth, aRect.Top() + nZHeight );
+
+ // Rand beruecksichtigen
+ aSize.Width() -= nBorderX;
+ aSize.Height() -= nBorderY;
+
+ // Ausgaberechteck neu setzen
+ aRect.Left() = rCenter.X() - ( aSize.Width() >> 1 );
+ aRect.Top() = rCenter.Y() - ( aSize.Height() >> 1 );
+
+ aRect.SetSize( aSize );
+ rBoundRect = rRect;
+ }
+}
+
+// -----------------------------------------------------------------------
+
Gradient& Gradient::operator=( const Gradient& rGradient )
{
DBG_CHKTHIS( Gradient, NULL );
diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx
index e550225..cc6facf 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;
@@ -444,67 +428,14 @@ void OutputDevice::ImplDrawComplexGradient( const Rectangle& rRect,
long nBlueSteps = nEndBlue - nStartBlue;
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
More information about the Libreoffice-commits
mailing list