[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET Class Library (pnetlib)
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET Class Library (pnetlib) branch, master, updated. 90aad1719f92d9dc7ddd9163d394a3c1ba7c8afe |
Date: |
Tue, 27 Apr 2010 17:56:55 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET Class Library (pnetlib)".
The branch, master has been updated
via 90aad1719f92d9dc7ddd9163d394a3c1ba7c8afe (commit)
from d74009c50c7fa4d6a19698aa4d029ca938eb504a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnetlib.git/commit/?id=90aad1719f92d9dc7ddd9163d394a3c1ba7c8afe
commit 90aad1719f92d9dc7ddd9163d394a3c1ba7c8afe
Author: Klaus Treichel <address@hidden>
Date: Tue Apr 27 19:56:38 2010 +0200
Optimize some locks away.
diff --git a/ChangeLog b/ChangeLog
index 9b7ddd0..7c83f36 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-27 Klaus Treichel <address@hidden>
+
+ * System.Drawing/Graphics.cs: Create the default graphics object in
+ a static constructor so that a lock is not needed in the getter.
+ Cache DpiX and DpiY of the underlying IToolkitGraphics object to avoid
+ locking the graphics object in the getters.
+
2010-04-25 Klaus Treichel <address@hidden>
* tests/runtime/System/TestMath.cs (TestMathTanDouble): Add tests for
the
diff --git a/System.Drawing/Graphics.cs b/System.Drawing/Graphics.cs
index 5f884b1..14b5d80 100644
--- a/System.Drawing/Graphics.cs
+++ b/System.Drawing/Graphics.cs
@@ -36,14 +36,19 @@ using System.Drawing.Toolkit;
public sealed class Graphics : MarshalByRefObject, IDisposable
{
// Internal state.
+ // static members
+ internal static Graphics defaultGraphics;
+
+ // instance members
private IToolkitGraphics graphics;
private TextLayoutManager textLayoutManager;
private Region clip;
internal Matrix transform;
private float pageScale;
+ private float dpiX;
+ private float dpiY;
private GraphicsUnit pageUnit;
internal GraphicsContainer stackTop;
- internal static Graphics defaultGraphics;
// The window this graphics represents overlying the IToolkitGraphics
internal Rectangle baseWindow;
// The current clip in device coordinates - useful when deciding if
something
@@ -53,6 +58,14 @@ public sealed class Graphics : MarshalByRefObject,
IDisposable
// Default DPI for the screen.
internal const float DefaultScreenDpi = 96.0f;
+ // Static constructor
+ static Graphics()
+ {
+ defaultGraphics = new Graphics
+
(ToolkitManager.Toolkit.GetDefaultGraphics());
+ defaultGraphics.PageUnit = GraphicsUnit.Pixel;
+ }
+
// Constructor.
internal Graphics(IToolkitGraphics graphics)
{
@@ -63,6 +76,16 @@ public sealed class Graphics : MarshalByRefObject,
IDisposable
this.pageUnit = GraphicsUnit.World;
this.stackTop = null;
this.baseWindow = Rectangle.Empty;
+ if(graphics != null)
+ {
+ dpiX = graphics.DpiX;
+ dpiY = graphics.DpiY;
+ }
+ else
+ {
+ dpiX = DefaultScreenDpi;
+ dpiY = DefaultScreenDpi;
+ }
}
// Window Constructor. Copies the existing Graphics and creates a new
@@ -83,6 +106,8 @@ public sealed class Graphics : MarshalByRefObject,
IDisposable
{
// Use the same toolkit
this.graphics = graphics.graphics;
+ dpiX = graphics.DpiX;
+ dpiY = graphics.DpiY;
if (graphics.clip != null)
{
clip = graphics.clip.Clone();
@@ -122,6 +147,8 @@ public sealed class Graphics : MarshalByRefObject,
IDisposable
{
graphics.Dispose();
graphics = null;
+ dpiX = DefaultScreenDpi;
+ dpiY = DefaultScreenDpi;
}
if (clip != null)
{
@@ -212,34 +239,14 @@ public sealed class Graphics : MarshalByRefObject,
IDisposable
{
get
{
- lock(this)
- {
- if(graphics != null)
- {
- return graphics.DpiX;
- }
- else
- {
- return DefaultScreenDpi;
- }
- }
+ return dpiX;
}
}
public float DpiY
{
get
{
- lock(this)
- {
- if(graphics != null)
- {
- return graphics.DpiY;
- }
- else
- {
- return DefaultScreenDpi;
- }
- }
+ return dpiY;
}
}
public InterpolationMode InterpolationMode
@@ -4539,16 +4546,7 @@ public sealed class Graphics : MarshalByRefObject,
IDisposable
{
get
{
- lock(typeof(Graphics))
- {
- if(defaultGraphics == null)
- {
- defaultGraphics = new
Graphics
-
(ToolkitManager.Toolkit.GetDefaultGraphics());
-
defaultGraphics.PageUnit = GraphicsUnit.Pixel;
- }
- return defaultGraphics;
- }
+ return defaultGraphics;
}
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 7 +++++
System.Drawing/Graphics.cs | 64 +++++++++++++++++++++----------------------
2 files changed, 38 insertions(+), 33 deletions(-)
hooks/post-receive
--
DotGNU Portable.NET Class Library (pnetlib)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET Class Library (pnetlib) branch, master, updated. 90aad1719f92d9dc7ddd9163d394a3c1ba7c8afe,
Klaus Treichel <=