diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 6cffd70..b186720 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | |||
@@ -60,14 +60,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
60 | private sbyte m_discardLevel=-1; | 60 | private sbyte m_discardLevel=-1; |
61 | private uint m_packetNumber; | 61 | private uint m_packetNumber; |
62 | private bool m_decoderequested = false; | 62 | private bool m_decoderequested = false; |
63 | private bool m_hasasset = false; | 63 | public bool m_hasasset = false; |
64 | private bool m_asset_requested = false; | 64 | private bool m_asset_requested = false; |
65 | private bool m_sentinfo = false; | 65 | private bool m_sentinfo = false; |
66 | private uint m_stopPacket = 0; | 66 | private uint m_stopPacket = 0; |
67 | private const int cImagePacketSize = 1000; | 67 | private const int cImagePacketSize = 1000; |
68 | private const int cFirstPacketSize = 600; | 68 | private const int cFirstPacketSize = 600; |
69 | |||
69 | private AssetBase m_asset = null; | 70 | private AssetBase m_asset = null; |
71 | private int m_assetDataLength = 0; | ||
72 | |||
70 | private LLImageManager m_image; | 73 | private LLImageManager m_image; |
74 | |||
71 | public J2KImage(LLImageManager image) | 75 | public J2KImage(LLImageManager image) |
72 | { | 76 | { |
73 | m_image = image; | 77 | m_image = image; |
@@ -99,7 +103,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
99 | return 0; | 103 | return 0; |
100 | try | 104 | try |
101 | { | 105 | { |
102 | return (ushort)(((m_asset.Data.Length - cFirstPacketSize + cImagePacketSize - 1) / cImagePacketSize) + 1); | 106 | return (ushort)(((m_assetDataLength - cFirstPacketSize + cImagePacketSize - 1) / cImagePacketSize) + 1); |
103 | } | 107 | } |
104 | catch (Exception) | 108 | catch (Exception) |
105 | { | 109 | { |
@@ -110,6 +114,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
110 | } | 114 | } |
111 | } | 115 | } |
112 | 116 | ||
117 | public void DropAsset() | ||
118 | { | ||
119 | m_log.WarnFormat("[LLIMAGE MANAGER]: Dropping texture asset {0}", m_requestedUUID); | ||
120 | m_asset = null; | ||
121 | m_hasasset = false; | ||
122 | m_asset_requested = false; | ||
123 | } | ||
124 | |||
113 | public void J2KDecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers) | 125 | public void J2KDecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers) |
114 | { | 126 | { |
115 | m_image.m_outstandingtextures++; | 127 | m_image.m_outstandingtextures++; |
@@ -127,8 +139,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
127 | } | 139 | } |
128 | else | 140 | else |
129 | { | 141 | { |
130 | m_asset = asset; | 142 | m_asset = asset; |
131 | } | 143 | } |
144 | |||
145 | m_assetDataLength = m_asset.Data.Length; | ||
146 | |||
132 | RunUpdate(); | 147 | RunUpdate(); |
133 | } | 148 | } |
134 | 149 | ||
@@ -150,8 +165,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
150 | public int LastPacketSize() | 165 | public int LastPacketSize() |
151 | { | 166 | { |
152 | if (m_packetNumber == 1) | 167 | if (m_packetNumber == 1) |
153 | return m_asset.Data.Length; | 168 | return m_assetDataLength; |
154 | int lastsize = (m_asset.Data.Length - cFirstPacketSize) % cImagePacketSize; | 169 | int lastsize = (m_assetDataLength - cFirstPacketSize) % cImagePacketSize; |
155 | //If the last packet size is zero, it's really cImagePacketSize, it sits on the boundary | 170 | //If the last packet size is zero, it's really cImagePacketSize, it sits on the boundary |
156 | if (lastsize == 0) | 171 | if (lastsize == 0) |
157 | { | 172 | { |
@@ -185,10 +200,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
185 | return true; | 200 | return true; |
186 | } | 201 | } |
187 | // Do we have less then 1 packet's worth of data? | 202 | // Do we have less then 1 packet's worth of data? |
188 | else if (m_asset.Data.Length <= cFirstPacketSize) | 203 | else if (m_assetDataLength <= cFirstPacketSize) |
189 | { | 204 | { |
190 | // Send only 1 packet | 205 | // Send only 1 packet |
191 | client.SendImageFirstPart(1, m_requestedUUID, (uint)m_asset.Data.Length, m_asset.Data, 2); | 206 | client.SendImageFirstPart(1, m_requestedUUID, (uint)m_assetDataLength, m_asset.Data, 2); |
192 | m_stopPacket = 0; | 207 | m_stopPacket = 0; |
193 | return true; | 208 | return true; |
194 | } | 209 | } |
@@ -198,7 +213,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
198 | try | 213 | try |
199 | { | 214 | { |
200 | Buffer.BlockCopy(m_asset.Data, 0, firstImageData, 0, (int)cFirstPacketSize); | 215 | Buffer.BlockCopy(m_asset.Data, 0, firstImageData, 0, (int)cFirstPacketSize); |
201 | client.SendImageFirstPart(TexturePacketCount(), m_requestedUUID, (uint)m_asset.Data.Length, firstImageData, 2); | 216 | client.SendImageFirstPart(TexturePacketCount(), m_requestedUUID, (uint)m_assetDataLength, firstImageData, 2); |
202 | } | 217 | } |
203 | catch (Exception) | 218 | catch (Exception) |
204 | { | 219 | { |
@@ -216,13 +231,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
216 | 231 | ||
217 | try | 232 | try |
218 | { | 233 | { |
219 | if ((CurrentBytePosition() + cImagePacketSize) > m_asset.Data.Length) | 234 | if ((CurrentBytePosition() + cImagePacketSize) > m_assetDataLength) |
220 | { | 235 | { |
221 | imagePacketSize = LastPacketSize(); | 236 | imagePacketSize = LastPacketSize(); |
222 | complete=true; | 237 | complete=true; |
223 | if ((CurrentBytePosition() + imagePacketSize) > m_asset.Data.Length) | 238 | if ((CurrentBytePosition() + imagePacketSize) > m_assetDataLength) |
224 | { | 239 | { |
225 | imagePacketSize = m_asset.Data.Length - CurrentBytePosition(); | 240 | imagePacketSize = m_assetDataLength - CurrentBytePosition(); |
226 | complete = true; | 241 | complete = true; |
227 | } | 242 | } |
228 | } | 243 | } |