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;
public const int DISP_EXPIRE = 1;
public const int DISP_TEMP = 2;
private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>();
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,
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<IJ2KDecoder>();
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;
lock(part)
{
// mostly keep the values from before
Primitive.TextureEntry tmptex = part.Shape.Textures;
if (Face == ALL_SIDES)
{
tmptex.DefaultTexture.TextureID = asset.FullID;
}
else
{
try
{
Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
texface.TextureID = asset.FullID;
tmptex.FaceTextures[Face] = texface;
}
catch(Exception)
// remove the old asset from the cache
oldID = tmptex.DefaultTexture.TextureID;
if(Face == ALL_SIDES)
{
tmptex.DefaultTexture.TextureID = asset.FullID;
}
else
{
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;
part.UpdateTexture(tmptex);
}
// 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)
if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
{
// scene.CommsManager.AssetCache.ExpireAsset(oldID);
scene.AssetService.Delete(oldID.ToString());

View File

@ -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);
}

View File

@ -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<IDynamicTextureManager>();
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();
}
}

View File

@ -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);

View File

@ -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)