From 54c37146b78812e286a495a4bfc39d97858d3f99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Sat, 8 Aug 2020 12:56:14 +0200 Subject: Clean-up of old VC6 work-around Change-Id: Ic518f48b62055a4fa229751a80362f9426e0ac42 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qrasterizer.cpp | 97 ++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 54 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index f3c193d799..e6f48a79b8 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -191,8 +191,8 @@ private: QDataBuffer m_active; - template - friend void qScanConvert(QScanConverter &d, T allVertical); + template + void scanConvert(); }; class QRasterizerPrivate @@ -301,71 +301,58 @@ static void split(QT_FT_Vector *b) } } -static inline bool topOrder(const QScanConverter::Line &a, const QScanConverter::Line &b) +template +void QScanConverter::scanConvert() { - return a.top < b.top; -} - -static inline bool xOrder(const QScanConverter::Line *a, const QScanConverter::Line *b) -{ - return a->x < b->x; -} - -template -struct QBoolToType -{ - inline bool operator()() const - { - return B; - } -}; - -// should be a member function but VC6 doesn't support member template functions -template -void qScanConvert(QScanConverter &d, T allVertical) -{ - if (!d.m_lines.size()) { - d.m_active.reset(); + if (!m_lines.size()) { + m_active.reset(); return; } - std::sort(d.m_lines.data(), d.m_lines.data() + d.m_lines.size(), QT_PREPEND_NAMESPACE(topOrder)); + constexpr auto topOrder = [](const Line &a, const Line &b) { + return a.top < b.top; + }; + constexpr auto xOrder = [](const Line *a, const Line *b) { + return a->x < b->x; + }; + + std::sort(m_lines.data(), m_lines.data() + m_lines.size(), topOrder); int line = 0; - for (int y = d.m_lines.first().top; y <= d.m_bottom; ++y) { - for (; line < d.m_lines.size() && d.m_lines.at(line).top == y; ++line) { + for (int y = m_lines.first().top; y <= m_bottom; ++y) { + for (; line < m_lines.size() && m_lines.at(line).top == y; ++line) { // add node to active list - if (allVertical()) { - QScanConverter::Line *l = &d.m_lines.at(line); - d.m_active.resize(d.m_active.size() + 1); + if constexpr(AllVertical) { + QScanConverter::Line *l = &m_lines.at(line); + m_active.resize(m_active.size() + 1); int j; - for (j = d.m_active.size() - 2; j >= 0 && QT_PREPEND_NAMESPACE(xOrder)(l, d.m_active.at(j)); --j) - d.m_active.at(j+1) = d.m_active.at(j); - d.m_active.at(j+1) = l; + for (j = m_active.size() - 2; j >= 0 && xOrder(l, m_active.at(j)); --j) + m_active.at(j+1) = m_active.at(j); + m_active.at(j+1) = l; } else { - d.m_active << &d.m_lines.at(line); + m_active << &m_lines.at(line); } } - int numActive = d.m_active.size(); - if (!allVertical()) { - // use insertion sort instead of qSort, as the active edge list is quite small - // and in the average case already sorted + int numActive = m_active.size(); + if constexpr(!AllVertical) { + // use insertion sort instead of std::sort, as the active edge list is quite small + // and in the average case already sorted for (int i = 1; i < numActive; ++i) { - QScanConverter::Line *l = d.m_active.at(i); + QScanConverter::Line *l = m_active.at(i); int j; - for (j = i-1; j >= 0 && QT_PREPEND_NAMESPACE(xOrder)(l, d.m_active.at(j)); --j) - d.m_active.at(j+1) = d.m_active.at(j); - d.m_active.at(j+1) = l; + for (j = i-1; j >= 0 && xOrder(l, m_active.at(j)); --j) + m_active.at(j+1) = m_active.at(j); + m_active.at(j+1) = l; } } int x = 0; int winding = 0; for (int i = 0; i < numActive; ++i) { - QScanConverter::Line *node = d.m_active.at(i); + QScanConverter::Line *node = m_active.at(i); const int current = Q16Dot16ToInt(node->x); - if (winding & d.m_fillRuleMask) - d.m_spanBuffer->addSpan(x, current - x, y, 0xff); + if (winding & m_fillRuleMask) + m_spanBuffer->addSpan(x, current - x, y, 0xff); x = current; winding += node->winding; @@ -373,15 +360,17 @@ void qScanConvert(QScanConverter &d, T allVertical) if (node->bottom == y) { // remove node from active list for (int j = i; j < numActive - 1; ++j) - d.m_active.at(j) = d.m_active.at(j+1); + m_active.at(j) = m_active.at(j+1); - d.m_active.resize(--numActive); + m_active.resize(--numActive); --i; - } else if (!allVertical()) - node->x += node->delta; + } else { + if constexpr(!AllVertical) + node->x += node->delta; + } } } - d.m_active.reset(); + m_active.reset(); } void QScanConverter::end() @@ -398,9 +387,9 @@ void QScanConverter::end() } } if (allVertical) - qScanConvert(*this, QBoolToType()); + scanConvert(); else - qScanConvert(*this, QBoolToType()); + scanConvert(); } else { for (int chunkTop = m_top; chunkTop <= m_bottom; chunkTop += CHUNK_SIZE) { prepareChunk(); -- cgit v1.2.3