summaryrefslogtreecommitdiff
path: root/include/vcl
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-10-23 12:46:28 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-12 14:31:10 +0100
commite717d1dcce7f8906311c5ccdbb2326b61a702630 (patch)
tree91290db5179fa4b4927af94c0f023f40dcda434c /include/vcl
parent9e50e5f82927742c56e89258b80bc8cd93bb7e3b (diff)
Resolves: #i121237# Rework/Cleanup of Region code...
due to missing complete support for B2DPolygon class (cherry picked from commit cab10eeb7878edf224a004fd7640bd4adf8d3c51) Conflicts: cppcanvas/source/mtfrenderer/implrenderer.cxx svx/source/sdr/overlay/overlaymanagerbuffered.cxx svx/source/svdraw/svdpntv.cxx vcl/aqua/source/gdi/salgdi.cxx vcl/inc/region.h vcl/inc/unx/gtk/gtkgdi.hxx vcl/inc/vcl/regband.hxx vcl/inc/vcl/region.hxx vcl/os2/source/gdi/salgdi.cxx vcl/source/gdi/bmpacc3.cxx vcl/source/gdi/outdev2.cxx vcl/source/gdi/outmap.cxx vcl/source/gdi/regband.cxx vcl/source/gdi/region.cxx vcl/source/window/window.cxx vcl/unx/generic/gdi/pspgraphics.cxx vcl/unx/headless/svpgdi.cxx vcl/unx/headless/svppspgraphics.cxx vcl/win/source/gdi/salgdi.cxx Change-Id: Iee9a66ff431c3cecb7603e445147b67715de0f7d Remove unused variable to prevent compiler warning (cherry picked from commit 0ac65ccf079e3e22ac23cbe7ae546504c863c31f) Change-Id: Icbcaa9d576a7e560d96debc7360bdbe9090b3fd3 Wrong comparison with bool corrected (cherry picked from commit 612cefdcf6176b6bb847ce899d89af40ef313a90) Change-Id: I1cf5de6734b588f78d8e870ba7b7860634b461ce
Diffstat (limited to 'include/vcl')
-rw-r--r--include/vcl/bmpacc.hxx6
-rw-r--r--include/vcl/outdev.hxx12
-rw-r--r--include/vcl/regband.hxx23
-rw-r--r--include/vcl/region.hxx167
4 files changed, 106 insertions, 102 deletions
diff --git a/include/vcl/bmpacc.hxx b/include/vcl/bmpacc.hxx
index 306f28a5b0b2..f3f5301c2567 100644
--- a/include/vcl/bmpacc.hxx
+++ b/include/vcl/bmpacc.hxx
@@ -195,6 +195,12 @@ public:
void FillRect( const Rectangle& rRect );
void DrawRect( const Rectangle& rRect );
+ void FillPolygon( const Polygon& rPoly );
+ void DrawPolygon( const Polygon& rPoly );
+
+ void FillPolyPolygon( const PolyPolygon& rPoly );
+ void DrawPolyPolygon( const PolyPolygon& rPolyPoly );
+
private:
BitmapColor* mpLineColor;
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index b3a2f9ef87e1..b76598f08452 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -965,6 +965,7 @@ public:
Rectangle LogicToPixel( const Rectangle& rLogicRect ) const;
Polygon LogicToPixel( const Polygon& rLogicPoly ) const;
PolyPolygon LogicToPixel( const PolyPolygon& rLogicPolyPoly ) const;
+ basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const;
Region LogicToPixel( const Region& rLogicRegion )const;
Point LogicToPixel( const Point& rLogicPt,
const MapMode& rMapMode ) const;
@@ -974,12 +975,19 @@ public:
const MapMode& rMapMode ) const;
Polygon LogicToPixel( const Polygon& rLogicPoly,
const MapMode& rMapMode ) const;
+ basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPoly,
+ const MapMode& rMapMode ) const;
+ PolyPolygon LogicToPixel( const PolyPolygon& rLogicPolyPoly,
+ const MapMode& rMapMode ) const;
basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly,
const MapMode& rMapMode ) const;
+ Region LogicToPixel( const Region& rLogicRegion,
+ const MapMode& rMapMode ) const;
Point PixelToLogic( const Point& rDevicePt ) const;
Size PixelToLogic( const Size& rDeviceSize ) const;
Rectangle PixelToLogic( const Rectangle& rDeviceRect ) const;
Polygon PixelToLogic( const Polygon& rDevicePoly ) const;
+ basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPoly ) const;
PolyPolygon PixelToLogic( const PolyPolygon& rDevicePolyPoly ) const;
basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly ) const;
Region PixelToLogic( const Region& rDeviceRegion ) const;
@@ -993,8 +1001,12 @@ public:
const MapMode& rMapMode ) const;
basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly,
const MapMode& rMapMode ) const;
+ PolyPolygon PixelToLogic( const PolyPolygon& rDevicePolyPoly,
+ const MapMode& rMapMode ) const;
basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly,
const MapMode& rMapMode ) const;
+ Region PixelToLogic( const Region& rDeviceRegion,
+ const MapMode& rMapMode ) const;
Point LogicToLogic( const Point& rPtSource,
const MapMode* pMapModeSource,
const MapMode* pMapModeDest ) const;
diff --git a/include/vcl/regband.hxx b/include/vcl/regband.hxx
index 0b60a801d83e..24fe7584a7b7 100644
--- a/include/vcl/regband.hxx
+++ b/include/vcl/regband.hxx
@@ -49,7 +49,7 @@ struct ImplRegionBandSep
ImplRegionBandSep* mpNextSep;
long mnXLeft;
long mnXRight;
- sal_Bool mbRemoved;
+ bool mbRemoved;
};
enum LineType { LINE_ASCENDING, LINE_DESCENDING, LINE_HORIZONTAL };
@@ -60,7 +60,7 @@ struct ImplRegionBandPoint
ImplRegionBandPoint* mpNextBandPoint;
long mnX;
long mnLineId;
- sal_Bool mbEndPoint;
+ bool mbEndPoint;
LineType meLineType;
};
@@ -77,7 +77,9 @@ public:
ImplRegionBandPoint* mpFirstBandPoint; // root of the list with lines
long mnYTop; // actual boundary of the band
long mnYBottom;
- sal_Bool mbTouched;
+
+ // bitfield
+ bool mbTouched : 1;
// create y-band with boundaries
ImplRegionBand( long nYTop, long nYBottom );
@@ -102,14 +104,14 @@ public:
long GetXRightBoundary() const;
// combine overlapping bands
- sal_Bool OptimizeBand();
+ bool OptimizeBand();
// generate separations from lines and process
// union with existing separations
void ProcessPoints();
// insert point in the list for later processing
- sal_Bool InsertPoint( long nX, long nLineID,
- sal_Bool bEndPoint, LineType eLineType );
+ bool InsertPoint( long nX, long nLineID,
+ bool bEndPoint, LineType eLineType );
void Union( long nXLeft, long nXRight );
void Intersect( long nXLeft, long nXRight );
@@ -119,11 +121,14 @@ public:
void MoveX( long nHorzMove );
void ScaleX( double fHorzScale );
- sal_Bool IsInside( long nX );
+ bool IsInside( long nX );
+ bool IsInside( long nLeft, long nRight );
+ bool IsOver( long nLeft, long nRight );
+
- sal_Bool IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); }
+ bool IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); }
- sal_Bool operator==( const ImplRegionBand& rRegionBand ) const;
+ bool operator==( const ImplRegionBand& rRegionBand ) const;
/** Split the called band at the given vertical coordinate. After the
split the called band will cover the upper part not including nY.
diff --git a/include/vcl/region.hxx b/include/vcl/region.hxx
index 88c55ea5b5fc..f2298e7a5d2a 100644
--- a/include/vcl/region.hxx
+++ b/include/vcl/region.hxx
@@ -25,115 +25,96 @@
#include <vcl/dllapi.h>
#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <boost/shared_ptr.hpp>
-class ImplRegion;
class ImplRegionBand;
+class RegionBand;
class Polygon;
class PolyPolygon;
-struct ImplRegionInfo;
-// --------------
-// - RegionType -
-// --------------
+//////////////////////////////////////////////////////////////////////////////
-enum RegionType { REGION_NULL, REGION_EMPTY, REGION_RECTANGLE, REGION_COMPLEX };
-enum RegionOverlapType { REGION_INSIDE, REGION_OVER, REGION_OUTSIDE };
+typedef boost::shared_ptr< RegionBand > RegionBandPtr;
+typedef boost::shared_ptr< PolyPolygon > PolyPolygonPtr;
+typedef boost::shared_ptr< basegfx::B2DPolyPolygon > B2DPolyPolygonPtr;
+typedef std::vector< Rectangle > RectangleVector;
-typedef sal_IntPtr RegionHandle;
-
-// ----------
-// - Region -
-// ----------
+//////////////////////////////////////////////////////////////////////////////
class VCL_DLLPUBLIC Region
{
+private:
friend class OutputDevice;
friend class Window;
friend class Bitmap;
-private:
- ImplRegion* mpImplRegion;
-
- SAL_DLLPRIVATE void ImplCopyData();
- SAL_DLLPRIVATE void ImplCreateRectRegion( const Rectangle& rRect );
- SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const PolyPolygon& rPolyPoly );
- SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const basegfx::B2DPolyPolygon& rPolyPoly );
- SAL_DLLPRIVATE void ImplPolyPolyRegionToBandRegionFunc();
- SAL_DLLPRIVATE inline void ImplPolyPolyRegionToBandRegion();
- SAL_DLLPRIVATE const ImplRegion* ImplGetImplRegion() const { return mpImplRegion; }
- SAL_DLLPRIVATE ImplRegion* ImplGetImplRegion() { return mpImplRegion; }
- SAL_DLLPRIVATE void ImplBeginAddRect( );
- SAL_DLLPRIVATE sal_Bool ImplAddRect( const Rectangle& rRect );
- SAL_DLLPRIVATE void ImplEndAddRect( );
- SAL_DLLPRIVATE void ImplIntersectWithPolyPolygon( const Region& );
- SAL_DLLPRIVATE void ImplExcludePolyPolygon( const Region& );
- SAL_DLLPRIVATE void ImplUnionPolyPolygon( const Region& );
- SAL_DLLPRIVATE void ImplXOrPolyPolygon( const Region& );
-
-public: // public within vcl
- VCL_PLUGIN_PUBLIC bool ImplGetFirstRect( ImplRegionInfo& rImplRegionInfo,
- long& nX, long& nY, long& nWidth, long& nHeight ) const;
- VCL_PLUGIN_PUBLIC bool ImplGetNextRect( ImplRegionInfo& rImplRegionInfo,
- long& nX, long& nY, long& nWidth, long& nHeight ) const;
-#ifdef DBG_UTIL
- friend const char* ImplDbgTestRegion( const void* pObj );
-#endif
+ // possible contents
+ B2DPolyPolygonPtr mpB2DPolyPolygon;
+ PolyPolygonPtr mpPolyPolygon;
+ RegionBandPtr mpRegionBand;
+
+ /// bitfield
+ bool mbIsNull : 1;
+
+ // helpers
+ SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const PolyPolygon& rPolyPoly );
+ SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const basegfx::B2DPolyPolygon& rPolyPoly );
+
+ SAL_DLLPRIVATE PolyPolygon ImplCreatePolyPolygonFromRegionBand() const;
+ SAL_DLLPRIVATE basegfx::B2DPolyPolygon ImplCreateB2DPolyPolygonFromRegionBand() const;
public:
- explicit Region();
- explicit Region( RegionType eType );
- explicit Region( const Rectangle& rRect );
- explicit Region( const Polygon& rPolygon );
- explicit Region( const PolyPolygon& rPolyPoly );
- explicit Region( const basegfx::B2DPolyPolygon& );
- Region( const Region& rRegion );
- ~Region();
-
- void Move( long nHorzMove, long nVertMove );
- void Scale( double fScaleX, double fScaleY );
- void Union( const Rectangle& rRegion );
- void Intersect( const Rectangle& rRegion );
- void Exclude( const Rectangle& rRegion );
- void XOr( const Rectangle& rRegion );
- void Union( const Region& rRegion );
- void Intersect( const Region& rRegion );
- void Exclude( const Region& rRegion );
- void XOr( const Region& rRegion );
-
- RegionType GetType() const;
- sal_Bool IsEmpty() const { return GetType() == REGION_EMPTY; };
- sal_Bool IsNull() const { return GetType() == REGION_NULL; };
-
- void SetEmpty();
- void SetNull();
-
- Rectangle GetBoundRect() const;
-
- sal_Bool HasPolyPolygon() const;
- PolyPolygon GetPolyPolygon() const;
- // returns an empty polypolygon in case HasPolyPolygon is sal_False
- const basegfx::B2DPolyPolygon GetB2DPolyPolygon() const;
- // returns a PolyPolygon either copied from the set PolyPolygon region
- // or created from the constituent rectangles
- basegfx::B2DPolyPolygon ConvertToB2DPolyPolygon();
-
- sal_uLong GetRectCount() const;
- RegionHandle BeginEnumRects();
- sal_Bool GetEnumRects( RegionHandle hRegionHandle, Rectangle& rRect );
- sal_Bool GetNextEnumRect( RegionHandle hRegionHandle, Rectangle& rRect )
- { return GetEnumRects( hRegionHandle, rRect ); }
- void EndEnumRects( RegionHandle hRegionHandle );
-
- sal_Bool IsInside( const Point& rPoint ) const;
- sal_Bool IsInside( const Rectangle& rRect ) const;
- sal_Bool IsOver( const Rectangle& rRect ) const;
-
- Region& operator=( const Region& rRegion );
- Region& operator=( const Rectangle& rRect );
-
- sal_Bool operator==( const Region& rRegion ) const;
- sal_Bool operator!=( const Region& rRegion ) const
- { return !(Region::operator==( rRegion )); }
+
+ explicit Region(bool bIsNull = false); // default creates empty region, with true a null region is created
+ explicit Region(const Rectangle& rRect);
+ explicit Region(const Polygon& rPolygon);
+ explicit Region(const PolyPolygon& rPolyPoly);
+ explicit Region(const basegfx::B2DPolyPolygon&);
+ Region(const Region& rRegion);
+ ~Region();
+
+ // direct access to contents
+ const basegfx::B2DPolyPolygon* getB2DPolyPolygon() const { return mpB2DPolyPolygon.get(); }
+ const PolyPolygon* getPolyPolygon() const { return mpPolyPolygon.get(); }
+ const RegionBand* getRegionBand() const { return mpRegionBand.get(); }
+
+ // access with converters, the asked data will be created from the most
+ // valuable data, buffered and returned
+ const PolyPolygon GetAsPolyPolygon() const;
+ const basegfx::B2DPolyPolygon GetAsB2DPolyPolygon() const;
+ const RegionBand* GetAsRegionBand() const;
+
+ // manipulators
+ void Move( long nHorzMove, long nVertMove );
+ void Scale( double fScaleX, double fScaleY );
+ bool Union( const Rectangle& rRegion );
+ bool Intersect( const Rectangle& rRegion );
+ bool Exclude( const Rectangle& rRegion );
+ bool XOr( const Rectangle& rRegion );
+ bool Union( const Region& rRegion );
+ bool Intersect( const Region& rRegion );
+ bool Exclude( const Region& rRegion );
+ bool XOr( const Region& rRegion );
+
+ bool IsEmpty() const;
+ bool IsNull() const;
+
+ void SetEmpty();
+ void SetNull();
+
+ Rectangle GetBoundRect() const;
+ bool HasPolyPolygonOrB2DPolyPolygon() const { return (getB2DPolyPolygon() || getPolyPolygon()); }
+ void GetRegionRectangles(RectangleVector& rTarget) const;
+
+ bool IsInside( const Point& rPoint ) const;
+ bool IsInside( const Rectangle& rRect ) const;
+ bool IsOver( const Rectangle& rRect ) const;
+
+ Region& operator=( const Region& rRegion );
+ Region& operator=( const Rectangle& rRect );
+
+ bool operator==( const Region& rRegion ) const;
+ bool operator!=( const Region& rRegion ) const { return !(Region::operator==( rRegion )); }
friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Region& rRegion );
friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Region& rRegion );