Skip to content

Commit b8a17d4

Browse files
committed
Optimized repaint clip for ripple animation from history view reply.
1 parent 5d95234 commit b8a17d4

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

Telegram/SourceFiles/history/view/history_view_element.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,8 +1247,8 @@ void Element::prepareCustomEmojiPaint(
12471247
}
12481248
}
12491249

1250-
void Element::repaint() const {
1251-
history()->owner().requestViewRepaint(this);
1250+
void Element::repaint(QRect r) const {
1251+
history()->owner().requestViewRepaint(this, r);
12521252
}
12531253

12541254
void Element::paintHighlight(

Telegram/SourceFiles/history/view/history_view_element.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ class Element
641641
const Reactions::InlineList &reactions) const;
642642
void clearCustomEmojiRepaint() const;
643643
void hideSpoilers();
644-
void repaint() const;
644+
void repaint(QRect r = QRect()) const;
645645

646646
[[nodiscard]] ClickHandlerPtr fromPhotoLink() const {
647647
return fromLink();

Telegram/SourceFiles/history/view/history_view_reply.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,11 @@ void Reply::paint(
819819
}
820820

821821
if (_ripple.animation) {
822+
_ripple.lastPaintedPoint = { x, y };
822823
_ripple.animation->paint(p, x, y, w, &rippleColor);
823824
if (_ripple.animation->empty()) {
824825
_ripple.animation.reset();
826+
_ripple.lastPaintedPoint = {};
825827
}
826828
}
827829

@@ -983,7 +985,7 @@ void Reply::createRippleAnimation(
983985
Ui::RippleAnimation::RoundRectMask(
984986
size,
985987
st::messageQuoteStyle.radius),
986-
[=] { view->repaint(); });
988+
[=] { view->repaint(QRect(_ripple.lastPaintedPoint, size)); });
987989
}
988990

989991
void Reply::saveRipplePoint(QPoint point) const {

Telegram/SourceFiles/history/view/history_view_reply.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ class Reply final : public RuntimeComponent<Reply, Element> {
139139
mutable PeerData *_externalSender = nullptr;
140140
mutable PeerData *_colorPeer = nullptr;
141141
mutable struct {
142-
mutable std::unique_ptr<Ui::RippleAnimation> animation;
142+
std::unique_ptr<Ui::RippleAnimation> animation;
143143
QPoint lastPoint;
144+
QPoint lastPaintedPoint;
144145
} _ripple;
145146
mutable Ui::Text::String _name;
146147
mutable Ui::Text::String _text;

0 commit comments

Comments
 (0)