diff options
author | Justin Clark-Casey (justincc) | 2012-09-06 22:12:05 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-09-06 22:12:05 +0100 |
commit | 8f02fd926e14dfad7f5eb77a67a6701f449511e0 (patch) | |
tree | 08e15f6bb44ff84027c278c51bb55a22951d5ecd /OpenSim/Region/CoreModules/Scripting/LoadImageURL | |
parent | Added missing configs, and deleted the [Profile] part on the Hypergrind config. (diff) | |
download | opensim-SC_OLD-8f02fd926e14dfad7f5eb77a67a6701f449511e0.zip opensim-SC_OLD-8f02fd926e14dfad7f5eb77a67a6701f449511e0.tar.gz opensim-SC_OLD-8f02fd926e14dfad7f5eb77a67a6701f449511e0.tar.bz2 opensim-SC_OLD-8f02fd926e14dfad7f5eb77a67a6701f449511e0.tar.xz |
If reusing dynamic textures, do not reuse small data length textures that fall below current viewer discard level 2 thresholds.
Viewer LL 3.3.4 and before sometimes fail to properly redisplay dynamic textures that have a small data length compared to pixel size when pulled from cache.
This appears to happen when the data length is smaller than the estimate discard level 2 size the viewer uses when making this GetTexture request.
This commit works around this by always regenerating dynamic textures that fall below this threshold rather than reusing them if ReuseDynamicTextures = true
This can be controlled by the [Textures] ReuseDynamicLowDataTextures config setting which defaults to false.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs | 41 |
1 files changed, 25 insertions, 16 deletions
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 |