mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 17:51:41 -05:00
Optimize animated sticker preview.
This commit is contained in:
parent
0d6ee3929d
commit
21dfb310f3
2 changed files with 14 additions and 2 deletions
|
@ -864,6 +864,13 @@ MediaPreviewWidget::MediaPreviewWidget(
|
||||||
subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
|
subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect MediaPreviewWidget::updateArea() const {
|
||||||
|
const auto size = currentDimensions();
|
||||||
|
return QRect(
|
||||||
|
QPoint((width() - size.width()) / 2, (height() - size.height()) / 2),
|
||||||
|
size);
|
||||||
|
}
|
||||||
|
|
||||||
void MediaPreviewWidget::paintEvent(QPaintEvent *e) {
|
void MediaPreviewWidget::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
QRect r(e->rect());
|
QRect r(e->rect());
|
||||||
|
@ -1048,7 +1055,11 @@ void MediaPreviewWidget::setupLottie() {
|
||||||
|
|
||||||
_lottie->updates(
|
_lottie->updates(
|
||||||
) | rpl::start_with_next_error([=](Lottie::Update update) {
|
) | rpl::start_with_next_error([=](Lottie::Update update) {
|
||||||
this->update();
|
update.data.match([&](const Lottie::Information &) {
|
||||||
|
this->update();
|
||||||
|
}, [&](const Lottie::DisplayFrameRequest &) {
|
||||||
|
this->update(updateArea());
|
||||||
|
});
|
||||||
}, [=](Lottie::Error error) {
|
}, [=](Lottie::Error error) {
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1163,7 @@ void MediaPreviewWidget::clipCallback(Media::Clip::Notification notification) {
|
||||||
|
|
||||||
case NotificationRepaint: {
|
case NotificationRepaint: {
|
||||||
if (_gif && !_gif->currentDisplayed()) {
|
if (_gif && !_gif->currentDisplayed()) {
|
||||||
update();
|
updateArea();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,7 @@ private:
|
||||||
void startShow();
|
void startShow();
|
||||||
void fillEmojiString();
|
void fillEmojiString();
|
||||||
void resetGifAndCache();
|
void resetGifAndCache();
|
||||||
|
QRect updateArea() const;
|
||||||
|
|
||||||
not_null<Window::SessionController*> _controller;
|
not_null<Window::SessionController*> _controller;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue