From 9f96237b8595e5fe3362c1c010c154a24f67ef5a Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 18 Dec 2019 22:00:19 +0300 Subject: [PATCH] Remove unnecessary repaints in an inactive window. --- .../history/view/media/history_view_gif.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index e6a76ba05d..c081f03f16 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -252,10 +252,8 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms const auto autoPaused = App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any); const auto cornerDownload = downloadInCorner(); const auto canBePlayed = _data->canBePlayed(); - const auto activeRoundPlaying = activeRoundStreamed(); - const auto activeOwnPlaying = activeOwnStreamed(); const auto autoplay = autoplayEnabled() && canBePlayed; - const auto streamingMode = _streamed || activeRoundPlaying || autoplay; + const auto activeRoundPlaying = activeRoundStreamed(); const auto startPlayAsync = autoplay && !_streamed && !activeRoundPlaying; @@ -268,6 +266,8 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms && !_streamed->instance.failed()) { startStreamedPlayer(); } + const auto streamingMode = _streamed || activeRoundPlaying || autoplay; + const auto activeOwnPlaying = activeOwnStreamed(); auto paintx = 0, painty = 0, paintw = width(), painth = height(); bool bubble = _parent->hasBubble(); @@ -1246,6 +1246,10 @@ void Gif::repaintStreamedContent() { if (own && !own->frozenFrame.isNull()) { return; } + if (App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any) + && !activeRoundStreamed()) { + return; + } history()->owner().requestViewRepaint(_parent); }