Improve loop implementations in WindowQuadList
Prefer for() to foreach(), as the latter is deprecated. Prefer iterating QList using the iteration_expression for() loops, rather than doing it by index.master
parent
f5900a5fd0
commit
474060a456
|
@ -928,7 +928,8 @@ bool WindowQuad::smoothNeeded() const
|
||||||
WindowQuadList WindowQuadList::splitAtX(double x) const
|
WindowQuadList WindowQuadList::splitAtX(double x) const
|
||||||
{
|
{
|
||||||
WindowQuadList ret;
|
WindowQuadList ret;
|
||||||
foreach (const WindowQuad & quad, *this) {
|
ret.reserve(count());
|
||||||
|
for (const WindowQuad & quad : *this) {
|
||||||
#if !defined(QT_NO_DEBUG)
|
#if !defined(QT_NO_DEBUG)
|
||||||
if (quad.isTransformed())
|
if (quad.isTransformed())
|
||||||
qFatal("Splitting quads is allowed only in pre-paint calls!");
|
qFatal("Splitting quads is allowed only in pre-paint calls!");
|
||||||
|
@ -960,7 +961,8 @@ WindowQuadList WindowQuadList::splitAtX(double x) const
|
||||||
WindowQuadList WindowQuadList::splitAtY(double y) const
|
WindowQuadList WindowQuadList::splitAtY(double y) const
|
||||||
{
|
{
|
||||||
WindowQuadList ret;
|
WindowQuadList ret;
|
||||||
foreach (const WindowQuad & quad, *this) {
|
ret.reserve(count());
|
||||||
|
for (const WindowQuad & quad : *this) {
|
||||||
#if !defined(QT_NO_DEBUG)
|
#if !defined(QT_NO_DEBUG)
|
||||||
if (quad.isTransformed())
|
if (quad.isTransformed())
|
||||||
qFatal("Splitting quads is allowed only in pre-paint calls!");
|
qFatal("Splitting quads is allowed only in pre-paint calls!");
|
||||||
|
@ -1013,7 +1015,7 @@ WindowQuadList WindowQuadList::makeGrid(int maxQuadSize) const
|
||||||
|
|
||||||
WindowQuadList ret;
|
WindowQuadList ret;
|
||||||
|
|
||||||
foreach (const WindowQuad &quad, *this) {
|
for (const WindowQuad &quad : *this) {
|
||||||
const double quadLeft = quad.left();
|
const double quadLeft = quad.left();
|
||||||
const double quadRight = quad.right();
|
const double quadRight = quad.right();
|
||||||
const double quadTop = quad.top();
|
const double quadTop = quad.top();
|
||||||
|
@ -1057,7 +1059,7 @@ WindowQuadList WindowQuadList::makeRegularGrid(int xSubdivisions, int ySubdivisi
|
||||||
double top = first().top();
|
double top = first().top();
|
||||||
double bottom = first().bottom();
|
double bottom = first().bottom();
|
||||||
|
|
||||||
foreach (const WindowQuad &quad, *this) {
|
for (const WindowQuad &quad : *this) {
|
||||||
#if !defined(QT_NO_DEBUG)
|
#if !defined(QT_NO_DEBUG)
|
||||||
if (quad.isTransformed())
|
if (quad.isTransformed())
|
||||||
qFatal("Splitting quads is allowed only in pre-paint calls!");
|
qFatal("Splitting quads is allowed only in pre-paint calls!");
|
||||||
|
@ -1073,7 +1075,7 @@ WindowQuadList WindowQuadList::makeRegularGrid(int xSubdivisions, int ySubdivisi
|
||||||
|
|
||||||
WindowQuadList ret;
|
WindowQuadList ret;
|
||||||
|
|
||||||
foreach (const WindowQuad &quad, *this) {
|
for (const WindowQuad &quad : *this) {
|
||||||
const double quadLeft = quad.left();
|
const double quadLeft = quad.left();
|
||||||
const double quadRight = quad.right();
|
const double quadRight = quad.right();
|
||||||
const double quadTop = quad.top();
|
const double quadTop = quad.top();
|
||||||
|
@ -1130,8 +1132,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic
|
||||||
case GL_QUADS:
|
case GL_QUADS:
|
||||||
#if defined(__SSE2__)
|
#if defined(__SSE2__)
|
||||||
if (!(intptr_t(vertex) & 0xf)) {
|
if (!(intptr_t(vertex) & 0xf)) {
|
||||||
for (int i = 0; i < count(); i++) {
|
for (const WindowQuad &quad : *this) {
|
||||||
const WindowQuad &quad = at(i);
|
|
||||||
alignas(16) GLVertex2D v[4];
|
alignas(16) GLVertex2D v[4];
|
||||||
|
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
|
@ -1154,9 +1155,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic
|
||||||
} else
|
} else
|
||||||
#endif // __SSE2__
|
#endif // __SSE2__
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count(); i++) {
|
for (const WindowQuad &quad : *this) {
|
||||||
const WindowQuad &quad = at(i);
|
|
||||||
|
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
const WindowVertex &wv = quad[j];
|
const WindowVertex &wv = quad[j];
|
||||||
|
|
||||||
|
@ -1173,8 +1172,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic
|
||||||
case GL_TRIANGLES:
|
case GL_TRIANGLES:
|
||||||
#if defined(__SSE2__)
|
#if defined(__SSE2__)
|
||||||
if (!(intptr_t(vertex) & 0xf)) {
|
if (!(intptr_t(vertex) & 0xf)) {
|
||||||
for (int i = 0; i < count(); i++) {
|
for (const WindowQuad &quad : *this) {
|
||||||
const WindowQuad &quad = at(i);
|
|
||||||
alignas(16) GLVertex2D v[4];
|
alignas(16) GLVertex2D v[4];
|
||||||
|
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
|
@ -1208,8 +1206,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic
|
||||||
} else
|
} else
|
||||||
#endif // __SSE2__
|
#endif // __SSE2__
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count(); i++) {
|
for (const WindowQuad &quad : *this) {
|
||||||
const WindowQuad &quad = at(i);
|
|
||||||
GLVertex2D v[4]; // Four unique vertices / quad
|
GLVertex2D v[4]; // Four unique vertices / quad
|
||||||
|
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
|
@ -1248,9 +1245,7 @@ void WindowQuadList::makeArrays(float **vertices, float **texcoords, const QSize
|
||||||
// Note: The positions in a WindowQuad are stored in clockwise order
|
// Note: The positions in a WindowQuad are stored in clockwise order
|
||||||
const int index[] = { 1, 0, 3, 3, 2, 1 };
|
const int index[] = { 1, 0, 3, 3, 2, 1 };
|
||||||
|
|
||||||
for (int i = 0; i < count(); i++) {
|
for (const WindowQuad &quad : *this) {
|
||||||
const WindowQuad &quad = at(i);
|
|
||||||
|
|
||||||
for (int j = 0; j < 6; j++) {
|
for (int j = 0; j < 6; j++) {
|
||||||
const WindowVertex &wv = quad[index[j]];
|
const WindowVertex &wv = quad[index[j]];
|
||||||
|
|
||||||
|
@ -1280,7 +1275,7 @@ WindowQuadList WindowQuadList::select(WindowQuadType type) const
|
||||||
|
|
||||||
WindowQuadList WindowQuadList::filterOut(WindowQuadType type) const
|
WindowQuadList WindowQuadList::filterOut(WindowQuadType type) const
|
||||||
{
|
{
|
||||||
foreach (const WindowQuad & q, *this) {
|
for (const WindowQuad & q : *this) {
|
||||||
if (q.type() == type) { // something to filter out, make a copy and filter
|
if (q.type() == type) { // something to filter out, make a copy and filter
|
||||||
WindowQuadList ret;
|
WindowQuadList ret;
|
||||||
foreach (const WindowQuad & q, *this) {
|
foreach (const WindowQuad & q, *this) {
|
||||||
|
@ -1295,18 +1290,12 @@ WindowQuadList WindowQuadList::filterOut(WindowQuadType type) const
|
||||||
|
|
||||||
bool WindowQuadList::smoothNeeded() const
|
bool WindowQuadList::smoothNeeded() const
|
||||||
{
|
{
|
||||||
foreach (const WindowQuad & q, *this)
|
return std::any_of(constBegin(), constEnd(), [] (const WindowQuad & q) { return q.smoothNeeded(); });
|
||||||
if (q.smoothNeeded())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowQuadList::isTransformed() const
|
bool WindowQuadList::isTransformed() const
|
||||||
{
|
{
|
||||||
foreach (const WindowQuad & q, *this)
|
return std::any_of(constBegin(), constEnd(), [] (const WindowQuad & q) { return q.isTransformed(); });
|
||||||
if (q.isTransformed())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
|
@ -1357,9 +1346,10 @@ QRegion PaintClipper::paintArea()
|
||||||
{
|
{
|
||||||
Q_ASSERT(areas != nullptr); // can be called only with clip() == true
|
Q_ASSERT(areas != nullptr); // can be called only with clip() == true
|
||||||
const QSize &s = effects->virtualScreenSize();
|
const QSize &s = effects->virtualScreenSize();
|
||||||
QRegion ret = QRegion(0, 0, s.width(), s.height());
|
QRegion ret(0, 0, s.width(), s.height());
|
||||||
foreach (const QRegion & r, *areas)
|
for (const QRegion & r : qAsConst(*areas)) {
|
||||||
ret &= r;
|
ret &= r;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue