summaryrefslogtreecommitdiff
path: root/basegfx/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-03-14 10:20:12 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-03-14 10:20:43 +0000
commit92c5d7f0aca578cd27506f8652fdb1c6ddb78541 (patch)
tree7b44fae8c09a52ea249efb01c745fe08a84131b0 /basegfx/source
parent0bd50d04cc8e67369b0263c199a8577ec89b8594 (diff)
Related: rhbz#684477 make sure this is thread safe
Diffstat (limited to 'basegfx/source')
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx34
1 files changed, 22 insertions, 12 deletions
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index 5f053b4b22e2..eb96cec171e9 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -32,6 +32,7 @@
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <osl/diagnose.h>
#include <rtl/math.hxx>
+#include <rtl/instance.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/range/b2drange.hxx>
@@ -1836,22 +1837,31 @@ namespace basegfx
return aRetval;
}
- B2DPolygon createUnitPolygon()
+ namespace
{
- static B2DPolygon aRetval;
-
- if(!aRetval.count())
+ struct theUnitPolygon :
+ public rtl::StaticWithInit<B2DPolygon, theUnitPolygon>
{
- aRetval.append( B2DPoint( 0.0, 0.0 ) );
- aRetval.append( B2DPoint( 1.0, 0.0 ) );
- aRetval.append( B2DPoint( 1.0, 1.0 ) );
- aRetval.append( B2DPoint( 0.0, 1.0 ) );
+ B2DPolygon operator () ()
+ {
+ B2DPolygon aRetval;
- // close
- aRetval.setClosed( true );
- }
+ aRetval.append( B2DPoint( 0.0, 0.0 ) );
+ aRetval.append( B2DPoint( 1.0, 0.0 ) );
+ aRetval.append( B2DPoint( 1.0, 1.0 ) );
+ aRetval.append( B2DPoint( 0.0, 1.0 ) );
- return aRetval;
+ // close
+ aRetval.setClosed( true );
+
+ return aRetval;
+ }
+ };
+ }
+
+ B2DPolygon createUnitPolygon()
+ {
+ return theUnitPolygon::get();
}
B2DPolygon createPolygonFromCircle( const B2DPoint& rCenter, double fRadius )