diff options
author | Justin Clark-Casey (justincc) | 2012-08-30 22:28:45 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-08-30 22:28:45 +0100 |
commit | d89b974680af52a2d950237962240dde82ff4a85 (patch) | |
tree | 637bdc2a478488214bb777e4ee8ed02523c4d045 /OpenSim/Region/CoreModules | |
parent | fixing bug where last element in list is ignored (diff) | |
download | opensim-SC_OLD-d89b974680af52a2d950237962240dde82ff4a85.zip opensim-SC_OLD-d89b974680af52a2d950237962240dde82ff4a85.tar.gz opensim-SC_OLD-d89b974680af52a2d950237962240dde82ff4a85.tar.bz2 opensim-SC_OLD-d89b974680af52a2d950237962240dde82ff4a85.tar.xz |
If the compile-time DynamicTextureModule.ReuseTextures flag is set, check metadata still exists for any reused asset in case some other process has removed it from the cache.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 102 |
1 files changed, 59 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 13b7498..f169117 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -186,63 +186,79 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
186 | public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, | 186 | public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, |
187 | string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face) | 187 | string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face) |
188 | { | 188 | { |
189 | if (RenderPlugins.ContainsKey(contentType)) | 189 | if (!RenderPlugins.ContainsKey(contentType)) |
190 | { | 190 | return UUID.Zero; |
191 | // If we want to reuse dynamic textures then we have to ignore any request from the caller to expire | ||
192 | // them. | ||
193 | if (ReuseTextures) | ||
194 | disp = disp & ~DISP_EXPIRE; | ||
195 | 191 | ||
196 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); | 192 | Scene scene; |
197 | updater.SimUUID = simID; | 193 | RegisteredScenes.TryGetValue(simID, out scene); |
198 | updater.PrimID = primID; | 194 | |
199 | updater.ContentType = contentType; | 195 | if (scene == null) |
200 | updater.BodyData = data; | 196 | return UUID.Zero; |
201 | updater.UpdateTimer = updateTimer; | ||
202 | updater.UpdaterID = UUID.Random(); | ||
203 | updater.Params = extraParams; | ||
204 | updater.BlendWithOldTexture = SetBlending; | ||
205 | updater.FrontAlpha = AlphaValue; | ||
206 | updater.Face = face; | ||
207 | updater.Url = "Local image"; | ||
208 | updater.Disp = disp; | ||
209 | 197 | ||
210 | object reusableTextureUUID = null; | 198 | SceneObjectPart part = scene.GetSceneObjectPart(primID); |
211 | 199 | ||
212 | if (ReuseTextures) | 200 | if (part == null) |
213 | reusableTextureUUID | 201 | return UUID.Zero; |
214 | = m_reuseableDynamicTextures.Get(GenerateReusableTextureKey(data, extraParams)); | 202 | |
203 | // If we want to reuse dynamic textures then we have to ignore any request from the caller to expire | ||
204 | // them. | ||
205 | if (ReuseTextures) | ||
206 | disp = disp & ~DISP_EXPIRE; | ||
207 | |||
208 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); | ||
209 | updater.SimUUID = simID; | ||
210 | updater.PrimID = primID; | ||
211 | updater.ContentType = contentType; | ||
212 | updater.BodyData = data; | ||
213 | updater.UpdateTimer = updateTimer; | ||
214 | updater.UpdaterID = UUID.Random(); | ||
215 | updater.Params = extraParams; | ||
216 | updater.BlendWithOldTexture = SetBlending; | ||
217 | updater.FrontAlpha = AlphaValue; | ||
218 | updater.Face = face; | ||
219 | updater.Url = "Local image"; | ||
220 | updater.Disp = disp; | ||
221 | |||
222 | object objReusableTextureUUID = null; | ||
223 | |||
224 | if (ReuseTextures && !updater.BlendWithOldTexture) | ||
225 | { | ||
226 | string reuseableTextureKey = GenerateReusableTextureKey(data, extraParams); | ||
227 | objReusableTextureUUID = m_reuseableDynamicTextures.Get(reuseableTextureKey); | ||
215 | 228 | ||
216 | // We cannot reuse a dynamic texture if the data is going to be blended with something already there. | 229 | if (objReusableTextureUUID != null) |
217 | if (reusableTextureUUID == null || updater.BlendWithOldTexture) | ||
218 | { | 230 | { |
219 | lock (Updaters) | 231 | // If something else has removed this temporary asset from the cache, detect and invalidate |
232 | // our cached uuid. | ||
233 | if (scene.AssetService.GetMetadata(objReusableTextureUUID.ToString()) == null) | ||
220 | { | 234 | { |
221 | if (!Updaters.ContainsKey(updater.UpdaterID)) | 235 | m_reuseableDynamicTextures.Invalidate(reuseableTextureKey); |
222 | { | 236 | objReusableTextureUUID = null; |
223 | Updaters.Add(updater.UpdaterID, updater); | ||
224 | } | ||
225 | } | 237 | } |
226 | |||
227 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); | ||
228 | } | 238 | } |
229 | else | 239 | } |
240 | |||
241 | // We cannot reuse a dynamic texture if the data is going to be blended with something already there. | ||
242 | if (objReusableTextureUUID == null) | ||
243 | { | ||
244 | lock (Updaters) | ||
230 | { | 245 | { |
231 | // No need to add to updaters as the texture is always the same. Not that this functionality | 246 | if (!Updaters.ContainsKey(updater.UpdaterID)) |
232 | // apppears to be implemented anyway. | ||
233 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) | ||
234 | { | 247 | { |
235 | SceneObjectPart part = RegisteredScenes[updater.SimUUID].GetSceneObjectPart(updater.PrimID); | 248 | Updaters.Add(updater.UpdaterID, updater); |
236 | |||
237 | if (part != null) | ||
238 | updater.UpdatePart(part, (UUID)reusableTextureUUID); | ||
239 | } | 249 | } |
240 | } | 250 | } |
241 | 251 | ||
242 | return updater.UpdaterID; | 252 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); |
243 | } | 253 | } |
244 | 254 | else | |
245 | return UUID.Zero; | 255 | { |
256 | // No need to add to updaters as the texture is always the same. Not that this functionality | ||
257 | // apppears to be implemented anyway. | ||
258 | updater.UpdatePart(part, (UUID)objReusableTextureUUID); | ||
259 | } | ||
260 | |||
261 | return updater.UpdaterID; | ||
246 | } | 262 | } |
247 | 263 | ||
248 | private string GenerateReusableTextureKey(string data, string extraParams) | 264 | private string GenerateReusableTextureKey(string data, string extraParams) |