[libkwineffects] Push render targets more efficiently in GLRenderTarget::pushRenderTargets

Summary:
If s_renderTargets is not empty, GLRenderTarget::pushRenderTargets starts
to do pretty heavy things: it deletes head of the targets param in a while loop.

There is no need to do that. Because QStack inherits QVector, we can use
append method to push new render targets in a more efficient way.

Test Plan: Background behind Konsole is still blurred.

Reviewers: #kwin, mart

Reviewed By: #kwin, mart

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13823
This commit is contained in:
Vlad Zagorodniy 2018-07-01 13:28:05 +03:00
parent 7ee83dc5e4
commit 709b7c2c58

View file

@ -1099,23 +1099,9 @@ void GLRenderTarget::pushRenderTargets(QStack <GLRenderTarget*> targets)
{
if (s_renderTargets.isEmpty()) {
glGetIntegerv(GL_VIEWPORT, s_virtualScreenViewport);
s_renderTargets = targets;
} else {
s_renderTargets.reserve(s_renderTargets.size() + targets.size());
/*
* Merging the two stacks.
* We cheat a little bit by using the inherited QVector functions.
* This is to not have the targets stack in reverse order without
* having to use a helper QStack first to reverse the order.
*/
while (!targets.isEmpty()) {
s_renderTargets.push(targets.first());
targets.removeFirst();
}
}
s_renderTargets.top()->enable();
targets.top()->enable();
s_renderTargets.append(targets);
}
GLRenderTarget* GLRenderTarget::popRenderTarget()