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.

0.7.3-extended
Justin Clark-Casey (justincc) 2012-08-30 22:28:45 +01:00
parent a100723aaf
commit 6c36471f0c
1 changed files with 66 additions and 50 deletions

View File

@ -186,8 +186,20 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face) string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face)
{ {
if (RenderPlugins.ContainsKey(contentType)) if (!RenderPlugins.ContainsKey(contentType))
{ return UUID.Zero;
Scene scene;
RegisteredScenes.TryGetValue(simID, out scene);
if (scene == null)
return UUID.Zero;
SceneObjectPart part = scene.GetSceneObjectPart(primID);
if (part == null)
return UUID.Zero;
// If we want to reuse dynamic textures then we have to ignore any request from the caller to expire // If we want to reuse dynamic textures then we have to ignore any request from the caller to expire
// them. // them.
if (ReuseTextures) if (ReuseTextures)
@ -207,14 +219,27 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.Url = "Local image"; updater.Url = "Local image";
updater.Disp = disp; updater.Disp = disp;
object reusableTextureUUID = null; object objReusableTextureUUID = null;
if (ReuseTextures) if (ReuseTextures && !updater.BlendWithOldTexture)
reusableTextureUUID {
= m_reuseableDynamicTextures.Get(GenerateReusableTextureKey(data, extraParams)); string reuseableTextureKey = GenerateReusableTextureKey(data, extraParams);
objReusableTextureUUID = m_reuseableDynamicTextures.Get(reuseableTextureKey);
if (objReusableTextureUUID != null)
{
// If something else has removed this temporary asset from the cache, detect and invalidate
// our cached uuid.
if (scene.AssetService.GetMetadata(objReusableTextureUUID.ToString()) == null)
{
m_reuseableDynamicTextures.Invalidate(reuseableTextureKey);
objReusableTextureUUID = null;
}
}
}
// We cannot reuse a dynamic texture if the data is going to be blended with something already there. // We cannot reuse a dynamic texture if the data is going to be blended with something already there.
if (reusableTextureUUID == null || updater.BlendWithOldTexture) if (objReusableTextureUUID == null)
{ {
lock (Updaters) lock (Updaters)
{ {
@ -230,21 +255,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
{ {
// No need to add to updaters as the texture is always the same. Not that this functionality // No need to add to updaters as the texture is always the same. Not that this functionality
// apppears to be implemented anyway. // apppears to be implemented anyway.
if (RegisteredScenes.ContainsKey(updater.SimUUID)) updater.UpdatePart(part, (UUID)objReusableTextureUUID);
{
SceneObjectPart part = RegisteredScenes[updater.SimUUID].GetSceneObjectPart(updater.PrimID);
if (part != null)
updater.UpdatePart(part, (UUID)reusableTextureUUID);
}
} }
return updater.UpdaterID; return updater.UpdaterID;
} }
return UUID.Zero;
}
private string GenerateReusableTextureKey(string data, string extraParams) private string GenerateReusableTextureKey(string data, string extraParams)
{ {
return string.Format("{0}{1}", data, extraParams); return string.Format("{0}{1}", data, extraParams);