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 +++++++++++++--------- .../Framework/Interfaces/IDynamicTextureManager.cs | 6 +- .../Shared/Api/Implementation/OSSL_Api.cs | 8 +-- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 4 +- .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 8 +-- 5 files changed, 59 insertions(+), 42 deletions(-) (limited to 'OpenSim/Region') 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()); diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs index f82b322..95f9cef 100644 --- a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs @@ -30,8 +30,10 @@ using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { + public interface IDynamicTextureManager { + void RegisterRender(string handleType, IDynamicTextureRender render); void ReturnData(UUID id, byte[] data); @@ -40,13 +42,13 @@ namespace OpenSim.Region.Framework.Interfaces UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, int updateTimer, bool SetBlending, byte AlphaValue); UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, - int updateTimer, bool SetBlending, byte AlphaValue, int face); + int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face); UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, int updateTimer); UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, int updateTimer, bool SetBlending, byte AlphaValue); UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, - int updateTimer, bool SetBlending, byte AlphaValue, int face); + int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face); void GetDrawStringSize(string contentType, string text, string fontName, int fontSize, out double xSize, out double ySize); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 9b65d8d..7f3db9c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -428,7 +428,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, - bool blend, int timer, int alpha, int face) + bool blend, int disp, int timer, int alpha, int face) { CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlendFace"); @@ -438,7 +438,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IDynamicTextureManager textureManager = World.RequestModuleInterface(); UUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, - extraParams, timer, blend, (byte) alpha, face); + extraParams, timer, blend, disp, (byte) alpha, face); return createdTexture.ToString(); } else @@ -508,7 +508,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, - bool blend, int timer, int alpha, int face) + bool blend, int disp, int timer, int alpha, int face) { CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlendFace"); @@ -524,7 +524,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } UUID createdTexture = textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, - extraParams, timer, blend, (byte) alpha, face); + extraParams, timer, blend, disp, (byte) alpha, face); return createdTexture.ToString(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index e337c6b..debbad6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -59,12 +59,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, int timer, int alpha); string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, - bool blend, int timer, int alpha, int face); + bool blend, int disp, int timer, int alpha, int face); string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer); string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, int timer, int alpha); string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, - bool blend, int timer, int alpha, int face); + bool blend, int disp, int timer, int alpha, int face); LSL_Float osTerrainGetHeight(int x, int y); LSL_Integer osTerrainSetHeight(int x, int y, double val); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 5df2d6e..193e2e0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -135,17 +135,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase } public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, - bool blend, int timer, int alpha, int face) + bool blend, int disp, int timer, int alpha, int face) { return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, - blend, timer, alpha, face); + blend, disp, timer, alpha, face); } public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, - bool blend, int timer, int alpha, int face) + bool blend, int disp, int timer, int alpha, int face) { return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, - blend, timer, alpha, face); + blend, disp, timer, alpha, face); } public LSL_Float osTerrainGetHeight(int x, int y) -- cgit v1.1