diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_generic.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_generic.cpp index 077a8ebd9..a3db7897f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_generic.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_generic.cpp @@ -441,7 +441,7 @@ void StickerInBubblePart::ensureCreated(Element *replacing) const { _skipTop = data.skipTop; _sticker.emplace(_parent, sticker, skipPremiumEffect, replacing); if (data.singleTimePlayback) { - _sticker->setDiceIndex(info->alt, 1); + _sticker->setPlayingOnce(true); } _sticker->initSize(data.size); _sticker->setCustomCachingTag(data.cacheTag); diff --git a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp index 0a9aea114..ba1c2ceeb 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp @@ -295,7 +295,7 @@ void PremiumGift::ensureStickerCreated() const { if (const auto sticker = document->sticker()) { const auto skipPremiumEffect = false; _sticker.emplace(_parent, document, skipPremiumEffect, _parent); - _sticker->setDiceIndex(sticker->alt, 1); + _sticker->setPlayingOnce(true); _sticker->initSize(st::msgServiceGiftBoxStickerSize); return; } @@ -308,7 +308,7 @@ void PremiumGift::ensureStickerCreated() const { if (const auto sticker = document->sticker()) { const auto skipPremiumEffect = false; _sticker.emplace(_parent, document, skipPremiumEffect, _parent); - _sticker->setDiceIndex(sticker->alt, 1); + _sticker->setPlayingOnce(true); _sticker->initSize(st::msgServiceGiftBoxStickerSize); } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp index 88e59cf95..a63541e0f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp @@ -249,7 +249,9 @@ DocumentData *Sticker::document() { } void Sticker::stickerClearLoopPlayed() { - _oncePlayed = false; + if (!_playingOnce) { + _oncePlayed = false; + } _premiumEffectSkipped = false; } @@ -304,7 +306,7 @@ void Sticker::paintAnimationFrame( _nextLastDiceFrame = !paused && (_diceIndex > 0) && (_frameIndex + 2 == count); - const auto playOnce = (_diceIndex > 0) + const auto playOnce = (_playingOnce || _diceIndex > 0) ? true : (_diceIndex == 0) ? false @@ -332,10 +334,10 @@ bool Sticker::paintPixmap( if (pixmap.isNull()) { return false; } - const auto position = QPoint( - r.x() + (r.width() - _size.width()) / 2, - r.y() + (r.height() - _size.height()) / 2); const auto size = pixmap.size() / pixmap.devicePixelRatio(); + const auto position = QPoint( + r.x() + (r.width() - size.width()) / 2, + r.y() + (r.height() - size.height()) / 2); const auto mirror = mirrorHorizontal(); if (mirror) { p.save(); @@ -386,6 +388,14 @@ void Sticker::paintPath( QPixmap Sticker::paintedPixmap(const PaintContext &context) const { auto helper = std::optional(); + const auto sticker = _data->sticker(); + const auto ratio = style::DevicePixelRatio(); + const auto adjust = [&](int side) { + return (((side * ratio) / 8) * 8) / ratio; + }; + const auto useSize = (sticker && sticker->type == StickerType::Tgs) + ? QSize(adjust(_size.width()), adjust(_size.height())) + : _size; const auto colored = (customEmojiPart() && _data->emojiUsesTextColor()) ? &helper.emplace(ComputeEmojiTextColor(context)).color() : context.selected() @@ -393,19 +403,19 @@ QPixmap Sticker::paintedPixmap(const PaintContext &context) const { : nullptr; const auto good = _dataMedia->goodThumbnail(); if (const auto image = _dataMedia->getStickerLarge()) { - return image->pix(_size, { .colored = colored }); + return image->pix(useSize, { .colored = colored }); // // Inline thumbnails can't have alpha channel. // //} else if (const auto blurred = _data->thumbnailInline()) { // return blurred->pix( - // _size, + // useSize, // { .colored = colored, .options = Images::Option::Blur }); } else if (good) { - return good->pix(_size, { .colored = colored }); + return good->pix(useSize, { .colored = colored }); } else if (const auto thumbnail = _dataMedia->thumbnail()) { return thumbnail->pix( - _size, + useSize, { .colored = colored, .options = Images::Option::Blur }); } return QPixmap(); @@ -511,6 +521,10 @@ void Sticker::setDiceIndex(const QString &emoji, int index) { _diceIndex = index; } +void Sticker::setPlayingOnce(bool once) { + _playingOnce = once; +} + void Sticker::setCustomCachingTag(ChatHelpers::StickerLottieSize tag) { _cachingTag = tag; } diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.h b/Telegram/SourceFiles/history/view/media/history_view_sticker.h index 91a69f7e2..d2709d153 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.h +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.h @@ -66,6 +66,7 @@ public: } void setDiceIndex(const QString &emoji, int index); + void setPlayingOnce(bool once); void setCustomCachingTag(ChatHelpers::StickerLottieSize tag); void setCustomEmojiPart(); void setEmojiSticker(); @@ -141,6 +142,7 @@ private: bool _customEmojiPart : 1 = false; bool _emojiSticker : 1 = false; bool _webpagePart : 1 = false; + bool _playingOnce : 1 = false; };