Exemple #1
0
        public void BeginFrame(bool clear = false)
        {
            if (clear)
            {
                _slots.Clear();
            }

            _map            = _gd.Map(_stagingTexture, _mapMode);
            _textureMapped  = true;
            _firstDirtySlot = uint.MaxValue;
            _lastDirtySlot  = uint.MinValue;
        }
Exemple #2
0
        /// <summary>
        /// Add index of the image to queue list
        /// </summary>
        /// <param name="index">Current index of image list</param>
        private void UpdateQueueList(int index)
        {
            // check valid index
            if (index < 0 || index >= ImgList.Count)
            {
                return;
            }

            var list = new HashSet <int>
            {
                index
            };

            var maxCachedItems = (MaxQueue * 2) + 1;
            var iRight         = index;
            var iLeft          = index;

            // add index in the range in order: index -> right -> left -> ...
            for (var i = 0; list.Count < maxCachedItems && list.Count < ImgList.Count; i++)
            {
                // if i is even number
                if ((i & 1) == 0)
                {
                    // add right item: [index + 1; ...; to]
                    iRight++;

                    if (iRight < ImgList.Count)
                    {
                        list.Add(iRight);
                    }
                    else
                    {
                        list.Add(iRight - ImgList.Count);
                    }
                }
                // if i is odd number
                else
                {
                    // add left item: [index - 1; ...; from]
                    iLeft--;

                    if (iLeft >= 0)
                    {
                        list.Add(iLeft);
                    }
                    else
                    {
                        list.Add(ImgList.Count + iLeft);
                    }
                }
            }

            // release the resources
            foreach (var indexItem in FreeList)
            {
                if (!list.Contains(indexItem) && indexItem >= 0 && indexItem < ImgList.Count)
                {
                    ImgList[indexItem].Dispose();
                }
            }

            // update new index of free list
            FreeList.Clear();
            FreeList.AddRange(list);

            // update queue list
            QueuedList.Clear();
            QueuedList.AddRange(list);
        }