From: Alan Webb <alan_webb@us.ibm.com>

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.
0.6.6-post-fixes
Dr Scofield 2009-06-09 06:39:27 +00:00
parent 0356fef9ab
commit 759636f37e
5 changed files with 60 additions and 43 deletions

View File

@ -46,6 +46,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
private const int ALL_SIDES = -1; private const int ALL_SIDES = -1;
public const int DISP_EXPIRE = 1;
public const int DISP_TEMP = 2;
private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>();
private Dictionary<string, IDynamicTextureRender> RenderPlugins = private Dictionary<string, IDynamicTextureRender> RenderPlugins =
@ -110,15 +113,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) 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, 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)) if (RenderPlugins.ContainsKey(contentType))
{ {
//m_log.Debug("dynamic texture being created: " + url + " of type " + contentType);
DynamicTextureUpdater updater = new DynamicTextureUpdater(); DynamicTextureUpdater updater = new DynamicTextureUpdater();
updater.SimUUID = simID; updater.SimUUID = simID;
@ -131,6 +136,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.BlendWithOldTexture = SetBlending; updater.BlendWithOldTexture = SetBlending;
updater.FrontAlpha = AlphaValue; updater.FrontAlpha = AlphaValue;
updater.Face = face; updater.Face = face;
updater.Disp = disp;
lock (Updaters) lock (Updaters)
{ {
@ -155,11 +161,12 @@ 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, byte AlphaValue) 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, 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)) if (RenderPlugins.ContainsKey(contentType))
{ {
@ -175,6 +182,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.FrontAlpha = AlphaValue; updater.FrontAlpha = AlphaValue;
updater.Face = face; updater.Face = face;
updater.Url = "Local image"; updater.Url = "Local image";
updater.Disp = disp;
lock (Updaters) lock (Updaters)
{ {
@ -252,6 +260,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID UpdaterID; public UUID UpdaterID;
public int UpdateTimer; public int UpdateTimer;
public int Face; public int Face;
public int Disp;
public string Url; public string Url;
public DynamicTextureUpdater() public DynamicTextureUpdater()
@ -269,7 +278,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
SceneObjectPart part = scene.GetSceneObjectPart(PrimID); SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
if (data == null || data.Length <= 1) if (part == null || data == null || data.Length <= 1)
{ {
string msg = string msg =
String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url); String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url);
@ -309,8 +318,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
asset.Type = 0; asset.Type = 0;
asset.Description = String.Format("URL image : {0}", Url); asset.Description = String.Format("URL image : {0}", Url);
asset.Local = false; asset.Local = false;
asset.Temporary = true; asset.Temporary = ((Disp & DISP_TEMP) != 0);
scene.AssetService.Store(asset); scene.AssetService.Store(asset);
// scene.CommsManager.AssetCache.AddAsset(asset);
IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>(); IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>();
if (cacheLayerDecode != null) if (cacheLayerDecode != null)
@ -320,11 +330,15 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
LastAssetID = asset.FullID; LastAssetID = asset.FullID;
} }
UUID oldID = UUID.Zero;
lock(part)
{
// mostly keep the values from before // mostly keep the values from before
Primitive.TextureEntry tmptex = part.Shape.Textures; Primitive.TextureEntry tmptex = part.Shape.Textures;
// remove the old asset from the cache later // remove the old asset from the cache
UUID oldID = tmptex.DefaultTexture.TextureID; oldID = tmptex.DefaultTexture.TextureID;
if(Face == ALL_SIDES) if(Face == ALL_SIDES)
{ {
@ -338,7 +352,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
texface.TextureID = asset.FullID; texface.TextureID = asset.FullID;
tmptex.FaceTextures[Face] = texface; tmptex.FaceTextures[Face] = texface;
} }
catch(Exception) catch(Exception e)
{ {
tmptex.DefaultTexture.TextureID = asset.FullID; tmptex.DefaultTexture.TextureID = asset.FullID;
} }
@ -349,8 +363,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
// tmptex.DefaultTexture.Fullbright = true; // tmptex.DefaultTexture.Fullbright = true;
part.UpdateTexture(tmptex); part.UpdateTexture(tmptex);
}
if (Face == ALL_SIDES) if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
{ {
// scene.CommsManager.AssetCache.ExpireAsset(oldID); // scene.CommsManager.AssetCache.ExpireAsset(oldID);
scene.AssetService.Delete(oldID.ToString()); scene.AssetService.Delete(oldID.ToString());

View File

@ -30,8 +30,10 @@ using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces namespace OpenSim.Region.Framework.Interfaces
{ {
public interface IDynamicTextureManager public interface IDynamicTextureManager
{ {
void RegisterRender(string handleType, IDynamicTextureRender render); void RegisterRender(string handleType, IDynamicTextureRender render);
void ReturnData(UUID id, byte[] data); 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, UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams,
int updateTimer, bool SetBlending, byte AlphaValue); int updateTimer, bool SetBlending, byte AlphaValue);
UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, 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, UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
int updateTimer); int updateTimer);
UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams,
int updateTimer, bool SetBlending, byte AlphaValue); int updateTimer, bool SetBlending, byte AlphaValue);
UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, string extraParams, 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, void GetDrawStringSize(string contentType, string text, string fontName, int fontSize,
out double xSize, out double ySize); out double xSize, out double ySize);
} }

View File

@ -428,7 +428,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, 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"); CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureURLBlendFace");
@ -438,7 +438,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
UUID createdTexture = UUID createdTexture =
textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, 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(); return createdTexture.ToString();
} }
else else
@ -508,7 +508,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, 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"); CheckThreatLevel(ThreatLevel.VeryLow, "osSetDynamicTextureDataBlendFace");
@ -524,7 +524,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
UUID createdTexture = UUID createdTexture =
textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data, 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(); return createdTexture.ToString();
} }
} }

View File

@ -59,12 +59,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
int timer, int alpha); int timer, int alpha);
string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, 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 osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer);
string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
int timer, int alpha); int timer, int alpha);
string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, 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_Float osTerrainGetHeight(int x, int y);
LSL_Integer osTerrainSetHeight(int x, int y, double val); LSL_Integer osTerrainSetHeight(int x, int y, double val);

View File

@ -135,17 +135,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
} }
public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, 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, 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, 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, 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) public LSL_Float osTerrainGetHeight(int x, int y)