Esempio n. 1
0
 private void SaveStateBodyBinary(BinaryWriter writer)
 {
     writer.Write(Count);
     for (var i = _firstStateIndex; i != _nextStateIndex; i = (i + 1) & STATEMASK)
     {
         writer.Write(_states[i].Frame);
         writer.Write(_states[i].Size);
     }
     if (Count != 0)
     {
         var startByte  = _states[_firstStateIndex].Start;
         var endByte    = (_states[HeadStateIndex].Start + _states[HeadStateIndex].Size) & _sizeMask;
         var destStream = SpanStream.GetOrBuild(writer.BaseStream);
         if (startByte > endByte)
         {
             _backingStore.Position = startByte;
             WaterboxUtils.CopySome(_backingStore, writer.BaseStream, Size - startByte);
             startByte = 0;
         }
         {
             _backingStore.Position = startByte;
             WaterboxUtils.CopySome(_backingStore, writer.BaseStream, endByte - startByte);
         }
     }
 }
Esempio n. 2
0
        private void LoadStateBodyBinary(BinaryReader reader)
        {
            _firstStateIndex = 0;
            _nextStateIndex  = reader.ReadInt32();
            long nextByte = 0;

            for (var i = 0; i < _nextStateIndex; i++)
            {
                _states[i].Frame = reader.ReadInt32();
                _states[i].Size  = reader.ReadInt32();
                _states[i].Start = nextByte;
                nextByte        += _states[i].Size;
            }
            _backingStore.Position = 0;
            WaterboxUtils.CopySome(reader.BaseStream, _backingStore, nextByte);
        }
Esempio n. 3
0
        private void LoadStateBodyBinary(BinaryReader reader)
        {
            _firstStateIndex = 0;
            _nextStateIndex  = reader.ReadInt32();
            long nextByte = 0;

            for (var i = 0; i < _nextStateIndex; i++)
            {
                _states[i].Frame = reader.ReadInt32();
                _states[i].Size  = reader.ReadInt32();
                _states[i].Start = nextByte;
                nextByte        += _states[i].Size;
            }
            // TODO: Use spans to avoid this extra copy in .net core
            var dest = _buffer.GetStream(_buffer.Start, (ulong)nextByte, true);

            WaterboxUtils.CopySome(reader.BaseStream, dest, nextByte);
        }