Compare commits

...

3 commits

Author SHA1 Message Date
pajlada 9b2bf17a0c
Merge branch 'master' into dependabot/submodules/lib/settings-ad12188 2024-01-24 18:13:42 +01:00
nerix 7604d7ea4a
perf: add signal to invalidate buffers without doing layout (#5123) 2024-01-24 18:13:31 +01:00
Rasmus Karlsson 7b2ba5ed97 bump again 2024-01-24 17:45:36 +01:00
8 changed files with 52 additions and 10 deletions

View file

@ -132,6 +132,7 @@
- Dev: Fix `NotebookTab` emitting updates for every message. (#5068) - Dev: Fix `NotebookTab` emitting updates for every message. (#5068)
- Dev: Added benchmark for parsing and building recent messages. (#5071) - Dev: Added benchmark for parsing and building recent messages. (#5071)
- Dev: Boost is depended on as a header-only library when using conan. (#5107) - Dev: Boost is depended on as a header-only library when using conan. (#5107)
- Dev: Added signal to invalidate paint buffers of channel views without forcing a relayout. (#5123)
## 2.4.6 ## 2.4.6

@ -1 +1 @@
Subproject commit ad12188bd3e94ffd3ee95ebb97b67b915857c471 Subproject commit 53be0788a000960dbbc34350315e20ad1e194970

View file

@ -74,7 +74,8 @@ int MessageLayout::getWidth() const
// Layout // Layout
// return true if redraw is required // return true if redraw is required
bool MessageLayout::layout(int width, float scale, MessageElementFlags flags) bool MessageLayout::layout(int width, float scale, MessageElementFlags flags,
bool shouldInvalidateBuffer)
{ {
// BenchmarkGuard benchmark("MessageLayout::layout()"); // BenchmarkGuard benchmark("MessageLayout::layout()");
@ -108,6 +109,11 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
if (!layoutRequired) if (!layoutRequired)
{ {
if (shouldInvalidateBuffer)
{
this->invalidateBuffer();
return true;
}
return false; return false;
} }

View file

@ -56,7 +56,8 @@ public:
MessageLayoutFlags flags; MessageLayoutFlags flags;
bool layout(int width, float scale_, MessageElementFlags flags); bool layout(int width, float scale_, MessageElementFlags flags,
bool shouldInvalidateBuffer);
// Painting // Painting
MessagePaintResult paint(const MessagePaintContext &ctx); MessagePaintResult paint(const MessagePaintContext &ctx);

View file

@ -211,6 +211,11 @@ void WindowManager::forceLayoutChannelViews()
this->layoutChannelViews(nullptr); this->layoutChannelViews(nullptr);
} }
void WindowManager::invalidateChannelViewBuffers(Channel *channel)
{
this->invalidateBuffersRequested.invoke(channel);
}
void WindowManager::repaintVisibleChatWidgets(Channel *channel) void WindowManager::repaintVisibleChatWidgets(Channel *channel)
{ {
this->layoutRequested.invoke(channel); this->layoutRequested.invoke(channel);
@ -407,10 +412,10 @@ void WindowManager::initialize(Settings &settings, const Paths &paths)
this->forceLayoutChannelViews(); this->forceLayoutChannelViews();
}); });
settings.alternateMessages.connect([this](auto, auto) { settings.alternateMessages.connect([this](auto, auto) {
this->forceLayoutChannelViews(); this->invalidateChannelViewBuffers();
}); });
settings.separateMessages.connect([this](auto, auto) { settings.separateMessages.connect([this](auto, auto) {
this->forceLayoutChannelViews(); this->invalidateChannelViewBuffers();
}); });
settings.collpseMessagesMinLines.connect([this](auto, auto) { settings.collpseMessagesMinLines.connect([this](auto, auto) {
this->forceLayoutChannelViews(); this->forceLayoutChannelViews();

View file

@ -66,6 +66,10 @@ public:
// This is called, for example, when the emote scale or timestamp format has // This is called, for example, when the emote scale or timestamp format has
// changed // changed
void forceLayoutChannelViews(); void forceLayoutChannelViews();
// Tell a channel (or all channels if channel is nullptr) to invalidate all paint buffers
void invalidateChannelViewBuffers(Channel *channel = nullptr);
void repaintVisibleChatWidgets(Channel *channel = nullptr); void repaintVisibleChatWidgets(Channel *channel = nullptr);
void repaintGifEmotes(); void repaintGifEmotes();
@ -124,6 +128,9 @@ public:
// This signal fires whenever views rendering a channel, or all views if the // This signal fires whenever views rendering a channel, or all views if the
// channel is a nullptr, need to redo their layout // channel is a nullptr, need to redo their layout
pajlada::Signals::Signal<Channel *> layoutRequested; pajlada::Signals::Signal<Channel *> layoutRequested;
// This signal fires whenever views rendering a channel, or all views if the
// channel is a nullptr, need to invalidate their paint buffers
pajlada::Signals::Signal<Channel *> invalidateBuffersRequested;
pajlada::Signals::NoArgSignal wordFlagsChanged; pajlada::Signals::NoArgSignal wordFlagsChanged;

View file

@ -425,6 +425,16 @@ void ChannelView::initializeSignals()
} }
}); });
this->signalHolder_.managedConnect(
getIApp()->getWindows()->invalidateBuffersRequested,
[this](Channel *channel) {
if (this->isVisible() &&
(channel == nullptr || this->channel_.get() == channel))
{
this->invalidateBuffers();
}
});
this->signalHolder_.managedConnect(getIApp()->getFonts()->fontChanged, this->signalHolder_.managedConnect(getIApp()->getFonts()->fontChanged,
[this] { [this] {
this->queueLayout(); this->queueLayout();
@ -590,6 +600,12 @@ void ChannelView::queueUpdate(const QRect &area)
this->update(area); this->update(area);
} }
void ChannelView::invalidateBuffers()
{
this->bufferInvalidationQueued_ = true;
this->queueLayout();
}
void ChannelView::queueLayout() void ChannelView::queueLayout()
{ {
if (this->isVisible()) if (this->isVisible())
@ -651,12 +667,13 @@ void ChannelView::layoutVisibleMessages(
{ {
const auto &message = messages[i]; const auto &message = messages[i];
redrawRequired |= redrawRequired |= message->layout(layoutWidth, this->scale(), flags,
message->layout(layoutWidth, this->scale(), flags); this->bufferInvalidationQueued_);
y += message->getHeight(); y += message->getHeight();
} }
} }
this->bufferInvalidationQueued_ = false;
if (redrawRequired) if (redrawRequired)
{ {
@ -685,7 +702,7 @@ void ChannelView::updateScrollbar(
{ {
auto *message = messages[i].get(); auto *message = messages[i].get();
message->layout(layoutWidth, this->scale(), flags); message->layout(layoutWidth, this->scale(), flags, false);
h -= message->getHeight(); h -= message->getHeight();
@ -1656,7 +1673,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
else else
{ {
snapshot[i - 1]->layout(this->getLayoutWidth(), snapshot[i - 1]->layout(this->getLayoutWidth(),
this->scale(), this->getFlags()); this->scale(), this->getFlags(),
false);
scrollFactor = 1; scrollFactor = 1;
currentScrollLeft = snapshot[i - 1]->getHeight(); currentScrollLeft = snapshot[i - 1]->getHeight();
} }
@ -1690,7 +1708,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
else else
{ {
snapshot[i + 1]->layout(this->getLayoutWidth(), snapshot[i + 1]->layout(this->getLayoutWidth(),
this->scale(), this->getFlags()); this->scale(), this->getFlags(),
false);
scrollFactor = 1; scrollFactor = 1;
currentScrollLeft = snapshot[i + 1]->getHeight(); currentScrollLeft = snapshot[i + 1]->getHeight();

View file

@ -148,7 +148,9 @@ public:
bool hasSourceChannel() const; bool hasSourceChannel() const;
LimitedQueueSnapshot<MessageLayoutPtr> &getMessagesSnapshot(); LimitedQueueSnapshot<MessageLayoutPtr> &getMessagesSnapshot();
void queueLayout(); void queueLayout();
void invalidateBuffers();
void clearMessages(); void clearMessages();
@ -270,6 +272,7 @@ private:
bool canReplyToMessages() const; bool canReplyToMessages() const;
bool layoutQueued_ = false; bool layoutQueued_ = false;
bool bufferInvalidationQueued_ = false;
bool lastMessageHasAlternateBackground_ = false; bool lastMessageHasAlternateBackground_ = false;
bool lastMessageHasAlternateBackgroundReverse_ = true; bool lastMessageHasAlternateBackgroundReverse_ = true;