diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
11 files changed, 230 insertions, 51 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 7d7176f..d698239 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -49,12 +49,8 @@ using OpenSim.Region.Framework.Scenes; | |||
49 | using OpenSim.Services.Interfaces; | 49 | using OpenSim.Services.Interfaces; |
50 | 50 | ||
51 | 51 | ||
52 | [assembly: Addin("FlotsamAssetCache", "1.1")] | 52 | namespace OpenSim.Region.CoreModules.Asset |
53 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
54 | |||
55 | namespace Flotsam.RegionModules.AssetCache | ||
56 | { | 53 | { |
57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
58 | public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService | 54 | public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService |
59 | { | 55 | { |
60 | private static readonly ILog m_log = | 56 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs index c91b25f..9276d1a 100644 --- a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs +++ b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs | |||
@@ -35,7 +35,7 @@ using Nini.Config; | |||
35 | using NUnit.Framework; | 35 | using NUnit.Framework; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenMetaverse.Assets; | 37 | using OpenMetaverse.Assets; |
38 | using Flotsam.RegionModules.AssetCache; | 38 | using OpenSim.Region.CoreModules.Asset; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Region.Framework.Scenes.Serialization; | 41 | using OpenSim.Region.Framework.Scenes.Serialization; |
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 424e0ab..a09945e 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | |||
@@ -34,6 +34,7 @@ | |||
34 | <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" /> | 34 | <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" /> |
35 | <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" /> | 35 | <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" /> |
36 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> | 36 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> |
37 | <RegionModule id="FlotsamAssetCache" type="OpenSim.Region.CoreModules.Asset.FlotsamAssetCache" /> | ||
37 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> | 38 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> |
38 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> | 39 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> |
39 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> | 40 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> |
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs new file mode 100644 index 0000000..fce9490 --- /dev/null +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Drawing; | ||
30 | using OpenSim.Region.Framework.Interfaces; | ||
31 | |||
32 | namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | ||
33 | { | ||
34 | public class DynamicTexture : IDynamicTexture | ||
35 | { | ||
36 | public string InputCommands { get; private set; } | ||
37 | public Uri InputUri { get; private set; } | ||
38 | public string InputParams { get; private set; } | ||
39 | public byte[] Data { get; private set; } | ||
40 | public Size Size { get; private set; } | ||
41 | public bool IsReuseable { get; private set; } | ||
42 | |||
43 | public DynamicTexture(string inputCommands, string inputParams, byte[] data, Size size, bool isReuseable) | ||
44 | { | ||
45 | InputCommands = inputCommands; | ||
46 | InputParams = inputParams; | ||
47 | Data = data; | ||
48 | Size = size; | ||
49 | IsReuseable = isReuseable; | ||
50 | } | ||
51 | |||
52 | public DynamicTexture(Uri inputUri, string inputParams, byte[] data, Size size, bool isReuseable) | ||
53 | { | ||
54 | InputUri = inputUri; | ||
55 | InputParams = inputParams; | ||
56 | Data = data; | ||
57 | Size = size; | ||
58 | IsReuseable = isReuseable; | ||
59 | } | ||
60 | } | ||
61 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 3eedf49..1f340df 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
42 | { | 42 | { |
43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager | 43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager |
44 | { | 44 | { |
45 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private const int ALL_SIDES = -1; | 47 | private const int ALL_SIDES = -1; |
48 | 48 | ||
@@ -54,6 +54,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
54 | /// </summary> | 54 | /// </summary> |
55 | public bool ReuseTextures { get; set; } | 55 | public bool ReuseTextures { get; set; } |
56 | 56 | ||
57 | /// <summary> | ||
58 | /// If false, then textures which have a low data size are not reused when ReuseTextures = true. | ||
59 | /// </summary> | ||
60 | /// <remarks> | ||
61 | /// LL viewers 3.3.4 and before appear to not fully render textures pulled from the viewer cache if those | ||
62 | /// textures have a relatively high pixel surface but a small data size. Typically, this appears to happen | ||
63 | /// if the data size is smaller than the viewer's discard level 2 size estimate. So if this is setting is | ||
64 | /// false, textures smaller than the calculation in IsSizeReuseable are always regenerated rather than reused | ||
65 | /// to work around this problem.</remarks> | ||
66 | public bool ReuseLowDataTextures { get; set; } | ||
67 | |||
57 | private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); | 68 | private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); |
58 | 69 | ||
59 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = | 70 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = |
@@ -83,18 +94,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
83 | /// <summary> | 94 | /// <summary> |
84 | /// Called by code which actually renders the dynamic texture to supply texture data. | 95 | /// Called by code which actually renders the dynamic texture to supply texture data. |
85 | /// </summary> | 96 | /// </summary> |
86 | /// <param name="id"></param> | 97 | /// <param name="updaterId"></param> |
87 | /// <param name="data"></param> | 98 | /// <param name="texture"></param> |
88 | /// <param name="isReuseable">True if the data generated can be reused for subsequent identical requests</param> | 99 | public void ReturnData(UUID updaterId, IDynamicTexture texture) |
89 | public void ReturnData(UUID id, byte[] data, bool isReuseable) | ||
90 | { | 100 | { |
91 | DynamicTextureUpdater updater = null; | 101 | DynamicTextureUpdater updater = null; |
92 | 102 | ||
93 | lock (Updaters) | 103 | lock (Updaters) |
94 | { | 104 | { |
95 | if (Updaters.ContainsKey(id)) | 105 | if (Updaters.ContainsKey(updaterId)) |
96 | { | 106 | { |
97 | updater = Updaters[id]; | 107 | updater = Updaters[updaterId]; |
98 | } | 108 | } |
99 | } | 109 | } |
100 | 110 | ||
@@ -103,11 +113,16 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
103 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) | 113 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) |
104 | { | 114 | { |
105 | Scene scene = RegisteredScenes[updater.SimUUID]; | 115 | Scene scene = RegisteredScenes[updater.SimUUID]; |
106 | UUID newTextureID = updater.DataReceived(data, scene); | 116 | UUID newTextureID = updater.DataReceived(texture.Data, scene); |
107 | 117 | ||
108 | if (ReuseTextures && isReuseable && !updater.BlendWithOldTexture) | 118 | if (ReuseTextures |
119 | && !updater.BlendWithOldTexture | ||
120 | && texture.IsReuseable | ||
121 | && (ReuseLowDataTextures || IsDataSizeReuseable(texture))) | ||
122 | { | ||
109 | m_reuseableDynamicTextures.Store( | 123 | m_reuseableDynamicTextures.Store( |
110 | GenerateReusableTextureKey(updater.BodyData, updater.Params), newTextureID); | 124 | GenerateReusableTextureKey(texture.InputCommands, texture.InputParams), newTextureID); |
125 | } | ||
111 | } | 126 | } |
112 | } | 127 | } |
113 | 128 | ||
@@ -123,6 +138,27 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
123 | } | 138 | } |
124 | } | 139 | } |
125 | 140 | ||
141 | /// <summary> | ||
142 | /// Determines whether the texture is reuseable based on its data size. | ||
143 | /// </summary> | ||
144 | /// <remarks> | ||
145 | /// This is a workaround for a viewer bug where very small data size textures relative to their pixel size | ||
146 | /// are not redisplayed properly when pulled from cache. The calculation here is based on the typical discard | ||
147 | /// level of 2, a 'rate' of 0.125 and 4 components (which makes for a factor of 0.5). | ||
148 | /// </remarks> | ||
149 | /// <returns></returns> | ||
150 | private bool IsDataSizeReuseable(IDynamicTexture texture) | ||
151 | { | ||
152 | // Console.WriteLine("{0} {1}", texture.Size.Width, texture.Size.Height); | ||
153 | int discardLevel2DataThreshold = (int)Math.Ceiling((texture.Size.Width >> 2) * (texture.Size.Height >> 2) * 0.5); | ||
154 | |||
155 | // m_log.DebugFormat( | ||
156 | // "[DYNAMIC TEXTURE MODULE]: Discard level 2 threshold {0}, texture data length {1}", | ||
157 | // discardLevel2DataThreshold, texture.Data.Length); | ||
158 | |||
159 | return discardLevel2DataThreshold < texture.Data.Length; | ||
160 | } | ||
161 | |||
126 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, | 162 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, |
127 | string extraParams, int updateTimer) | 163 | string extraParams, int updateTimer) |
128 | { | 164 | { |
@@ -249,10 +285,18 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
249 | } | 285 | } |
250 | } | 286 | } |
251 | 287 | ||
288 | // m_log.DebugFormat( | ||
289 | // "[DYNAMIC TEXTURE MODULE]: Requesting generation of new dynamic texture for {0} in {1}", | ||
290 | // part.Name, part.ParentGroup.Scene.Name); | ||
291 | |||
252 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); | 292 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); |
253 | } | 293 | } |
254 | else | 294 | else |
255 | { | 295 | { |
296 | // m_log.DebugFormat( | ||
297 | // "[DYNAMIC TEXTURE MODULE]: Reusing cached texture {0} for {1} in {2}", | ||
298 | // objReusableTextureUUID, part.Name, part.ParentGroup.Scene.Name); | ||
299 | |||
256 | // No need to add to updaters as the texture is always the same. Not that this functionality | 300 | // No need to add to updaters as the texture is always the same. Not that this functionality |
257 | // apppears to be implemented anyway. | 301 | // apppears to be implemented anyway. |
258 | updater.UpdatePart(part, (UUID)objReusableTextureUUID); | 302 | updater.UpdatePart(part, (UUID)objReusableTextureUUID); |
@@ -285,7 +329,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
285 | { | 329 | { |
286 | IConfig texturesConfig = config.Configs["Textures"]; | 330 | IConfig texturesConfig = config.Configs["Textures"]; |
287 | if (texturesConfig != null) | 331 | if (texturesConfig != null) |
332 | { | ||
288 | ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); | 333 | ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); |
334 | ReuseLowDataTextures = texturesConfig.GetBoolean("ReuseDynamicLowDataTextures", false); | ||
335 | } | ||
289 | 336 | ||
290 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) | 337 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
291 | { | 338 | { |
@@ -448,8 +495,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
448 | IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>(); | 495 | IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>(); |
449 | if (cacheLayerDecode != null) | 496 | if (cacheLayerDecode != null) |
450 | { | 497 | { |
451 | cacheLayerDecode.Decode(asset.FullID, asset.Data); | 498 | if (!cacheLayerDecode.Decode(asset.FullID, asset.Data)) |
452 | cacheLayerDecode = null; | 499 | m_log.WarnFormat( |
500 | "[DYNAMIC TEXTURE MODULE]: Decoding of dynamically generated asset {0} for {1} in {2} failed", | ||
501 | asset.ID, part.Name, part.ParentGroup.Scene.Name); | ||
453 | } | 502 | } |
454 | 503 | ||
455 | UUID oldID = UpdatePart(part, asset.FullID); | 504 | UUID oldID = UpdatePart(part, asset.FullID); |
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs index 2b3a0f2..45e6527 100644 --- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs | |||
@@ -32,6 +32,7 @@ using System.Net; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenMetaverse.Imaging; | 34 | using OpenMetaverse.Imaging; |
35 | using OpenSim.Region.CoreModules.Scripting.DynamicTexture; | ||
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
37 | using log4net; | 38 | using log4net; |
@@ -73,12 +74,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
73 | // return false; | 74 | // return false; |
74 | // } | 75 | // } |
75 | 76 | ||
76 | public byte[] ConvertUrl(string url, string extraParams) | 77 | public IDynamicTexture ConvertUrl(string url, string extraParams) |
77 | { | 78 | { |
78 | return null; | 79 | return null; |
79 | } | 80 | } |
80 | 81 | ||
81 | public byte[] ConvertData(string bodyData, string extraParams) | 82 | public IDynamicTexture ConvertData(string bodyData, string extraParams) |
82 | { | 83 | { |
83 | return null; | 84 | return null; |
84 | } | 85 | } |
@@ -171,11 +172,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
171 | 172 | ||
172 | private void HttpRequestReturn(IAsyncResult result) | 173 | private void HttpRequestReturn(IAsyncResult result) |
173 | { | 174 | { |
174 | |||
175 | RequestState state = (RequestState) result.AsyncState; | 175 | RequestState state = (RequestState) result.AsyncState; |
176 | WebRequest request = (WebRequest) state.Request; | 176 | WebRequest request = (WebRequest) state.Request; |
177 | Stream stream = null; | 177 | Stream stream = null; |
178 | byte[] imageJ2000 = new byte[0]; | 178 | byte[] imageJ2000 = new byte[0]; |
179 | Size newSize = new Size(0, 0); | ||
179 | 180 | ||
180 | try | 181 | try |
181 | { | 182 | { |
@@ -188,37 +189,43 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
188 | try | 189 | try |
189 | { | 190 | { |
190 | Bitmap image = new Bitmap(stream); | 191 | Bitmap image = new Bitmap(stream); |
191 | Size newsize; | ||
192 | 192 | ||
193 | // TODO: make this a bit less hard coded | 193 | // TODO: make this a bit less hard coded |
194 | if ((image.Height < 64) && (image.Width < 64)) | 194 | if ((image.Height < 64) && (image.Width < 64)) |
195 | { | 195 | { |
196 | newsize = new Size(32, 32); | 196 | newSize.Width = 32; |
197 | newSize.Height = 32; | ||
197 | } | 198 | } |
198 | else if ((image.Height < 128) && (image.Width < 128)) | 199 | else if ((image.Height < 128) && (image.Width < 128)) |
199 | { | 200 | { |
200 | newsize = new Size(64, 64); | 201 | newSize.Width = 64; |
202 | newSize.Height = 64; | ||
201 | } | 203 | } |
202 | else if ((image.Height < 256) && (image.Width < 256)) | 204 | else if ((image.Height < 256) && (image.Width < 256)) |
203 | { | 205 | { |
204 | newsize = new Size(128, 128); | 206 | newSize.Width = 128; |
207 | newSize.Height = 128; | ||
205 | } | 208 | } |
206 | else if ((image.Height < 512 && image.Width < 512)) | 209 | else if ((image.Height < 512 && image.Width < 512)) |
207 | { | 210 | { |
208 | newsize = new Size(256, 256); | 211 | newSize.Width = 256; |
212 | newSize.Height = 256; | ||
209 | } | 213 | } |
210 | else if ((image.Height < 1024 && image.Width < 1024)) | 214 | else if ((image.Height < 1024 && image.Width < 1024)) |
211 | { | 215 | { |
212 | newsize = new Size(512, 512); | 216 | newSize.Width = 512; |
217 | newSize.Height = 512; | ||
213 | } | 218 | } |
214 | else | 219 | else |
215 | { | 220 | { |
216 | newsize = new Size(1024, 1024); | 221 | newSize.Width = 1024; |
222 | newSize.Height = 1024; | ||
217 | } | 223 | } |
218 | 224 | ||
219 | Bitmap resize = new Bitmap(image, newsize); | 225 | using (Bitmap resize = new Bitmap(image, newSize)) |
220 | 226 | { | |
221 | imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); | 227 | imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); |
228 | } | ||
222 | } | 229 | } |
223 | catch (Exception) | 230 | catch (Exception) |
224 | { | 231 | { |
@@ -233,7 +240,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
233 | } | 240 | } |
234 | catch (WebException) | 241 | catch (WebException) |
235 | { | 242 | { |
236 | |||
237 | } | 243 | } |
238 | finally | 244 | finally |
239 | { | 245 | { |
@@ -243,10 +249,13 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
243 | } | 249 | } |
244 | } | 250 | } |
245 | 251 | ||
246 | m_log.DebugFormat("[LOADIMAGEURLMODULE] Returning {0} bytes of image data for request {1}", | 252 | m_log.DebugFormat("[LOADIMAGEURLMODULE]: Returning {0} bytes of image data for request {1}", |
247 | imageJ2000.Length, state.RequestID); | 253 | imageJ2000.Length, state.RequestID); |
248 | 254 | ||
249 | m_textureManager.ReturnData(state.RequestID, imageJ2000, false); | 255 | m_textureManager.ReturnData( |
256 | state.RequestID, | ||
257 | new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture( | ||
258 | request.RequestUri, null, imageJ2000, newSize, false)); | ||
250 | } | 259 | } |
251 | 260 | ||
252 | #region Nested type: RequestState | 261 | #region Nested type: RequestState |
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs index b50c0bd..41baccc 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs | |||
@@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests | |||
57 | 57 | ||
58 | m_dtm = new DynamicTextureModule(); | 58 | m_dtm = new DynamicTextureModule(); |
59 | m_dtm.ReuseTextures = reuseTextures; | 59 | m_dtm.ReuseTextures = reuseTextures; |
60 | // m_dtm.ReuseLowDataTextures = reuseTextures; | ||
60 | 61 | ||
61 | m_vrm = new VectorRenderModule(); | 62 | m_vrm = new VectorRenderModule(); |
62 | 63 | ||
@@ -201,6 +202,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests | |||
201 | public void TestRepeatSameDrawReusingTexture() | 202 | public void TestRepeatSameDrawReusingTexture() |
202 | { | 203 | { |
203 | TestHelpers.InMethod(); | 204 | TestHelpers.InMethod(); |
205 | // TestHelpers.EnableLogging(); | ||
204 | 206 | ||
205 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; | 207 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; |
206 | 208 | ||
@@ -228,6 +230,46 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests | |||
228 | Assert.That(firstDynamicTextureID, Is.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); | 230 | Assert.That(firstDynamicTextureID, Is.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
229 | } | 231 | } |
230 | 232 | ||
233 | /// <summary> | ||
234 | /// Test a low data dynamically generated texture such that it is treated as a low data texture that causes | ||
235 | /// problems for current viewers. | ||
236 | /// </summary> | ||
237 | /// <remarks> | ||
238 | /// As we do not set DynamicTextureModule.ReuseLowDataTextures = true in this test, it should not reuse the | ||
239 | /// texture | ||
240 | /// </remarks> | ||
241 | [Test] | ||
242 | public void TestRepeatSameDrawLowDataTexture() | ||
243 | { | ||
244 | TestHelpers.InMethod(); | ||
245 | // TestHelpers.EnableLogging(); | ||
246 | |||
247 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; | ||
248 | |||
249 | SetupScene(true); | ||
250 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); | ||
251 | |||
252 | m_dtm.AddDynamicTextureData( | ||
253 | m_scene.RegionInfo.RegionID, | ||
254 | so.UUID, | ||
255 | m_vrm.GetContentType(), | ||
256 | dtText, | ||
257 | "1024", | ||
258 | 0); | ||
259 | |||
260 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; | ||
261 | |||
262 | m_dtm.AddDynamicTextureData( | ||
263 | m_scene.RegionInfo.RegionID, | ||
264 | so.UUID, | ||
265 | m_vrm.GetContentType(), | ||
266 | dtText, | ||
267 | "1024", | ||
268 | 0); | ||
269 | |||
270 | Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); | ||
271 | } | ||
272 | |||
231 | [Test] | 273 | [Test] |
232 | public void TestRepeatSameDrawDifferentExtraParamsReusingTexture() | 274 | public void TestRepeatSameDrawDifferentExtraParamsReusingTexture() |
233 | { | 275 | { |
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index f687646..1e17b02 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -35,6 +35,7 @@ using System.Net; | |||
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenMetaverse.Imaging; | 37 | using OpenMetaverse.Imaging; |
38 | using OpenSim.Region.CoreModules.Scripting.DynamicTexture; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
40 | using log4net; | 41 | using log4net; |
@@ -46,6 +47,11 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
46 | { | 47 | { |
47 | public class VectorRenderModule : IRegionModule, IDynamicTextureRender | 48 | public class VectorRenderModule : IRegionModule, IDynamicTextureRender |
48 | { | 49 | { |
50 | // These fields exist for testing purposes, please do not remove. | ||
51 | // private static bool s_flipper; | ||
52 | // private static byte[] s_asset1Data; | ||
53 | // private static byte[] s_asset2Data; | ||
54 | |||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 56 | ||
51 | private Scene m_scene; | 57 | private Scene m_scene; |
@@ -80,20 +86,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
80 | // return lines.Any((str, r) => str.StartsWith("Image")); | 86 | // return lines.Any((str, r) => str.StartsWith("Image")); |
81 | // } | 87 | // } |
82 | 88 | ||
83 | public byte[] ConvertUrl(string url, string extraParams) | 89 | public IDynamicTexture ConvertUrl(string url, string extraParams) |
84 | { | 90 | { |
85 | return null; | 91 | return null; |
86 | } | 92 | } |
87 | 93 | ||
88 | public byte[] ConvertData(string bodyData, string extraParams) | 94 | public IDynamicTexture ConvertData(string bodyData, string extraParams) |
89 | { | ||
90 | bool reuseable; | ||
91 | return Draw(bodyData, extraParams, out reuseable); | ||
92 | } | ||
93 | |||
94 | private byte[] ConvertData(string bodyData, string extraParams, out bool reuseable) | ||
95 | { | 95 | { |
96 | return Draw(bodyData, extraParams, out reuseable); | 96 | return Draw(bodyData, extraParams); |
97 | } | 97 | } |
98 | 98 | ||
99 | public bool AsyncConvertUrl(UUID id, string url, string extraParams) | 99 | public bool AsyncConvertUrl(UUID id, string url, string extraParams) |
@@ -104,10 +104,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
104 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) | 104 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) |
105 | { | 105 | { |
106 | // XXX: This isn't actually being done asynchronously! | 106 | // XXX: This isn't actually being done asynchronously! |
107 | bool reuseable; | 107 | m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams)); |
108 | byte[] data = ConvertData(bodyData, extraParams, out reuseable); | ||
109 | |||
110 | m_textureManager.ReturnData(id, data, reuseable); | ||
111 | 108 | ||
112 | return true; | 109 | return true; |
113 | } | 110 | } |
@@ -161,6 +158,13 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
161 | { | 158 | { |
162 | m_textureManager.RegisterRender(GetContentType(), this); | 159 | m_textureManager.RegisterRender(GetContentType(), this); |
163 | } | 160 | } |
161 | |||
162 | // This code exists for testing purposes, please do not remove. | ||
163 | // s_asset1Data = m_scene.AssetService.Get("00000000-0000-1111-9999-000000000001").Data; | ||
164 | // s_asset1Data = m_scene.AssetService.Get("9f4acf0d-1841-4e15-bdb8-3a12efc9dd8f").Data; | ||
165 | |||
166 | // Terrain dirt - smallest bin/assets file (6004 bytes) | ||
167 | // s_asset2Data = m_scene.AssetService.Get("b8d3965a-ad78-bf43-699b-bff8eca6c975").Data; | ||
164 | } | 168 | } |
165 | 169 | ||
166 | public void Close() | 170 | public void Close() |
@@ -179,7 +183,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
179 | 183 | ||
180 | #endregion | 184 | #endregion |
181 | 185 | ||
182 | private byte[] Draw(string data, string extraParams, out bool reuseable) | 186 | private IDynamicTexture Draw(string data, string extraParams) |
183 | { | 187 | { |
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 | 188 | // 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 |
185 | // we will now support multiple comma seperated params in the form width:256,height:512,alpha:255 | 189 | // we will now support multiple comma seperated params in the form width:256,height:512,alpha:255 |
@@ -322,6 +326,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
322 | 326 | ||
323 | Bitmap bitmap = null; | 327 | Bitmap bitmap = null; |
324 | Graphics graph = null; | 328 | Graphics graph = null; |
329 | bool reuseable = false; | ||
325 | 330 | ||
326 | try | 331 | try |
327 | { | 332 | { |
@@ -364,6 +369,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
364 | } | 369 | } |
365 | 370 | ||
366 | byte[] imageJ2000 = new byte[0]; | 371 | byte[] imageJ2000 = new byte[0]; |
372 | |||
373 | // This code exists for testing purposes, please do not remove. | ||
374 | // if (s_flipper) | ||
375 | // imageJ2000 = s_asset1Data; | ||
376 | // else | ||
377 | // imageJ2000 = s_asset2Data; | ||
378 | // | ||
379 | // s_flipper = !s_flipper; | ||
367 | 380 | ||
368 | try | 381 | try |
369 | { | 382 | { |
@@ -376,7 +389,8 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
376 | e.Message, e.StackTrace); | 389 | e.Message, e.StackTrace); |
377 | } | 390 | } |
378 | 391 | ||
379 | return imageJ2000; | 392 | return new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture( |
393 | data, extraParams, imageJ2000, new Size(width, height), reuseable); | ||
380 | } | 394 | } |
381 | finally | 395 | finally |
382 | { | 396 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index b286d17..57ae549 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -43,7 +43,7 @@ using OpenSim.Tests.Common; | |||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests |
44 | { | 44 | { |
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class GridConnectorsTests | 46 | public class GridConnectorsTests : OpenSimTestCase |
47 | { | 47 | { |
48 | LocalGridServicesConnector m_LocalConnector; | 48 | LocalGridServicesConnector m_LocalConnector; |
49 | private void SetUp() | 49 | private void SetUp() |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 5deaf52..904110e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -51,7 +51,7 @@ using RegionSettings = OpenSim.Framework.RegionSettings; | |||
51 | namespace OpenSim.Region.CoreModules.World.Archiver.Tests | 51 | namespace OpenSim.Region.CoreModules.World.Archiver.Tests |
52 | { | 52 | { |
53 | [TestFixture] | 53 | [TestFixture] |
54 | public class ArchiverTests | 54 | public class ArchiverTests : OpenSimTestCase |
55 | { | 55 | { |
56 | private Guid m_lastRequestId; | 56 | private Guid m_lastRequestId; |
57 | private string m_lastErrorMessage; | 57 | private string m_lastErrorMessage; |
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 3c48d07..33f6c3f 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | |||
@@ -222,6 +222,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
222 | bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height); | 222 | bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height); |
223 | } | 223 | } |
224 | 224 | ||
225 | // XXX: It shouldn't really be necesary to force a GC here as one should occur anyway pretty shortly | ||
226 | // afterwards. It's generally regarded as a bad idea to manually GC. If Warp3D is using lots of memory | ||
227 | // then this may be some issue with the Warp3D code itself, though it's also quite possible that generating | ||
228 | // this map tile simply takes a lot of memory. | ||
229 | GC.Collect(); | ||
230 | m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()"); | ||
231 | |||
225 | return bitmap; | 232 | return bitmap; |
226 | } | 233 | } |
227 | 234 | ||