コード例 #1
0
        public void FrameLimit()
        {
            var p = new RenderTargetPool(_graphicsService);

            p.FrameLimit = 5;

            var r0 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));
            var r1 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));

            Assert.IsFalse(r0.IsDisposed);
            Assert.IsFalse(r1.IsDisposed);

            p.Recycle(r0);

            p.Update();
            p.Update();

            p.Recycle(r1);

            p.Update();
            p.Update();

            Assert.IsFalse(r0.IsDisposed);
            Assert.IsFalse(r1.IsDisposed);
            Assert.AreEqual(2, p.Counters2D.Count);

            p.Update();
            p.Update();

            Assert.IsTrue(r0.IsDisposed);
            Assert.IsFalse(r1.IsDisposed);
            Assert.AreEqual(1, p.Counters2D.Count);

            p.Update();
            p.Update();

            Assert.IsTrue(r0.IsDisposed);
            Assert.IsTrue(r1.IsDisposed);
            Assert.AreEqual(0, p.Counters2D.Count);
        }
コード例 #2
0
        public void FrameLimit()
        {
            var p = new RenderTargetPool(_graphicsService);
              p.FrameLimit = 5;

              var r0 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));
              var r1 = p.Obtain2D(new RenderTargetFormat(100, 100, false, SurfaceFormat.Color, DepthFormat.None));

              Assert.IsFalse(r0.IsDisposed);
              Assert.IsFalse(r1.IsDisposed);

              p.Recycle(r0);

              p.Update();
              p.Update();

              p.Recycle(r1);

              p.Update();
              p.Update();

              Assert.IsFalse(r0.IsDisposed);
              Assert.IsFalse(r1.IsDisposed);
              Assert.AreEqual(2, p.Counters2D.Count);

              p.Update();
              p.Update();

              Assert.IsTrue(r0.IsDisposed);
              Assert.IsFalse(r1.IsDisposed);
              Assert.AreEqual(1, p.Counters2D.Count);

              p.Update();
              p.Update();

              Assert.IsTrue(r0.IsDisposed);
              Assert.IsTrue(r1.IsDisposed);
              Assert.AreEqual(0, p.Counters2D.Count);
        }