Revving format to 2 with smaller string encoding.

This commit is contained in:
Luigi Rosso
2020-07-19 18:18:34 -07:00
parent 2ca33a8a11
commit 4cb915605f
14 changed files with 11 additions and 8 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -44,7 +44,7 @@ class _MyHomePageState extends State<MyHomePage> {
// Load the animation file from the bundle, note that you could also
// download this. The RiveFile just expects a list of bytes.
rootBundle.load('assets/colors_juice.riv').then(
rootBundle.load('assets/teeny_tiny.riv').then(
(data) async {
var file = RiveFile();
// Load the RiveFile from the binary data.
@ -56,7 +56,7 @@ class _MyHomePageState extends State<MyHomePage> {
// Add a controller to play back a known animation on the main/default
// artboard.We store a reference to it so we can toggle playback.
artboard.addController(
_controller = SimpleAnimation('walk'),
_controller = SimpleAnimation('idle'),
);
setState(() => _riveArtboard = artboard);
}

View File

@ -3,7 +3,8 @@ import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
class CoreStringType extends CoreFieldType<String> {
@override
String deserialize(BinaryReader reader) => reader.readString();
String deserialize(BinaryReader reader) =>
reader.readString(explicitLength: false);
@override
String lerp(String from, String to, double f) => from;

View File

@ -4,7 +4,7 @@ import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
import 'exceptions/rive_format_error_exception.dart';
class RuntimeHeader {
static const int majorVersion = 1;
static const int majorVersion = 2;
static const int minorVersion = 0;
static const String fingerprint = 'RIVE';
final int ownerId;

View File

@ -115,8 +115,8 @@ class BinaryReader {
/// Read a string encoded into the stream. Strings are encoded with a varuint
/// integer length written first followed by length number of utf8 encoded
/// bytes.
String readString() {
int length = readVarUint();
String readString({bool explicitLength = true}) {
int length = explicitLength ? readVarUint() : buffer.lengthInBytes;
String value = _utf8Decoder.convert(Uint8List.view(
buffer.buffer, buffer.offsetInBytes + _readIndex, length));
_readIndex += length;

View File

@ -151,9 +151,11 @@ class BinaryWriter {
/// Encode a string into the buffer. Strings are encoded with a varuint
/// integer length written first followed by length number of utf8 encoded
/// bytes.
void writeString(String value) {
void writeString(String value, {bool explicitLength = true}) {
var list = _utf8Encoder.convert(value);
if (explicitLength) {
writeVarUint(list.length);
}
write(list);
}