diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 05eaaec..f687646 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -30,6 +30,7 @@ using System.Drawing; | |||
30 | using System.Drawing.Imaging; | 30 | using System.Drawing.Imaging; |
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Linq; | ||
33 | using System.Net; | 34 | using System.Net; |
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -47,7 +48,6 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
47 | { | 48 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 50 | ||
50 | private string m_name = "VectorRenderModule"; | ||
51 | private Scene m_scene; | 51 | private Scene m_scene; |
52 | private IDynamicTextureManager m_textureManager; | 52 | private IDynamicTextureManager m_textureManager; |
53 | private Graphics m_graph; | 53 | private Graphics m_graph; |
@@ -61,12 +61,12 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
61 | 61 | ||
62 | public string GetContentType() | 62 | public string GetContentType() |
63 | { | 63 | { |
64 | return ("vector"); | 64 | return "vector"; |
65 | } | 65 | } |
66 | 66 | ||
67 | public string GetName() | 67 | public string GetName() |
68 | { | 68 | { |
69 | return m_name; | 69 | return Name; |
70 | } | 70 | } |
71 | 71 | ||
72 | public bool SupportsAsynchronous() | 72 | public bool SupportsAsynchronous() |
@@ -74,14 +74,26 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
74 | return true; | 74 | return true; |
75 | } | 75 | } |
76 | 76 | ||
77 | // public bool AlwaysIdenticalConversion(string bodyData, string extraParams) | ||
78 | // { | ||
79 | // string[] lines = GetLines(bodyData); | ||
80 | // return lines.Any((str, r) => str.StartsWith("Image")); | ||
81 | // } | ||
82 | |||
77 | public byte[] ConvertUrl(string url, string extraParams) | 83 | public byte[] ConvertUrl(string url, string extraParams) |
78 | { | 84 | { |
79 | return null; | 85 | return null; |
80 | } | 86 | } |
81 | 87 | ||
82 | public byte[] ConvertStream(Stream data, string extraParams) | 88 | public byte[] ConvertData(string bodyData, string extraParams) |
83 | { | 89 | { |
84 | return null; | 90 | bool reuseable; |
91 | return Draw(bodyData, extraParams, out reuseable); | ||
92 | } | ||
93 | |||
94 | private byte[] ConvertData(string bodyData, string extraParams, out bool reuseable) | ||
95 | { | ||
96 | return Draw(bodyData, extraParams, out reuseable); | ||
85 | } | 97 | } |
86 | 98 | ||
87 | public bool AsyncConvertUrl(UUID id, string url, string extraParams) | 99 | public bool AsyncConvertUrl(UUID id, string url, string extraParams) |
@@ -91,7 +103,12 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
91 | 103 | ||
92 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) | 104 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) |
93 | { | 105 | { |
94 | Draw(bodyData, id, extraParams); | 106 | // XXX: This isn't actually being done asynchronously! |
107 | bool reuseable; | ||
108 | byte[] data = ConvertData(bodyData, extraParams, out reuseable); | ||
109 | |||
110 | m_textureManager.ReturnData(id, data, reuseable); | ||
111 | |||
95 | return true; | 112 | return true; |
96 | } | 113 | } |
97 | 114 | ||
@@ -152,7 +169,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
152 | 169 | ||
153 | public string Name | 170 | public string Name |
154 | { | 171 | { |
155 | get { return m_name; } | 172 | get { return "VectorRenderModule"; } |
156 | } | 173 | } |
157 | 174 | ||
158 | public bool IsSharedModule | 175 | public bool IsSharedModule |
@@ -162,7 +179,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
162 | 179 | ||
163 | #endregion | 180 | #endregion |
164 | 181 | ||
165 | private void Draw(string data, UUID id, string extraParams) | 182 | private byte[] Draw(string data, string extraParams, out bool reuseable) |
166 | { | 183 | { |
167 | // We need to cater for old scripts that didnt use extraParams neatly, they use either an integer size which represents both width and height, or setalpha | 184 | // We need to cater for old scripts that didnt use extraParams neatly, they use either an integer size which represents both width and height, or setalpha |
168 | // we will now support multiple comma seperated params in the form width:256,height:512,alpha:255 | 185 | // we will now support multiple comma seperated params in the form width:256,height:512,alpha:255 |
@@ -343,7 +360,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
343 | } | 360 | } |
344 | } | 361 | } |
345 | 362 | ||
346 | GDIDraw(data, graph, altDataDelim); | 363 | GDIDraw(data, graph, altDataDelim, out reuseable); |
347 | } | 364 | } |
348 | 365 | ||
349 | byte[] imageJ2000 = new byte[0]; | 366 | byte[] imageJ2000 = new byte[0]; |
@@ -359,7 +376,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
359 | e.Message, e.StackTrace); | 376 | e.Message, e.StackTrace); |
360 | } | 377 | } |
361 | 378 | ||
362 | m_textureManager.ReturnData(id, imageJ2000); | 379 | return imageJ2000; |
363 | } | 380 | } |
364 | finally | 381 | finally |
365 | { | 382 | { |
@@ -434,8 +451,21 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
434 | } | 451 | } |
435 | */ | 452 | */ |
436 | 453 | ||
437 | private void GDIDraw(string data, Graphics graph, char dataDelim) | 454 | /// <summary> |
455 | /// Split input data into discrete command lines. | ||
456 | /// </summary> | ||
457 | /// <returns></returns> | ||
458 | /// <param name='data'></param> | ||
459 | /// <param name='dataDelim'></param> | ||
460 | private string[] GetLines(string data, char dataDelim) | ||
438 | { | 461 | { |
462 | char[] lineDelimiter = { dataDelim }; | ||
463 | return data.Split(lineDelimiter); | ||
464 | } | ||
465 | |||
466 | private void GDIDraw(string data, Graphics graph, char dataDelim, out bool reuseable) | ||
467 | { | ||
468 | reuseable = true; | ||
439 | Point startPoint = new Point(0, 0); | 469 | Point startPoint = new Point(0, 0); |
440 | Point endPoint = new Point(0, 0); | 470 | Point endPoint = new Point(0, 0); |
441 | Pen drawPen = null; | 471 | Pen drawPen = null; |
@@ -450,11 +480,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
450 | myFont = new Font(fontName, fontSize); | 480 | myFont = new Font(fontName, fontSize); |
451 | myBrush = new SolidBrush(Color.Black); | 481 | myBrush = new SolidBrush(Color.Black); |
452 | 482 | ||
453 | char[] lineDelimiter = {dataDelim}; | ||
454 | char[] partsDelimiter = {','}; | 483 | char[] partsDelimiter = {','}; |
455 | string[] lines = data.Split(lineDelimiter); | ||
456 | 484 | ||
457 | foreach (string line in lines) | 485 | foreach (string line in GetLines(data, dataDelim)) |
458 | { | 486 | { |
459 | string nextLine = line.Trim(); | 487 | string nextLine = line.Trim(); |
460 | //replace with switch, or even better, do some proper parsing | 488 | //replace with switch, or even better, do some proper parsing |
@@ -485,6 +513,10 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
485 | } | 513 | } |
486 | else if (nextLine.StartsWith("Image")) | 514 | else if (nextLine.StartsWith("Image")) |
487 | { | 515 | { |
516 | // We cannot reuse any generated texture involving fetching an image via HTTP since that image | ||
517 | // can change. | ||
518 | reuseable = false; | ||
519 | |||
488 | float x = 0; | 520 | float x = 0; |
489 | float y = 0; | 521 | float y = 0; |
490 | GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y); | 522 | GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y); |