mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show webm animation in stickers box set thumbnail.
This commit is contained in:
parent
c359646702
commit
fa61cf3c85
1 changed files with 55 additions and 18 deletions
|
@ -225,6 +225,10 @@ private:
|
||||||
void validateAnimation(not_null<Row*> row);
|
void validateAnimation(not_null<Row*> row);
|
||||||
void updateRowThumbnail(not_null<Row*> row);
|
void updateRowThumbnail(not_null<Row*> row);
|
||||||
|
|
||||||
|
void clipCallback(
|
||||||
|
not_null<Row*> row,
|
||||||
|
Media::Clip::Notification notification);
|
||||||
|
|
||||||
void readVisibleSets();
|
void readVisibleSets();
|
||||||
|
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
|
@ -1361,21 +1365,16 @@ void StickersBox::Inner::paintRowThumbnail(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
validateAnimation(row);
|
validateAnimation(row);
|
||||||
if (!row->lottie) {
|
const auto thumb = row->thumbnailMedia
|
||||||
const auto thumb = row->thumbnailMedia
|
? row->thumbnailMedia->image()
|
||||||
? row->thumbnailMedia->image()
|
: row->stickerMedia
|
||||||
: row->stickerMedia
|
? row->stickerMedia->thumbnail()
|
||||||
? row->stickerMedia->thumbnail()
|
: nullptr;
|
||||||
: nullptr;
|
const auto paused = _controller->isGifPausedAtLeastFor(
|
||||||
if (!thumb) {
|
Window::GifPauseReason::Layer);
|
||||||
return;
|
const auto x = left + (st::contactsPhotoSize - row->pixw) / 2;
|
||||||
}
|
const auto y = st::contactsPadding.top() + (st::contactsPhotoSize - row->pixh) / 2;
|
||||||
p.drawPixmapLeft(
|
if (row->lottie && row->lottie->ready()) {
|
||||||
left + (st::contactsPhotoSize - row->pixw) / 2,
|
|
||||||
st::contactsPadding.top() + (st::contactsPhotoSize - row->pixh) / 2,
|
|
||||||
width(),
|
|
||||||
thumb->pix(row->pixw, row->pixh));
|
|
||||||
} else if (row->lottie->ready()) {
|
|
||||||
const auto frame = row->lottie->frame();
|
const auto frame = row->lottie->frame();
|
||||||
const auto size = frame.size() / cIntRetinaFactor();
|
const auto size = frame.size() / cIntRetinaFactor();
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
|
@ -1385,11 +1384,23 @@ void StickersBox::Inner::paintRowThumbnail(
|
||||||
size.width(),
|
size.width(),
|
||||||
size.height()),
|
size.height()),
|
||||||
frame);
|
frame);
|
||||||
const auto paused = _controller->isGifPausedAtLeastFor(
|
|
||||||
Window::GifPauseReason::Layer);
|
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
row->lottie->markFrameShown();
|
row->lottie->markFrameShown();
|
||||||
}
|
}
|
||||||
|
} else if (row->webm && row->webm->started()) {
|
||||||
|
p.drawPixmapLeft(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width(),
|
||||||
|
row->webm->current(
|
||||||
|
{ .frame = { row->pixw, row->pixh }, .keepAlpha = true },
|
||||||
|
paused ? 0 : crl::now()));
|
||||||
|
} else if (thumb) {
|
||||||
|
p.drawPixmapLeft(
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width(),
|
||||||
|
thumb->pix(row->pixw, row->pixh));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1426,10 +1437,36 @@ void StickersBox::Inner::validateWebmAnimation(not_null<Row*> row) {
|
||||||
row->stickerMedia.get())) {
|
row->stickerMedia.get())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto callback = [=](Media::Clip::Notification notification) {
|
||||||
|
clipCallback(row, notification);
|
||||||
|
};
|
||||||
row->webm = ChatHelpers::WebmThumbnail(
|
row->webm = ChatHelpers::WebmThumbnail(
|
||||||
row->thumbnailMedia.get(),
|
row->thumbnailMedia.get(),
|
||||||
row->stickerMedia.get(),
|
row->stickerMedia.get(),
|
||||||
[=](Media::Clip::Notification) { updateRowThumbnail(row); });
|
std::move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StickersBox::Inner::clipCallback(
|
||||||
|
not_null<Row*> row,
|
||||||
|
Media::Clip::Notification notification) {
|
||||||
|
using namespace Media::Clip;
|
||||||
|
switch (notification) {
|
||||||
|
case Notification::Reinit: {
|
||||||
|
if (!row->webm) {
|
||||||
|
return;
|
||||||
|
} else if (row->webm->state() == State::Error) {
|
||||||
|
row->webm.setBad();
|
||||||
|
} else if (row->webm->ready() && !row->webm->started()) {
|
||||||
|
row->webm->start({
|
||||||
|
.frame = { row->pixw, row->pixh },
|
||||||
|
.keepAlpha = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case Notification::Repaint: break;
|
||||||
|
}
|
||||||
|
updateRowThumbnail(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersBox::Inner::validateAnimation(not_null<Row*> row) {
|
void StickersBox::Inner::validateAnimation(not_null<Row*> row) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue