예제 #1
0
        public void can_create_buffer_with_markup()
        {
            var buffer = BufferGenerator.CreateBuffer("Console.WriteLine($$);", "program.cs@region1");

            buffer.Should().NotBeNull();
            buffer.Id.Should().Be(new BufferId("program.cs", "region1"));
            buffer.Content.Should().Be("Console.WriteLine();");
            buffer.AbsolutePosition.Should().Be(18);
        }
예제 #2
0
        public void can_create_buffer_from_code_and_bufferId()
        {
            var buffer = BufferGenerator.CreateBuffer("Console.WriteLine(12);", "program.cs");

            buffer.Should().NotBeNull();
            buffer.Id.Should().Be(new BufferId("program.cs"));
            buffer.Content.Should().Be("Console.WriteLine(12);");
            buffer.AbsolutePosition.Should().Be(0);
        }
예제 #3
0
        public void can_create_buffers_from_file_without_regions()
        {
            var file = FileGenerator.Create("Program.cs", SourceCodeProvider.ConsoleProgramNoRegion);

            var buffers = BufferGenerator.CreateBuffers(file).ToList();

            buffers.Should().NotBeNullOrEmpty();
            buffers.Count.Should().Be(1);
            buffers.Should().Contain(b => b.Id == "Program.cs");
        }
예제 #4
0
        public void Can_create_buffer_from_fsharp_file()
        {
            var file    = FileGenerator.Create("Program.fs", SourceCodeProvider.FSharpConsoleProgramMultipleRegions);
            var buffers = BufferGenerator.CreateBuffers(file).ToList();

            buffers.Should().NotBeNullOrEmpty();
            buffers.Count.Should().Be(2);
            buffers.Should().Contain(b => b.Id == "Program.fs@alpha");
            buffers.Should().Contain(b => b.Id == "Program.fs@beta");
        }
예제 #5
0
        protected override void Prepare(PrepareManager manager)
        {
            if (Count > 0)
            {
                _BufferGenerator = Container.RenderManager.GetBufferGenerator <BufferGenerator <GeometryVertex> >();

                _DrawArguments = _DrawArgumentsListPool.Allocate(null);
                var swb = _BufferGenerator.Allocate(VertexCount, IndexCount, true);
                _SoftwareBuffer = swb;

                var vb = new Internal.VertexBuffer <GeometryVertex>(swb.Vertices);
                var ib = new Internal.IndexBuffer(swb.Indices);
                int vertexOffset = 0, indexOffset = 0;
                int totalPrimCount = 0;

                foreach (var kvp in Lists)
                {
                    var l = kvp.Value;
                    var c = l.Count;

                    l.FastCLRSort(_DrawCallSorter);

                    int vertexCount = vb.Count, indexCount = ib.Count;

                    var _l = l.GetBuffer();
                    for (int i = 0; i < c; i++)
                    {
                        var dc = _l[i];
                        dc.Preparer(ref vb, ref ib, ref dc);
                    }

                    vertexCount = vb.Count - vertexCount;
                    indexCount  = ib.Count - indexCount;

                    int primCount;
                    MakeDrawArguments(kvp.Key, ref vb, ref ib, ref vertexOffset, ref indexOffset, out primCount, vertexCount, indexCount);

                    totalPrimCount += primCount;
                }

                NativeBatch.RecordPrimitives(totalPrimCount);
            }
        }