示例#1
0
		public void EndToEndTest()
		{	
			// Arrange.
		    var device = new Device();
            var logger = new TracefileBuilder(device);
            var expectedData = RenderScene(device);

            var stringWriter = new StringWriter();
			logger.WriteTo(stringWriter);

			var loggedJson = stringWriter.ToString();
			var logReader = new StringReader(loggedJson);
			var tracefile = Tracefile.FromTextReader(logReader);

			// Act.
			var swapChainPresenter = new RawSwapChainPresenter();
			var replayer = new Replayer(
                tracefile.Frames[0], tracefile.Frames[0].Events.Last(),
                swapChainPresenter);
			replayer.Replay();
            var actualData = swapChainPresenter.Data;

			// Assert.
			Assert.That(actualData, Is.EqualTo(expectedData));
		}
		private void OnSelectedEventChanged(object sender, TracefileEventChangedEventArgs e)
		{
            NotifyOfPropertyChange(() => SelectedEvent);

		    if (_selectionService.SelectedEvent == null)
		        return;

            var swapChainPresenter = new WpfSwapChainPresenter(Dispatcher.CurrentDispatcher);
            var replayer = new Replayer(
                _selectionService.SelectedFrame.Model, _selectionService.SelectedEvent.Model,
                swapChainPresenter);

            //Task.Factory.StartNew(() =>
            //{
            //    replayer.Replay();

				
            //});
		}
		private void OnSelectedEventChanged(object sender, TracefileEventChangedEventArgs e)
		{
            NotifyOfPropertyChange(() => SelectedEvent);

			_objects.Clear();

		    if (_selectionService.SelectedEvent == null)
		        return;

            var swapChainPresenter = new WpfSwapChainPresenter(Dispatcher.CurrentDispatcher);
            var replayer = new Replayer(
                _selectionService.SelectedFrame.Model, _selectionService.SelectedEvent.Model,
                swapChainPresenter);

			Task.Factory.StartNew(() =>
			{
				replayer.Replay();

				_objects.AddRange(replayer.Device.DeviceChildren
                    .Select(x => new GraphicsObjectViewModel(x)));
			});
		}
		private void OnSelectedPixelChanged(object sender, PixelChangedEventArgs e)
		{
		    FrameNumber = _selectionService.SelectedFrame.Number;
		    PixelLocation = e.SelectedPixel;

		    HasSelectedPixel = true;
			_pixelEvents.Clear();

            var swapChainPresenter = new WpfSwapChainPresenter(Dispatcher.CurrentDispatcher);
            var replayer = new Replayer(
                _selectionService.SelectedFrame.Model, _selectionService.SelectedEvent.Model,
                swapChainPresenter, 
                _selectionService.SelectedFrame.ActiveRenderTargetViewIdentifier,
                _selectionService.SelectedFrame.ActiveRenderTargetArraySlice,
                e.SelectedPixel.X, e.SelectedPixel.Y);

			Task.Factory.StartNew(() =>
			{
				replayer.Replay();

				var events = replayer.Logger.GetPixelHistoryEvents(_selectionService.SelectedFrame.Number);
				_pixelEvents.AddRange(events.Select(x => new PixelHistoryEventViewModel(x)));

			    FinalFrameBufferColor = ((ColorResultViewModel) _pixelEvents.Last(x => x.Result is ColorResultViewModel).Result).Result;
			});
		}