aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Scripting
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs33
1 files changed, 16 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 50afe8b..0ed094b 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -55,11 +55,12 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
55// private static byte[] s_asset2Data; 55// private static byte[] s_asset2Data;
56 56
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 private static object thisLock = new object();
59 private static Graphics m_graph = null; // just to get chars sizes
58 60
59 private Scene m_scene; 61 private Scene m_scene;
60 private IDynamicTextureManager m_textureManager; 62 private IDynamicTextureManager m_textureManager;
61 63
62 private Graphics m_graph;
63 private string m_fontName = "Arial"; 64 private string m_fontName = "Arial";
64 65
65 public VectorRenderModule() 66 public VectorRenderModule()
@@ -120,18 +121,15 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
120 public void GetDrawStringSize(string text, string fontName, int fontSize, 121 public void GetDrawStringSize(string text, string fontName, int fontSize,
121 out double xSize, out double ySize) 122 out double xSize, out double ySize)
122 { 123 {
123 lock (this) 124 lock (thisLock)
124 { 125 {
125 using (Font myFont = new Font(fontName, fontSize)) 126 using (Font myFont = new Font(fontName, fontSize))
126 { 127 {
127 SizeF stringSize = new SizeF(); 128 SizeF stringSize = new SizeF();
128 // XXX: This lock may be unnecessary. 129
129 lock (m_graph) 130 stringSize = m_graph.MeasureString(text, myFont);
130 { 131 xSize = stringSize.Width;
131 stringSize = m_graph.MeasureString(text, myFont); 132 ySize = stringSize.Height;
132 xSize = stringSize.Width;
133 ySize = stringSize.Height;
134 }
135 } 133 }
136 } 134 }
137 } 135 }
@@ -151,8 +149,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
151 149
152 // We won't dispose of these explicitly since this module is only removed when the entire simulator 150 // We won't dispose of these explicitly since this module is only removed when the entire simulator
153 // is shut down. 151 // is shut down.
154 Bitmap bitmap = new Bitmap(1024, 1024, PixelFormat.Format32bppArgb); 152 lock(thisLock)
155 m_graph = Graphics.FromImage(bitmap); 153 {
154 if(m_graph == null)
155 {
156 Bitmap bitmap = new Bitmap(32, 32, PixelFormat.Format32bppArgb);
157 m_graph = Graphics.FromImage(bitmap);
158 }
159 }
156 } 160 }
157 161
158 public void PostInitialise() 162 public void PostInitialise()
@@ -404,12 +408,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
404 } 408 }
405 finally 409 finally
406 { 410 {
407 // XXX: In testing, it appears that if multiple threads dispose of separate GDI+ objects simultaneously, 411 lock (thisLock)
408 // the native malloc heap can become corrupted, possibly due to a double free(). This may be due to
409 // bugs in the underlying libcairo used by mono's libgdiplus.dll on Linux/OSX. These problems were
410 // seen with both libcario 1.10.2-6.1ubuntu3 and 1.8.10-2ubuntu1. They go away if disposal is perfomed
411 // under lock.
412 lock (this)
413 { 412 {
414 if (graph != null) 413 if (graph != null)
415 graph.Dispose(); 414 graph.Dispose();