tvg: recover the broken compatibility.

The issue was introduced by b214fd23bc
This commit is contained in:
Hermet Park 2023-06-13 11:58:26 +09:00 committed by Hermet Park
parent 4627daf6f7
commit 8398fdbca7
3 changed files with 14 additions and 5 deletions

View file

@ -26,9 +26,6 @@
/* TODO: Need to consider whether uin8_t is enough size for extension... /* TODO: Need to consider whether uin8_t is enough size for extension...
Rather than optimal data, we can use enough size and data compress? */ Rather than optimal data, we can use enough size and data compress? */
/* Data types, do not change data types once Tvg Format is officially released,
That would occur the abi break. */
using TvgBinByte = uint8_t; using TvgBinByte = uint8_t;
using TvgBinCounter = uint32_t; using TvgBinCounter = uint32_t;
using TvgBinTag = TvgBinByte; using TvgBinTag = TvgBinByte;
@ -39,7 +36,7 @@ using TvgBinFlag = TvgBinByte;
#define TVG_HEADER_SIZE 33 //TVG_HEADER_SIGNATURE_LENGTH + TVG_HEADER_VERSION_LENGTH + 2*SIZE(float) + TVG_HEADER_RESERVED_LENGTH + TVG_HEADER_COMPRESS_SIZE #define TVG_HEADER_SIZE 33 //TVG_HEADER_SIGNATURE_LENGTH + TVG_HEADER_VERSION_LENGTH + 2*SIZE(float) + TVG_HEADER_RESERVED_LENGTH + TVG_HEADER_COMPRESS_SIZE
#define TVG_HEADER_SIGNATURE "ThorVG" #define TVG_HEADER_SIGNATURE "ThorVG"
#define TVG_HEADER_SIGNATURE_LENGTH 6 #define TVG_HEADER_SIGNATURE_LENGTH 6
#define TVG_HEADER_VERSION "000400" //Major 00, Minor 04, Micro 00 #define TVG_HEADER_VERSION "001000" //Major 00, Minor 10, Micro 00
#define TVG_HEADER_VERSION_LENGTH 6 #define TVG_HEADER_VERSION_LENGTH 6
#define TVG_HEADER_RESERVED_LENGTH 1 //Storing flags for extensions #define TVG_HEADER_RESERVED_LENGTH 1 //Storing flags for extensions
#define TVG_HEADER_COMPRESS_SIZE 12 //TVG_HEADER_UNCOMPRESSED_SIZE + TVG_HEADER_COMPRESSED_SIZE + TVG_HEADER_COMPRESSED_SIZE_BITS #define TVG_HEADER_COMPRESS_SIZE 12 //TVG_HEADER_UNCOMPRESSED_SIZE + TVG_HEADER_COMPRESSED_SIZE + TVG_HEADER_COMPRESSED_SIZE_BITS
@ -63,8 +60,9 @@ using TvgBinFlag = TvgBinByte;
#define TVG_TAG_PAINT_CMP_METHOD (TvgBinTag)0x20 #define TVG_TAG_PAINT_CMP_METHOD (TvgBinTag)0x20
//TODO: Keep this for the compatibility, Remove in TVG 1.0 release
//Scene //Scene
#define TVG_TAG_SCENE_RESERVEDCNT (TvgBinTag)0x30 #define TVG_TAG_SCENE_RESERVEDCNT (TvgBinTag)0x30
//Shape //Shape

View file

@ -108,6 +108,16 @@ static bool _parseScene(TvgBinBlock block, Paint *paint)
{ {
auto scene = static_cast<Scene*>(paint); auto scene = static_cast<Scene*>(paint);
//TODO: Keep this for the compatibility, Remove in TVG 1.0 release
//Case1: scene reserve count
if (block.type == TVG_TAG_SCENE_RESERVEDCNT) {
if (block.length != SIZE(uint32_t)) return false;
uint32_t reservedCnt;
READ_UI32(&reservedCnt, block.data);
//scene->reserve(reservedCnt);
return true;
}
//Case2: Base Paint Properties //Case2: Base Paint Properties
if (_parsePaintProperty(block, scene)) return true; if (_parsePaintProperty(block, scene)) return true;

View file

@ -676,6 +676,7 @@ TvgBinCounter TvgSaver::serializeChildren(Iterator* it, const Matrix* pTransform
children.push(child); children.push(child);
} }
//TODO: Keep this for the compatibility, Remove in TVG 1.0 release
//The children of a reserved scene //The children of a reserved scene
if (reserved && children.count > 1) { if (reserved && children.count > 1) {
cnt += writeTagProperty(TVG_TAG_SCENE_RESERVEDCNT, SIZE(children.count), &children.count); cnt += writeTagProperty(TVG_TAG_SCENE_RESERVEDCNT, SIZE(children.count), &children.count);