Show webm stickers in media preview.

This commit is contained in:
John Preston 2022-01-25 10:16:42 +03:00
parent fa61cf3c85
commit 545392f90f
2 changed files with 7 additions and 3 deletions

View file

@ -260,7 +260,9 @@ void MediaPreviewWidget::setupLottie() {
QPixmap MediaPreviewWidget::currentImage() const {
const auto blur = Images::PrepareArgs{ .options = Images::Option::Blur };
if (_document) {
if (const auto sticker = _document->sticker()) {
const auto sticker = _document->sticker();
const auto webm = sticker && sticker->isWebm();
if (sticker && !webm) {
if (_cacheStatus != CacheLoaded) {
if (sticker->isLottie() && !_lottie && _documentMedia->loaded()) {
const_cast<MediaPreviewWidget*>(this)->setupLottie();
@ -288,7 +290,7 @@ QPixmap MediaPreviewWidget::currentImage() const {
const auto paused = _controller->isGifPausedAtLeastFor(
Window::GifPauseReason::MediaPreview);
return gif->current(
{ .frame = currentDimensions() },
{ .frame = currentDimensions(), .keepAlpha = webm },
paused ? 0 : crl::now());
}
if (_cacheStatus != CacheThumbLoaded
@ -337,7 +339,7 @@ QPixmap MediaPreviewWidget::currentImage() const {
void MediaPreviewWidget::startGifAnimation(
const Media::Clip::ReaderPointer &gif) {
gif->start({ .frame = currentDimensions() });
gif->start({ .frame = currentDimensions(), .keepAlpha = _gifWithAlpha });
}
void MediaPreviewWidget::validateGifAnimation() {
@ -370,6 +372,7 @@ void MediaPreviewWidget::validateGifAnimation() {
const auto callback = [=](Media::Clip::Notification notification) {
clipCallback(notification);
};
_gifWithAlpha = (_documentMedia->owner()->sticker() != nullptr);
if (contentLoaded) {
_gif = Media::Clip::MakeReader(
_documentMedia->owner()->location(),

View file

@ -66,6 +66,7 @@ private:
std::shared_ptr<Data::PhotoMedia> _photoMedia;
std::shared_ptr<Data::DocumentMedia> _documentMedia;
Media::Clip::ReaderPointer _gif, _gifThumbnail;
bool _gifWithAlpha = false;
crl::time _gifLastPosition = 0;
std::unique_ptr<Lottie::SinglePlayer> _lottie;