Ejemplo n.º 1
0
        /// <summary>
        /// Rent 'n' buffers -> return all -> re-rent, verify if there is at least one in common.
        /// </summary>
        private bool CheckIsPooled <T>(int n, int count)
            where T : struct
        {
            lock (this.monitor)
            {
                T[][] original = new T[n][];

                for (int i = 0; i < n; i++)
                {
                    original[i] = PixelDataPool <T> .Rent(count);
                }

                for (int i = 0; i < n; i++)
                {
                    PixelDataPool <T> .Return(original[i]);
                }

                T[][] verification = new T[n][];

                for (int i = 0; i < n; i++)
                {
                    verification[i] = PixelDataPool <T> .Rent(count);
                }

                return(original.Intersect(verification).Any());
            }
        }
Ejemplo n.º 2
0
        public void PixelDataPoolCleansRentedArray()
        {
            Color[] pixels = PixelDataPool <Color> .Rent(256);

            for (int i = 0; i < pixels.Length; i++)
            {
                pixels[i] = Color.Azure;
            }

            Assert.True(pixels.All(p => p == Color.Azure));

            PixelDataPool <Color> .Return(pixels);

            Assert.True(pixels.All(p => p == default(Color)));
        }
Ejemplo n.º 3
0
        public void PixelDataPoolRentsEmptyArray()
        {
            for (int i = 16; i < 1024; i += 16)
            {
                Color[] pixels = PixelDataPool <Color> .Rent(i);

                Assert.True(pixels.All(p => p == default(Color)));

                PixelDataPool <Color> .Return(pixels);
            }

            for (int i = 16; i < 1024; i += 16)
            {
                Color[] pixels = PixelDataPool <Color> .Rent(i);

                Assert.True(pixels.All(p => p == default(Color)));

                PixelDataPool <Color> .Return(pixels);
            }
        }
        public void RentNonIPixelData()
        {
            byte[] data = PixelDataPool <byte> .Rent(16384);

            Assert.True(data.Length >= 16384);
        }
        public void PixelDataPoolRentsMinimumSize()
        {
            Color[] pixels = PixelDataPool <Color> .Rent(1024);

            Assert.True(pixels.Length >= 1024);
        }
Ejemplo n.º 6
0
        public void PixelDataPoolRentsMinimumSize(int size)
        {
            Rgba32[] pixels = PixelDataPool <Rgba32> .Rent(size);

            Assert.True(pixels.Length >= size);
        }
Ejemplo n.º 7
0
        public void PixelDataPoolRentsMinimumSize()
        {
            Rgba32[] pixels = PixelDataPool <Rgba32> .Rent(1024);

            Assert.True(pixels.Length >= 1024);
        }