mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-06-28 02:37:16 +08:00
Removing signed integer from the core system.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
## [0.0.5] - 2020-08-07 20:05:18
|
||||||
|
|
||||||
|
- Updating format to only use unsigned integers to overcome a dart2js weakness with signed integers on the web.
|
||||||
|
|
||||||
## [0.0.4] - 2020-07-28 18:35:44
|
## [0.0.4] - 2020-07-28 18:35:44
|
||||||
|
|
||||||
- Fundamental changes to runtime format enabling smaller file sizes. Format bumps to version 3.0 as it breaks backwards compatibility.
|
- Fundamental changes to runtime format enabling smaller file sizes. Format bumps to version 3.0 as it breaks backwards compatibility.
|
||||||
|
@ -3,5 +3,5 @@ import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
|
|||||||
|
|
||||||
class CoreIntType extends CoreFieldType<int> {
|
class CoreIntType extends CoreFieldType<int> {
|
||||||
@override
|
@override
|
||||||
int deserialize(BinaryReader reader) => reader.readVarInt();
|
int deserialize(BinaryReader reader) => reader.readVarUint();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import 'package:rive/src/core/field_types/core_bool_type.dart';
|
|||||||
import 'package:rive/src/core/field_types/core_color_type.dart';
|
import 'package:rive/src/core/field_types/core_color_type.dart';
|
||||||
import 'package:rive/src/core/field_types/core_double_type.dart';
|
import 'package:rive/src/core/field_types/core_double_type.dart';
|
||||||
import 'package:rive/src/core/field_types/core_field_type.dart';
|
import 'package:rive/src/core/field_types/core_field_type.dart';
|
||||||
import 'package:rive/src/core/field_types/core_int_type.dart';
|
|
||||||
import 'package:rive/src/core/field_types/core_string_type.dart';
|
import 'package:rive/src/core/field_types/core_string_type.dart';
|
||||||
import 'package:rive/src/core/field_types/core_uint_type.dart';
|
import 'package:rive/src/core/field_types/core_uint_type.dart';
|
||||||
import 'package:rive/src/generated/animation/animation_base.dart';
|
import 'package:rive/src/generated/animation/animation_base.dart';
|
||||||
@ -479,7 +478,6 @@ class RiveCoreContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoreFieldType uintType = CoreUintType();
|
static CoreFieldType uintType = CoreUintType();
|
||||||
static CoreFieldType intType = CoreIntType();
|
|
||||||
static CoreFieldType stringType = CoreStringType();
|
static CoreFieldType stringType = CoreStringType();
|
||||||
static CoreFieldType doubleType = CoreDoubleType();
|
static CoreFieldType doubleType = CoreDoubleType();
|
||||||
static CoreFieldType colorType = CoreColorType();
|
static CoreFieldType colorType = CoreColorType();
|
||||||
@ -487,25 +485,24 @@ class RiveCoreContext {
|
|||||||
static CoreFieldType coreType(int propertyKey) {
|
static CoreFieldType coreType(int propertyKey) {
|
||||||
switch (propertyKey) {
|
switch (propertyKey) {
|
||||||
case KeyedObjectBase.objectIdPropertyKey:
|
case KeyedObjectBase.objectIdPropertyKey:
|
||||||
case KeyFrameBase.interpolatorIdPropertyKey:
|
|
||||||
case KeyFrameDrawOrderValueBase.drawableIdPropertyKey:
|
|
||||||
case KeyFrameDrawOrderValueBase.valuePropertyKey:
|
|
||||||
case ComponentBase.parentIdPropertyKey:
|
|
||||||
case DrawableBase.drawOrderPropertyKey:
|
|
||||||
return uintType;
|
|
||||||
case KeyedPropertyBase.propertyKeyPropertyKey:
|
case KeyedPropertyBase.propertyKeyPropertyKey:
|
||||||
case KeyFrameBase.framePropertyKey:
|
case KeyFrameBase.framePropertyKey:
|
||||||
case KeyFrameBase.interpolationTypePropertyKey:
|
case KeyFrameBase.interpolationTypePropertyKey:
|
||||||
|
case KeyFrameBase.interpolatorIdPropertyKey:
|
||||||
case LinearAnimationBase.fpsPropertyKey:
|
case LinearAnimationBase.fpsPropertyKey:
|
||||||
case LinearAnimationBase.durationPropertyKey:
|
case LinearAnimationBase.durationPropertyKey:
|
||||||
case LinearAnimationBase.loopValuePropertyKey:
|
case LinearAnimationBase.loopValuePropertyKey:
|
||||||
case LinearAnimationBase.workStartPropertyKey:
|
case LinearAnimationBase.workStartPropertyKey:
|
||||||
case LinearAnimationBase.workEndPropertyKey:
|
case LinearAnimationBase.workEndPropertyKey:
|
||||||
|
case KeyFrameDrawOrderValueBase.drawableIdPropertyKey:
|
||||||
|
case KeyFrameDrawOrderValueBase.valuePropertyKey:
|
||||||
|
case ComponentBase.parentIdPropertyKey:
|
||||||
case StrokeBase.capPropertyKey:
|
case StrokeBase.capPropertyKey:
|
||||||
case StrokeBase.joinPropertyKey:
|
case StrokeBase.joinPropertyKey:
|
||||||
case FillBase.fillRulePropertyKey:
|
case FillBase.fillRulePropertyKey:
|
||||||
|
case DrawableBase.drawOrderPropertyKey:
|
||||||
case DrawableBase.blendModeValuePropertyKey:
|
case DrawableBase.blendModeValuePropertyKey:
|
||||||
return intType;
|
return uintType;
|
||||||
case AnimationBase.namePropertyKey:
|
case AnimationBase.namePropertyKey:
|
||||||
case ComponentBase.namePropertyKey:
|
case ComponentBase.namePropertyKey:
|
||||||
return stringType;
|
return stringType;
|
||||||
@ -568,28 +565,14 @@ class RiveCoreContext {
|
|||||||
switch (propertyKey) {
|
switch (propertyKey) {
|
||||||
case KeyedObjectBase.objectIdPropertyKey:
|
case KeyedObjectBase.objectIdPropertyKey:
|
||||||
return (object as KeyedObjectBase).objectId;
|
return (object as KeyedObjectBase).objectId;
|
||||||
case KeyFrameBase.interpolatorIdPropertyKey:
|
|
||||||
return (object as KeyFrameBase).interpolatorId;
|
|
||||||
case KeyFrameDrawOrderValueBase.drawableIdPropertyKey:
|
|
||||||
return (object as KeyFrameDrawOrderValueBase).drawableId;
|
|
||||||
case KeyFrameDrawOrderValueBase.valuePropertyKey:
|
|
||||||
return (object as KeyFrameDrawOrderValueBase).value;
|
|
||||||
case ComponentBase.parentIdPropertyKey:
|
|
||||||
return (object as ComponentBase).parentId;
|
|
||||||
case DrawableBase.drawOrderPropertyKey:
|
|
||||||
return (object as DrawableBase).drawOrder;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int getInt(Core object, int propertyKey) {
|
|
||||||
switch (propertyKey) {
|
|
||||||
case KeyedPropertyBase.propertyKeyPropertyKey:
|
case KeyedPropertyBase.propertyKeyPropertyKey:
|
||||||
return (object as KeyedPropertyBase).propertyKey;
|
return (object as KeyedPropertyBase).propertyKey;
|
||||||
case KeyFrameBase.framePropertyKey:
|
case KeyFrameBase.framePropertyKey:
|
||||||
return (object as KeyFrameBase).frame;
|
return (object as KeyFrameBase).frame;
|
||||||
case KeyFrameBase.interpolationTypePropertyKey:
|
case KeyFrameBase.interpolationTypePropertyKey:
|
||||||
return (object as KeyFrameBase).interpolationType;
|
return (object as KeyFrameBase).interpolationType;
|
||||||
|
case KeyFrameBase.interpolatorIdPropertyKey:
|
||||||
|
return (object as KeyFrameBase).interpolatorId;
|
||||||
case LinearAnimationBase.fpsPropertyKey:
|
case LinearAnimationBase.fpsPropertyKey:
|
||||||
return (object as LinearAnimationBase).fps;
|
return (object as LinearAnimationBase).fps;
|
||||||
case LinearAnimationBase.durationPropertyKey:
|
case LinearAnimationBase.durationPropertyKey:
|
||||||
@ -600,12 +583,20 @@ class RiveCoreContext {
|
|||||||
return (object as LinearAnimationBase).workStart;
|
return (object as LinearAnimationBase).workStart;
|
||||||
case LinearAnimationBase.workEndPropertyKey:
|
case LinearAnimationBase.workEndPropertyKey:
|
||||||
return (object as LinearAnimationBase).workEnd;
|
return (object as LinearAnimationBase).workEnd;
|
||||||
|
case KeyFrameDrawOrderValueBase.drawableIdPropertyKey:
|
||||||
|
return (object as KeyFrameDrawOrderValueBase).drawableId;
|
||||||
|
case KeyFrameDrawOrderValueBase.valuePropertyKey:
|
||||||
|
return (object as KeyFrameDrawOrderValueBase).value;
|
||||||
|
case ComponentBase.parentIdPropertyKey:
|
||||||
|
return (object as ComponentBase).parentId;
|
||||||
case StrokeBase.capPropertyKey:
|
case StrokeBase.capPropertyKey:
|
||||||
return (object as StrokeBase).cap;
|
return (object as StrokeBase).cap;
|
||||||
case StrokeBase.joinPropertyKey:
|
case StrokeBase.joinPropertyKey:
|
||||||
return (object as StrokeBase).join;
|
return (object as StrokeBase).join;
|
||||||
case FillBase.fillRulePropertyKey:
|
case FillBase.fillRulePropertyKey:
|
||||||
return (object as FillBase).fillRule;
|
return (object as FillBase).fillRule;
|
||||||
|
case DrawableBase.drawOrderPropertyKey:
|
||||||
|
return (object as DrawableBase).drawOrder;
|
||||||
case DrawableBase.blendModeValuePropertyKey:
|
case DrawableBase.blendModeValuePropertyKey:
|
||||||
return (object as DrawableBase).blendModeValue;
|
return (object as DrawableBase).blendModeValue;
|
||||||
}
|
}
|
||||||
@ -739,26 +730,6 @@ class RiveCoreContext {
|
|||||||
case KeyedObjectBase.objectIdPropertyKey:
|
case KeyedObjectBase.objectIdPropertyKey:
|
||||||
(object as KeyedObjectBase).objectId = value;
|
(object as KeyedObjectBase).objectId = value;
|
||||||
break;
|
break;
|
||||||
case KeyFrameBase.interpolatorIdPropertyKey:
|
|
||||||
(object as KeyFrameBase).interpolatorId = value;
|
|
||||||
break;
|
|
||||||
case KeyFrameDrawOrderValueBase.drawableIdPropertyKey:
|
|
||||||
(object as KeyFrameDrawOrderValueBase).drawableId = value;
|
|
||||||
break;
|
|
||||||
case KeyFrameDrawOrderValueBase.valuePropertyKey:
|
|
||||||
(object as KeyFrameDrawOrderValueBase).value = value;
|
|
||||||
break;
|
|
||||||
case ComponentBase.parentIdPropertyKey:
|
|
||||||
(object as ComponentBase).parentId = value;
|
|
||||||
break;
|
|
||||||
case DrawableBase.drawOrderPropertyKey:
|
|
||||||
(object as DrawableBase).drawOrder = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setInt(Core object, int propertyKey, int value) {
|
|
||||||
switch (propertyKey) {
|
|
||||||
case KeyedPropertyBase.propertyKeyPropertyKey:
|
case KeyedPropertyBase.propertyKeyPropertyKey:
|
||||||
(object as KeyedPropertyBase).propertyKey = value;
|
(object as KeyedPropertyBase).propertyKey = value;
|
||||||
break;
|
break;
|
||||||
@ -768,6 +739,9 @@ class RiveCoreContext {
|
|||||||
case KeyFrameBase.interpolationTypePropertyKey:
|
case KeyFrameBase.interpolationTypePropertyKey:
|
||||||
(object as KeyFrameBase).interpolationType = value;
|
(object as KeyFrameBase).interpolationType = value;
|
||||||
break;
|
break;
|
||||||
|
case KeyFrameBase.interpolatorIdPropertyKey:
|
||||||
|
(object as KeyFrameBase).interpolatorId = value;
|
||||||
|
break;
|
||||||
case LinearAnimationBase.fpsPropertyKey:
|
case LinearAnimationBase.fpsPropertyKey:
|
||||||
(object as LinearAnimationBase).fps = value;
|
(object as LinearAnimationBase).fps = value;
|
||||||
break;
|
break;
|
||||||
@ -783,6 +757,15 @@ class RiveCoreContext {
|
|||||||
case LinearAnimationBase.workEndPropertyKey:
|
case LinearAnimationBase.workEndPropertyKey:
|
||||||
(object as LinearAnimationBase).workEnd = value;
|
(object as LinearAnimationBase).workEnd = value;
|
||||||
break;
|
break;
|
||||||
|
case KeyFrameDrawOrderValueBase.drawableIdPropertyKey:
|
||||||
|
(object as KeyFrameDrawOrderValueBase).drawableId = value;
|
||||||
|
break;
|
||||||
|
case KeyFrameDrawOrderValueBase.valuePropertyKey:
|
||||||
|
(object as KeyFrameDrawOrderValueBase).value = value;
|
||||||
|
break;
|
||||||
|
case ComponentBase.parentIdPropertyKey:
|
||||||
|
(object as ComponentBase).parentId = value;
|
||||||
|
break;
|
||||||
case StrokeBase.capPropertyKey:
|
case StrokeBase.capPropertyKey:
|
||||||
(object as StrokeBase).cap = value;
|
(object as StrokeBase).cap = value;
|
||||||
break;
|
break;
|
||||||
@ -792,6 +775,9 @@ class RiveCoreContext {
|
|||||||
case FillBase.fillRulePropertyKey:
|
case FillBase.fillRulePropertyKey:
|
||||||
(object as FillBase).fillRule = value;
|
(object as FillBase).fillRule = value;
|
||||||
break;
|
break;
|
||||||
|
case DrawableBase.drawOrderPropertyKey:
|
||||||
|
(object as DrawableBase).drawOrder = value;
|
||||||
|
break;
|
||||||
case DrawableBase.blendModeValuePropertyKey:
|
case DrawableBase.blendModeValuePropertyKey:
|
||||||
(object as DrawableBase).blendModeValue = value;
|
(object as DrawableBase).blendModeValue = value;
|
||||||
break;
|
break;
|
||||||
|
@ -99,8 +99,8 @@ abstract class Path extends PathBase {
|
|||||||
}
|
}
|
||||||
List<PathVertex> renderPoints = [];
|
List<PathVertex> renderPoints = [];
|
||||||
int pl = pts.length;
|
int pl = pts.length;
|
||||||
const double iarcConstant = 1.0 - circleConstant;
|
const arcConstant = circleConstant;
|
||||||
|
const double iarcConstant = 1.0 - arcConstant;
|
||||||
PathVertex previous = isClosed ? pts[pl - 1] : null;
|
PathVertex previous = isClosed ? pts[pl - 1] : null;
|
||||||
for (int i = 0; i < pl; i++) {
|
for (int i = 0; i < pl; i++) {
|
||||||
PathVertex point = pts[i];
|
PathVertex point = pts[i];
|
||||||
|
@ -77,28 +77,6 @@ class BinaryReader {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read a variable length signed integer from the buffer encoded as an LEB128
|
|
||||||
/// signed integer.
|
|
||||||
int readVarInt() {
|
|
||||||
int result = 0;
|
|
||||||
int shift = 0;
|
|
||||||
while (true) {
|
|
||||||
int byte = buffer.getUint8(_readIndex);
|
|
||||||
result |= (byte & 0x7f) << shift;
|
|
||||||
shift += 7;
|
|
||||||
if ((byte & 0x80) == 0) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
_readIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((shift < 64) && (buffer.getUint8(_readIndex) & 0x40) != 0) {
|
|
||||||
result |= ~0 << shift;
|
|
||||||
}
|
|
||||||
_readIndex += 1;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Read a variable length unsigned integer from the buffer encoded as an
|
/// Read a variable length unsigned integer from the buffer encoded as an
|
||||||
/// LEB128 unsigned integer.
|
/// LEB128 unsigned integer.
|
||||||
int readVarUint() {
|
int readVarUint() {
|
||||||
@ -130,14 +108,4 @@ class BinaryReader {
|
|||||||
_readIndex += length;
|
_readIndex += length;
|
||||||
return allocNew ? Uint8List.fromList(view) : view;
|
return allocNew ? Uint8List.fromList(view) : view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read a list of encoded integers.
|
|
||||||
List<int> readIntList() {
|
|
||||||
int length = readVarUint();
|
|
||||||
var list = List<int>(length);
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
list[i] = readVarInt();
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -107,28 +107,6 @@ class BinaryWriter {
|
|||||||
_writeIndex += length;
|
_writeIndex += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write an integer as a list of bytes that contain an LEB128 signed integer.
|
|
||||||
/// The size of the integer is decided automatically.
|
|
||||||
void writeVarInt(int value) {
|
|
||||||
var more = true;
|
|
||||||
int index = 0;
|
|
||||||
while (more) {
|
|
||||||
var byte = value & 0x7f;
|
|
||||||
//ignore: parameter_assignments
|
|
||||||
value >>= 7;
|
|
||||||
if (value == 0 && (byte & 0x40) == 0) {
|
|
||||||
more = false;
|
|
||||||
} else if (value == -1 && (byte & 0x40) > 0) {
|
|
||||||
more = false;
|
|
||||||
} else {
|
|
||||||
byte |= 0x80;
|
|
||||||
}
|
|
||||||
_variableEncodeList[index++] = byte;
|
|
||||||
}
|
|
||||||
|
|
||||||
write(_variableEncodeList, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Write an integer as a list of bytes that contain an LEB128 unsigned
|
/// Write an integer as a list of bytes that contain an LEB128 unsigned
|
||||||
/// integer. The size of the integer is decided automatically.
|
/// integer. The size of the integer is decided automatically.
|
||||||
void writeVarUint(int value) {
|
void writeVarUint(int value) {
|
||||||
@ -158,11 +136,4 @@ class BinaryWriter {
|
|||||||
}
|
}
|
||||||
write(list);
|
write(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a list of integers as varint.
|
|
||||||
void writeIntList(List<int> list) {
|
|
||||||
assert(list != null);
|
|
||||||
writeVarUint(list.length);
|
|
||||||
list.forEach(writeVarInt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user