mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-06-27 18:28:18 +08:00
Revving format to 2 with smaller string encoding.
This commit is contained in:
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.
BIN
example/assets/teeny_tiny.riv
Normal file
BIN
example/assets/teeny_tiny.riv
Normal file
Binary file not shown.
Binary file not shown.
@ -44,7 +44,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
|
|
||||||
// Load the animation file from the bundle, note that you could also
|
// Load the animation file from the bundle, note that you could also
|
||||||
// download this. The RiveFile just expects a list of bytes.
|
// 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 {
|
(data) async {
|
||||||
var file = RiveFile();
|
var file = RiveFile();
|
||||||
// Load the RiveFile from the binary data.
|
// 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
|
// 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.We store a reference to it so we can toggle playback.
|
||||||
artboard.addController(
|
artboard.addController(
|
||||||
_controller = SimpleAnimation('walk'),
|
_controller = SimpleAnimation('idle'),
|
||||||
);
|
);
|
||||||
setState(() => _riveArtboard = artboard);
|
setState(() => _riveArtboard = artboard);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
|
|||||||
|
|
||||||
class CoreStringType extends CoreFieldType<String> {
|
class CoreStringType extends CoreFieldType<String> {
|
||||||
@override
|
@override
|
||||||
String deserialize(BinaryReader reader) => reader.readString();
|
String deserialize(BinaryReader reader) =>
|
||||||
|
reader.readString(explicitLength: false);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String lerp(String from, String to, double f) => from;
|
String lerp(String from, String to, double f) => from;
|
||||||
|
@ -4,7 +4,7 @@ import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
|
|||||||
import 'exceptions/rive_format_error_exception.dart';
|
import 'exceptions/rive_format_error_exception.dart';
|
||||||
|
|
||||||
class RuntimeHeader {
|
class RuntimeHeader {
|
||||||
static const int majorVersion = 1;
|
static const int majorVersion = 2;
|
||||||
static const int minorVersion = 0;
|
static const int minorVersion = 0;
|
||||||
static const String fingerprint = 'RIVE';
|
static const String fingerprint = 'RIVE';
|
||||||
final int ownerId;
|
final int ownerId;
|
||||||
|
@ -115,8 +115,8 @@ class BinaryReader {
|
|||||||
/// Read a string encoded into the stream. Strings are encoded with a varuint
|
/// Read a string encoded into the stream. Strings are encoded with a varuint
|
||||||
/// integer length written first followed by length number of utf8 encoded
|
/// integer length written first followed by length number of utf8 encoded
|
||||||
/// bytes.
|
/// bytes.
|
||||||
String readString() {
|
String readString({bool explicitLength = true}) {
|
||||||
int length = readVarUint();
|
int length = explicitLength ? readVarUint() : buffer.lengthInBytes;
|
||||||
String value = _utf8Decoder.convert(Uint8List.view(
|
String value = _utf8Decoder.convert(Uint8List.view(
|
||||||
buffer.buffer, buffer.offsetInBytes + _readIndex, length));
|
buffer.buffer, buffer.offsetInBytes + _readIndex, length));
|
||||||
_readIndex += length;
|
_readIndex += length;
|
||||||
|
@ -151,9 +151,11 @@ class BinaryWriter {
|
|||||||
/// Encode a string into the buffer. Strings are encoded with a varuint
|
/// Encode a string into the buffer. Strings are encoded with a varuint
|
||||||
/// integer length written first followed by length number of utf8 encoded
|
/// integer length written first followed by length number of utf8 encoded
|
||||||
/// bytes.
|
/// bytes.
|
||||||
void writeString(String value) {
|
void writeString(String value, {bool explicitLength = true}) {
|
||||||
var list = _utf8Encoder.convert(value);
|
var list = _utf8Encoder.convert(value);
|
||||||
writeVarUint(list.length);
|
if (explicitLength) {
|
||||||
|
writeVarUint(list.length);
|
||||||
|
}
|
||||||
write(list);
|
write(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user