summaryrefslogtreecommitdiff
path: root/vcl/aqua
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-12-03 17:47:10 +0100
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM>2010-12-03 17:47:10 +0100
commit65d95afb7eadeabb540de3a3ea31a35ae41ec70e (patch)
treebb5e96e00ee903a758f47dad9bb62b651a2e3106 /vcl/aqua
parentead04f8f0b7f51bf281ce41d8d590df0ca14af38 (diff)
vcl118: #i115905# improved clip region interface on SAL layer (part 2, mac implementation)
Diffstat (limited to 'vcl/aqua')
-rw-r--r--vcl/aqua/inc/salgdi.h8
-rw-r--r--vcl/aqua/source/gdi/salgdi.cxx59
2 files changed, 27 insertions, 40 deletions
diff --git a/vcl/aqua/inc/salgdi.h b/vcl/aqua/inc/salgdi.h
index 17c4aa7acd44..b1262dca499c 100644
--- a/vcl/aqua/inc/salgdi.h
+++ b/vcl/aqua/inc/salgdi.h
@@ -176,8 +176,7 @@ public:
// InvalidateContext does an UnsetState and sets mrContext to 0
void InvalidateContext();
- virtual BOOL unionClipRegion( long nX, long nY, long nWidth, long nHeight );
- virtual bool unionClipRegion( const ::basegfx::B2DPolyPolygon& );
+ virtual bool setClipRegion( const Region& );
// draw --> LineColor and FillColor and RasterOp and ClipRegion
virtual void drawPixel( long nX, long nY );
@@ -250,11 +249,6 @@ public:
// set the clip region to empty
virtual void ResetClipRegion();
- // begin setting the clip region, add rectangles to the
- // region with the UnionClipRegion call
- virtual void BeginSetClipRegion( ULONG nCount );
- // all rectangles were added and the clip region should be set now
- virtual void EndSetClipRegion();
// set the line color to transparent (= don't draw lines)
virtual void SetLineColor();
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx
index e1daf649f6da..9fcf3edcdddf 100644
--- a/vcl/aqua/source/gdi/salgdi.cxx
+++ b/vcl/aqua/source/gdi/salgdi.cxx
@@ -41,6 +41,7 @@
#include "vcl/sysdata.hxx"
#include "vcl/sallayout.hxx"
#include "vcl/svapp.hxx"
+#include "vcl/region.h"
#include "osl/file.hxx"
#include "osl/process.h"
@@ -562,7 +563,7 @@ void AquaSalGraphics::ResetClipRegion()
// -----------------------------------------------------------------------
-void AquaSalGraphics::BeginSetClipRegion( ULONG nRectCount )
+bool AquaSalGraphics::setClipRegion( const Region& i_rClip )
{
// release old clip path
if( mxClipPath )
@@ -570,41 +571,33 @@ void AquaSalGraphics::BeginSetClipRegion( ULONG nRectCount )
CGPathRelease( mxClipPath );
mxClipPath = NULL;
}
-}
-
-// -----------------------------------------------------------------------
-
-BOOL AquaSalGraphics::unionClipRegion( long nX, long nY, long nWidth, long nHeight )
-{
- if( (nWidth <= 0) || (nHeight <= 0) )
- return TRUE;
-
- if( !mxClipPath )
- mxClipPath = CGPathCreateMutable();
- const CGRect aClipRect = {{nX,nY},{nWidth,nHeight}};
- CGPathAddRect( mxClipPath, NULL, aClipRect );
- return TRUE;
-}
-
-// -----------------------------------------------------------------------
-
-bool AquaSalGraphics::unionClipRegion( const ::basegfx::B2DPolyPolygon& rPolyPolygon )
-{
- if( rPolyPolygon.count() <= 0 )
- return true;
-
- if( !mxClipPath )
- mxClipPath = CGPathCreateMutable();
- AddPolyPolygonToPath( mxClipPath, rPolyPolygon, !getAntiAliasB2DDraw(), false );
- return true;
-}
-
-// -----------------------------------------------------------------------
+ mxClipPath = CGPathCreateMutable();
-void AquaSalGraphics::EndSetClipRegion()
-{
+ // set current path, either as polypolgon or sequence of rectangles
+ if( i_rClip.HasPolyPolygon() )
+ {
+ basegfx::B2DPolyPolygon aClip( const_cast<Region&>(i_rClip).ConvertToB2DPolyPolygon() );
+ AddPolyPolygonToPath( mxClipPath, aClip, !getAntiAliasB2DDraw(), false );
+ }
+ else
+ {
+ long nX, nY, nW, nH;
+ ImplRegionInfo aInfo;
+ bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH );
+ while( bRegionRect )
+ {
+ if( nW && nH )
+ {
+ CGRect aRect = {{nX,nY}, {nW,nH}};
+ CGPathAddRect( mxClipPath, NULL, aRect );
+ }
+ bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH );
+ }
+ }
+ // set the current path as clip region
if( CheckContext() )
SetState();
+ return true;
}
// -----------------------------------------------------------------------