Exemplo n.º 1
0
        private MemoryStream GetPreviousStateMemoryStream()
        {
            if (_rewindDeltaEnable)
            {
                // When capturing deltas, the most recent state is stored in _lastState, and the
                // last item in the rewind buffer gets us back to the previous state.
                return(_rewindBuffer.PopMemoryStream());
            }
            else
            {
                // When capturing full states, the last item in the rewind buffer is the most
                // recent state, so we need to get the item before it.
                _rewindBuffer.Pop();
                return(_rewindBuffer.PeekMemoryStream());
            }

            // Note that in both cases, after loading the state, we still have a copy of it
            // either in _lastState or as the last item in the rewind buffer. This is good
            // because once we resume capturing, the first capture doesn't happen until
            // stepping forward to the following frame, which would result in a gap if we
            // didn't still have a copy of the current state here.
        }