|
|
|
@ -23,16 +23,18 @@ struct TimeBasedDrawnSectionMetaData { |
|
|
|
std::int64_t endTimestamp{}; |
|
|
|
std::int64_t endTimestamp{}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
static std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
static std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
static std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
static std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
static std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
static std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
static std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
static std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
static std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
static std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
static std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
static std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
static std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
static std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts); |
|
|
|
static std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion); |
|
|
|
|
|
|
|
|
|
|
|
static std::expected<AlwaysDrawnSectionMetaData, ParseError> parseAlwaysDrawnSection(std::span<std::byte const>& data) { |
|
|
|
static std::expected<AlwaysDrawnSectionMetaData, ParseError> parseAlwaysDrawnSection(std::span<std::byte const>& data, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
|
|
|
|
|
|
|
auto type = readU8LE(data); |
|
|
|
auto type = readU8LE(data); |
|
|
|
if (!type) { |
|
|
|
if (!type) { |
|
|
|
return std::unexpected(type.error()); |
|
|
|
return std::unexpected(type.error()); |
|
|
|
@ -71,7 +73,9 @@ static std::expected<AlwaysDrawnSectionMetaData, ParseError> parseAlwaysDrawnSec |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static std::expected<TimeBasedDrawnSectionMetaData, ParseError> parseTimeBasedDrawnSection(std::span<std::byte const>& data) { |
|
|
|
static std::expected<TimeBasedDrawnSectionMetaData, ParseError> parseTimeBasedDrawnSection(std::span<std::byte const>& data, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
|
|
|
|
|
|
|
auto type = readU8LE(data); |
|
|
|
auto type = readU8LE(data); |
|
|
|
if (!type) { |
|
|
|
if (!type) { |
|
|
|
return std::unexpected(type.error()); |
|
|
|
return std::unexpected(type.error()); |
|
|
|
@ -120,7 +124,9 @@ static std::expected<TimeBasedDrawnSectionMetaData, ParseError> parseTimeBasedDr |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static std::expected<std::span<std::byte const>, ParseError> parseCustomFontSection(std::span<std::byte const>& data) { |
|
|
|
static std::expected<std::span<std::byte const>, ParseError> parseCustomFontSection(std::span<std::byte const>& data, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
|
|
|
|
|
|
|
auto type = readU8LE(data); |
|
|
|
auto type = readU8LE(data); |
|
|
|
if (!type) { |
|
|
|
if (!type) { |
|
|
|
return std::unexpected(type.error()); |
|
|
|
return std::unexpected(type.error()); |
|
|
|
@ -197,7 +203,7 @@ std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, O |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (static_cast<SectionType>(*sectionType) == SectionType::CustomFont) { |
|
|
|
if (static_cast<SectionType>(*sectionType) == SectionType::CustomFont) { |
|
|
|
auto fontData = parseCustomFontSection(*rawSectionData); |
|
|
|
auto fontData = parseCustomFontSection(*rawSectionData, *version); |
|
|
|
if (!fontData) { |
|
|
|
if (!fontData) { |
|
|
|
return std::unexpected(fontData.error()); |
|
|
|
return std::unexpected(fontData.error()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -209,13 +215,13 @@ std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, O |
|
|
|
|
|
|
|
|
|
|
|
AlwaysDrawnSectionMetaData section; |
|
|
|
AlwaysDrawnSectionMetaData section; |
|
|
|
if (static_cast<SectionType>(*sectionType) == SectionType::AlwaysDrawn) { |
|
|
|
if (static_cast<SectionType>(*sectionType) == SectionType::AlwaysDrawn) { |
|
|
|
auto metaData = parseAlwaysDrawnSection(*rawSectionData); |
|
|
|
auto metaData = parseAlwaysDrawnSection(*rawSectionData, *version); |
|
|
|
if (!metaData) { |
|
|
|
if (!metaData) { |
|
|
|
return std::unexpected(metaData.error()); |
|
|
|
return std::unexpected(metaData.error()); |
|
|
|
} |
|
|
|
} |
|
|
|
section = *metaData; |
|
|
|
section = *metaData; |
|
|
|
} else if (static_cast<SectionType>(*sectionType) == SectionType::TimeBasedDrawn) { |
|
|
|
} else if (static_cast<SectionType>(*sectionType) == SectionType::TimeBasedDrawn) { |
|
|
|
auto metaData = parseTimeBasedDrawnSection(*rawSectionData); |
|
|
|
auto metaData = parseTimeBasedDrawnSection(*rawSectionData, *version); |
|
|
|
if (!metaData) { |
|
|
|
if (!metaData) { |
|
|
|
return std::unexpected(metaData.error()); |
|
|
|
return std::unexpected(metaData.error()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -249,14 +255,14 @@ std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, O |
|
|
|
auto eType = static_cast<ElementType>(*type); |
|
|
|
auto eType = static_cast<ElementType>(*type); |
|
|
|
std::expected<void, ParseError> parseResult; |
|
|
|
std::expected<void, ParseError> parseResult; |
|
|
|
switch (eType) { |
|
|
|
switch (eType) { |
|
|
|
case ElementType::Image: parseResult = handleImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
case ElementType::Image: parseResult = handleImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
case ElementType::Animation: parseResult = handleAnimation(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
case ElementType::Animation: parseResult = handleAnimation(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
case ElementType::HScrollImage: parseResult = handleHScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
case ElementType::HScrollImage: parseResult = handleHScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
case ElementType::VScrollImage: parseResult = handleVScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
case ElementType::VScrollImage: parseResult = handleVScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
case ElementType::Line: parseResult = handleLine(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
case ElementType::Line: parseResult = handleLine(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
case ElementType::ClippedText: parseResult = handleClippedText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
case ElementType::ClippedText: parseResult = handleClippedText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
case ElementType::HScrollText: parseResult = handleHScrollText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
case ElementType::HScrollText: parseResult = handleHScrollText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
case ElementType::CurrentTime: parseResult = handleCurrentTime(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; |
|
|
|
case ElementType::CurrentTime: parseResult = handleCurrentTime(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; |
|
|
|
default: parseResult = std::unexpected(ParseError::InvalidValue); |
|
|
|
default: parseResult = std::unexpected(ParseError::InvalidValue); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -269,7 +275,9 @@ std::expected<void, ParseError> parseAndApply(std::span<std::byte const> data, O |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
|
|
|
|
|
|
|
|
auto type = readU16LE(buffer); |
|
|
|
auto type = readU16LE(buffer); |
|
|
|
if (!type) { |
|
|
|
if (!type) { |
|
|
|
return std::unexpected(type.error()); |
|
|
|
return std::unexpected(type.error()); |
|
|
|
@ -324,7 +332,8 @@ std::expected<void, ParseError> handleImage(std::span<std::byte const>& buffer, |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = customFonts; |
|
|
|
std::ignore = customFonts; |
|
|
|
|
|
|
|
|
|
|
|
@ -396,7 +405,8 @@ std::expected<void, ParseError> handleAnimation(std::span<std::byte const>& buff |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = customFonts; |
|
|
|
std::ignore = customFonts; |
|
|
|
|
|
|
|
|
|
|
|
@ -561,7 +571,8 @@ std::expected<void, ParseError> handleHScrollImage(std::span<std::byte const>& b |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = customFonts; |
|
|
|
std::ignore = customFonts; |
|
|
|
|
|
|
|
|
|
|
|
@ -726,7 +737,8 @@ std::expected<void, ParseError> handleVScrollImage(std::span<std::byte const>& b |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
std::ignore = animationTick; |
|
|
|
std::ignore = animationTick; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = customFonts; |
|
|
|
std::ignore = customFonts; |
|
|
|
@ -798,7 +810,8 @@ std::expected<void, ParseError> handleLine(std::span<std::byte const>& buffer, O |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
std::ignore = animationTick; |
|
|
|
std::ignore = animationTick; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
|
|
|
|
|
|
|
@ -867,7 +880,8 @@ std::expected<void, ParseError> handleClippedText(std::span<std::byte const>& bu |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
std::ignore = currentTimestamp; |
|
|
|
|
|
|
|
|
|
|
|
auto type = readU16LE(buffer); |
|
|
|
auto type = readU16LE(buffer); |
|
|
|
@ -1028,7 +1042,8 @@ std::expected<void, ParseError> handleHScrollText(std::span<std::byte const>& bu |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts) { |
|
|
|
std::expected<void, ParseError> handleCurrentTime(std::span<std::byte const>& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span<std::span<std::byte const>> customFonts, std::uint32_t formatVersion) { |
|
|
|
|
|
|
|
std::ignore = formatVersion; |
|
|
|
std::ignore = animationTick; |
|
|
|
std::ignore = animationTick; |
|
|
|
|
|
|
|
|
|
|
|
auto type = readU16LE(buffer); |
|
|
|
auto type = readU16LE(buffer); |
|
|
|
|