mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 17:51:41 -05:00
Fix lottie caching.
This commit is contained in:
parent
37689affc5
commit
ead212f31b
2 changed files with 15 additions and 0 deletions
|
@ -517,6 +517,8 @@ bool Cache::renderFrame(
|
||||||
_framesReady = 0;
|
_framesReady = 0;
|
||||||
_data = QByteArray();
|
_data = QByteArray();
|
||||||
return false;
|
return false;
|
||||||
|
} else if (index + 1 == _framesReady && _data.size() > _offset) {
|
||||||
|
_data.resize(_offset);
|
||||||
}
|
}
|
||||||
if (xored) {
|
if (xored) {
|
||||||
Xor(_previous, _uncompressed);
|
Xor(_previous, _uncompressed);
|
||||||
|
@ -576,6 +578,8 @@ void Cache::finalizeEncoding() {
|
||||||
if (_data.isEmpty()) {
|
if (_data.isEmpty()) {
|
||||||
_data.reserve(size);
|
_data.reserve(size);
|
||||||
writeHeader();
|
writeHeader();
|
||||||
|
} else {
|
||||||
|
updateFramesReadyCount();
|
||||||
}
|
}
|
||||||
const auto offset = _data.size();
|
const auto offset = _data.size();
|
||||||
_data.resize(size);
|
_data.resize(size);
|
||||||
|
@ -609,6 +613,16 @@ void Cache::writeHeader() {
|
||||||
<< qint32(_framesReady);
|
<< qint32(_framesReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cache::updateFramesReadyCount() {
|
||||||
|
Expects(_data.size() >= headerSize());
|
||||||
|
|
||||||
|
const auto serialized = qint32(_framesReady);
|
||||||
|
const auto offset = headerSize() - sizeof(qint32);
|
||||||
|
bytes::copy(
|
||||||
|
bytes::make_detached_span(_data).subspan(offset),
|
||||||
|
bytes::object_as_span(&serialized));
|
||||||
|
}
|
||||||
|
|
||||||
void Cache::prepareBuffers() {
|
void Cache::prepareBuffers() {
|
||||||
// 12 bit per pixel in YUV420P.
|
// 12 bit per pixel in YUV420P.
|
||||||
const auto bytesPerLine = _size.width();
|
const auto bytesPerLine = _size.width();
|
||||||
|
|
|
@ -101,6 +101,7 @@ private:
|
||||||
void finalizeEncoding();
|
void finalizeEncoding();
|
||||||
|
|
||||||
void writeHeader();
|
void writeHeader();
|
||||||
|
void updateFramesReadyCount();
|
||||||
[[nodiscard]] bool readHeader(const FrameRequest &request);
|
[[nodiscard]] bool readHeader(const FrameRequest &request);
|
||||||
[[nodiscard]] ReadResult readCompressedFrame();
|
[[nodiscard]] ReadResult readCompressedFrame();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue