From 693d886d81300845688b0b409e38239f4227b168 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 19 May 2022 17:57:39 +0400 Subject: [PATCH] Disable sync between sticker and effect. --- .../SourceFiles/boxes/sticker_preview_box.cpp | 8 +- .../history/view/history_view_element.cpp | 24 +++--- .../history/view/history_view_element.h | 6 +- .../view/history_view_emoji_interactions.cpp | 48 ++++++------ .../history/view/media/history_view_media.h | 24 +++--- .../media/history_view_media_unwrapped.cpp | 22 +++--- .../view/media/history_view_media_unwrapped.h | 22 +++--- .../view/media/history_view_sticker.cpp | 78 +++++++++---------- .../history/view/media/history_view_sticker.h | 10 +-- .../window/window_media_preview.cpp | 8 +- 10 files changed, 125 insertions(+), 125 deletions(-) diff --git a/Telegram/SourceFiles/boxes/sticker_preview_box.cpp b/Telegram/SourceFiles/boxes/sticker_preview_box.cpp index 052da279c..0f6be3091 100644 --- a/Telegram/SourceFiles/boxes/sticker_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_preview_box.cpp @@ -119,12 +119,12 @@ void PreloadSticker(const std::shared_ptr &media) { state->lottie->frame()); p.drawImage(raw->rect(), state->effect->frame()); - if (!frame.image.isNull() - && ((frame.index % effectsCount) <= effect.index)) { + if (!frame.image.isNull()/* + && ((frame.index % effectsCount) <= effect.index)*/) { state->lottie->markFrameShown(); } - if (!effect.image.isNull() - && ((effect.index % framesCount) <= frame.index)) { + if (!effect.image.isNull()/* + && ((effect.index % framesCount) <= frame.index)*/) { state->effect->markFrameShown(); } }, lifetime); diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 9a0b37ecb..e409f1407 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -412,18 +412,18 @@ void Element::setY(int y) { void Element::refreshDataIdHook() { } -void Element::externalLottieProgressing(bool external) const { - if (const auto media = _media.get()) { - media->externalLottieProgressing(external); - } -} - -bool Element::externalLottieTill(ExternalLottieInfo info) const { - if (const auto media = _media.get()) { - return media->externalLottieTill(info); - } - return true; -} +//void Element::externalLottieProgressing(bool external) const { +// if (const auto media = _media.get()) { +// media->externalLottieProgressing(external); +// } +//} +// +//bool Element::externalLottieTill(ExternalLottieInfo info) const { +// if (const auto media = _media.get()) { +// return media->externalLottieTill(info); +// } +// return true; +//} void Element::repaint() const { history()->owner().requestViewRepaint(this); diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index fd6e4e404..46130dae3 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -44,7 +44,7 @@ enum class InfoDisplayType : char; struct StateRequest; struct TextState; class Media; -struct ExternalLottieInfo; +//struct ExternalLottieInfo; using PaintContext = Ui::ChatPaintContext; @@ -272,8 +272,8 @@ public: Context context() const; void refreshDataId(); - void externalLottieProgressing(bool external) const; - bool externalLottieTill(ExternalLottieInfo info) const; + //void externalLottieProgressing(bool external) const; + //bool externalLottieTill(ExternalLottieInfo info) const; QDateTime dateTime() const; diff --git a/Telegram/SourceFiles/history/view/history_view_emoji_interactions.cpp b/Telegram/SourceFiles/history/view/history_view_emoji_interactions.cpp index 4f2f8c9ab..afd67ae76 100644 --- a/Telegram/SourceFiles/history/view/history_view_emoji_interactions.cpp +++ b/Telegram/SourceFiles/history/view/history_view_emoji_interactions.cpp @@ -65,11 +65,11 @@ EmojiInteractions::EmojiInteractions( } EmojiInteractions::~EmojiInteractions() { - for (const auto &play : _plays) { - if (play.premium) { - play.view->externalLottieProgressing(false); - } - } + //for (const auto &play : _plays) { + // if (play.premium) { + // play.view->externalLottieProgressing(false); + // } + //} } void EmojiInteractions::play( @@ -103,13 +103,13 @@ void EmojiInteractions::playPremiumEffect( if (replacing) { const auto i = ranges::find(_plays, replacing, &Play::view); if (i != end(_plays)) { - if (i->premium) { - replacing->externalLottieProgressing(false); - } + //if (i->premium) { + // replacing->externalLottieProgressing(false); + //} i->view = view; - if (i->premium) { - view->externalLottieProgressing(true); - } + //if (i->premium) { + // view->externalLottieProgressing(true); + //} return; } } @@ -133,8 +133,8 @@ void EmojiInteractions::cancelPremiumEffect(not_null view) { _plays.erase(ranges::remove_if(_plays, [&](const Play &play) { if (play.view != view) { return false; - } else if (play.premium) { - play.view->externalLottieProgressing(false); + //} else if (play.premium) { + // play.view->externalLottieProgressing(false); } return true; }), end(_plays)); @@ -192,9 +192,9 @@ void EmojiInteractions::play( } }); }, lottie->lifetime()); - if (premium) { - view->externalLottieProgressing(true); - } + //if (premium) { + // view->externalLottieProgressing(true); + //} _plays.push_back({ .view = view, .lottie = std::move(lottie), @@ -328,19 +328,19 @@ void EmojiInteractions::paint(QPainter &p) { p.drawImage( QRect(rect.topLeft(), frame.image.size() / factor), frame.image); - const auto info = HistoryView::ExternalLottieInfo{ - .frame = frame.index, - .count = play.framesCount, - }; - if (!play.premium || play.view->externalLottieTill(info)) { + //const auto info = HistoryView::ExternalLottieInfo{ + // .frame = frame.index, + // .count = play.framesCount, + //}; + //if (!play.premium || play.view->externalLottieTill(info)) { play.lottie->markFrameShown(); - } + //} } _plays.erase(ranges::remove_if(_plays, [](const Play &play) { if (!play.finished) { return false; - } else if (play.premium) { - play.view->externalLottieProgressing(false); + //} else if (play.premium) { + // play.view->externalLottieProgressing(false); } return true; }), end(_plays)); diff --git a/Telegram/SourceFiles/history/view/media/history_view_media.h b/Telegram/SourceFiles/history/view/media/history_view_media.h index 51c9f3944..ef97df565 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media.h +++ b/Telegram/SourceFiles/history/view/media/history_view_media.h @@ -69,10 +69,10 @@ enum class MediaInBubbleState { TimeId duration, const QString &base); -struct ExternalLottieInfo { - int frame = -1; - int count = -1; -}; +//struct ExternalLottieInfo { +// int frame = -1; +// int count = -1; +//}; class Media : public Object { public: @@ -178,14 +178,14 @@ public: virtual void checkAnimation() { } - virtual void externalLottieProgressing(bool external) { - } - virtual bool externalLottieTill(ExternalLottieInfo info) { - return true; - } - virtual ExternalLottieInfo externalLottieInfo() const { - return {}; - } + //virtual void externalLottieProgressing(bool external) { + //} + //virtual bool externalLottieTill(ExternalLottieInfo info) { + // return true; + //} + //virtual ExternalLottieInfo externalLottieInfo() const { + // return {}; + //} [[nodiscard]] virtual QSize sizeForGroupingOptimal(int maxWidth) const { Unexpected("Grouping method call."); diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp index f15fa9ab5..d57ff81b3 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp @@ -460,17 +460,17 @@ std::unique_ptr UnwrappedMedia::stickerTakeLottie( return _content->stickerTakeLottie(data, replacements); } -void UnwrappedMedia::externalLottieProgressing(bool external) { - _content->externalLottieProgressing(external); -} - -bool UnwrappedMedia::externalLottieTill(ExternalLottieInfo info) { - return _content->externalLottieTill(info); -} - -ExternalLottieInfo UnwrappedMedia::externalLottieInfo() const { - return _content->externalLottieInfo(); -} +//void UnwrappedMedia::externalLottieProgressing(bool external) { +// _content->externalLottieProgressing(external); +//} +// +//bool UnwrappedMedia::externalLottieTill(ExternalLottieInfo info) { +// return _content->externalLottieTill(info); +//} +// +//ExternalLottieInfo UnwrappedMedia::externalLottieInfo() const { +// return _content->externalLottieInfo(); +//} int UnwrappedMedia::calculateFullRight(const QRect &inner) const { const auto rightAligned = _parent->hasOutLayout() diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h index 0dff76b92..85be053d9 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h @@ -41,14 +41,14 @@ public: not_null data, const Lottie::ColorReplacements *replacements); - virtual void externalLottieProgressing(bool external) { - } - virtual bool externalLottieTill(ExternalLottieInfo info) { - return true; - } - virtual ExternalLottieInfo externalLottieInfo() const { - return {}; - } + //virtual void externalLottieProgressing(bool external) { + //} + //virtual bool externalLottieTill(ExternalLottieInfo info) { + // return true; + //} + //virtual ExternalLottieInfo externalLottieInfo() const { + // return {}; + //} virtual bool hasHeavyPart() const { return false; @@ -102,9 +102,9 @@ public: not_null data, const Lottie::ColorReplacements *replacements) override; - void externalLottieProgressing(bool external) override; - bool externalLottieTill(ExternalLottieInfo info) override; - ExternalLottieInfo externalLottieInfo() const override; + //void externalLottieProgressing(bool external) override; + //bool externalLottieTill(ExternalLottieInfo info) override; + //ExternalLottieInfo externalLottieInfo() const override; bool hasHeavyPart() const override { return _content->hasHeavyPart(); diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp index cf110ec10..ea96b68c4 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp @@ -75,7 +75,7 @@ Sticker::Sticker( if (const auto media = replacing ? replacing->media() : nullptr) { _lottie = media->stickerTakeLottie(_data, _replacements); if (_lottie) { - _externalInfo = media->externalLottieInfo(); + //_externalInfo = media->externalLottieInfo(); if (_data->isPremiumSticker() && !_premiumEffectPlayed) { _premiumEffectPlayed = true; @@ -217,9 +217,9 @@ void Sticker::paintLottie( const auto count = _lottie->information().framesCount; _frameIndex = frame.index; _framesCount = count; - const auto paused = (_externalInfo.frame >= 0) + const auto paused = /*(_externalInfo.frame >= 0) ? (_frameIndex % _externalInfo.count >= _externalInfo.frame) - : _parent->delegate()->elementIsGifPaused(); + : */_parent->delegate()->elementIsGifPaused(); _nextLastDiceFrame = !paused && (_diceIndex > 0) && (_frameIndex + 2 == count); @@ -230,8 +230,8 @@ void Sticker::paintLottie( : (isEmojiSticker() || !Core::App().settings().loopAnimatedStickers()); const auto lastDiceFrame = (_diceIndex > 0) && atTheEnd(); - const auto switchToNext = (_externalInfo.frame >= 0) - || !playOnce + const auto switchToNext = /*(_externalInfo.frame >= 0) + || */!playOnce || (!lastDiceFrame && (_frameIndex != 0 || !_lottieOncePlayed)); if (!paused && switchToNext @@ -426,7 +426,7 @@ void Sticker::lottieCreated() { ) | rpl::start_with_next([=](Lottie::Update update) { v::match(update.data, [&](const Lottie::Information &information) { _parent->history()->owner().requestViewResize(_parent); - markFramesTillExternal(); + //markFramesTillExternal(); }, [&](const Lottie::DisplayFrameRequest &request) { _parent->history()->owner().requestViewRepaint(_parent); }); @@ -465,38 +465,38 @@ std::unique_ptr Sticker::stickerTakeLottie( : nullptr; } -void Sticker::externalLottieProgressing(bool external) { - _externalInfo = !external - ? ExternalLottieInfo{} - : (_externalInfo.frame > 0) - ? _externalInfo - : ExternalLottieInfo{ 0, 2 }; -} - -bool Sticker::externalLottieTill(ExternalLottieInfo info) { - if (_externalInfo.frame >= 0) { - _externalInfo = info; - } - return markFramesTillExternal(); -} - -ExternalLottieInfo Sticker::externalLottieInfo() const { - return _externalInfo; -} - -bool Sticker::markFramesTillExternal() { - if (_externalInfo.frame < 0 || !_lottie) { - return true; - } else if (!_lottie->ready()) { - return false; - } - const auto till = _externalInfo.frame % _lottie->framesCount(); - while (_lottie->frameIndex() < till) { - if (!_lottie->markFrameShown()) { - return false; - } - } - return true; -} +//void Sticker::externalLottieProgressing(bool external) { +// _externalInfo = !external +// ? ExternalLottieInfo{} +// : (_externalInfo.frame > 0) +// ? _externalInfo +// : ExternalLottieInfo{ 0, 2 }; +//} +// +//bool Sticker::externalLottieTill(ExternalLottieInfo info) { +// if (_externalInfo.frame >= 0) { +// _externalInfo = info; +// } +// return markFramesTillExternal(); +//} +// +//ExternalLottieInfo Sticker::externalLottieInfo() const { +// return _externalInfo; +//} +// +//bool Sticker::markFramesTillExternal() { +// if (_externalInfo.frame < 0 || !_lottie) { +// return true; +// } else if (!_lottie->ready()) { +// return false; +// } +// const auto till = _externalInfo.frame % _lottie->framesCount(); +// while (_lottie->frameIndex() < till) { +// if (!_lottie->markFrameShown()) { +// return false; +// } +// } +// return true; +//} } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.h b/Telegram/SourceFiles/history/view/media/history_view_sticker.h index 408e6c049..04e5e1251 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.h +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.h @@ -51,9 +51,9 @@ public: not_null data, const Lottie::ColorReplacements *replacements) override; - void externalLottieProgressing(bool external) override; - bool externalLottieTill(ExternalLottieInfo info) override; - ExternalLottieInfo externalLottieInfo() const override; + //void externalLottieProgressing(bool external) override; + //bool externalLottieTill(ExternalLottieInfo info) override; + //ExternalLottieInfo externalLottieInfo() const override; bool hasHeavyPart() const override; void unloadHeavyPart() override; @@ -96,7 +96,7 @@ private: void lottieCreated(); void unloadLottie(); void emojiStickerClicked(); - bool markFramesTillExternal(); + //bool markFramesTillExternal(); const not_null _parent; const not_null _data; @@ -107,7 +107,7 @@ private: QSize _size; QImage _lastDiceFrame; QString _diceEmoji; - ExternalLottieInfo _externalInfo; + //ExternalLottieInfo _externalInfo; int _diceIndex = -1; mutable int _frameIndex = -1; mutable int _framesCount = -1; diff --git a/Telegram/SourceFiles/window/window_media_preview.cpp b/Telegram/SourceFiles/window/window_media_preview.cpp index 00c047367..36d3a9339 100644 --- a/Telegram/SourceFiles/window/window_media_preview.cpp +++ b/Telegram/SourceFiles/window/window_media_preview.cpp @@ -116,12 +116,12 @@ void MediaPreviewWidget::paintEvent(QPaintEvent *e) { emojiLeft += _emojiSize + st::stickerEmojiSkip; } } - if (!frame.image.isNull() - && (!_effect || ((frame.index % effectsCount) <= effect.index))) { + if (!frame.image.isNull()/* + && (!_effect || ((frame.index % effectsCount) <= effect.index))*/) { _lottie->markFrameShown(); } - if (!effect.image.isNull() - && ((effect.index % framesCount) <= frame.index)) { + if (!effect.image.isNull()/* + && ((effect.index % framesCount) <= frame.index)*/) { _effect->markFrameShown(); } }