Rml initial work (#10542) 199af78f1e

* feature: adding rml compiler

* chore: fixing multi fields missing

* chore: cleanup

* chore: updating to latest master

* chore: allowing saving rml

* sorting items correctly

* hiding unnecessary xml props

* stripping unnecessary ids

* chore: add missed files

* chore: adding missed files

* add serializer to rev

* fractional index

* list id types

* include non runtime objects on export

* more rml

* sort root nodes

* add flags support

* fixes

* add parenting to definitions

* fix id clash

* skip computed values

* add full parentable support

* fix bit flags

* fix keyframes

* add interpolators as children

* support multiple parented objects

* handle duplicate parent

* cli

* add rml docker

* clang format

* add support for new properties in core definition

* restore initial values of json

Co-authored-by: Luigi Rosso <luigi.rosso@gmail.com>
Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
bodymovin
2025-09-09 18:51:39 +00:00
parent 825c51c8ba
commit 03d74fb282
34 changed files with 134 additions and 33 deletions

View File

@@ -1 +1 @@
01521839447257aa13ad0d70d1a9d2c3a5f8c304
199af78f1e68b83d7d844314db4b5b82db31a4c6

View File

@@ -26,7 +26,6 @@
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 73,
"string": "order"

View File

@@ -31,7 +31,6 @@
},
"animationOrder": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 169,
"string": "animationorder"

View File

@@ -20,7 +20,6 @@
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 230,

View File

@@ -27,7 +27,6 @@
},
"machineOrder": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 139,
"string": "machineorder"

View File

@@ -16,6 +16,24 @@
"string": "eventid"
},
"description": "Id of the Event referenced."
},
"occursValue": {
"type": "uint",
"initialValue": "0",
"key": {
"int": 393,
"string": "occursvalue"
},
"description": "When the event fires."
},
"fireOrder": {
"type": "FractionalIndex",
"key": {
"int": 394,
"string": "fireorder"
},
"description": "Order value for sorting transitions in states.",
"runtime": false
}
}
}

View File

@@ -47,7 +47,6 @@
},
"transitionOrder": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 159,
"string": "transitionorder"

View File

@@ -20,7 +20,6 @@
},
"conditionOrder": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 154,

View File

@@ -27,7 +27,6 @@
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 205,
"string": "order"

View File

@@ -14,7 +14,8 @@
"string": "dependentIds"
},
"description": "List of integer ids for objects registered in the same context that depend on this object.",
"runtime": false
"runtime": false,
"computed": true
},
"name": {
"type": "String",
@@ -48,7 +49,6 @@
},
"childOrder": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 6,

View File

@@ -8,7 +8,6 @@
"properties": {
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 661,

View File

@@ -7,7 +7,6 @@
"properties": {
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 678,
"string": "order"

View File

@@ -7,7 +7,6 @@
"properties": {
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 772,
"string": "order"

View File

@@ -35,7 +35,6 @@
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 388,
"string": "order"
@@ -51,7 +50,8 @@
"string": "dependentids"
},
"description": "Object ids assigned to this tag.",
"runtime": false
"runtime": false,
"computed": true
}
}
}

View File

@@ -7,7 +7,6 @@
"properties": {
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 570,

View File

@@ -35,7 +35,6 @@
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 581,

View File

@@ -8,7 +8,6 @@
"properties": {
"viewModelOrder": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 563,

View File

@@ -48,7 +48,6 @@
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 739,
"string": "order"

View File

@@ -49,7 +49,6 @@
},
"order": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"key": {
"int": 552,
"string": "order"

View File

@@ -20,7 +20,6 @@
},
"propertyOrder": {
"type": "FractionalIndex",
"initialValue": "FractionalIndex.invalid",
"initialValueRuntime": "0",
"key": {
"int": 559,

View File

@@ -31,8 +31,13 @@ public:
const uint8_t* position() const;
std::string readString();
std::string readString(size_t length);
Span<const uint8_t> readBytes();
Span<const uint8_t> readBytes(size_t length);
float readFloat32();
#ifdef WITH_RIVE_TOOLS
double readFloat64();
#endif
uint8_t readByte();
uint16_t readUint16();
uint32_t readUint32();

View File

@@ -9,6 +9,9 @@ class CoreBoolType
public:
static const int id = 4;
static bool deserialize(BinaryReader& reader);
#ifdef WITH_RIVE_TOOLS
static bool deserializeRev(BinaryReader& reader);
#endif
};
} // namespace rive
#endif

View File

@@ -12,6 +12,9 @@ class CoreBytesType
public:
static const int id = 1;
static Span<const uint8_t> deserialize(BinaryReader& reader);
#ifdef WITH_RIVE_TOOLS
static Span<const uint8_t> deserializeRev(BinaryReader& reader);
#endif
};
} // namespace rive
#endif

View File

@@ -9,6 +9,9 @@ class CoreColorType
public:
static const int id = 3;
static int deserialize(BinaryReader& reader);
#ifdef WITH_RIVE_TOOLS
static int deserializeRev(BinaryReader& reader);
#endif
};
} // namespace rive
#endif

View File

@@ -9,6 +9,9 @@ class CoreDoubleType
public:
static const int id = 2;
static float deserialize(BinaryReader& reader);
#ifdef WITH_RIVE_TOOLS
static float deserializeRev(BinaryReader& reader);
#endif
};
} // namespace rive
#endif

View File

@@ -11,6 +11,9 @@ class CoreStringType
public:
static const int id = 1;
static std::string deserialize(BinaryReader& reader);
#ifdef WITH_RIVE_TOOLS
static std::string deserializeRev(BinaryReader& reader);
#endif
};
} // namespace rive
#endif

View File

@@ -9,6 +9,9 @@ class CoreUintType
public:
static const int id = 0;
static unsigned int deserialize(BinaryReader& reader);
#ifdef WITH_RIVE_TOOLS
static unsigned int deserializeRev(BinaryReader& reader);
#endif
};
} // namespace rive
#endif

View File

@@ -49,14 +49,8 @@ uint64_t BinaryReader::readVarUint64()
return value;
}
std::string BinaryReader::readString()
std::string BinaryReader::readString(size_t length)
{
uint64_t length = readVarUint64();
if (didOverflow())
{
return std::string();
}
std::vector<char> rawValue((size_t)length + 1);
auto readBytes =
decode_string(length, m_Position, m_Bytes.end(), &rawValue[0]);
@@ -69,6 +63,16 @@ std::string BinaryReader::readString()
return std::string(rawValue.data(), (size_t)length);
}
std::string BinaryReader::readString()
{
uint64_t length = readVarUint64();
if (didOverflow())
{
return std::string();
}
return readString(length);
}
Span<const uint8_t> BinaryReader::readBytes()
{
uint64_t length = readVarUint64();
@@ -77,6 +81,11 @@ Span<const uint8_t> BinaryReader::readBytes()
return Span<const uint8_t>(m_Position, 0);
}
return readBytes((size_t)length);
}
Span<const uint8_t> BinaryReader::readBytes(size_t length)
{
const uint8_t* start = m_Position;
m_Position += length;
return {start, (size_t)length};
@@ -95,6 +104,21 @@ float BinaryReader::readFloat32()
return value;
}
#ifdef WITH_RIVE_TOOLS
double BinaryReader::readFloat64()
{
double value;
auto readBytes = decode_double(m_Position, m_Bytes.end(), &value);
if (readBytes == 0)
{
overflow();
return 0.0f;
}
m_Position += readBytes;
return value;
}
#endif
uint8_t BinaryReader::readByte()
{
if (m_Bytes.end() - m_Position < 1)

View File

@@ -6,4 +6,11 @@ using namespace rive;
bool CoreBoolType::deserialize(BinaryReader& reader)
{
return reader.readByte() == 1;
}
}
#ifdef WITH_RIVE_TOOLS
bool CoreBoolType::deserializeRev(BinaryReader& reader)
{
return deserialize(reader);
}
#endif

View File

@@ -6,4 +6,11 @@ using namespace rive;
Span<const uint8_t> CoreBytesType::deserialize(BinaryReader& reader)
{
return reader.readBytes();
}
}
#ifdef WITH_RIVE_TOOLS
Span<const uint8_t> CoreBytesType::deserializeRev(BinaryReader& reader)
{
return reader.readBytes(reader.lengthInBytes());
}
#endif

View File

@@ -6,4 +6,11 @@ using namespace rive;
int CoreColorType::deserialize(BinaryReader& reader)
{
return reader.readUint32();
}
}
#ifdef WITH_RIVE_TOOLS
int CoreColorType::deserializeRev(BinaryReader& reader)
{
return (int)reader.readVarUint64();
}
#endif

View File

@@ -6,4 +6,20 @@ using namespace rive;
float CoreDoubleType::deserialize(BinaryReader& reader)
{
return reader.readFloat32();
}
}
#ifdef WITH_RIVE_TOOLS
float CoreDoubleType::deserializeRev(BinaryReader& reader)
{
size_t length = reader.lengthInBytes();
if (length == 4)
{
return reader.readFloat32();
}
else if (length == 8)
{
return (float)reader.readFloat64();
}
return 0.0f;
}
#endif

View File

@@ -6,4 +6,12 @@ using namespace rive;
std::string CoreStringType::deserialize(BinaryReader& reader)
{
return reader.readString();
}
}
#ifdef WITH_RIVE_TOOLS
std::string CoreStringType::deserializeRev(BinaryReader& reader)
{
size_t length = reader.lengthInBytes();
return reader.readString(length);
}
#endif

View File

@@ -7,3 +7,10 @@ unsigned int CoreUintType::deserialize(BinaryReader& reader)
{
return reader.readVarUintAs<unsigned int>();
}
#ifdef WITH_RIVE_TOOLS
unsigned int CoreUintType::deserializeRev(BinaryReader& reader)
{
return deserialize(reader);
}
#endif