diff options
author | Armin Le Grand <alg@apache.org> | 2012-10-23 12:46:28 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-12 14:31:10 +0100 |
commit | e717d1dcce7f8906311c5ccdbb2326b61a702630 (patch) | |
tree | 91290db5179fa4b4927af94c0f023f40dcda434c /include/vcl/region.hxx | |
parent | 9e50e5f82927742c56e89258b80bc8cd93bb7e3b (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/region.hxx')
-rw-r--r-- | include/vcl/region.hxx | 167 |
1 files changed, 74 insertions, 93 deletions
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 ); |