From 759636f37e4ea212af4ca40565b2d4e9be1eebbe Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 9 Jun 2009 06:39:27 +0000 Subject: From: Alan Webb This change addresses two issues: [1] It adds a flag field to the blendface call which allows the caller to indicate whether or not the generated asset is temporary, and whether or not the asset being replaced should be explicitly retired fromt the memory cache. The decimal values correspond to: 0 - Permanent asset, do not expire old asset 1 - Permanent asset, expire old asset 2 - Temporary asset, do not expire old asset 3 - Temporary asset, expire old asset '3' corresponds to the default behavior seen today, and is the continued behavior of the non-blendface calls. [2] The dynamic texture routines are highly-asynchronous and can be scheduled simultaneously on a multi-core machine. The nature of the texture management interfaece is such that updates may be lost, and the nature of asynchornous operation means that they may be processed out of order. A lock has been added to ensure that updates are at least atomic. No attempt has been made to enforce ordering. The lock applies to the SceneObjectPart being updated and is held for the lifetime of the TextureEntry used to carry texture updates (the one instance carries all faces supported by the prim). Users of these services should remember that the dynamic texture call is asynchronous and control will be returned *before* the texture update has actually occurred. As a result, a isubsequent GetTexture call may not return the expected asset id. A script must wait for the corresponding TEXTURE_CHANGED event before retrieving any texture information. --- .../DynamicTexture/DynamicTextureModule.cs | 75 +++++++++++++--------- 1 file changed, 45 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 2d9143a..a547df5 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -46,6 +46,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture private const int ALL_SIDES = -1; + public const int DISP_EXPIRE = 1; + public const int DISP_TEMP = 2; + private Dictionary RegisteredScenes = new Dictionary(); private Dictionary RenderPlugins = @@ -110,15 +113,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) { - return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, SetBlending, AlphaValue, ALL_SIDES); + return AddDynamicTextureURL(simID, primID, contentType, url, + extraParams, updateTimer, SetBlending, + (int)(DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES); } public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, - string extraParams, int updateTimer, bool SetBlending, byte AlphaValue, int face) + string extraParams, int updateTimer, bool SetBlending, + int disp, byte AlphaValue, int face) { if (RenderPlugins.ContainsKey(contentType)) { - //m_log.Debug("dynamic texture being created: " + url + " of type " + contentType); DynamicTextureUpdater updater = new DynamicTextureUpdater(); updater.SimUUID = simID; @@ -131,6 +136,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture updater.BlendWithOldTexture = SetBlending; updater.FrontAlpha = AlphaValue; updater.Face = face; + updater.Disp = disp; lock (Updaters) { @@ -155,11 +161,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) { - return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, SetBlending, AlphaValue, ALL_SIDES); + return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, SetBlending, + (int) (DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES); } public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, - string extraParams, int updateTimer, bool SetBlending, byte AlphaValue, int face) + string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face) { if (RenderPlugins.ContainsKey(contentType)) { @@ -175,6 +182,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture updater.FrontAlpha = AlphaValue; updater.Face = face; updater.Url = "Local image"; + updater.Disp = disp; lock (Updaters) { @@ -252,6 +260,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture public UUID UpdaterID; public int UpdateTimer; public int Face; + public int Disp; public string Url; public DynamicTextureUpdater() @@ -269,7 +278,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture SceneObjectPart part = scene.GetSceneObjectPart(PrimID); - if (data == null || data.Length <= 1) + if (part == null || data == null || data.Length <= 1) { string msg = String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url); @@ -309,8 +318,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture asset.Type = 0; asset.Description = String.Format("URL image : {0}", Url); asset.Local = false; - asset.Temporary = true; + asset.Temporary = ((Disp & DISP_TEMP) != 0); scene.AssetService.Store(asset); +// scene.CommsManager.AssetCache.AddAsset(asset); IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface(); if (cacheLayerDecode != null) @@ -320,37 +330,42 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture LastAssetID = asset.FullID; } - // mostly keep the values from before - Primitive.TextureEntry tmptex = part.Shape.Textures; + UUID oldID = UUID.Zero; - // remove the old asset from the cache later - UUID oldID = tmptex.DefaultTexture.TextureID; - - if (Face == ALL_SIDES) - { - tmptex.DefaultTexture.TextureID = asset.FullID; - } - else + lock(part) { - try + // mostly keep the values from before + Primitive.TextureEntry tmptex = part.Shape.Textures; + + // remove the old asset from the cache + oldID = tmptex.DefaultTexture.TextureID; + + if(Face == ALL_SIDES) { - Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face); - texface.TextureID = asset.FullID; - tmptex.FaceTextures[Face] = texface; + tmptex.DefaultTexture.TextureID = asset.FullID; } - catch(Exception) + else { - tmptex.DefaultTexture.TextureID = asset.FullID; + try + { + Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face); + texface.TextureID = asset.FullID; + tmptex.FaceTextures[Face] = texface; + } + catch(Exception e) + { + tmptex.DefaultTexture.TextureID = asset.FullID; + } } - } - // I'm pretty sure we always want to force this to true - // I'm pretty sure noone whats to set fullbright true if it wasn't true before. - // tmptex.DefaultTexture.Fullbright = true; + // I'm pretty sure we always want to force this to true + // I'm pretty sure noone whats to set fullbright true if it wasn't true before. + // tmptex.DefaultTexture.Fullbright = true; - part.UpdateTexture(tmptex); - - if (Face == ALL_SIDES) + part.UpdateTexture(tmptex); + } + + if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) { // scene.CommsManager.AssetCache.ExpireAsset(oldID); scene.AssetService.Delete(oldID.ToString()); -- cgit v1.1