diff options
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneManager.cs | 127 |
2 files changed, 129 insertions, 1 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs index 53e66fc..cf76ebc 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/J2KDecoderModule.cs | |||
@@ -236,7 +236,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
236 | // Cache Decoded layers | 236 | // Cache Decoded layers |
237 | lock (m_cacheddecode) | 237 | lock (m_cacheddecode) |
238 | { | 238 | { |
239 | m_cacheddecode.Add(AssetId, layers); | 239 | if (!m_cacheddecode.ContainsKey(AssetId)) |
240 | m_cacheddecode.Add(AssetId, layers); | ||
240 | 241 | ||
241 | } | 242 | } |
242 | 243 | ||
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 040a0d4..b2b79b4 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs | |||
@@ -547,5 +547,132 @@ namespace OpenSim.Region.Environment.Scenes | |||
547 | { | 547 | { |
548 | m_localScenes.ForEach(action); | 548 | m_localScenes.ForEach(action); |
549 | } | 549 | } |
550 | |||
551 | public void CacheJ2kDecode(int threads) | ||
552 | { | ||
553 | if (threads < 1) threads = 1; | ||
554 | |||
555 | IJ2KDecoder m_decoder = m_localScenes[0].RequestModuleInterface<IJ2KDecoder>(); | ||
556 | |||
557 | List<UUID> assetRequestList = new List<UUID>(); | ||
558 | |||
559 | #region AssetGathering! | ||
560 | foreach (Scene scene in m_localScenes) | ||
561 | { | ||
562 | List<EntityBase> entitles = scene.GetEntities(); | ||
563 | foreach (EntityBase entity in entitles) | ||
564 | { | ||
565 | if (entity is SceneObjectGroup) | ||
566 | { | ||
567 | SceneObjectGroup sog = (SceneObjectGroup) entity; | ||
568 | foreach (SceneObjectPart part in sog.Children.Values) | ||
569 | { | ||
570 | if (part.Shape != null) | ||
571 | { | ||
572 | if (part.Shape.TextureEntry.Length > 0) | ||
573 | { | ||
574 | OpenMetaverse.Primitive.TextureEntry te = | ||
575 | new Primitive.TextureEntry(part.Shape.TextureEntry, 0, | ||
576 | part.Shape.TextureEntry.Length); | ||
577 | if (te.DefaultTexture != null) // this has been null for some reason... | ||
578 | { | ||
579 | if (te.DefaultTexture.TextureID != UUID.Zero) | ||
580 | assetRequestList.Add(te.DefaultTexture.TextureID); | ||
581 | } | ||
582 | for (int i=0; i<te.FaceTextures.Length; i++) | ||
583 | { | ||
584 | if (te.FaceTextures[i] != null) | ||
585 | { | ||
586 | if (te.FaceTextures[i].TextureID != UUID.Zero) | ||
587 | { | ||
588 | assetRequestList.Add(te.FaceTextures[i].TextureID); | ||
589 | } | ||
590 | } | ||
591 | } | ||
592 | } | ||
593 | if (part.Shape.SculptTexture != UUID.Zero) | ||
594 | { | ||
595 | assetRequestList.Add(part.Shape.SculptTexture); | ||
596 | } | ||
597 | |||
598 | } | ||
599 | } | ||
600 | } | ||
601 | } | ||
602 | } | ||
603 | #endregion | ||
604 | |||
605 | int entries_per_thread = (assetRequestList.Count/threads) + 1; | ||
606 | |||
607 | UUID[] arrAssetRequestList = assetRequestList.ToArray(); | ||
608 | |||
609 | int currpos = 0; | ||
610 | |||
611 | List<UUID[]> arrvalus = new List<UUID[]>(); | ||
612 | |||
613 | //split into separate arrays | ||
614 | for (int j=0;j<threads;j++) | ||
615 | { | ||
616 | List<UUID> val = new List<UUID>(); | ||
617 | |||
618 | for (int k=j*entries_per_thread; k < ((j+1)* entries_per_thread);k++) | ||
619 | { | ||
620 | if (k < arrAssetRequestList.Length) | ||
621 | { | ||
622 | val.Add(arrAssetRequestList[k]); | ||
623 | } | ||
624 | |||
625 | } | ||
626 | arrvalus.Add(val.ToArray()); | ||
627 | } | ||
628 | |||
629 | for (int l=0;l<arrvalus.Count;l++) | ||
630 | { | ||
631 | DecodeThreadContents threadworkItem = new DecodeThreadContents(); | ||
632 | threadworkItem.sn = m_localScenes[0]; | ||
633 | threadworkItem.j2kdecode = m_decoder; | ||
634 | threadworkItem.arrassets = arrvalus[l]; | ||
635 | |||
636 | System.Threading.Thread decodethread = | ||
637 | new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(threadworkItem.run)); | ||
638 | |||
639 | threadworkItem.SetThread(decodethread); | ||
640 | |||
641 | decodethread.Priority = System.Threading.ThreadPriority.Lowest; | ||
642 | decodethread.Name = "J2kCacheDecodeThread_" + l+1; | ||
643 | ThreadTracker.Add(decodethread); | ||
644 | decodethread.Start(); | ||
645 | |||
646 | } | ||
647 | |||
648 | |||
649 | |||
650 | } | ||
651 | } | ||
652 | public class DecodeThreadContents | ||
653 | { | ||
654 | public Scene sn; | ||
655 | public UUID[] arrassets; | ||
656 | public IJ2KDecoder j2kdecode; | ||
657 | private System.Threading.Thread thisthread; | ||
658 | |||
659 | public void run( object o) | ||
660 | { | ||
661 | for (int i=0;i<arrassets.Length;i++) | ||
662 | { | ||
663 | AssetBase ab = sn.AssetCache.GetAsset(arrassets[i], true); | ||
664 | if (ab != null && ab.Data != null) | ||
665 | { | ||
666 | j2kdecode.syncdecode(arrassets[i], ab.Data); | ||
667 | } | ||
668 | } | ||
669 | ThreadTracker.Remove(thisthread); | ||
670 | } | ||
671 | |||
672 | public void SetThread(System.Threading.Thread thr) | ||
673 | { | ||
674 | thisthread = thr; | ||
675 | } | ||
676 | |||
550 | } | 677 | } |
551 | } | 678 | } |