示例#1
0
        public bool ProcessImageQueue(int packetsToSend)
        {
            int StartTime = Util.EnvironmentTickCount();

            int             packetsSent   = 0;
            List <J2KImage> imagesToReAdd = new List <J2KImage>();

            while (packetsSent < packetsToSend)
            {
                J2KImage image = GetHighestPriorityImage();

                // If null was returned, the texture priority queue is currently empty
                if (image == null)
                {
                    break; //Break so that we add any images back that we might remove because they arn't finished decoding
                }
                if (image.IsDecoded)
                {
                    if (image.Layers == null)
                    {
                        //We don't have it, tell the client that it doesn't exist
                        m_client.SendAssetUploadCompleteMessage((sbyte)AssetType.Texture, false, image.TextureID);
                        RemoveImageFromQueue(image);
                        packetsSent++;
                    }
                    else
                    {
                        int  sent;
                        bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent);
                        packetsSent += sent;

                        // If the send is complete, destroy any knowledge of this transfer
                        if (imageDone)
                        {
                            RemoveImageFromQueue(image);
                        }
                    }
                }
                else
                {
                    //Add it to the other queue and delete it from the top
                    imagesToReAdd.Add(image);
                    m_priorityQueue.DeleteMax();
                    packetsSent++; //We tried to send one
                    // UNTODO: This was a limitation of how LLImageManager is currently
                    // written. Undecoded textures should not be going into the priority
                    // queue, because a high priority undecoded texture will clog up the
                    // pipeline for a client
                    //return true;
                }
            }

            //Add all the ones we removed so that we wouldn't block the queue
            if (imagesToReAdd.Count != 0)
            {
                foreach (J2KImage image in imagesToReAdd)
                {
                    this.AddImageToQueue(image);
                }
            }

            int            EndTime = Util.EnvironmentTickCountSubtract(StartTime);
            IMonitorModule module  = m_client.Scene.RequestModuleInterface <IMonitorModule>();

            if (module != null)
            {
                IImageFrameTimeMonitor monitor = (IImageFrameTimeMonitor)module.GetMonitor(m_client.Scene.RegionInfo.RegionID.ToString(), "Images Frame Time");
                monitor.AddImageTime(EndTime);
            }

            return(m_priorityQueue.Count > 0);
        }