diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 02eaf5dee5..e901ff6f23 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -826,12 +826,7 @@ namespace OpenSim.Client.MXP.ClientStack OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene; AvatarAppearance appearance; scene.GetAvatarAppearance(this,out appearance); - List visualParams = new List(); - foreach (byte visualParam in appearance.VisualParams) - { - visualParams.Add(visualParam); - } - OnSetAppearance(appearance.Texture.GetBytes(), visualParams); + OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); } public void Stop() @@ -1649,5 +1644,9 @@ namespace OpenSim.Client.MXP.ClientStack public void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled) { } + + public void SendRebakeAvatarTextures(UUID textureID) + { + } } } diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index bfca954818..8c9eb5fdd5 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -1145,5 +1145,9 @@ namespace OpenSim.Client.VWoHTTP.ClientStack } #endregion + + public void SendRebakeAvatarTextures(UUID textureID) + { + } } } diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 940ae3b0b4..3f4214e580 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -380,13 +380,13 @@ namespace OpenSim.Framework /// /// Set up appearance textures and avatar parameters, including a height calculation /// - /// - /// - public virtual void SetAppearance(byte[] texture, List visualParam) + public virtual void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) { - Primitive.TextureEntry textureEnt = new Primitive.TextureEntry(texture, 0, texture.Length); - m_texture = textureEnt; - m_visualparams = visualParam.ToArray(); + if (textureEntry != null) + m_texture = textureEntry; + if (visualParams != null) + m_visualparams = visualParams; + m_avatarHeight = 1.23077f // Shortest possible avatar height + 0.516945f * (float)m_visualparams[(int)VPElement.SHAPE_HEIGHT] / 255.0f // Body height + 0.072514f * (float)m_visualparams[(int)VPElement.SHAPE_HEAD_SIZE] / 255.0f // Head size diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs index e03229b6ac..857930aaef 100644 --- a/OpenSim/Framework/BlockingQueue.cs +++ b/OpenSim/Framework/BlockingQueue.cs @@ -66,7 +66,9 @@ namespace OpenSim.Framework if (m_pqueue.Count > 0) return m_pqueue.Dequeue(); - return m_queue.Dequeue(); + if (m_queue.Count > 0) + return m_queue.Dequeue(); + return default(T); } } @@ -119,6 +121,7 @@ namespace OpenSim.Framework { m_pqueue.Clear(); m_queue.Clear(); + Monitor.Pulse(m_queueSync); } } } diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 4bc35e6fa7..d3bd9e7f1e 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); - public delegate void SetAppearance(byte[] texture, List visualParamList); + public delegate void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams); public delegate void StartAnim(IClientAPI remoteClient, UUID animID); @@ -1127,7 +1127,6 @@ namespace OpenSim.Framework void SetClientOption(string option, string value); string GetClientOption(string option); - void Terminate(); void SendSetFollowCamProperties(UUID objectID, SortedDictionary parameters); void SendClearFollowCamProperties(UUID objectID); @@ -1175,5 +1174,7 @@ namespace OpenSim.Framework void KillEndDone(); bool AddGenericPacketHandler(string MethodName, GenericMessage handler); + + void SendRebakeAvatarTextures(UUID textureID); } } diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Framework/PacketPool.cs index 8075ce632c..7e2860e07d 100644 --- a/OpenSim/Framework/PacketPool.cs +++ b/OpenSim/Framework/PacketPool.cs @@ -234,7 +234,8 @@ namespace OpenSim.Framework lock (DataBlocks) { - DataBlocks[typeof(T)].Push(block); + if (DataBlocks[typeof(T)].Count < 50) + DataBlocks[typeof(T)].Push(block); } } } diff --git a/OpenSim/Framework/Servers/HttpServer/Tests/BaseRequestHandlerTests.cs b/OpenSim/Framework/Servers/HttpServer/Tests/BaseRequestHandlerTests.cs deleted file mode 100644 index 2fa118d4e4..0000000000 --- a/OpenSim/Framework/Servers/HttpServer/Tests/BaseRequestHandlerTests.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using NUnit.Framework; -using OpenSim.Tests.Common.Setup; - -namespace OpenSim.Framework.Servers.HttpServer.Tests -{ - [TestFixture] - public class BaseRequestHandlerTests - { - private const string BASE_PATH = "/testpath"; - - private class BaseRequestHandlerImpl : BaseRequestHandler - { - public BaseRequestHandlerImpl(string httpMethod, string path) : base(httpMethod, path) - { - } - } - - [Test] - public void TestConstructor() - { - new BaseRequestHandlerImpl(null, null); - } - - [Test] - public void TestGetParams() - { - BaseRequestHandlerImpl handler = new BaseRequestHandlerImpl(null, BASE_PATH); - - BaseRequestHandlerTestHelper.BaseTestGetParams(handler, BASE_PATH); - } - - [Test] - public void TestSplitParams() - { - BaseRequestHandlerImpl handler = new BaseRequestHandlerImpl(null, BASE_PATH); - - BaseRequestHandlerTestHelper.BaseTestSplitParams(handler, BASE_PATH); - } - } -} diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs index ecd35c02a9..2fda6f31cc 100644 --- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs +++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs @@ -227,8 +227,7 @@ namespace OpenSim.Framework.Tests wearbyte.Add(VisualParams[i]); } - - AvAppearance.SetAppearance(AvAppearance.Texture.GetBytes(), wearbyte); + AvAppearance.SetAppearance(AvAppearance.Texture, (byte[])VisualParams.Clone()); } /// diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index f0708124b5..4d8409bb52 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -306,10 +306,6 @@ namespace OpenSim "delete-region ", "Delete a region from disk", RunCommand); - m_console.Commands.AddCommand("region", false, "predecode-j2k", - "predecode-j2k []>", - "Precache assets,decode j2k layerdata", RunCommand); - m_console.Commands.AddCommand("region", false, "modules list", "modules list", "List modules", HandleModules); @@ -744,17 +740,6 @@ namespace OpenSim } break; - case "predecode-j2k": - if (cmdparams.Length > 0) - { - m_sceneManager.CacheJ2kDecode(Convert.ToInt32(cmdparams[0])); - } - else - { - m_sceneManager.CacheJ2kDecode(1); - } - break; - } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs index 32a4ad41a6..31f9580a88 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs @@ -34,16 +34,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP { public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes); public delegate void PacketDrop(Packet pack, Object id); + public delegate void QueueEmpty(ThrottleOutPacketType queue); public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, UUID agentID, ThrottleOutPacketType throttlePacketType); /// /// Interface to a class that handles all the activity involved with maintaining the client circuit (handling acks, /// resends, pings, etc.) /// - public interface ILLPacketHandler + public interface ILLPacketHandler : IDisposable { event PacketStats OnPacketStats; event PacketDrop OnPacketDrop; + event QueueEmpty OnQueueEmpty; SynchronizeClientHandler SynchronizeClient { set; } int PacketsReceived { get; } @@ -70,12 +72,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP void OutPacket(Packet NewPack, ThrottleOutPacketType throttlePacketType, Object id); LLPacketQueue PacketQueue { get; } - void Stop(); void Flush(); void Clear(); ClientInfo GetClientInfo(); void SetClientInfo(ClientInfo info); void AddImportantPacket(PacketType type); void RemoveImportantPacket(PacketType type); + int GetQueueCount(ThrottleOutPacketType queue); } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 638c765f93..5f549b5da1 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs @@ -38,40 +38,37 @@ using System.Reflection; namespace OpenSim.Region.ClientStack.LindenUDP { /// - /// We use this class to store image data and associated request data and attributes + /// Stores information about a current texture download and a reference to the texture asset /// public class J2KImage { + private const int IMAGE_PACKET_SIZE = 1000; + private const int FIRST_PACKET_SIZE = 600; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public double m_designatedPriorityKey; - public double m_requestedPriority = 0.0d; - public uint m_lastSequence = 0; + public uint m_lastSequence; + public float m_requestedPriority; public uint m_requestedPacketNumber; public sbyte m_requestedDiscardLevel; public UUID m_requestedUUID; public IJ2KDecoder m_j2kDecodeModule; public IAssetService m_assetCache; - public OpenJPEG.J2KLayerInfo[] Layers = new OpenJPEG.J2KLayerInfo[0]; - public AssetBase m_MissingSubstitute = null; - public bool m_decoded = false; - public bool m_completedSendAtCurrentDiscardLevel; + public OpenJPEG.J2KLayerInfo[] m_layers; + public bool m_decoded; + public bool m_hasasset; + public C5.IPriorityQueueHandle m_priorityQueueHandle; - private sbyte m_discardLevel=-1; private uint m_packetNumber; - private bool m_decoderequested = false; - private bool m_hasasset = false; - private bool m_asset_requested = false; - private bool m_sentinfo = false; - private uint m_stopPacket = 0; - private const int cImagePacketSize = 1000; - private const int cFirstPacketSize = 600; - private AssetBase m_asset = null; - private LLImageManager m_image; - public J2KImage(LLImageManager image) - { - m_image = image; - } + private bool m_decoderequested; + private bool m_asset_requested; + private bool m_sentinfo; + private uint m_stopPacket; + private AssetBase m_asset; + private int m_assetDataLength; + private LLImageManager m_imageManager; + + #region Properties public uint m_pPacketNumber { @@ -84,10 +81,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP public byte[] Data { - get - { - if (m_asset != null) - return m_asset.Data; + get + { + if (m_asset != null) + return m_asset.Data; else return null; } @@ -97,9 +94,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (!m_decoded) return 0; + try { - return (ushort)(((m_asset.Data.Length - cFirstPacketSize + cImagePacketSize - 1) / cImagePacketSize) + 1); + return (ushort)(((m_assetDataLength - FIRST_PACKET_SIZE + IMAGE_PACKET_SIZE - 1) / IMAGE_PACKET_SIZE) + 1); } catch (Exception) { @@ -110,119 +108,154 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - public void J2KDecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers) + #endregion Properties + + public J2KImage(LLImageManager imageManager) { - m_image.m_outstandingtextures++; - Layers = layers; - m_decoded = true; - RunUpdate(); + m_imageManager = imageManager; } - public void AssetDataCallback(UUID AssetID, AssetBase asset) + public bool SendPackets(LLClientView client, int maxpack) { - m_hasasset = true; - if (asset == null || asset.Data == null) + if (m_packetNumber <= m_stopPacket) { - m_asset = m_MissingSubstitute; - } - else - { - m_asset = asset; - } - RunUpdate(); - } - - protected void AssetReceived(string id, Object sender, AssetBase asset) - { - UUID assetID = UUID.Zero; - if (asset != null) - assetID = asset.FullID; - - AssetDataCallback(assetID, asset); - - } - - private int GetPacketForBytePosition(int bytePosition) - { - return ((bytePosition - cFirstPacketSize + cImagePacketSize - 1) / cImagePacketSize) + 1; - } - - public int LastPacketSize() - { - if (m_packetNumber == 1) - return m_asset.Data.Length; - int lastsize = (m_asset.Data.Length - cFirstPacketSize) % cImagePacketSize; - //If the last packet size is zero, it's really cImagePacketSize, it sits on the boundary - if (lastsize == 0) - { - lastsize = cImagePacketSize; - } - return lastsize; - } - - public int CurrentBytePosition() - { - if (m_packetNumber == 0) - return 0; - if (m_packetNumber == 1) - return cFirstPacketSize; - - int result = cFirstPacketSize + ((int)m_packetNumber - 2) * cImagePacketSize; - if (result < 0) - { - result = cFirstPacketSize; - } - return result; - } - - public bool SendFirstPacket(LLClientView client) - { - // this means we don't have - if (Data == null) - { - client.SendImageNotFound(m_requestedUUID); - m_log.WarnFormat("[TEXTURE]: Got null Data element on a asset {0}.. and the missing image Data property is al", m_requestedUUID); - return true; - } - // Do we have less then 1 packet's worth of data? - else if (m_asset.Data.Length <= cFirstPacketSize) - { - // Send only 1 packet - client.SendImageFirstPart(1, m_requestedUUID, (uint)m_asset.Data.Length, m_asset.Data, 2); - m_stopPacket = 0; - return true; - } - else - { - byte[] firstImageData = new byte[cFirstPacketSize]; - try - { - Buffer.BlockCopy(m_asset.Data, 0, firstImageData, 0, (int)cFirstPacketSize); - client.SendImageFirstPart(TexturePacketCount(), m_requestedUUID, (uint)m_asset.Data.Length, firstImageData, 2); - } - catch (Exception) + bool SendMore = true; + if (!m_sentinfo || (m_packetNumber == 0)) { - m_log.Error("Texture block copy failed. Possibly out of memory?"); + if (SendFirstPacket(client)) + { + SendMore = false; + } + m_sentinfo = true; + m_packetNumber++; + } + // bool ignoreStop = false; + if (m_packetNumber < 2) + { + m_packetNumber = 2; + } + + int count = 0; + while (SendMore && count < maxpack && m_packetNumber <= m_stopPacket) + { + count++; + SendMore = SendPacket(client); + m_packetNumber++; + } + + if (m_packetNumber > m_stopPacket) return true; + } + + return false; + } + + public void RunUpdate() + { + //This is where we decide what we need to update + //and assign the real discardLevel and packetNumber + //assuming of course that the connected client might be bonkers + + if (!m_hasasset) + { + if (!m_asset_requested) + { + m_asset_requested = true; + m_assetCache.Get(m_requestedUUID.ToString(), this, AssetReceived); + } + } + else + { + if (!m_decoded) + { + //We need to decode the requested image first + if (!m_decoderequested) + { + //Request decode + m_decoderequested = true; + // Do we have a jpeg decoder? + if (m_j2kDecodeModule != null) + { + if (Data == null) + { + J2KDecodedCallback(m_requestedUUID, new OpenJPEG.J2KLayerInfo[0]); + } + else + { + // Send it off to the jpeg decoder + m_j2kDecodeModule.BeginDecode(m_requestedUUID, Data, J2KDecodedCallback); + } + + } + else + { + J2KDecodedCallback(m_requestedUUID, new OpenJPEG.J2KLayerInfo[0]); + } + } + } + else + { + // Check for missing image asset data + if (m_asset == null || m_asset.Data == null) + { + // FIXME: + m_packetNumber = m_stopPacket; + return; + } + + if (m_requestedDiscardLevel >= 0 || m_stopPacket == 0) + { + int maxDiscardLevel = Math.Max(0, m_layers.Length - 1); + + // Treat initial texture downloads with a DiscardLevel of -1 a request for the highest DiscardLevel + if (m_requestedDiscardLevel < 0 && m_stopPacket == 0) + m_requestedDiscardLevel = (sbyte)maxDiscardLevel; + + // Clamp at the highest discard level + m_requestedDiscardLevel = (sbyte)Math.Min(m_requestedDiscardLevel, maxDiscardLevel); + + //Calculate the m_stopPacket + if (m_layers.Length > 0) + { + m_stopPacket = (uint)GetPacketForBytePosition(m_layers[(m_layers.Length - 1) - m_requestedDiscardLevel].End); + //I don't know why, but the viewer seems to expect the final packet if the file + //is just one packet bigger. + if (TexturePacketCount() == m_stopPacket + 1) + { + m_stopPacket = TexturePacketCount(); + } + } + else + { + m_stopPacket = TexturePacketCount(); + } + + m_packetNumber = m_requestedPacketNumber; + } + + if (m_imageManager.Client.PacketHandler.GetQueueCount(ThrottleOutPacketType.Texture) == 0) + { + //m_log.Debug("No textures queued, sending one packet to kickstart it"); + SendPacket(m_imageManager.Client); + } } } - return false; } private bool SendPacket(LLClientView client) { bool complete = false; - int imagePacketSize = ((int)m_packetNumber == (TexturePacketCount())) ? LastPacketSize() : cImagePacketSize; + int imagePacketSize = ((int)m_packetNumber == (TexturePacketCount())) ? LastPacketSize() : IMAGE_PACKET_SIZE; try { - if ((CurrentBytePosition() + cImagePacketSize) > m_asset.Data.Length) + if ((CurrentBytePosition() + IMAGE_PACKET_SIZE) > m_assetDataLength) { imagePacketSize = LastPacketSize(); - complete=true; - if ((CurrentBytePosition() + imagePacketSize) > m_asset.Data.Length) + complete = true; + if ((CurrentBytePosition() + imagePacketSize) > m_assetDataLength) { - imagePacketSize = m_asset.Data.Length - CurrentBytePosition(); + imagePacketSize = m_assetDataLength - CurrentBytePosition(); complete = true; } } @@ -244,7 +277,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } //Send the packet - client.SendImageNextPart((ushort)(m_packetNumber-1), m_requestedUUID, imageData); + client.SendImageNextPart((ushort)(m_packetNumber - 1), m_requestedUUID, imageData); } if (complete) { @@ -260,143 +293,115 @@ namespace OpenSim.Region.ClientStack.LindenUDP return false; } } - public bool SendPackets(LLClientView client, int maxpack) + + private int GetPacketForBytePosition(int bytePosition) { + return ((bytePosition - FIRST_PACKET_SIZE + IMAGE_PACKET_SIZE - 1) / IMAGE_PACKET_SIZE) + 1; + } - if (!m_completedSendAtCurrentDiscardLevel) + private int LastPacketSize() + { + if (m_packetNumber == 1) + return m_assetDataLength; + int lastsize = (m_assetDataLength - FIRST_PACKET_SIZE) % IMAGE_PACKET_SIZE; + //If the last packet size is zero, it's really cImagePacketSize, it sits on the boundary + if (lastsize == 0) { - if (m_packetNumber <= m_stopPacket) + lastsize = IMAGE_PACKET_SIZE; + } + return lastsize; + } + + private int CurrentBytePosition() + { + if (m_packetNumber == 0) + return 0; + if (m_packetNumber == 1) + return FIRST_PACKET_SIZE; + + int result = FIRST_PACKET_SIZE + ((int)m_packetNumber - 2) * IMAGE_PACKET_SIZE; + if (result < 0) + { + result = FIRST_PACKET_SIZE; + } + return result; + } + + private bool SendFirstPacket(LLClientView client) + { + // this means we don't have + if (Data == null) + { + client.SendImageNotFound(m_requestedUUID); + m_log.WarnFormat("[TEXTURE]: Got null Data element on a asset {0}.. and the missing image Data property is also null", m_requestedUUID); + return true; + } + // Do we have less then 1 packet's worth of data? + else if (m_assetDataLength <= FIRST_PACKET_SIZE) + { + // Send only 1 packet + client.SendImageFirstPart(1, m_requestedUUID, (uint)m_assetDataLength, m_asset.Data, 2); + m_stopPacket = 0; + return true; + } + else + { + byte[] firstImageData = new byte[FIRST_PACKET_SIZE]; + try { - bool SendMore = true; - if (!m_sentinfo || (m_packetNumber == 0)) - { - if (SendFirstPacket(client)) - { - SendMore = false; - } - m_sentinfo = true; - m_packetNumber++; - } - // bool ignoreStop = false; - if (m_packetNumber < 2) - { - m_packetNumber = 2; - } - - int count = 0; - while (SendMore && count < maxpack && m_packetNumber <= m_stopPacket) - { - count++; - SendMore = SendPacket(client); - m_packetNumber++; - } - - if (m_packetNumber > m_stopPacket) - { - return true; - } + Buffer.BlockCopy(m_asset.Data, 0, firstImageData, 0, (int)FIRST_PACKET_SIZE); + client.SendImageFirstPart(TexturePacketCount(), m_requestedUUID, (uint)m_assetDataLength, firstImageData, 2); + } + catch (Exception) + { + m_log.Error("Texture block copy failed. Possibly out of memory?"); + return true; } } return false; } - public void RunUpdate() + private void J2KDecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers) { - //This is where we decide what we need to update - //and assign the real discardLevel and packetNumber - //assuming of course that the connected client might be bonkers + m_layers = layers; + m_decoded = true; + RunUpdate(); + } - if (!m_hasasset) + private void AssetDataCallback(UUID AssetID, AssetBase asset) + { + m_hasasset = true; + + if (asset == null || asset.Data == null) { - - if (!m_asset_requested) + if (m_imageManager.MissingImage != null) { - m_asset_requested = true; - m_assetCache.Get(m_requestedUUID.ToString(), this, AssetReceived); - - } - - } - else - { - - - if (!m_decoded) - { - //We need to decode the requested image first - if (!m_decoderequested) - { - //Request decode - m_decoderequested = true; - // Do we have a jpeg decoder? - if (m_j2kDecodeModule != null) - { - if (Data == null) - { - J2KDecodedCallback(m_requestedUUID, new OpenJPEG.J2KLayerInfo[0]); - } - // Send it off to the jpeg decoder - m_j2kDecodeModule.decode(m_requestedUUID, Data, J2KDecodedCallback); - - } - else - { - J2KDecodedCallback(m_requestedUUID, new OpenJPEG.J2KLayerInfo[0]); - } - } - + m_asset = m_imageManager.MissingImage; + m_assetDataLength = m_asset.Data.Length; } else { - //discardLevel of -1 means just update the priority - if (m_requestedDiscardLevel != -1) - { - //Evaluate the discard level - //First, is it positive? - if (m_requestedDiscardLevel >= 0) - { - if (m_requestedDiscardLevel > Layers.Length - 1) - { - m_discardLevel = (sbyte)(Layers.Length - 1); - } - else - { - m_discardLevel = m_requestedDiscardLevel; - } - - //Calculate the m_stopPacket - if (Layers.Length > 0) - { - m_stopPacket = (uint)GetPacketForBytePosition(Layers[(Layers.Length - 1) - m_discardLevel].End); - //I don't know why, but the viewer seems to expect the final packet if the file - //is just one packet bigger. - if (TexturePacketCount() == m_stopPacket + 1) - { - m_stopPacket = TexturePacketCount(); - } - } - else - { - m_stopPacket = TexturePacketCount(); - } - //Don't reset packet number unless we're waiting or it's ahead of us - if (m_completedSendAtCurrentDiscardLevel || m_requestedPacketNumber>m_packetNumber) - { - m_packetNumber = m_requestedPacketNumber; - } - - if (m_packetNumber <= m_stopPacket) - { - m_completedSendAtCurrentDiscardLevel = false; - } - } - } - else - { - m_packetNumber = m_stopPacket; - } + m_asset = null; + m_decoded = true; } } + else + { + m_asset = asset; + m_assetDataLength = m_asset.Data.Length; + } + + RunUpdate(); + } + + private void AssetReceived(string id, Object sender, AssetBase asset) + { + UUID assetID = UUID.Zero; + if (asset != null) + assetID = asset.FullID; + + AssetDataCallback(assetID, asset); + } } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 88ace6af05..3b43771861 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -81,8 +81,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP private List m_primFullUpdates = new List(); - private Timer m_textureRequestTimer; - private bool m_clientBlocked; private int m_probesWithNoIngressPackets; @@ -143,9 +141,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected int m_primTerseUpdateRate = 10; protected int m_primFullUpdateRate = 14; - protected int m_textureRequestRate = 100; - protected int m_textureSendLimit = 10; - protected int m_textureDataLimit = 5; + protected int m_textureSendLimit = 20; + protected int m_textureDataLimit = 10; protected int m_packetMTU = 1400; @@ -534,6 +531,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_PacketHandler = new LLPacketHandler(this, m_networkServer, userSettings); m_PacketHandler.SynchronizeClient = SynchronizeClient; m_PacketHandler.OnPacketStats += PopulateStats; + m_PacketHandler.OnQueueEmpty += HandleQueueEmpty; if (scene.Config != null) { @@ -555,9 +553,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_primFullUpdateRate = clientConfig.GetInt("FullUpdateRate", m_primFullUpdateRate); - m_textureRequestRate = clientConfig.GetInt("TextureRequestRate", - m_textureRequestRate); - m_textureSendLimit = clientConfig.GetInt("TextureSendLimit", m_textureSendLimit); @@ -607,9 +602,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_primFullUpdateTimer.Enabled) lock (m_primFullUpdateTimer) m_primFullUpdateTimer.Stop(); - if (m_textureRequestTimer.Enabled) - lock (m_textureRequestTimer) - m_textureRequestTimer.Stop(); // This is just to give the client a reasonable chance of // flushing out all it's packets. There should probably @@ -633,6 +625,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // of the client thread regardless of where Close() is called. KillEndDone(); } + + Terminate(); } /// @@ -704,10 +698,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_primFullUpdateTimer.Enabled) lock (m_primFullUpdateTimer) m_primFullUpdateTimer.Stop(); - - if (m_textureRequestTimer.Enabled) - lock (m_textureRequestTimer) - m_textureRequestTimer.Stop(); } public void Restart() @@ -730,23 +720,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_primFullUpdateTimer = new Timer(m_primFullUpdateRate); m_primFullUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessPrimFullUpdates); m_primFullUpdateTimer.AutoReset = false; - - m_textureRequestTimer = new Timer(m_textureRequestRate); - m_textureRequestTimer.Elapsed += new ElapsedEventHandler(ProcessTextureRequests); - m_textureRequestTimer.AutoReset = false; - } - public void Terminate() + private void Terminate() { + IsActive = false; + + m_clientPingTimer.Close(); + m_avatarTerseUpdateTimer.Close(); + m_primTerseUpdateTimer.Close(); + m_primFullUpdateTimer.Close(); + m_PacketHandler.OnPacketStats -= PopulateStats; - m_PacketHandler.Stop(); + m_PacketHandler.Dispose(); // wait for thread stoped - m_clientThread.Join(); + // m_clientThread.Join(); // delete circuit code - m_networkServer.CloseClient(this); + //m_networkServer.CloseClient(this); } #endregion @@ -876,6 +868,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP while (IsActive) { LLQueItem nextPacket = m_PacketHandler.PacketQueue.Dequeue(); + + if (nextPacket == null) { + m_log.DebugFormat("[CLIENT]: PacketQueue return null LLQueItem"); + continue; + } if (nextPacket.Incoming) { @@ -967,10 +964,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_primFullUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessPrimFullUpdates); m_primFullUpdateTimer.AutoReset = false; - m_textureRequestTimer = new Timer(m_textureRequestRate); - m_textureRequestTimer.Elapsed += new ElapsedEventHandler(ProcessTextureRequests); - m_textureRequestTimer.AutoReset = false; - m_scene.AddNewClient(this); RefreshGroupMembership(); @@ -1042,26 +1035,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - protected virtual void TextureRequestHandler() - { - m_log.DebugFormat("[TRH] Thread started"); - while (m_imageManager != null) - { - try - { - while (m_imageManager != null) - { - } - } - catch (Exception e) - { - m_log.WarnFormat("[TRH] Exception in handler loop: {0}", e.Message); - m_log.Debug(e); - } - } - m_log.DebugFormat("[TRH] Thread terminated"); - } - # endregion // Previously ClientView.API partial class @@ -3161,20 +3134,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - // Unlike the other timers, this one is only started after - // the first request is seen. + void HandleQueueEmpty(ThrottleOutPacketType queue) + { + switch (queue) + { + case ThrottleOutPacketType.Texture: + ProcessTextureRequests(); + break; + } + } - void ProcessTextureRequests(object sender, ElapsedEventArgs e) + void ProcessTextureRequests() { if (m_imageManager != null) - { - if (m_imageManager.ProcessImageQueue(m_textureSendLimit, - m_textureDataLimit)) - { - lock (m_textureRequestTimer) - m_textureRequestTimer.Start(); - } - } + m_imageManager.ProcessImageQueue(m_textureSendLimit, m_textureDataLimit); } void ProcessPrimFullUpdates(object sender, ElapsedEventArgs e) @@ -5275,13 +5248,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP // for the client session anyway, in order to protect ourselves against bad code in plugins try { - List visualparams = new List(); - foreach (AgentSetAppearancePacket.VisualParamBlock x in appear.VisualParam) - { - visualparams.Add(x.ParamValue); - } + byte[] visualparams = new byte[appear.VisualParam.Length]; + for (int i = 0; i < appear.VisualParam.Length; i++) + visualparams[i] = appear.VisualParam[i].ParamValue; - handlerSetAppearance(appear.ObjectData.TextureEntry, visualparams); + Primitive.TextureEntry te = null; + if (appear.ObjectData.TextureEntry.Length > 1) + te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); + + handlerSetAppearance(te, visualparams); } catch (Exception e) { @@ -6624,8 +6599,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_imageManager != null) { m_imageManager.EnqueueReq(args); - lock (m_textureRequestTimer) - m_textureRequestTimer.Start(); } } } @@ -11026,5 +10999,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion + + public void SendRebakeAvatarTextures(UUID textureID) + { + RebakeAvatarTexturesPacket pack = + (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures); + + pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock(); + pack.TextureData.TextureID = textureID; + OutPacket(pack, ThrottleOutPacketType.Task); + } } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 295a5e6f99..a484fdf83d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs @@ -27,58 +27,60 @@ using System; using System.Threading; +using System.Collections; using System.Collections.Generic; +using System.Reflection; using OpenMetaverse; using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Services.Interfaces; using log4net; -using System.Reflection; namespace OpenSim.Region.ClientStack.LindenUDP { - public class LLImageManager { - - //Public interfaces: - //Constructor - (LLClientView, IAssetCache, IJ2KDecoder); - //void EnqueueReq - (TextureRequestArgs) - //ProcessImageQueue - //Close + private sealed class J2KImageComparer : IComparer + { + public int Compare(J2KImage x, J2KImage y) + { + return x.m_requestedPriority.CompareTo(y.m_requestedPriority); + } + } + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_shuttingdown = false; private long m_lastloopprocessed = 0; + private AssetBase m_missingImage = null; private LLClientView m_client; //Client we're assigned to private IAssetService m_assetCache; //Asset Cache private IJ2KDecoder m_j2kDecodeModule; //Our J2K module + private C5.IntervalHeap m_priorityQueue = new C5.IntervalHeap(10, new J2KImageComparer()); - private readonly AssetBase m_missingsubstitute; //Sustitute for bad decodes - private Dictionary m_imagestore; // Our main image storage dictionary - private SortedList m_priorities; // For fast image lookup based on priority - private Dictionary m_priorityresolver; //Enabling super fast assignment of images with the same priorities - - private const double doubleMinimum = .0000001; - - public int m_outstandingtextures = 0; - //Constructor public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) { - - m_imagestore = new Dictionary(); - m_priorities = new SortedList(); - m_priorityresolver = new Dictionary(); m_client = client; m_assetCache = pAssetCache; if (pAssetCache != null) - m_missingsubstitute = pAssetCache.Get("5748decc-f629-461c-9a36-a35a221fe21f"); + m_missingImage = pAssetCache.Get("5748decc-f629-461c-9a36-a35a221fe21f"); else - m_log.Error("[ClientView] - couldn't set missing image, all manner of things will probably break"); + m_log.Error("[ClientView] - couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); + m_j2kDecodeModule = pJ2kDecodeModule; } + public LLClientView Client + { + get { return m_client; } + } + + public AssetBase MissingImage + { + get { return m_missingImage; } + } + public void EnqueueReq(TextureRequestArgs newRequest) { //newRequest is the properties of our new texture fetch request. @@ -88,234 +90,203 @@ namespace OpenSim.Region.ClientStack.LindenUDP //Make sure we're not shutting down.. if (!m_shuttingdown) { + J2KImage imgrequest; - //Do we already know about this UUID? - if (m_imagestore.ContainsKey(newRequest.RequestedAssetID)) + // Do a linear search for this texture download + lock (m_priorityQueue) + m_priorityQueue.Find(delegate(J2KImage img) { return img.m_requestedUUID == newRequest.RequestedAssetID; }, out imgrequest); + + if (imgrequest != null) { - //Check the packet sequence to make sure this isn't older than - //one we've already received - - J2KImage imgrequest = m_imagestore[newRequest.RequestedAssetID]; - - // This is the inbound request sequence number. We can ignore - // "old" ones. - - if (newRequest.requestSequence > imgrequest.m_lastSequence) + if (newRequest.DiscardLevel == -1 && newRequest.Priority == 0f) { + //m_log.Debug("[TEX]: (CAN) ID=" + newRequest.RequestedAssetID); - imgrequest.m_lastSequence = newRequest.requestSequence; - - //Check the priority - - double priority = imgrequest.m_requestedPriority; - if (priority != newRequest.Priority) + try { - //Remove the old priority - m_priorities.Remove(imgrequest.m_designatedPriorityKey); - //Assign a new unique priority - imgrequest.m_requestedPriority = newRequest.Priority; - imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority); + lock (m_priorityQueue) + m_priorityQueue.Delete(imgrequest.m_priorityQueueHandle); } + catch (Exception) { } + } + else + { + //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", + // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); - //Update the requested discard level - imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel; - - //Update the requested packet number - imgrequest.m_requestedPacketNumber = newRequest.PacketNumber; - - //Check if this will create an outstanding texture request - bool activated = imgrequest.m_completedSendAtCurrentDiscardLevel; - //Run an update - - imgrequest.RunUpdate(); - - if (activated && !imgrequest.m_completedSendAtCurrentDiscardLevel && imgrequest.m_decoded) + //Check the packet sequence to make sure this isn't older than + //one we've already received + if (newRequest.requestSequence > imgrequest.m_lastSequence) { - Interlocked.Increment(ref m_outstandingtextures); + //Update the sequence number of the last RequestImage packet + imgrequest.m_lastSequence = newRequest.requestSequence; + + //Update the requested discard level + imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel; + + //Update the requested packet number + imgrequest.m_requestedPacketNumber = newRequest.PacketNumber; + + //Update the requested priority + imgrequest.m_requestedPriority = newRequest.Priority; + try + { + lock (m_priorityQueue) + m_priorityQueue.Replace(imgrequest.m_priorityQueueHandle, imgrequest); + } + catch (Exception) + { + imgrequest.m_priorityQueueHandle = null; + lock (m_priorityQueue) + m_priorityQueue.Add(ref imgrequest.m_priorityQueueHandle, imgrequest); + } + + //Run an update + imgrequest.RunUpdate(); } } } else { - J2KImage imgrequest = new J2KImage(this); + if (newRequest.DiscardLevel == -1 && newRequest.Priority == 0f) + { + //m_log.DebugFormat("[TEX]: (IGN) ID={0}: D={1}, S={2}, P={3}", + // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); + } + else + { + //m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}", + // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); - //Assign our missing substitute - imgrequest.m_MissingSubstitute = m_missingsubstitute; + imgrequest = new J2KImage(this); - //Assign our decoder module - imgrequest.m_j2kDecodeModule = m_j2kDecodeModule; + //Assign our decoder module + imgrequest.m_j2kDecodeModule = m_j2kDecodeModule; - //Assign our asset cache module - imgrequest.m_assetCache = m_assetCache; + //Assign our asset cache module + imgrequest.m_assetCache = m_assetCache; - //Assign a priority based on our request - imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority); + //Assign the requested discard level + imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel; - //Assign the requested discard level - imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel; + //Assign the requested packet number + imgrequest.m_requestedPacketNumber = newRequest.PacketNumber; - //Assign the requested packet number - imgrequest.m_requestedPacketNumber = newRequest.PacketNumber; + //Assign the requested priority + imgrequest.m_requestedPriority = newRequest.Priority; - //Assign the requested priority - imgrequest.m_requestedPriority = newRequest.Priority; + //Assign the asset uuid + imgrequest.m_requestedUUID = newRequest.RequestedAssetID; - //Assign the asset uuid - imgrequest.m_requestedUUID = newRequest.RequestedAssetID; + //Assign the requested priority + imgrequest.m_requestedPriority = newRequest.Priority; - m_imagestore.Add(imgrequest.m_requestedUUID, imgrequest); - - //Run an update - imgrequest.RunUpdate(); + //Add this download to the priority queue + lock (m_priorityQueue) + m_priorityQueue.Add(ref imgrequest.m_priorityQueueHandle, imgrequest); + //Run an update + imgrequest.RunUpdate(); + } } } } - private double AssignPriority(UUID pAssetID, double pPriority) - { - - //First, find out if we can just assign directly - if (m_priorityresolver.ContainsKey((int)pPriority) == false) - { - m_priorities.Add((double)((int)pPriority), pAssetID); - m_priorityresolver.Add((int)pPriority, 0); - return (double)((int)pPriority); - } - else - { - //Use the hash lookup goodness of a secondary dictionary to find a free slot - double mFreePriority = ((int)pPriority) + (doubleMinimum * (m_priorityresolver[(int)pPriority] + 1)); - m_priorities[mFreePriority] = pAssetID; - m_priorityresolver[(int)pPriority]++; - return mFreePriority; - } - - - - } - public bool ProcessImageQueue(int count, int maxpack) { + lock (this) + { + //count is the number of textures we want to process in one go. + //As part of this class re-write, that number will probably rise + //since we're processing in a more efficient manner. - // this can happen during Close() - if (m_client == null) - return false; - - //Count is the number of textures we want to process in one go. - //As part of this class re-write, that number will probably rise - //since we're processing in a more efficient manner. - - int numCollected = 0; + // this can happen during Close() + if (m_client == null) + return false; - //Calculate our threshold - int threshold; - if (m_lastloopprocessed == 0) - { - if (m_client.PacketHandler == null || m_client.PacketHandler.PacketQueue == null || m_client.PacketHandler.PacketQueue.TextureThrottle == null) - return false; - //This is decent for a semi fast machine, but we'll calculate it more accurately based on time below - threshold = m_client.PacketHandler.PacketQueue.TextureThrottle.Current / 6300; - m_lastloopprocessed = DateTime.Now.Ticks; - } - else - { - double throttleseconds = ((double)DateTime.Now.Ticks - (double)m_lastloopprocessed) / (double)TimeSpan.TicksPerSecond; - throttleseconds = throttleseconds * m_client.PacketHandler.PacketQueue.TextureThrottle.Current; - - //Average of 1000 bytes per packet - throttleseconds = throttleseconds / 1000; - - //Safe-zone multiplier of 2.0 - threshold = (int)(throttleseconds * 2.0); - m_lastloopprocessed = DateTime.Now.Ticks; - - } - - if (threshold < 10) - { - threshold = 10; - } + int numCollected = 0; - if (m_client.PacketHandler == null) - return false; - - if (m_client.PacketHandler.PacketQueue == null) - return false; - - //First of all make sure our packet queue isn't above our threshold - - //Uncomment this to see what the texture stack is doing - //m_log.Debug("Queue: " + m_client.PacketHandler.PacketQueue.TextureOutgoingPacketQueueCount.ToString() + " Threshold: " + threshold.ToString() + " outstanding: " + m_outstandingtextures.ToString()); - if (m_client.PacketHandler.PacketQueue.TextureOutgoingPacketQueueCount < threshold && m_outstandingtextures > 0) - { - bool justreset = false; - - for (int x = m_priorities.Count - 1; x > -1; x--) + //Calculate our threshold + int threshold; + if (m_lastloopprocessed == 0) { - - J2KImage imagereq = m_imagestore[m_priorities.Values[x]]; - if (imagereq.m_decoded == true && !imagereq.m_completedSendAtCurrentDiscardLevel) + if (m_client.PacketHandler == null || m_client.PacketHandler.PacketQueue == null || m_client.PacketHandler.PacketQueue.TextureThrottle == null) + return false; + //This is decent for a semi fast machine, but we'll calculate it more accurately based on time below + threshold = m_client.PacketHandler.PacketQueue.TextureThrottle.Current / 6300; + m_lastloopprocessed = DateTime.Now.Ticks; + } + else + { + double throttleseconds = ((double)DateTime.Now.Ticks - (double)m_lastloopprocessed) / (double)TimeSpan.TicksPerSecond; + throttleseconds = throttleseconds * m_client.PacketHandler.PacketQueue.TextureThrottle.Current; + + //Average of 1000 bytes per packet + throttleseconds = throttleseconds / 1000; + + //Safe-zone multiplier of 2.0 + threshold = (int)(throttleseconds * 2.0); + m_lastloopprocessed = DateTime.Now.Ticks; + + } + + if (m_client.PacketHandler == null) + return false; + + if (m_client.PacketHandler.PacketQueue == null) + return false; + + if (threshold < 10) + threshold = 10; + + //Uncomment this to see what the texture stack is doing + //m_log.Debug("Queue: " + m_client.PacketHandler.PacketQueue.getQueueCount(ThrottleOutPacketType.Texture).ToString() + " Threshold: " + threshold.ToString() + " outstanding: " + m_outstandingtextures.ToString()); + if (true) //m_client.PacketHandler.PacketQueue.GetQueueCount(ThrottleOutPacketType.Texture) < threshold) + { + while (m_priorityQueue.Count > 0) { - numCollected++; - //SendPackets will send up to ten packets per cycle - if (imagereq.SendPackets(m_client, maxpack)) + J2KImage imagereq = null; + lock (m_priorityQueue) + imagereq = m_priorityQueue.FindMax(); + + if (imagereq.m_decoded == true) { - //Send complete - if (!imagereq.m_completedSendAtCurrentDiscardLevel) + // we need to test this here now that we are dropping assets + if (!imagereq.m_hasasset) { - imagereq.m_completedSendAtCurrentDiscardLevel = true; - Interlocked.Decrement(ref m_outstandingtextures); - //Re-assign priority to bottom - //Remove the old priority - m_priorities.Remove(imagereq.m_designatedPriorityKey); - int lowest; - if (m_priorities.Count > 0) - { - lowest = (int)m_priorities.Keys[0]; - lowest--; - } - else - { - lowest = -10000; - } - m_priorities.Add((double)lowest, imagereq.m_requestedUUID); - imagereq.m_designatedPriorityKey = (double)lowest; - if (m_priorityresolver.ContainsKey((int)lowest)) - { - m_priorityresolver[(int)lowest]++; - } - else - { - m_priorityresolver.Add((int)lowest, 0); + m_log.WarnFormat("[LLIMAGE MANAGER]: Re-requesting the image asset {0}", imagereq.m_requestedUUID); + imagereq.RunUpdate(); + continue; + } + + ++numCollected; + + //SendPackets will send up to ten packets per cycle + if (imagereq.SendPackets(m_client, maxpack)) + { + // Send complete. Destroy any knowledge of this transfer + try + { + lock (m_priorityQueue) + m_priorityQueue.Delete(imagereq.m_priorityQueueHandle); } + catch (Exception) { } } } - if (numCollected == count) - { - break; - } - } - if (numCollected == count || m_outstandingtextures == 0) - break; - if (numCollected % m_outstandingtextures == 0 && !justreset) - { - //We've gotten as much as we can from the stack, - //reset to the top so that we can send MOAR DATA (nomnomnom)! - x = m_priorities.Count - 1; - justreset = true; //prevents us from getting stuck in a loop + if (numCollected == count) + break; } } - } - return m_outstandingtextures != 0; + return m_priorityQueue.Count > 0; + } } //Faux destructor public void Close() { - + m_shuttingdown = true; m_j2kDecodeModule = null; m_assetCache = null; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index eaf8f603a9..e98a360211 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs @@ -129,6 +129,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // public event PacketStats OnPacketStats; public event PacketDrop OnPacketDrop; + public event QueueEmpty OnQueueEmpty; //private SynchronizeClientHandler m_SynchronizeClient = null; @@ -172,13 +173,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_PacketQueue = new LLPacketQueue(client.AgentId, userSettings); + m_PacketQueue.OnQueueEmpty += TriggerOnQueueEmpty; + m_AckTimer.Elapsed += AckTimerElapsed; m_AckTimer.Start(); } - public void Stop() + public void Dispose() { m_AckTimer.Stop(); + m_AckTimer.Close(); m_PacketQueue.Enqueue(null); m_PacketQueue.Close(); @@ -768,6 +772,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerPacketDrop(packet, id); } + private void TriggerOnQueueEmpty(ThrottleOutPacketType queue) + { + QueueEmpty handlerQueueEmpty = OnQueueEmpty; + + if (handlerQueueEmpty != null) + handlerQueueEmpty(queue); + } + // Convert the packet to bytes and stuff it onto the send queue // public void ProcessOutPacket(LLQueItem item) @@ -849,5 +861,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_PacketQueue.Close(); Thread.CurrentThread.Abort(); } + + public int GetQueueCount(ThrottleOutPacketType queue) + { + return m_PacketQueue.GetQueueCount(queue); + } } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs index c4278705a4..3eed2e0fc1 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs @@ -39,7 +39,7 @@ using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack.LindenUDP { - public class LLPacketQueue : IPullStatsProvider + public class LLPacketQueue : IPullStatsProvider, IDisposable { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -62,6 +62,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private Queue TextureOutgoingPacketQueue; private Queue AssetOutgoingPacketQueue; + private List Empty = new List(); + // m_log.Info("[THROTTLE]: Entering Throttle"); // private Dictionary PendingAcks = new Dictionary(); // private Dictionary NeedAck = new Dictionary(); @@ -85,26 +87,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP private Dictionary contents = new Dictionary(); - /// - /// The number of packets in the OutgoingPacketQueue - /// - /// - internal int TextureOutgoingPacketQueueCount - { - get - { - if (TextureOutgoingPacketQueue == null) - return 0; - return TextureOutgoingPacketQueue.Count; - } - } - // private long LastThrottle; // private long ThrottleInterval; private Timer throttleTimer; private UUID m_agentId; + public event QueueEmpty OnQueueEmpty; + public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings) { // While working on this, the BlockingQueue had me fooled for a bit. @@ -210,28 +200,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP switch (item.throttleType & ThrottleOutPacketType.TypeMask) { case ThrottleOutPacketType.Resend: - ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); + ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item, ThrottleOutPacketType.Resend); break; case ThrottleOutPacketType.Texture: - ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); + ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item, ThrottleOutPacketType.Texture); break; case ThrottleOutPacketType.Task: if ((item.throttleType & ThrottleOutPacketType.LowPriority) != 0) - ThrottleCheck(ref TaskThrottle, ref TaskLowpriorityPacketQueue, item); + ThrottleCheck(ref TaskThrottle, ref TaskLowpriorityPacketQueue, item, ThrottleOutPacketType.Task); else - ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); + ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item, ThrottleOutPacketType.Task); break; case ThrottleOutPacketType.Land: - ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); + ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item, ThrottleOutPacketType.Land); break; case ThrottleOutPacketType.Asset: - ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); + ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item, ThrottleOutPacketType.Asset); break; case ThrottleOutPacketType.Cloud: - ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); + ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item, ThrottleOutPacketType.Cloud); break; case ThrottleOutPacketType.Wind: - ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); + ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item, ThrottleOutPacketType.Wind); break; default: @@ -283,43 +273,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP { lock (this) { - while (PacketsWaiting()) + // These categories do not contain transactional packets so we can safely drop any pending data in them + LandOutgoingPacketQueue.Clear(); + WindOutgoingPacketQueue.Clear(); + CloudOutgoingPacketQueue.Clear(); + TextureOutgoingPacketQueue.Clear(); + AssetOutgoingPacketQueue.Clear(); + + // Now comes the fun part.. we dump all remaining resend and task packets into the send queue + while (ResendOutgoingPacketQueue.Count > 0 || TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0) { - //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. if (ResendOutgoingPacketQueue.Count > 0) - { SendQueue.Enqueue(ResendOutgoingPacketQueue.Dequeue()); - } - if (LandOutgoingPacketQueue.Count > 0) - { - SendQueue.Enqueue(LandOutgoingPacketQueue.Dequeue()); - } - if (WindOutgoingPacketQueue.Count > 0) - { - SendQueue.Enqueue(WindOutgoingPacketQueue.Dequeue()); - } - if (CloudOutgoingPacketQueue.Count > 0) - { - SendQueue.Enqueue(CloudOutgoingPacketQueue.Dequeue()); - } + if (TaskOutgoingPacketQueue.Count > 0) - { SendQueue.PriorityEnqueue(TaskOutgoingPacketQueue.Dequeue()); - } + if (TaskLowpriorityPacketQueue.Count > 0) - { SendQueue.Enqueue(TaskLowpriorityPacketQueue.Dequeue()); - } - if (TextureOutgoingPacketQueue.Count > 0) - { - SendQueue.Enqueue(TextureOutgoingPacketQueue.Dequeue()); - } - if (AssetOutgoingPacketQueue.Count > 0) - { - SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue()); - } } - // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); } } @@ -341,12 +313,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP } public void Close() + { + Dispose(); + } + + public void Dispose() { Flush(); WipeClean(); // I'm sure there's a dirty joke in here somewhere. -AFrisby m_enabled = false; throttleTimer.Stop(); + throttleTimer.Close(); if (StatsManager.SimExtraStats != null) { @@ -388,6 +366,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once. int throttleLoops = 0; + List e; // We're going to dequeue all of the saved up packets until // we've hit the throttle limit or there's no more packets to send @@ -399,7 +378,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP bool qchanged = true; ResetCounters(); - // m_log.Info("[THROTTLE]: Entering Throttle"); + while (TotalThrottle.UnderLimit() && qchanged && throttleLoops <= MaxThrottleLoops) { qchanged = false; // We will break out of the loop if no work was accomplished @@ -425,6 +404,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP TotalThrottle.AddBytes(qpack.Length); LandThrottle.AddBytes(qpack.Length); qchanged = true; + + if (LandOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Land)) + Empty.Add(ThrottleOutPacketType.Land); } if ((WindOutgoingPacketQueue.Count > 0) && WindThrottle.UnderLimit()) @@ -435,6 +417,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP TotalThrottle.AddBytes(qpack.Length); WindThrottle.AddBytes(qpack.Length); qchanged = true; + + if (WindOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Wind)) + Empty.Add(ThrottleOutPacketType.Wind); } if ((CloudOutgoingPacketQueue.Count > 0) && CloudThrottle.UnderLimit()) @@ -445,6 +430,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP TotalThrottle.AddBytes(qpack.Length); CloudThrottle.AddBytes(qpack.Length); qchanged = true; + + if (CloudOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Cloud)) + Empty.Add(ThrottleOutPacketType.Cloud); } if ((TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0) && TaskThrottle.UnderLimit()) @@ -464,6 +452,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP TotalThrottle.AddBytes(qpack.Length); TaskThrottle.AddBytes(qpack.Length); qchanged = true; + + if (TaskOutgoingPacketQueue.Count == 0 && TaskLowpriorityPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Task)) + Empty.Add(ThrottleOutPacketType.Task); } if ((TextureOutgoingPacketQueue.Count > 0) && TextureThrottle.UnderLimit()) @@ -474,6 +465,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP TotalThrottle.AddBytes(qpack.Length); TextureThrottle.AddBytes(qpack.Length); qchanged = true; + + if (TextureOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Texture)) + Empty.Add(ThrottleOutPacketType.Texture); } if ((AssetOutgoingPacketQueue.Count > 0) && AssetThrottle.UnderLimit()) @@ -484,10 +478,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP TotalThrottle.AddBytes(qpack.Length); AssetThrottle.AddBytes(qpack.Length); qchanged = true; + + if (AssetOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Asset)) + Empty.Add(ThrottleOutPacketType.Asset); } } // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); + + e = new List(Empty); + Empty.Clear(); } + + foreach (ThrottleOutPacketType t in e) + { + if (GetQueueCount(t) == 0) + TriggerOnQueueEmpty(t); + } + } + + private void TriggerOnQueueEmpty(ThrottleOutPacketType queue) + { + QueueEmpty handlerQueueEmpty = OnQueueEmpty; + + if (handlerQueueEmpty != null) + handlerQueueEmpty(queue); } private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) @@ -497,7 +511,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ProcessThrottle(); } - private void ThrottleCheck(ref LLPacketThrottle throttle, ref Queue q, LLQueItem item) + private void ThrottleCheck(ref LLPacketThrottle throttle, ref Queue q, LLQueItem item, ThrottleOutPacketType itemType) { // The idea.. is if the packet throttle queues are empty // and the client is under throttle for the type. Queue @@ -513,6 +527,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP throttle.AddBytes(item.Length); TotalThrottle.AddBytes(item.Length); SendQueue.Enqueue(item); + lock (this) + { + if (!Empty.Contains(itemType)) + Empty.Add(itemType); + } } catch (Exception e) { @@ -698,5 +717,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP { get { return throttleMultiplier; } } + + public int GetQueueCount(ThrottleOutPacketType queue) + { + switch (queue) + { + case ThrottleOutPacketType.Land: + return LandOutgoingPacketQueue.Count; + case ThrottleOutPacketType.Wind: + return WindOutgoingPacketQueue.Count; + case ThrottleOutPacketType.Cloud: + return CloudOutgoingPacketQueue.Count; + case ThrottleOutPacketType.Task: + return TaskOutgoingPacketQueue.Count; + case ThrottleOutPacketType.Texture: + return TextureOutgoingPacketQueue.Count; + case ThrottleOutPacketType.Asset: + return AssetOutgoingPacketQueue.Count; + } + + return 0; + } } } diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 1fdb00371d..a0f359b629 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -34,8 +34,8 @@ using System.Threading; using log4net; using Nini.Config; using OpenMetaverse; -using OpenMetaverse.Assets; using OpenMetaverse.Imaging; +using CSJ2K; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -43,31 +43,25 @@ using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Agent.TextureSender { - public delegate void J2KDecodeDelegate(UUID AssetId); + public delegate void J2KDecodeDelegate(UUID assetID); public class J2KDecoderModule : IRegionModule, IJ2KDecoder { - #region IRegionModule Members + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Cached Decoded Layers - /// - private readonly Dictionary m_cacheddecode = new Dictionary(); - private bool OpenJpegFail = false; - private string CacheFolder = Util.dataDir() + "/j2kDecodeCache"; - private int CacheTimeout = 720; - private J2KDecodeFileCache fCache = null; - private Thread CleanerThread = null; - private IAssetService AssetService = null; - private Scene m_Scene = null; - - /// - /// List of client methods to notify of results of decode - /// + /// Temporarily holds deserialized layer data information in memory + private readonly ExpiringCache m_decodedCache = new ExpiringCache(); + /// List of client methods to notify of results of decode private readonly Dictionary> m_notifyList = new Dictionary>(); + /// Cache that will store decoded JPEG2000 layer boundary data + private IImprovedAssetCache m_cache; + /// Reference to a scene (doesn't matter which one as long as it can load the cache module) + private Scene m_scene; + + #region IRegionModule + + public string Name { get { return "J2KDecoderModule"; } } + public bool IsSharedModule { get { return true; } } public J2KDecoderModule() { @@ -75,630 +69,267 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender public void Initialise(Scene scene, IConfigSource source) { - if (m_Scene == null) - m_Scene = scene; - - IConfig j2kConfig = source.Configs["J2KDecoder"]; - if (j2kConfig != null) - { - CacheFolder = j2kConfig.GetString("CacheDir", CacheFolder); - CacheTimeout = j2kConfig.GetInt("CacheTimeout", CacheTimeout); - } - - if (fCache == null) - fCache = new J2KDecodeFileCache(CacheFolder, CacheTimeout); + if (m_scene == null) + m_scene = scene; scene.RegisterModuleInterface(this); - - if (CleanerThread == null && CacheTimeout != 0) - { - CleanerThread = new Thread(CleanCache); - CleanerThread.Name = "J2KCleanerThread"; - CleanerThread.IsBackground = true; - CleanerThread.Start(); - } } public void PostInitialise() { - AssetService = m_Scene.AssetService; + m_cache = m_scene.RequestModuleInterface(); } public void Close() { - } - public string Name + #endregion IRegionModule + + #region IJ2KDecoder + + public void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback) { - get { return "J2KDecoderModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - #region IJ2KDecoder Members - - - public void decode(UUID AssetId, byte[] assetData, DecodedCallback decodedReturn) - { - // Dummy for if decoding fails. - OpenJPEG.J2KLayerInfo[] result = new OpenJPEG.J2KLayerInfo[0]; - - // Check if it's cached - bool cached = false; - lock (m_cacheddecode) - { - if (m_cacheddecode.ContainsKey(AssetId)) - { - cached = true; - result = m_cacheddecode[AssetId]; - } - } + OpenJPEG.J2KLayerInfo[] result; // If it's cached, return the cached results - if (cached) + if (m_decodedCache.TryGetValue(assetID, out result)) { - decodedReturn(AssetId, result); + callback(assetID, result); } else { - // not cached, so we need to decode it + // Not cached, we need to decode it. // Add to notify list and start decoding. // Next request for this asset while it's decoding will only be added to the notify list // once this is decoded, requests will be served from the cache and all clients in the notifylist will be updated bool decode = false; lock (m_notifyList) { - if (m_notifyList.ContainsKey(AssetId)) + if (m_notifyList.ContainsKey(assetID)) { - m_notifyList[AssetId].Add(decodedReturn); + m_notifyList[assetID].Add(callback); } else { List notifylist = new List(); - notifylist.Add(decodedReturn); - m_notifyList.Add(AssetId, notifylist); + notifylist.Add(callback); + m_notifyList.Add(assetID, notifylist); decode = true; } } + // Do Decode! if (decode) - { - doJ2kDecode(AssetId, assetData); - } + DoJ2KDecode(assetID, j2kData); } } /// /// Provides a synchronous decode so that caller can be assured that this executes before the next line /// - /// - /// - public void syncdecode(UUID AssetId, byte[] j2kdata) + /// + /// + public void Decode(UUID assetID, byte[] j2kData) { - doJ2kDecode(AssetId, j2kdata); + DoJ2KDecode(assetID, j2kData); } - #endregion + #endregion IJ2KDecoder /// /// Decode Jpeg2000 Asset Data /// - /// UUID of Asset - /// Byte Array Asset Data - private void doJ2kDecode(UUID AssetId, byte[] j2kdata) + /// UUID of Asset + /// JPEG2000 data + private void DoJ2KDecode(UUID assetID, byte[] j2kData) { int DecodeTime = 0; DecodeTime = Environment.TickCount; - OpenJPEG.J2KLayerInfo[] layers = new OpenJPEG.J2KLayerInfo[0]; // Dummy result for if it fails. Informs that there's only full quality + OpenJPEG.J2KLayerInfo[] layers; - if (!OpenJpegFail) + if (!TryLoadCacheForAsset(assetID, out layers)) { - if (!fCache.TryLoadCacheForAsset(AssetId, out layers)) + try { - try - { + List layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData)); - AssetTexture texture = new AssetTexture(AssetId, j2kdata); - if (texture.DecodeLayerBoundaries()) + if (layerStarts != null && layerStarts.Count > 0) + { + layers = new OpenJPEG.J2KLayerInfo[layerStarts.Count]; + + for (int i = 0; i < layerStarts.Count; i++) { - bool sane = true; + OpenJPEG.J2KLayerInfo layer = new OpenJPEG.J2KLayerInfo(); - // Sanity check all of the layers - for (int i = 0; i < texture.LayerInfo.Length; i++) - { - if (texture.LayerInfo[i].End > texture.AssetData.Length) - { - sane = false; - break; - } - } - - if (sane) - { - layers = texture.LayerInfo; - fCache.SaveFileCacheForAsset(AssetId, layers); - - - // Write out decode time - m_log.InfoFormat("[J2KDecoderModule]: {0} Decode Time: {1}", Environment.TickCount - DecodeTime, - AssetId); - - } + if (i == 0) + layer.Start = 0; else - { - m_log.WarnFormat( - "[J2KDecoderModule]: JPEG2000 texture decoding succeeded, but sanity check failed for {0}", - AssetId); - } - } + layer.Start = layerStarts[i]; - else - { - /* - Random rnd = new Random(); - // scramble ends for test - for (int i = 0; i < texture.LayerInfo.Length; i++) - { - texture.LayerInfo[i].End = rnd.Next(999999); - } - */ - - // Try to do some heuristics error correction! Yeah. - bool sane2Heuristics = true; - - - if (texture.Image == null) - sane2Heuristics = false; - - if (texture.LayerInfo == null) - sane2Heuristics = false; - - if (sane2Heuristics) - { - - - if (texture.LayerInfo.Length == 0) - sane2Heuristics = false; - } - - if (sane2Heuristics) - { - // Last layer start is less then the end of the file and last layer start is greater then 0 - if (texture.LayerInfo[texture.LayerInfo.Length - 1].Start < texture.AssetData.Length && texture.LayerInfo[texture.LayerInfo.Length - 1].Start > 0) - { - } - else - { - sane2Heuristics = false; - } - - } - - if (sane2Heuristics) - { - int start = 0; - - // try to fix it by using consistant data in the start field - for (int i = 0; i < texture.LayerInfo.Length; i++) - { - if (i == 0) - start = 0; - - if (i == texture.LayerInfo.Length - 1) - texture.LayerInfo[i].End = texture.AssetData.Length; - else - texture.LayerInfo[i].End = texture.LayerInfo[i + 1].Start - 1; - - // in this case, the end of the next packet is less then the start of the last packet - // after we've attempted to fix it which means the start of the last packet is borked - // there's no recovery from this - if (texture.LayerInfo[i].End < start) - { - sane2Heuristics = false; - break; - } - - if (texture.LayerInfo[i].End < 0 || texture.LayerInfo[i].End > texture.AssetData.Length) - { - sane2Heuristics = false; - break; - } - - if (texture.LayerInfo[i].Start < 0 || texture.LayerInfo[i].Start > texture.AssetData.Length) - { - sane2Heuristics = false; - break; - } - - start = texture.LayerInfo[i].Start; - } - } - - if (sane2Heuristics) - { - layers = texture.LayerInfo; - fCache.SaveFileCacheForAsset(AssetId, layers); - - - // Write out decode time - m_log.InfoFormat("[J2KDecoderModule]: HEURISTICS SUCCEEDED {0} Decode Time: {1}", Environment.TickCount - DecodeTime, - AssetId); - - } + if (i == layerStarts.Count - 1) + layer.End = j2kData.Length; else - { - m_log.WarnFormat("[J2KDecoderModule]: JPEG2000 texture decoding failed for {0}. Is this a texture? is it J2K?", AssetId); - } + layer.End = layerStarts[i + 1] - 1; + + layers[i] = layer; } - texture = null; // dereference and dispose of ManagedImage - } - catch (DllNotFoundException) - { - m_log.Error( - "[J2KDecoderModule]: OpenJpeg is not installed properly. Decoding disabled! This will slow down texture performance! Often times this is because of an old version of GLIBC. You must have version 2.4 or above!"); - OpenJpegFail = true; - } - catch (Exception ex) - { - m_log.WarnFormat( - "[J2KDecoderModule]: JPEG2000 texture decoding threw an exception for {0}, {1}", - AssetId, ex); } } - + catch (Exception ex) + { + m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message); + } + + if (layers == null || layers.Length == 0) + { + m_log.Warn("[J2KDecoderModule]: Failed to decode layer data for texture " + assetID + ", guessing sane defaults"); + // Layer decoding completely failed. Guess at sane defaults for the layer boundaries + layers = CreateDefaultLayers(j2kData.Length); + } + + // Cache Decoded layers + SaveFileCacheForAsset(assetID, layers); } - - // Cache Decoded layers - lock (m_cacheddecode) - { - if (m_cacheddecode.ContainsKey(AssetId)) - m_cacheddecode.Remove(AssetId); - m_cacheddecode.Add(AssetId, layers); - - } - + // Notify Interested Parties lock (m_notifyList) { - if (m_notifyList.ContainsKey(AssetId)) + if (m_notifyList.ContainsKey(assetID)) { - foreach (DecodedCallback d in m_notifyList[AssetId]) + foreach (DecodedCallback d in m_notifyList[assetID]) { if (d != null) - d.DynamicInvoke(AssetId, layers); + d.DynamicInvoke(assetID, layers); } - m_notifyList.Remove(AssetId); + m_notifyList.Remove(assetID); } } } - - private void CleanCache() + + private OpenJPEG.J2KLayerInfo[] CreateDefaultLayers(int j2kLength) { - m_log.Info("[J2KDecoderModule]: Cleaner thread started"); + OpenJPEG.J2KLayerInfo[] layers = new OpenJPEG.J2KLayerInfo[5]; - while (true) - { - if (AssetService != null) - fCache.ScanCacheFiles(RedecodeTexture); + for (int i = 0; i < layers.Length; i++) + layers[i] = new OpenJPEG.J2KLayerInfo(); - System.Threading.Thread.Sleep(600000); - } + // These default layer sizes are based on a small sampling of real-world texture data + // with extra padding thrown in for good measure. This is a worst case fallback plan + // and may not gracefully handle all real world data + layers[0].Start = 0; + layers[1].Start = (int)((float)j2kLength * 0.02f); + layers[2].Start = (int)((float)j2kLength * 0.05f); + layers[3].Start = (int)((float)j2kLength * 0.20f); + layers[4].Start = (int)((float)j2kLength * 0.50f); + + layers[0].End = layers[1].Start - 1; + layers[1].End = layers[2].Start - 1; + layers[2].End = layers[3].Start - 1; + layers[3].End = layers[4].Start - 1; + layers[4].End = j2kLength; + + return layers; } - private void RedecodeTexture(UUID assetID) + private void SaveFileCacheForAsset(UUID AssetId, OpenJPEG.J2KLayerInfo[] Layers) { - AssetBase texture = AssetService.Get(assetID.ToString()); - if (texture == null) - return; + m_decodedCache.AddOrUpdate(AssetId, Layers, TimeSpan.FromMinutes(10)); - doJ2kDecode(assetID, texture.Data); - } - } - - public class J2KDecodeFileCache - { - private readonly string m_cacheDecodeFolder; - private readonly int m_cacheTimeout; - private bool enabled = true; - - private static readonly ILog m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// Creates a new instance of a file cache - /// - /// base folder for the cache. Will be created if it doesn't exist - public J2KDecodeFileCache(string pFolder, int timeout) - { - m_cacheDecodeFolder = pFolder; - m_cacheTimeout = timeout; - if (!Directory.Exists(pFolder)) + if (m_cache != null) { - Createj2KCacheFolder(pFolder); - } - } + AssetBase layerDecodeAsset = new AssetBase(); + layerDecodeAsset.ID = "j2kCache_" + AssetId.ToString(); + layerDecodeAsset.Local = true; + layerDecodeAsset.Name = layerDecodeAsset.ID; + layerDecodeAsset.Temporary = true; + layerDecodeAsset.Type = (sbyte)AssetType.Notecard; + + #region Serialize Layer Data - /// - /// Save Layers to Disk Cache - /// - /// Asset to Save the layers. Used int he file name by default - /// The Layer Data from OpenJpeg - /// - public bool SaveFileCacheForAsset(UUID AssetId, OpenJPEG.J2KLayerInfo[] Layers) - { - if (Layers.Length > 0 && enabled) - { - FileStream fsCache = - new FileStream(String.Format("{0}/{1}", m_cacheDecodeFolder, FileNameFromAssetId(AssetId)), - FileMode.Create); - StreamWriter fsSWCache = new StreamWriter(fsCache); StringBuilder stringResult = new StringBuilder(); string strEnd = "\n"; for (int i = 0; i < Layers.Length; i++) { - if (i == (Layers.Length - 1)) - strEnd = ""; + if (i == Layers.Length - 1) + strEnd = String.Empty; stringResult.AppendFormat("{0}|{1}|{2}{3}", Layers[i].Start, Layers[i].End, Layers[i].End - Layers[i].Start, strEnd); } - fsSWCache.Write(stringResult.ToString()); - fsSWCache.Close(); - fsSWCache.Dispose(); - fsCache.Dispose(); - return true; + + layerDecodeAsset.Data = Encoding.UTF8.GetBytes(stringResult.ToString()); + + #endregion Serialize Layer Data + + m_cache.Cache(layerDecodeAsset); } - - - return false; } - - /// - /// Loads the Layer data from the disk cache - /// Returns true if load succeeded - /// - /// AssetId that we're checking the cache for - /// out layers to save to - /// true if load succeeded - public bool TryLoadCacheForAsset(UUID AssetId, out OpenJPEG.J2KLayerInfo[] Layers) + bool TryLoadCacheForAsset(UUID AssetId, out OpenJPEG.J2KLayerInfo[] Layers) { - string filename = String.Format("{0}/{1}", m_cacheDecodeFolder, FileNameFromAssetId(AssetId)); - Layers = new OpenJPEG.J2KLayerInfo[0]; - - if (!File.Exists(filename)) - return false; - - if (!enabled) + if (m_decodedCache.TryGetValue(AssetId, out Layers)) { - return false; + return true; } - - string readResult = string.Empty; - - try + else if (m_cache != null) { - FileStream fsCachefile = - new FileStream(filename, - FileMode.Open); + string assetName = "j2kCache_" + AssetId.ToString(); + AssetBase layerDecodeAsset = m_cache.Get(assetName); - StreamReader sr = new StreamReader(fsCachefile); - readResult = sr.ReadToEnd(); - - sr.Close(); - sr.Dispose(); - fsCachefile.Dispose(); - - } - catch (IOException ioe) - { - if (ioe is PathTooLongException) + if (layerDecodeAsset != null) { - m_log.Error( - "[J2KDecodeCache]: Cache Read failed. Path is too long."); - } - else if (ioe is DirectoryNotFoundException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Read failed. Cache Directory does not exist!"); - enabled = false; - } - else - { - m_log.Error( - "[J2KDecodeCache]: Cache Read failed. IO Exception."); - } - return false; + #region Deserialize Layer Data - } - catch (UnauthorizedAccessException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Read failed. UnauthorizedAccessException Exception. Do you have the proper permissions on this file?"); - return false; - } - catch (ArgumentException ae) - { - if (ae is ArgumentNullException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Read failed. No Filename provided"); - } - else - { - m_log.Error( - "[J2KDecodeCache]: Cache Read failed. Filname was invalid"); - } - return false; - } - catch (NotSupportedException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Read failed, not supported. Cache disabled!"); - enabled = false; + string readResult = Encoding.UTF8.GetString(layerDecodeAsset.Data); + string[] lines = readResult.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); - return false; - } - catch (Exception e) - { - m_log.ErrorFormat( - "[J2KDecodeCache]: Cache Read failed, unknown exception. Error: {0}", - e.ToString()); - return false; - } - - string[] lines = readResult.Split('\n'); - - if (lines.Length <= 0) - return false; - - Layers = new OpenJPEG.J2KLayerInfo[lines.Length]; - - for (int i = 0; i < lines.Length; i++) - { - string[] elements = lines[i].Split('|'); - if (elements.Length == 3) - { - int element1, element2; - - try + if (lines.Length == 0) { - element1 = Convert.ToInt32(elements[0]); - element2 = Convert.ToInt32(elements[1]); - } - catch (FormatException) - { - m_log.WarnFormat("[J2KDecodeCache]: Cache Read failed with ErrorConvert for {0}", AssetId); - Layers = new OpenJPEG.J2KLayerInfo[0]; + m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (empty) " + assetName); + m_cache.Expire(assetName); return false; } - Layers[i] = new OpenJPEG.J2KLayerInfo(); - Layers[i].Start = element1; - Layers[i].End = element2; + Layers = new OpenJPEG.J2KLayerInfo[lines.Length]; - } - else - { - // reading failed - m_log.WarnFormat("[J2KDecodeCache]: Cache Read failed for {0}", AssetId); - Layers = new OpenJPEG.J2KLayerInfo[0]; - return false; + for (int i = 0; i < lines.Length; i++) + { + string[] elements = lines[i].Split('|'); + if (elements.Length == 3) + { + int element1, element2; + + try + { + element1 = Convert.ToInt32(elements[0]); + element2 = Convert.ToInt32(elements[1]); + } + catch (FormatException) + { + m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (format) " + assetName); + m_cache.Expire(assetName); + return false; + } + + Layers[i] = new OpenJPEG.J2KLayerInfo(); + Layers[i].Start = element1; + Layers[i].End = element2; + } + else + { + m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (layout) " + assetName); + m_cache.Expire(assetName); + return false; + } + } + + #endregion Deserialize Layer Data + + return true; } } - - - - return true; - } - - /// - /// Routine which converts assetid to file name - /// - /// asset id of the image - /// string filename - public string FileNameFromAssetId(UUID AssetId) - { - return String.Format("j2kCache_{0}.cache", AssetId); - } - - public UUID AssetIdFromFileName(string fileName) - { - string rawId = fileName.Replace("j2kCache_", "").Replace(".cache", ""); - UUID asset; - if (!UUID.TryParse(rawId, out asset)) - return UUID.Zero; - - return asset; - } - - /// - /// Creates the Cache Folder - /// - /// Folder to Create - public void Createj2KCacheFolder(string pFolder) - { - try - { - Directory.CreateDirectory(pFolder); - } - catch (IOException ioe) - { - if (ioe is PathTooLongException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Directory does not exist and create failed because the path to the cache folder is too long. Cache disabled!"); - } - else if (ioe is DirectoryNotFoundException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Directory does not exist and create failed because the supplied base of the directory folder does not exist. Cache disabled!"); - } - else - { - m_log.Error( - "[J2KDecodeCache]: Cache Directory does not exist and create failed because of an IO Exception. Cache disabled!"); - } - enabled = false; - - } - catch (UnauthorizedAccessException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Directory does not exist and create failed because of an UnauthorizedAccessException Exception. Cache disabled!"); - enabled = false; - } - catch (ArgumentException ae) - { - if (ae is ArgumentNullException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Directory does not exist and create failed because the folder provided is invalid! Cache disabled!"); - } - else - { - m_log.Error( - "[J2KDecodeCache]: Cache Directory does not exist and create failed because no cache folder was provided! Cache disabled!"); - } - enabled = false; - } - catch (NotSupportedException) - { - m_log.Error( - "[J2KDecodeCache]: Cache Directory does not exist and create failed because it's not supported. Cache disabled!"); - enabled = false; - } - catch (Exception e) - { - m_log.ErrorFormat( - "[J2KDecodeCache]: Cache Directory does not exist and create failed because of an unknown exception. Cache disabled! Error: {0}", - e.ToString()); - enabled = false; - } - } - - public void ScanCacheFiles(J2KDecodeDelegate decode) - { - DirectoryInfo dir = new DirectoryInfo(m_cacheDecodeFolder); - FileInfo[] files = dir.GetFiles("j2kCache_*.cache"); - - foreach (FileInfo f in files) - { - TimeSpan fileAge = DateTime.Now - f.CreationTime; - - if (m_cacheTimeout != 0 && fileAge >= TimeSpan.FromMinutes(m_cacheTimeout)) - { - File.Delete(f.Name); - decode(AssetIdFromFileName(f.Name)); - System.Threading.Thread.Sleep(5000); - } - } + return false; } } } diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 14eb9a27b2..9a6c49aae0 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -325,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface(); if (cacheLayerDecode != null) { - cacheLayerDecode.syncdecode(asset.FullID, asset.Data); + cacheLayerDecode.Decode(asset.FullID, asset.Data); cacheLayerDecode = null; LastAssetID = asset.FullID; } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index f4526ae044..8ad4844c7a 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -1102,5 +1102,9 @@ namespace OpenSim.Region.Examples.SimpleModule { } #endregion + + public void SendRebakeAvatarTextures(UUID textureID) + { + } } } diff --git a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs index b1539970ad..856eb119ab 100644 --- a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs +++ b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs @@ -30,12 +30,11 @@ using OpenMetaverse.Imaging; namespace OpenSim.Region.Framework.Interfaces { - public delegate void DecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers); public interface IJ2KDecoder { - void decode(UUID AssetId, byte[] assetData, DecodedCallback decodedReturn); - void syncdecode(UUID AssetId, byte[] j2kdata); + void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback); + void Decode(UUID assetID, byte[] j2kData); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 1d4efd0d9f..3097929501 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -540,127 +540,5 @@ namespace OpenSim.Region.Framework.Scenes { m_localScenes.ForEach(action); } - - public void CacheJ2kDecode(int threads) - { - if (threads < 1) threads = 1; - - IJ2KDecoder m_decoder = m_localScenes[0].RequestModuleInterface(); - - List assetRequestList = new List(); - - #region AssetGathering! - foreach (Scene scene in m_localScenes) - { - List entitles = scene.GetEntities(); - foreach (EntityBase entity in entitles) - { - if (entity is SceneObjectGroup) - { - SceneObjectGroup sog = (SceneObjectGroup) entity; - foreach (SceneObjectPart part in sog.Children.Values) - { - if (part.Shape != null) - { - if (part.Shape.TextureEntry.Length > 0) - { - OpenMetaverse.Primitive.TextureEntry te = - new Primitive.TextureEntry(part.Shape.TextureEntry, 0, - part.Shape.TextureEntry.Length); - if (te.DefaultTexture != null) // this has been null for some reason... - { - if (te.DefaultTexture.TextureID != UUID.Zero) - assetRequestList.Add(te.DefaultTexture.TextureID); - } - for (int i=0; i arrvalus = new List(); - - //split into separate arrays - for (int j = 0; j < threads; j++) - { - List val = new List(); - - for (int k = j * entries_per_thread; k < ((j + 1) * entries_per_thread); k++) - { - if (k < arrAssetRequestList.Length) - { - val.Add(arrAssetRequestList[k]); - } - - } - arrvalus.Add(val.ToArray()); - } - - for (int l = 0; l < arrvalus.Count; l++) - { - DecodeThreadContents threadworkItem = new DecodeThreadContents(); - threadworkItem.sn = m_localScenes[0]; - threadworkItem.j2kdecode = m_decoder; - threadworkItem.arrassets = arrvalus[l]; - - System.Threading.Thread decodethread = - new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(threadworkItem.run)); - - threadworkItem.SetThread(decodethread); - - decodethread.Priority = System.Threading.ThreadPriority.Lowest; - decodethread.Name = "J2kCacheDecodeThread_" + l + 1; - ThreadTracker.Add(decodethread); - decodethread.Start(); - - } - } - } - - public class DecodeThreadContents - { - public Scene sn; - public UUID[] arrassets; - public IJ2KDecoder j2kdecode; - private System.Threading.Thread thisthread; - - public void run(object o) - { - for (int i=0;i /// /// - public void SetAppearance(byte[] texture, List visualParam) + public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) { if (m_physicsActor != null) { @@ -2704,7 +2706,30 @@ namespace OpenSim.Region.Framework.Scenes AddToPhysicalScene(flyingTemp); } } - m_appearance.SetAppearance(texture, visualParam); + + #region Bake Cache Check + + if (textureEntry != null) + { + for (int i = 0; i < BAKE_INDICES.Length; i++) + { + int j = BAKE_INDICES[i]; + Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; + + if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) + { + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + { + m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + (AppearanceManager.TextureIndex)j + ") for avatar " + this.Name); + this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); + } + } + } + } + + #endregion Bake Cache Check + + m_appearance.SetAppearance(textureEntry, visualParams); if (m_appearance.AvatarHeight > 0) SetHeight(m_appearance.AvatarHeight); m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); @@ -3255,14 +3280,14 @@ namespace OpenSim.Region.Framework.Scenes wears[i++] = new AvatarWearable(itemId, assetId); } m_appearance.Wearables = wears; - byte[] te = null; - if (cAgent.AgentTextures != null) - te = cAgent.AgentTextures; + Primitive.TextureEntry te; + if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) + te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); else - te = AvatarAppearance.GetDefaultTexture().GetBytes(); + te = AvatarAppearance.GetDefaultTexture(); if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); - m_appearance.SetAppearance(te, new List(cAgent.VisualParams)); + m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); } catch (Exception e) { diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 605645becd..ee2d2dbfcc 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -861,12 +861,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server Scene scene = (Scene)Scene; AvatarAppearance appearance; scene.GetAvatarAppearance(this, out appearance); - List visualParams = new List(); - foreach (byte visualParam in appearance.VisualParams) - { - visualParams.Add(visualParam); - } - OnSetAppearance(appearance.Texture.GetBytes(), visualParams); + OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); } public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) @@ -1609,5 +1604,9 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } #endregion + + public void SendRebakeAvatarTextures(UUID textureID) + { + } } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index f0bdf3bb7e..ac8b98c8d6 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -1101,5 +1101,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } #endregion + + public void SendRebakeAvatarTextures(UUID textureID) + { + } } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index b3bfe07cc1..30a2675ea4 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -163,13 +163,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene); - List wearbyte = new List(); - for (int i = 0; i < x.VisualParams.Length; i++) - { - wearbyte.Add(x.VisualParams[i]); - } - - sp.SetAppearance(x.Texture.GetBytes(), wearbyte); + sp.SetAppearance(x.Texture, (byte[])x.VisualParams.Clone()); } m_avatars.Add(npcAvatar.AgentId, npcAvatar); diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 56eb359572..d56ddc8973 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -78,6 +78,20 @@ namespace OpenSim.Region.Physics.Meshing private Dictionary m_uniqueMeshes = new Dictionary(); + public Meshmerizer() + { + try + { + if (!Directory.Exists(decodedScultMapPath)) + Directory.CreateDirectory(decodedScultMapPath); + } + catch (Exception e) + { + m_log.WarnFormat("[SCULPT]: Unable to create {0} directory: ", decodedScultMapPath, e.Message); + } + + } + /// /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may /// be useful as a backup proxy when level of detail is not needed or when more complex meshes fail diff --git a/OpenSim/Server/Handlers/Tests/Asset/AssetServerGetHandlerTests.cs b/OpenSim/Server/Handlers/Tests/Asset/AssetServerGetHandlerTests.cs deleted file mode 100644 index 04a73e4fcb..0000000000 --- a/OpenSim/Server/Handlers/Tests/Asset/AssetServerGetHandlerTests.cs +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using NUnit.Framework; -using OpenSim.Framework; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Server.Handlers.Asset; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common; -using OpenSim.Tests.Common.Mock; -using OpenSim.Tests.Common.Setup; - -namespace OpenSim.Server.Handlers.Tests.Asset -{ - [TestFixture] - public class AssetServerGetHandlerTests - { - private const string ASSETS_PATH = "/assets"; - - [Test] - public void TestConstructor() - { - TestHelper.InMethod(); - - new AssetServerGetHandler(null); - } - - [Test] - public void TestGetParams() - { - TestHelper.InMethod(); - - AssetServerGetHandler handler = new AssetServerGetHandler(null); - BaseRequestHandlerTestHelper.BaseTestGetParams(handler, ASSETS_PATH); - } - - [Test] - public void TestSplitParams() - { - TestHelper.InMethod(); - - AssetServerGetHandler handler = new AssetServerGetHandler(null); - BaseRequestHandlerTestHelper.BaseTestSplitParams(handler, ASSETS_PATH); - } - - // TODO: unused - // private static AssetBase CreateTestEnvironment(out AssetServerGetHandler handler, out OSHttpResponse response) - // { - // AssetBase asset = GetAssetStreamHandlerTestHelpers.CreateCommonTestResources(out response); - // IAssetService assetDataPlugin = new TestAssetService(); - // handler = new AssetServerGetHandler(assetDataPlugin); - // assetDataPlugin.Store(asset); - // return asset; - // } - } -} diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index fe31729fe2..2b548905e0 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -1163,5 +1163,9 @@ namespace OpenSim.Tests.Common.Mock { } + public void SendRebakeAvatarTextures(UUID textureID) + { + } + } } diff --git a/Prebuild/AUTHORS b/Prebuild/AUTHORS deleted file mode 100644 index 9e86ac018f..0000000000 --- a/Prebuild/AUTHORS +++ /dev/null @@ -1,10 +0,0 @@ -Dave Hudson (jendave@yahoo.com), -Matthew Holmes (matthew@wildfiregames.com) -Dan Moorehead (dan05a@gmail.com) -Rob Loach (http://www.robloach.net) -C.J. Adams-Collier (cjac@colliertech.org) - -Patch Contributers -lbsa71 -chi11ken -sdague diff --git a/Prebuild/COPYING b/Prebuild/COPYING deleted file mode 100644 index c57c080b15..0000000000 --- a/Prebuild/COPYING +++ /dev/null @@ -1,65 +0,0 @@ -BSD License -Copyright (c)2004-2008 - -See AUTHORS file for list of copyright holders - -Dave Hudson (jendave@yahoo.com), -Matthew Holmes (matthew@wildfiregames.com) -Dan Moorehead (dan05a@gmail.com) -Rob Loach (http://www.robloach.net) -C.J. Adams-Collier (cjac@colliertech.org) - -http://dnpb.sourceforge.net -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. The names of the authors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - ---- - -Portions of src/Core/Targets/AutotoolsTarget.cs -// Copyright (C) 2006 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Prebuild/ChangeLog b/Prebuild/ChangeLog deleted file mode 100644 index bb8e7b09d8..0000000000 --- a/Prebuild/ChangeLog +++ /dev/null @@ -1,461 +0,0 @@ -2008-12-09T02:15 D. Moonfire - * src/Core/Kernel.cs - - Added a /ppi target to get the results of processing but before - processing the actual results. - * src/Core/Preprocessor.cs - - Applied the patch from kanato with formatting changes. - - Uses the format. - * tests/ - - Added some lightweight tests to test the functionality of the - include patch. - -2008-06-19T09:37 John Anderson - * src/Core/Kernel.cs - - Only Loop through targets that are not abstract. - * src/Core/Targets/VSGenericTarget.cs - - Marked abstract and removed the Target attribute. - -2008-06-16T17:37 John Anderson - * src/Core/Nodes/ProjectNode.cs,data/prebuild-1.7.xsd - - Added the ability to hardcode guid's in the projects - -2008-05-21T0737 C.J. Adams-Collier - * src/Core/Targets/AutotoolsTarget.cs - - catch exception when unable to compile AssemblyInfo.cs - -2008-05-07T17:29 John Anderson - * src/Core/Targets/VSGenericTarget.cs - - Generate asp.net output in bin\ folder (asp.net requires it there) - -2008-04-30T17:29 John Anderson - * src/Core/Nodes/DatabaseReferenceNode.cs, - src/Core/Nodes/Datanode.cs, - src/Core/Nodes/FileNode.cs, - src/Core/Nodes/FileNodes.cs, - src/Core/Nodes/MatchNode.cs, - src/Core/Targets/VS2008Target.cs, - src/data/prebuild-1.7.xsd - - Refactored the project generation code to handle web projects and more - logically handle embedded resources and designer files. - -2008-04-30T17:29 Joseph Lombrozo - * src/Core/Nodes/SolutionNode.cs - - Had solutions inherit Configurations in the same way that Projects do. - -2008-04-29T06:35 Joseph Lombrozo - * src/Core/Targets/VS2008Target.cs, - src/Core/Nodes/DatabaseProjectNode.cs, - src/Core/Nodes/DatabaseReferenceNode.cs, - src/data/prebuild-1.7.xsd - - Added database references to database projects. - - Prevented nested solutions from being written to disk. - -2008-04-29T05:43 Joseph Lombrozo - * src/Core/Targets/VS2008Target.cs - - Enabled embedded solutions to contain Files. - -2008-04-29T04:13 Joseph Lombrozo - * src/Core/VSVersion.cs - - Fixed spelling mistake in enum comment. - * src/Core/Attributes/DataNodeAttribute.cs - - Allowed the DataNodeAttribute to be attached to a single class - more than once, allowing one class to be used to parse more than - one node at a time. - * src/Core/Kernel.cs - - Changed CacheNodeTypes() to allow for multiple DataNodeAttribute - instances in one class. Refactored ProcessFile(...) to return Solutions, - rather than adding them to the Kernel. - * src/Core/Nodes/SolutionNode.cs - - Added Guid (for embedded folders) - - Added DatabaseProjects, Solutions and Processes to the SolutionNode - when parsing. - * src/Core/Nodes/ProjectNode.cs - - Added FrameworkVersion property to allow for 2.0/3.0/3.5 differentiation. - * src/Core/Targets/VS2008Target.cs, src/data/prebuild-1.7.xsd - - Added ability to have embedded solutions, and externally referenced - prebuild scripts. - -2008-04-24T04:33 John M. Anderson - * src/Core/Targets/VS2003Target.cs, src/Core/Targets/VSVersion.cs - - Moved the VSVersion enum into its own file. - * src/Core/Targets/VS2008Target.cs - - added support for VS2008 - * src/Core/Nodes/ProjectNode.cs - - Added initial support for ASP.NET projects - * src/Core/Nodes/DatabaseProjectNode.cs - - Added support for Visual Studio database projects - -2008-02-19T07:08 C.J. Adams-Collier - * TODO - - added some tasks from Sam Hocevar - * src/Core/Targets/AutotoolsTarget.cs - - added a missing end paren - * COPYING - - Removed Randy Ridge's name from the copyright. Looks to me like - his name was present only because the file was nabbed from Tao - -2008-02-09T20:29 C.J. Adams-Collier - * COPYING - - added MIT/X11 license due to inclusion of code from Monodevelop - * THANKS - - added Lluis Sanchez Gual and Todd Berman - I yoinked code from - their pkg-config .pc file parser to build AutotoolsTarget.cs. - Sorry it took me so long to remember to add mention of you guys! - * src/Core/Targets/AutotoolsTarget.cs - - added MIT/X11 license. see above. - -2008-02-07T08:27 C.J. Adams-Collier - * AUTHORS - - consolidated names and contact info found laying around the - source - * src/Core/Kernel.cs - - updated copyright date - - re-formatted license for 80-column editor - - updated log banner to indicate new date, new authors - * src/Core/Targets/AutotoolsTarget.cs - - clarified reasoning behind use of constants in - AutotoolsTarget.ParsePCFile - - reduced length of some long lines using newline/indent - - added log messages for parsing .pc files, emitting solutions, - projects - - robustified the inter-package dependency resolution target - - log warning when we can't find assembly for - - clarified code for case of inability to find embedded - autotools.xml - * src/data/autotools.xml - - adding system lookup of resgen2 to configure.ac - - fixed .resource -> .resources typo - - added a rule to create .response file containing all sources - - using @.response on $(CSC) command line instead of listing - all source files - * src/Properties/AssemblyInfo.cs - - re-formatted license for an 80-column editor - - added more authors to the AssemblyCopyright attribute - - bumped version to 2.0.3 - * prebuild.xml - - bumped version to 2.0.3 - * scripts/autotools.sh - - if 'mono' is in the path, run Prebuild.exe with it - - using dirname to capture correct path to prebuild.xml &c - -2008-02-06T17:18 C.J. Adams-Collier - * src/Core/Targets/NAntTarget.cs - - re-formatted the license for an 80-column editor - - added myself to the copyright - - added a fix submitted by Gryc Ueusp - * src/Core/Targets/AutotoolsTarget.cs - - updated copyright to include 2008 - * THANKS - - created file, added Gryc Ueusp - -2008-01-01T14:50 C.J. Adams-Collier - * src/data/autotools.xml - - fixed .resx -> .resource compilation - - fixed failing edge case where Project is an unsigned Library - - added $(RESOURCE_SRC) to list of extra dist files - * src/Core/Targets/AutotoolsTarget.cs - - removed embeddedResources from extraDistFiles list - -2007-04-18T07:49 C.J. Adams-Collier - * src/data/prebuild-1.7.xsd - - removed default version from references - -2007-04-06T12:42 C.J. Adams-Collier - * src/data/autotools.xml - - added support for /doc: output when XmlDocFile is not empty - - not printing \t \\n on lines that have no content - - gacutil now installs the root assembly instead of the one under - bin/Debug or whatever - -2007-04-04T22:12 C.J. Adams-Collier - * src/Core/Targets/AutotoolsTarget.cs - - removed debugging Console.WriteLine() - * src/data/autotools.xml - - ensuring that install-sh and missing get distributed - - explicitly stating that the sources, snk, resources and binary - references live under $(srcdir) - - corrected uninstall target - - verified distcheck completes successfully - -2007-04-03T21:56 C.J. Adams-Collier - * src/Core/Targets/AutotoolsTarget.cs - - added a using for System.Diagnostics - - added enum ClrVersion for use with the pkg-config parser - - added class SystemPackage for use with the pkg-config parser - - removed explicit "private" property of members since it is implied - - flushing the stream-writer before it's closed - - removed excess braces around an if statement - ! NormalizeAsmName(), AddAssembly(), GetAssembliesWithLibInfo(), - GetAssembliesWithoutLibInfo(), ProcessPiece(), - GetVariableFromPkgConfig(), ParsePCFile(), - RegisterSystemAssemblies(), RunInitialization() - - pulled the above from MonoDevelop to parse the system pkgconfig - files and determine /pkg: arguments. Original sources are here: - http://svn.myrealbox.com/source/trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core/SystemAssemblyService.cs - http://svn.myrealbox.com/source/trunk/monodevelop/Core/src/MonoDevelop.Core/MonoDevelop.Core/ClrVersion.cs - ! WriteProject() - - now gathering project version from AssemblyInfo.cs if it is part - of the project - - changed the declaration of the ArrayList's in the method - - now copying assembly .config files to the project, distributing, - installing - - making sure all needed files live under the Project directory - - copying strongname keys to project directory - - parsing AssemblyInfo.cs to determine assembly version - - removing all references to ".." - - removed superfluous if(project.References.Count > 0) around - for(int refNum = 0; refNum < project.References.Count; refNum++) - - removed use of runtimeLibs - - adding hook to copy sibling project's generated assemblies to - this project during Make time - - added extra dist target to ensure all files required to build - get distributed during "make dist" - - added new xslt processing args: - -- assemblyName - -- extraDistFiles - -- pkgLibs (/pkg:foo) - -- localCopyTargets (to copy sibling assemblies at Make time) - -- projectVersion (if determined from AssemblyInfo.cs) - -- hasAssemblyConfig (if there's a assembly.exe.config present) - ! Write() - - calling RunInitialization() to gather pkg-config data - * src/data/autotools.xml - - accepting new args passed from AutotoolsTarget.cs - - modernized configure.ac a bit - - using a version of tar that allows >99-char filenames - - added ASSEMBLY_NAME variable - - using assembly name rather than project name for gac installation - - generated assembly is now assembly name and not project name - - accepting /pkg: flags gathered from AutotoolsTarget.cs - - adding Makefile targets to copy sibling project assemblies to . - - fixed Debug, Release targets - - adding support for strongname key signing - - adding /unsafe support - - adding a clean make target - - only running gacutil /u if the assembly being uninstalled is in gac - - added some templates to determine each Configuration's .snk - - added explanation as to why .exe assemblies live in $prefix/lib - * src/Properties/AssemblyInfo.cs - - bumped assembly version - * prebuild.xml - - bumped assembly version - -2007-03-29T18:03 C.J. Adams-Collier - * src/Core/Targets/AutotoolsTarget.cs - ! WriteProject() - - re-named incorrectly-named variable gacLibs to systemLibs - - added another reference list, runtimeLibs which contains the - libs we will need at runtime. we use this to build a MONO_PATH - - added monoPath to the xslt args list - * src/data/autotools.xml - ! - - renamed gacLibs to systemLibs - - added the sources to the dist list - - added logic to install libs that aren't strongnamed - ! - - accepting a param to update the MONO_PATH - -2007-03-28T19:46 C.J. Adams-Collier - * src/Core/Targets/MonoDevelopTarget.cs - ! CleanProject() - - using Assembly.LoadWithPartialName to locate the assembly - * src/Core/Targets/AutotoolsTarget.cs - ! WriteCombine() - - no longer using $PWD to determine a project's source dir; this - doesn't work with elements - - passing the solution name to all templates - fixes - multi-solution prebuild systems - ! WriteProject() - - no longer using $PWD to determine a project's source dir; this - doesn't work with elements - - passing the solution name to all templates - fixes - multi-solution prebuild systems - - copying strongname key to the autotools directory - - using Assembly.LoadWithPartialName to locate assemblies - * src/data/autotools.xml - ! - - fixed the .pc AC_CONFIG_FILES macro - ! - - added solution name param - - wrapping if type=exe check around script install macro - - added type=lib check and .pc file install macro - - added support for Configuration-specific builds (Debug, Release, etc) - - added strongname keyfile code - - TODO: support non-strongnamed library installation - ! - - added space preservation attribute to stylesheet element - - added a lower-case project name variable - - added solution name param - - made for-each template more specific - ! - - added solution name param - ! - - added solution name param - ! - - added solution name param - ! - - added solution name param - -2007-03-27T09:33 C.J. Adams-Collier - * src/Core/Targets/AutotoolsTarget.cs - - now processing the wrapper script if type is "Exe" or "WinExe" - * src/data/autotools.xml - ! - - being more exact about where text escaping is used - - using the correct variable name for the GACUTIL_FLAGS template - - using correct test="" for the AC_CONFIG_FILES macros - ! - - uncommented the bin_SCRIPTS section now that the script is being - generated correctly - ! - - fixed whitespace at beginning of file, before #! - - using lower-case packageName to indicate installation location - -2007-03-27T09:33 C.J. Adams-Collier - * src/data/autotools.xml - ! - * added a lcProjectName which is $projectName lower-cased - * moved autoconf template specifier near AC_OUTPUT - * AC_OUTPUT with args is deprecated. now using AC_CONFIG_FILES - * placed AC_CONFIG_FILES() calls for wrapper script or pkg-config - file in xslt project type checks - ! - * commented out bin_SCRIPTS - * added a lcProjectName which is $projectName lower-cased - * using $lcProjectName instead of the longer version - -2007-03-27T08:39 C.J. Adams-Collier - * src/data/autotools.xml - ! - - added whitespace-preservation - - added the missing projectName param - - replaced bin_SCRIPTS with something that worked - -2007-03-27T07:56 C.J. Adams-Collier - * src/data/autotools.xml - ! - - cleaned up duplicate checks - - placed initialization macros above system check macros - - added some more messages about what's going on - - added GACUTIL_FLAGS variable including /package option - ! - - added an incomplete bin_SCRIPTS - - RCS check says "building" instead of "compiling" - ! - - removed macros that are useful only for projects - ! - - created this element on this revision - - this is a wrapper shell script that lives in the $PATH and runs - the CIL assembly - -2007-03-26T20:18 C.J. Adams-Collier - * src/Core/Targets/AutotoolsTarget.cs - - creating new template arguments to contain the list of libs to - reference: source, binary & GAC - - source libs are included as part of this solution (untested) - - binary libs are distributed with the source (untested) - - GAC libs are assumed to be in the GAC or other lib path (tested) - * src/data/autotools.xml - - created new params through which to accept reference info - - created a working $(CSC) line - - added a TODO item for ordering project dependency for - AC_CONFIG_SUBDIRS code - -2007-03-26T08:41 C.J. Adams-Collier - * src/Core/Targets/AutotoolsTarget.cs - - now creating list of source files in managed code and passing - them to the template via s - * src/data/prebuild-1.7.xsd - - updated the header comment to 2007 - * src/data/autotools.xml - ! - - copied checks from Solution-level configure.ac - - copied solution-level config status - ! - - added elements for file list to be passed through - - made a temporary target for the assembly we're building - - added this target to the deps of "all:" - ! - - changed status header/footer from "- - -" to "===" - -2007-03-23T08:33 C.J. Adams-Collier - Added version attribute handling code for Property element - Added description element handling code - * prebuild.xml - - added /Prebuild/Solution/Property/@version attribute - - added /Prebuild/Solution/Property/Description element - * src/Core/Nodes/ProjectNode.cs - - added some docs where they were missing and obvious - - added code to handle @version - * src/Core/Nodes/DescriptionNode.cs - - new file. Used to handle /Prebuild/Solution/Property/Description - * src/Core/Targets/AutotoolsTarget.cs - - added mkdirDashP(), a recursive directory creation method - - WriteProject() now copies the files to autotools/ - * src/data/prebuild-1.7.xsd - - added /Prebuild/Solution/Property/Description element - - added /Prebuild/Solution/Property/@version attribute - * src/data/autotools.xml - - removed excess - - explicitly using dnpb: prefix - -2007-03-23T04:31 C.J. Adams-Collier - Merged code from my stripped-down test - Adding support for the /Prebuild/Solution/Project/Author element - * prebuild.xml - - added Author elements - - cleaned up the really long Project element - * src/Core/Nodes/ProjectNode.cs - - added Author tag processing code - * src/Core/Nodes/AuthorNode.cs - - Created to process Author elements - - based off of ReferencePathNode.cs - * src/Core/Targets/AutotoolsTarget.cs - - merged code from https://svn.colliertech.org/mono/dnpbAutotools/dnpbAutotools/test.cs - - renamed old WriteCombine to WriteCombineOld - - renamed old WriteProject to WriteProjectOld - * src/data/prebuild-1.7.xsd - - added Author element to Project - * src/data/autotools.xml - - lower-cased utf - - -2007-03-22T13:58 C.J. Adams-Collier - Exposing an XmlDocument that represents the prebuild.xml file - passed to the program - - * src/Core/Kernel.cs - - created an object member called XmlDocument m_CurrentDoc - - created a property to access its value - - using m_CurrentDoc to load up the prebuild.xml file rather than - a local variable called "doc" - -2007-03-22 C.J. Adams-Collier - * prebuild.xml - - added autotools.xml created at https://svn.colliertech.org/mono/dnpbAutotools/dnpbAutotools/autotools.xml - * src/data/autotools.xml - - the same - * src/Core/Targets/MonoDevelopTarget.cs - - fixed bug introduced in r206 - -2007-03-07 C.J. Adams-Collier - * src/data/prebuild-1.7.xsd - - added version attribute to Solution and Project elements - -2006-11-04T00:38 C.J. Adams-Collier - * placing AssemblyInfo.cs into Properties/ - * Fixed double-mention of the package name - -2006-11-03T15:23 C.J. Adams-Collier - * corrected a problem in the Include.am generation code - * created the new .exe - * copied it to the root of the build - -2006-11-03T14:57 C.J. Adams-Collier - * Updated the .exe file - -2006-11-03 C.J. Adams-Collier - * Added a TODO file - * Added a ChangeLog file - * applied some fixes for autotools gac and pkg-config installation - problems diff --git a/Prebuild/INSTALL b/Prebuild/INSTALL deleted file mode 100644 index 23e5f25d0e..0000000000 --- a/Prebuild/INSTALL +++ /dev/null @@ -1,236 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free -Software Foundation, Inc. - -This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - -These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - -You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - -By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - -Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - -Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). Here is a another example: - - /bin/bash ./configure CONFIG_SHELL=/bin/bash - -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent -configuration-related scripts to be executed by `/bin/bash'. - -`configure' Invocation -====================== - -`configure' recognizes the following options to control how it operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/Prebuild/NEWS b/Prebuild/NEWS deleted file mode 100644 index 3ab3108b4c..0000000000 --- a/Prebuild/NEWS +++ /dev/null @@ -1,200 +0,0 @@ -Prebuild is an XML-driven pre-build tool allowing developers to easily generate project or make files for major IDE's and .NET development tools including: Visual Studio 2005, Visual Studio 2003, Visual Studio 2002, SharpDevelop, MonoDevelop, and NAnt. - -Documentation and downloads are available at http://dnpb.sourceforge.net. - -Prebuild is licensed under the BSD license. - -[ XXXXXXX XX, XXX - 1.3.2 ] - + Added Keyfile signing to NAnt target and VS2005 target - + Updated XSD file to 1.7 - + Boo and VisualBasic Language support in VS2005 target - + Added basic Autotools target. It creates a non-recursive Autotools system. - ! Multiple files can be excluded from the Match node - ! VS2005 now handles .resx files correctly. - ! NAnt and Autotools now handle defines - ! NAnt and Autotools now handle resources - + Conditional XML variables can be passed through the command line. - + Added /install and /remove command line flags to install and remove assemblies from the GAC - + Many fixes to VS2005 target - -[ July 21, 2006 - 1.3.1 ] - ! VS2005 fixes from Rob Loach - ! NAnt fixes from Rob Loach and David Hudson - ! XML doc fixes from Rob Loach - + Added SharpDevelop2 target (really just uses VS2005 target) - ! Fixed bug with BuildEvents in Monodevelop target - + Passing /yes will default to answering yes to any warnings - -[ February 28, 2006 - 1.3 ] - + Added MonoDevelop target. - + Added NAnt target. - + Lots of fixes to all targets. - * Cleaned up the code using FXCop. - * Updated schema to 1.6 to fix a typo and add a new parameter. - * jendave is now the maintainer of the project. RobLoach has been added as a developer. - * Removed references to 'dnpb'. - + Added rudimentary support for pre- and post- build scripts - * Updated examples. - -[ August 5, 2004 - 1.2 ] - + Added Visual Studio Express (vs2005express) target contributed by Borrillis and modified for use with different languages - + Added the allowedgroups command line option followed by a pipe-delimited list of project group filter flags (eg. Group1|Group2) allow optional filtering of all projects that dont have at least one of these flags - + Added the filterGroups XML attribute to the project node and updated the scheme to v1.5 for this addition, it is used to specified the delimited list of filter groups to which a project belongs - * Modified the removedir command line option to allow for a pipe-delimited list of directory names - ! Modified the resource loading code to search for resourced without the prepended namespace (as Visual Studio .NET does it) to allow for it to be compiled with SharpDevelop as well - + Added the GenerateXmlDocFile boolean option to the Options XML element - * Changed the behavior of the XmlDocFile option so that if not specified it uses the assemblyName (without file extension) + .xml for the file name instead of just not generating the file since the new GenerateXmlDocFile takes care of this - -[ January 3, 2004 - 1.1 ] - ! Replaced regex use for more efficient manual parsing to allow use on non-windows platforms with Mono which has Regex problems - + Added the checkOsVars attribute to the root element for enabling interpolation for Enviroment variables in the form ${var}, otherwise no checking is performed for efficiency-sake - * Make the version attribute on the root element optional as it isn't used and not needed since the schema url contains the version - -[ December 30, 2004 - 1.1 ] - ! Applied Leed's fix for SharpDevelop references - + Rewrote much of the processing for better validation and without the use of a temp file - + Added support for configurations at the project level which are named All. They now apply changes to all Solution level defined configs - * Changed all spaces into tabs - + Added support for the None build action - * Replaced all sequence's in the XML schema for all's because the order doesn't matter since the xml file is loaded into an XmlDocument - -[ December 25, 2004 - 1.0 ] - + Added the /removedir option for cleaning directories like obj before file releases - + Changed WriteTempXml() and the new DeleteTempXml() methods to be compiled only in DEBUG builds - * Made path optional for Match elements (defaults to current directory) and updates schema for it - ! Fixed XML example in the readme.txt - + Added example xml files to docs directory - * Updated license.txt to add Dan Moorehead and update copyright years - + Updated prebuild.xml to take advantage of the default path attribute for match elements - + Updated Clean to delete the obj directories - -[ December 25, 2004 - 0.13 ] - + Added dnpb.exe so that it can be used to generate the project files - + Added dnpb.ico - * Added parameterless Write statement to Log for writing a single line - * Changed scehema to version 1.3 for support of icon attribute - * Added support for All configuration name under a Project node signifying common settings for all configurations - ! Fixed the SupressWarnings by adding the corresponding field to OptionsNode - * Wrote documentation in docs/readme.txt - * Added Dan Moorehead to copyrights and extended date from 2004 to 2004-2005 - * Updated prebuild.xml - * Optimized Log class - * Updated OutputUsage() - * /clean targets all by default - * No log file is used by default, /log without value specified uses default file name - + Added support for the /pause which pauses the utility after execution to observe output - - -[ September 27, 2004 - 0.12.2a ] - ! Fixed a nasty bug when trying to delete our temp file for pre-processing. - -[ September 15, 2004 - 0.12.2 ] - + Expanded platform identification, thanks to the NAnt guys for shedding some - light on how to properly check for UNIX platforms! Thanks guys! - * POSIX OS identifier changed to UNIX. Valid OS names are now "Win32", "UNIX", - and "Unknown". - ! Fixed SharpDevelop target to properly use the 'rootNamespace' attribute of - the Project tag. - + New command-line switch, /ppo, forces DNPB to pre-process the file and write - the pre-processed file. This allows you to test/debug your pre-processor - macros. No other processing will be done. You can specify a target file as - a paramter for the /ppo switch, or DNPB will write the file 'preprocessed.xml' - if you do not specify a file. - + The Match tag now has a 'buildAction' attribute which functions exactly like - the attribute of the same name for the File tag. - -[ August 5, 2004 - 0.12.1 ] - + Added environment variable expansion for all values. Environment variables - should be listed in the form ${VAR}. - -[ July 30, 2004 - 0.12.0 ] - + Added preprocessing via XML processing information tags. Available tags - are: ?>, ?>, and . The - current expression parser is very basic, but will be replaced with a more - capable parser over time. Current operators available are: =, !=, <, >, - <=, >=. Current test variables available: OS, RuntimeVersion, RuntimeMajor, - RuntimeMinor, RuntimeRevision. - -[ July 27, 2004 - 0.11.4 ] - + Added 'useRegex' attribute to the Match tag. Matches can now use regular - expressions to match filenames. - + Added the 'assemblyName' attribute to the Project tag. Projects can now - set their output assembly name. - ! Fixed several bugs in the way that Project tags inheirt their parent - Solutions configuration options. This operation should now work fully as - intended. - ! Due to some wierdness, Project Guid's are now stored as part of the Project - node and created at parse time. - -[ May 11, 2004 - 0.11.3 ] - ! Fixed a bug where I was writing the wrong property name for a projects root - namespace. - ! Removed a DEBUG statement I had left in the code in 0.11.2. - ! Fixed a bug in the VS2002 writer which caused the version variables to not - be overriden correctly. - + Added the rootNamespace property to the element, allowing you to - specify the root namespace. - * /target and /clean are now mutually exclusive command line switches, and - they both now take the all option. In the case of /target all, all build - file for all targets will be created. In the case of /clean all, the user - will be prompted to make sure they want to do it, and if so, will clean - all build files for all targets. - -[ April 22, 2004 - 0.11.2 ] - ! Fixed a bug with the /file command-line operator. Was using the unresolved - file path rather then the resolved one, was making the attempt to open the - dnpb file fail. - ! Fixed a bug in the schema that required at least 1 solution and 1 reference - path. We can do just fine with 0 of either of these. Some files may be all - statements and not have any tags. - ! Fixed a bug that caused the project references not to be written with the - SharpDevelop target. - * Changed the schema to version 1.2, allowing for Configuration nodes to exist - under project nodes. The inheritance of values is hierarchical. Meaning, if - you define a configuration named Debug at the Soltion level, and one by the - same name at the Project level, the one at the Project level will first - inherit the options of the Solution level configuration, then set it's own - options. If you define a configuration at the Project level and it does not - exist at the Solution level, it will be created at the Solution level. - * Project references should now work correctly across the board. Note that due - to a restriction in Visual Studio, you can only reference projects in the same - solution. - -[ April 21, 2004 - 0.11.1 ] - ! Fixed a problem with resolving paths in various targets. Was not properly - setting the CWD. - * Schema updated to 1.1, moving the ReferencePath element from the Options - element to the Project element. This makes more logical sense, given that - reference paths are resolved relative to the project path. Any prebuild.xml - file referecning verison 1.0 will fail! Please update to the 1.1 schema. - -[ April 19, 2004 - 0.11.0 ] - * Added several attributes across the code to make FxCop happy - ! Fixed bugs in reference paths being written in the VS targets. - ! Fixed a bug in ProjectNode which was doing two CWDStack.Push() calls instead of - a Push/Pop pair. Was wreaking havoc with tags. - ! Fixed some bugs in the path tracking, both the Project and Solution nodes now - have a FullPath property, which is the full path to the file resolved at load - time. This should fix all path relativity problems. - + Added new /clean switch, allowing the target to clean up any files it generated. - in accordance, the ITarget interface has been updated to support a new Clean() - method. - + Completed addition of the tag, to allow the referencing of external - prebuild.xml files. - + Added the runtime attribute to the Project element. This allows the developer - to specify which runtime a project should target (Mono or Microsoft). This is - of course ignored in certain targets like the Visual Studio targets. - + Added the SharpDevelop target. - -[ April 13, 2004 - 0.10.1a ] - + Added the buildAction attribute to the File node. This is needed for dnpb - to even be able to bootstrap itself (dnpb-1.0.xsd must be an embedded resource) - -[ April 13, 2004 - 0.10.1 ] - * First Release - -[ Key ] -* = Change or information -+ = Addition -! = Bug Fix - diff --git a/Prebuild/README b/Prebuild/README deleted file mode 100644 index e8a2d69530..0000000000 --- a/Prebuild/README +++ /dev/null @@ -1,274 +0,0 @@ -Prebuild Instructions - -Prebuild is an XML-driven pre-build tool allowing developers to easily generate project or make files for major IDE's and .NET development tools including: Visual Studio 2005, Visual Studio 2003, Visual Studio 2002, SharpDevelop, SharpDevelop2, MonoDevelop, and NAnt. - -_______________________________________________________________________________ -Overview - -Prebuild can be either be run from the command line to generate the -project and make files or you can execute the included batch (*.bat) -and Unix Shell script (*.sh) files. - -_______________________________________________________________________________ -The currently supported developement tools and their associated batch -and shell script files. - -Visual Studio .NET 2005 (VS2005.bat) -Visual Studio .NET 2003 (VS2003.bat) -Visual Studio .NET 2002 (VS2002.bat) -SharpDevelop (SharpDevelop.bat) - http://www.icsharpcode.net/OpenSource/SD/ -SharpDevelop2 (SharpDevelop.bat) - http://www.icsharpcode.net/OpenSource/SD/ -MonoDevelop (MonoDevelop.sh) - http://www.monodevelop.com/ -NAnt (nant.sh and nant.bat) - http://nant.sourceforge.net/ -Autotools (autotools.bat and autotools.sh) - http://en.wikipedia.org/wiki/GNU_build_system - -Notes: - -A Unix Shell script is provided for MonoDevelop, as it does not run on -Windows at this time. - -Visual Studio .NET 2005 and the Visual Express IDE's can import -solutions from older versions of Visual Studio .NET. - -Makefiles are not currently supported. - -_______________________________________________________________________________ -Command Line Syntax: - -Example: -> Prebuild /target vs2003 - -This will generate the project files for Visual Studio.NET 2003 and -place the redirect the log to a file named PrebuildLog.txt in the -parent directory - - -The syntax structure is as below, where commandParameter is optional -depending on the command and you can provide several option-value -pairs. - -Note: The '> ' signifies the command prompt, do not enter this literally - -> Prebuild / - - - - ../../../../../bin/ - - - - - ../../../../../bin/ - - - - ../../../../../bin/ - - - - - - - - - - - - - - - - @@ -3829,40 +3801,6 @@ - - - - ../../../../bin/ - - - - - ../../../../bin/ - - - - ../../../../bin/ - - - - - - - - - - - - - - - - - - - - -