From 2632ec45bd7530f914d30d0af3e5d9d431dd18ca Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 11 Feb 2022 02:58:54 +0300 Subject: [PATCH] Added support to skip parts of gifs drawing. --- .../history/view/media/history_view_gif.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 707a7a35c..a43fb709c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -381,7 +381,9 @@ void Gif::draw(Painter &p, const PaintContext &context) const { | ((isRoundedInBubbleBottom() && _caption.isEmpty()) ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None)); - if (streamed) { + const auto skipDrawingContent = context.skipDrawingParts + == PaintContext::SkipDrawingParts::Content; + if (streamed && !skipDrawingContent) { auto paused = autoPaused; if (isRound) { if (activeRoundStreamed()) { @@ -455,7 +457,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { p.setOpacity(1.); } } - } else { + } else if (!skipDrawingContent) { ensureDataMediaCreated(); const auto size = QSize(_thumbw, _thumbh); const auto args = Images::PrepareArgs{ @@ -591,9 +593,12 @@ void Gif::draw(Painter &p, const PaintContext &context) const { sti->historyVideoMessageMute.paintInCenter(p, muteRect); } - if (!unwrapped) { + const auto skipDrawingSurrounding = context.skipDrawingParts + == PaintContext::SkipDrawingParts::Surrounding; + + if (!unwrapped && !skipDrawingSurrounding) { drawCornerStatus(p, context, QPoint()); - } else { + } else if (!skipDrawingSurrounding) { if (isRound) { const auto mediaUnread = item->hasUnreadMediaFlag(); auto statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x(); @@ -658,7 +663,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { if (!unwrapped && !_caption.isEmpty()) { p.setPen(stm->historyTextFg); _caption.draw(p, st::msgPadding.left(), painty + painth + st::mediaCaptionSkip, captionw, style::al_left, 0, -1, context.selection); - } else if (!inWebPage) { + } else if (!inWebPage && !skipDrawingSurrounding) { auto fullRight = paintx + usex + usew; auto fullBottom = painty + painth; auto maxRight = _parent->width() - st::msgMargin.left();