Optimize many animated emoji repaint requests.

This commit is contained in:
John Preston 2022-06-28 17:46:31 +04:00
parent 6db3a0ec98
commit c796dd142b
4 changed files with 11 additions and 2 deletions

View file

@ -375,6 +375,13 @@ void HistoryItem::invalidateChatListEntry() {
history()->lastItemDialogsView.itemInvalidated(this);
}
void HistoryItem::customEmojiRepaint() {
if (!_textRepaintScheduled) {
_textRepaintScheduled = true;
history()->owner().requestItemRepaint(this);
}
}
void HistoryItem::finishEditionToEmpty() {
finishEdition(-1);
_history->itemVanished(this);

View file

@ -463,6 +463,7 @@ protected:
MessageFlags _flags = 0;
void invalidateChatListEntry();
void customEmojiRepaint();
void setGroupId(MessageGroupId groupId);
@ -473,6 +474,7 @@ protected:
Ui::Text::String _text = { st::msgMinWidth };
int _textWidth = -1;
int _textHeight = 0;
bool _textRepaintScheduled = false;
struct SavedMediaData {
TextWithEntities text;

View file

@ -1498,8 +1498,7 @@ void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
clearIsolatedEmoji();
const auto context = Core::MarkedTextContext{
.session = &history()->session(),
.customEmojiRepaint = [=] {
history()->owner().requestItemRepaint(this); },
.customEmojiRepaint = [=] { customEmojiRepaint(); },
};
_text.setMarkedText(
st::messageTextStyle,

View file

@ -1258,6 +1258,7 @@ void Message::paintText(
0,
-1,
context.selection);
item->_textRepaintScheduled = false;
if (!_heavyCustomEmoji && custom) {
_heavyCustomEmoji = true;
history()->owner().registerHeavyViewPart(const_cast<Message*>(this));