From 615d51e094e9cd9db6b5adf85c598fad78df650e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 15 Mar 2010 11:24:46 +0100 Subject: That file was forgotten when adding SSE support under mingw --- src/multimedia/audio/qaudioinput_win32_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h index d555eff..a2cf2ea 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.h +++ b/src/multimedia/audio/qaudioinput_win32_p.h @@ -122,7 +122,7 @@ private: volatile int waveFreeBlockCount; int waveCurrentBlock; - static void CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, + static void QT_WIN_CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); WAVEHDR* allocateBlocks(int size, int count); -- cgit v0.12 From ff5349090312e5a4d1ab22820440ea717cc2fd04 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 12 Mar 2010 13:05:42 +0100 Subject: --warn; --- src/declarative/qml/qdeclarativelist.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h index eac4967..ed402a8 100644 --- a/src/declarative/qml/qdeclarativelist.h +++ b/src/declarative/qml/qdeclarativelist.h @@ -61,12 +61,12 @@ struct QDeclarativeListProperty { typedef T *(*AtFunction)(QDeclarativeListProperty *, int); typedef void (*ClearFunction)(QDeclarativeListProperty *); - QDeclarativeListProperty() + QDeclarativeListProperty() : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} QDeclarativeListProperty(QObject *o, QList &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), clear(qlist_clear), dummy1(0), dummy2(0) {} - QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, + QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, ClearFunction r = 0) : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} @@ -81,7 +81,7 @@ struct QDeclarativeListProperty { QObject *object; void *data; - + AppendFunction append; CountFunction count; @@ -94,7 +94,7 @@ struct QDeclarativeListProperty { private: static void qlist_append(QDeclarativeListProperty *p, T *v) { - ((QList *)p->data)->append(v); + ((QList *)p->data)->append(v); } static int qlist_count(QDeclarativeListProperty *p) { return ((QList *)p->data)->count(); -- cgit v0.12 From fd2409d3a8ae78f6081adca8b71a42e862659c84 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 15 Mar 2010 07:22:45 +0100 Subject: Get debug code compiling since function signature changes --- src/gui/painting/qtextureglyphcache.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 4418018..fc8b3e7 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -73,7 +73,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const const QFixedPoint *) { #ifdef CACHE_DEBUG - printf("Populating with '%s'\n", QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data()); + printf("Populating with %d glyphs\n", numGlyphs); qDebug() << " -> current transformation: " << m_transform; #endif @@ -93,17 +93,14 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const glyph_metrics_t metrics = fontEngine->boundingBox(glyph, m_transform); #ifdef CACHE_DEBUG - printf("'%c' (%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f, ti.ascent=%.2f, ti.descent=%.2f\n", - ti.chars[i].toLatin1(), + printf("(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n", glyph, metrics.width.toReal(), metrics.height.toReal(), metrics.xoff.toReal(), metrics.yoff.toReal(), metrics.x.toReal(), - metrics.y.toReal(), - ti.ascent.toReal(), - ti.descent.toReal()); + metrics.y.toReal()); #endif int glyph_width = metrics.width.ceil().toInt(); int glyph_height = metrics.height.ceil().toInt(); @@ -333,10 +330,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g) QPoint base(c.x + glyphMargin(), c.y + glyphMargin() + c.baseLineY-1); if (m_image.rect().contains(base)) m_image.setPixel(base, 255); - m_image.save(QString::fromLatin1("cache-%1-%2-%3.png") - .arg(m_current_textitem->font().family()) - .arg(m_current_textitem->font().pointSize()) - .arg(m_transform.type())); + m_image.save(QString::fromLatin1("cache-%1.png").arg(int(this))); #endif } -- cgit v0.12 From 73884b00e1ab5b064c605ac3430558412692cf5f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 15 Mar 2010 07:30:58 +0100 Subject: Fixed wasted space in the texture cache. We were using the height of the texture to position the next row, rather than just adding the rowHeight. This used to work when the texture cached grew by rowHeight, now it grows to next power of two... Reviewed-by: Eskil --- src/gui/painting/qtextureglyphcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index fc8b3e7..4a563ed 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -136,7 +136,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const if (m_cx + c.w > m_w) { // no room on the current line, start new glyph strip m_cx = 0; - m_cy = m_h; + m_cy += rowHeight; } if (m_cy + c.h > m_h) { int new_height = m_h*2; -- cgit v0.12 From 8e98c4c159c38ea48b6321674105762b2d3f517b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 15 Mar 2010 13:23:38 +0100 Subject: small cleanup regarding delayed layout in itemviews --- src/gui/itemviews/qabstractitemview.cpp | 30 ++++++------------------------ src/gui/itemviews/qabstractitemview_p.h | 10 +++++----- src/gui/itemviews/qlistview.cpp | 2 +- src/gui/itemviews/qtreeview.cpp | 10 +++++----- 4 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 2faf755..443e669 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -103,8 +103,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() verticalScrollMode(QAbstractItemView::ScrollPerItem), horizontalScrollMode(QAbstractItemView::ScrollPerItem), currentIndexSet(false), - wrapItemText(false), - delayedPendingLayout(false) + wrapItemText(false) { } @@ -2396,9 +2395,8 @@ void QAbstractItemView::timerEvent(QTimerEvent *event) d->delayedEditing.stop(); edit(currentIndex()); } else if (event->timerId() == d->delayedLayout.timerId()) { - d->delayedLayout.stop(); + d->interruptDelayedItemsLayout(); if (isVisible()) { - d->interruptDelayedItemsLayout(); doItemsLayout(); const QModelIndex current = currentIndex(); if (current.isValid() && d->state == QAbstractItemView::EditingState) @@ -3060,7 +3058,7 @@ void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget d->addEditor(index, widget, true); widget->show(); dataChanged(index, index); // update the geometry - if (!d->delayedPendingLayout) + if (!d->delayedPendingLayout()) widget->setGeometry(visualRect(index)); } } @@ -3100,7 +3098,7 @@ void QAbstractItemView::scrollToTop() void QAbstractItemView::scrollToBottom() { Q_D(QAbstractItemView); - if (d->delayedPendingLayout) { + if (d->delayedPendingLayout()) { d->executePostedLayout(); updateGeometries(); } @@ -3145,14 +3143,14 @@ void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelInde delegate->setEditorData(editorInfo.editor, topLeft); } } - if (isVisible() && !d->delayedPendingLayout) { + if (isVisible() && !d->delayedPendingLayout()) { // otherwise the items will be update later anyway update(topLeft); } return; } d->updateEditorData(topLeft, bottomRight); - if (!isVisible() || d->delayedPendingLayout) + if (!isVisible() || d->delayedPendingLayout()) return; // no need to update d->viewport->update(); } @@ -3876,22 +3874,6 @@ bool QAbstractItemViewPrivate::shouldAutoScroll(const QPoint &pos) const || (area.right() - pos.x() < autoScrollMargin); } -void QAbstractItemViewPrivate::doDelayedItemsLayout(int delay) -{ - if (!delayedPendingLayout) { - delayedPendingLayout = true; - delayedLayout.start(delay, q_func()); - } -} - -void QAbstractItemViewPrivate::interruptDelayedItemsLayout() const -{ - delayedLayout.stop(); - delayedPendingLayout = false; -} - - - QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index, const QStyleOptionViewItem &options) { diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 82fd1a6..3511c28 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -124,8 +124,10 @@ public: bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const; bool shouldForwardEvent(QAbstractItemView::EditTrigger trigger, const QEvent *event) const; bool shouldAutoScroll(const QPoint &pos) const; - void doDelayedItemsLayout(int delay = 0); - void interruptDelayedItemsLayout() const; + void doDelayedItemsLayout(int delay = 0) { if (!delayedPendingLayout()) delayedLayout.start(delay, q_func()); } + void interruptDelayedItemsLayout() const { delayedLayout.stop(); } + bool delayedPendingLayout() const { return delayedLayout.isActive(); } + void startAutoScroll() { // ### it would be nice to make this into a style hint one day @@ -207,7 +209,7 @@ public: } inline void executePostedLayout() const { - if (delayedPendingLayout && state != QAbstractItemView::CollapsingState) { + if (delayedPendingLayout() && state != QAbstractItemView::CollapsingState) { interruptDelayedItemsLayout(); const_cast(q_func())->doItemsLayout(); } @@ -416,9 +418,7 @@ public: QAbstractItemView::ScrollMode horizontalScrollMode; bool currentIndexSet; - bool wrapItemText; - mutable bool delayedPendingLayout; private: mutable QBasicTimer delayedLayout; diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index b2def39..b2c8c51 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -823,7 +823,7 @@ void QListView::timerEvent(QTimerEvent *e) void QListView::resizeEvent(QResizeEvent *e) { Q_D(QListView); - if (d->delayedPendingLayout) + if (d->delayedPendingLayout()) return; QSize delta = e->size() - e->oldSize(); diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 4135ba0..2acd160 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -668,7 +668,7 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto Q_D(QTreeView); // if we are going to do a complete relayout anyway, there is no need to update - if (d->delayedPendingLayout) + if (d->delayedPendingLayout()) return; // refresh the height cache here; we don't really lose anything by getting the size hint, @@ -742,7 +742,7 @@ void QTreeView::expand(const QModelIndex &index) Q_D(QTreeView); if (!d->isIndexValid(index)) return; - if (d->delayedPendingLayout) { + if (d->delayedPendingLayout()) { //A complete relayout is going to be performed, just store the expanded index, no need to layout. if (d->storeExpanded(index)) emit expanded(index); @@ -776,7 +776,7 @@ void QTreeView::collapse(const QModelIndex &index) //if the current item is now invisible, the autoscroll will expand the tree to see it, so disable the autoscroll d->delayedAutoScroll.stop(); - if (d->delayedPendingLayout) { + if (d->delayedPendingLayout()) { //A complete relayout is going to be performed, just un-store the expanded index, no need to layout. if (d->isPersistent(index) && d->expandedIndexes.remove(index)) emit collapsed(index); @@ -2431,7 +2431,7 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) { Q_D(QTreeView); // if we are going to do a complete relayout anyway, there is no need to update - if (d->delayedPendingLayout) { + if (d->delayedPendingLayout()) { QAbstractItemView::rowsInserted(parent, start, end); return; } @@ -3755,7 +3755,7 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, int start, int end, bool after) { // if we are going to do a complete relayout anyway, there is no need to update - if (delayedPendingLayout) { + if (delayedPendingLayout()) { _q_rowsRemoved(parent, start, end); return; } -- cgit v0.12 From 378a82e8965f841f6f712a2f1725554f577e568a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 15 Mar 2010 14:35:15 +0100 Subject: Fix a crash in QSortFilterProxyModel when deleting a row ...while changing data. Reviewed-By: gabi Task-Number: QTBUG-8841 --- src/gui/itemviews/qsortfilterproxymodel.cpp | 34 ++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index 5c7d24b7..c6ad345 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -111,6 +111,35 @@ private: }; +//this struct is used to store what are the rows that are removed +//between a call to rowsAboutToBeRemoved and rowsRemoved +//it avoids readding rows to the mapping that are currently being removed +struct QRowsRemoval +{ + QRowsRemoval(const QModelIndex &parent_source, int start, int end) : parent_source(parent_source), start(start), end(end) + { + } + + QRowsRemoval() : start(-1), end(-1) + { + } + + bool contains(QModelIndex parent, int row) + { + do { + if (parent == parent_source) + return row >= start && row <= end; + row = parent.row(); + parent = parent.parent(); + } while (row >= 0); + return false; + } +private: + QModelIndex parent_source; + int start; + int end; +}; + class QSortFilterProxyModelPrivate : public QAbstractProxyModelPrivate { Q_DECLARE_PUBLIC(QSortFilterProxyModel) @@ -139,6 +168,7 @@ public: int filter_role; bool dynamic_sortfilter; + QRowsRemoval itemsBeingRemoved; QModelIndexPairList saved_persistent_indexes; @@ -1096,7 +1126,7 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc source_rows_change.append(source_row); } } else { - if (q->filterAcceptsRow(source_row, source_parent)) { + if (!itemsBeingRemoved.contains(source_parent, source_row) && q->filterAcceptsRow(source_row, source_parent)) { // This source row now satisfies the filter, so it must be added source_rows_insert.append(source_row); } @@ -1253,6 +1283,7 @@ void QSortFilterProxyModelPrivate::_q_sourceRowsInserted( void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeRemoved( const QModelIndex &source_parent, int start, int end) { + itemsBeingRemoved = QRowsRemoval(source_parent, start, end); source_items_about_to_be_removed(source_parent, start, end, Qt::Vertical); } @@ -1260,6 +1291,7 @@ void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeRemoved( void QSortFilterProxyModelPrivate::_q_sourceRowsRemoved( const QModelIndex &source_parent, int start, int end) { + itemsBeingRemoved = QRowsRemoval(); source_items_removed(source_parent, start, end, Qt::Vertical); } -- cgit v0.12 From b912cac358a0a84f72f727767772caad22062a45 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 16 Mar 2010 10:46:52 +0100 Subject: Make sure the delete and backspace keys are ignored when keyb-searching Task-number: QTBUG-8270 Reviewed-by: gabi --- src/gui/itemviews/qabstractitemview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 443e669..61defdc 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2296,6 +2296,8 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) case Qt::Key_Escape: case Qt::Key_Shift: case Qt::Key_Control: + case Qt::Key_Delete: + case Qt::Key_BackSpace: event->ignore(); break; case Qt::Key_Space: -- cgit v0.12 From e0dd5b450e1b04feb6c72a3c635c586b244392da Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 16 Mar 2010 10:56:15 +0100 Subject: Revert "small cleanup regarding delayed layout in itemviews" This reverts commit 8e98c4c159c38ea48b6321674105762b2d3f517b. --- src/gui/itemviews/qabstractitemview.cpp | 30 ++++++++++++++++++++++++------ src/gui/itemviews/qabstractitemview_p.h | 10 +++++----- src/gui/itemviews/qlistview.cpp | 2 +- src/gui/itemviews/qtreeview.cpp | 10 +++++----- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 61defdc..fb6e418 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -103,7 +103,8 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() verticalScrollMode(QAbstractItemView::ScrollPerItem), horizontalScrollMode(QAbstractItemView::ScrollPerItem), currentIndexSet(false), - wrapItemText(false) + wrapItemText(false), + delayedPendingLayout(false) { } @@ -2397,8 +2398,9 @@ void QAbstractItemView::timerEvent(QTimerEvent *event) d->delayedEditing.stop(); edit(currentIndex()); } else if (event->timerId() == d->delayedLayout.timerId()) { - d->interruptDelayedItemsLayout(); + d->delayedLayout.stop(); if (isVisible()) { + d->interruptDelayedItemsLayout(); doItemsLayout(); const QModelIndex current = currentIndex(); if (current.isValid() && d->state == QAbstractItemView::EditingState) @@ -3060,7 +3062,7 @@ void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget d->addEditor(index, widget, true); widget->show(); dataChanged(index, index); // update the geometry - if (!d->delayedPendingLayout()) + if (!d->delayedPendingLayout) widget->setGeometry(visualRect(index)); } } @@ -3100,7 +3102,7 @@ void QAbstractItemView::scrollToTop() void QAbstractItemView::scrollToBottom() { Q_D(QAbstractItemView); - if (d->delayedPendingLayout()) { + if (d->delayedPendingLayout) { d->executePostedLayout(); updateGeometries(); } @@ -3145,14 +3147,14 @@ void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelInde delegate->setEditorData(editorInfo.editor, topLeft); } } - if (isVisible() && !d->delayedPendingLayout()) { + if (isVisible() && !d->delayedPendingLayout) { // otherwise the items will be update later anyway update(topLeft); } return; } d->updateEditorData(topLeft, bottomRight); - if (!isVisible() || d->delayedPendingLayout()) + if (!isVisible() || d->delayedPendingLayout) return; // no need to update d->viewport->update(); } @@ -3876,6 +3878,22 @@ bool QAbstractItemViewPrivate::shouldAutoScroll(const QPoint &pos) const || (area.right() - pos.x() < autoScrollMargin); } +void QAbstractItemViewPrivate::doDelayedItemsLayout(int delay) +{ + if (!delayedPendingLayout) { + delayedPendingLayout = true; + delayedLayout.start(delay, q_func()); + } +} + +void QAbstractItemViewPrivate::interruptDelayedItemsLayout() const +{ + delayedLayout.stop(); + delayedPendingLayout = false; +} + + + QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index, const QStyleOptionViewItem &options) { diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 3511c28..82fd1a6 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -124,10 +124,8 @@ public: bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const; bool shouldForwardEvent(QAbstractItemView::EditTrigger trigger, const QEvent *event) const; bool shouldAutoScroll(const QPoint &pos) const; - void doDelayedItemsLayout(int delay = 0) { if (!delayedPendingLayout()) delayedLayout.start(delay, q_func()); } - void interruptDelayedItemsLayout() const { delayedLayout.stop(); } - bool delayedPendingLayout() const { return delayedLayout.isActive(); } - + void doDelayedItemsLayout(int delay = 0); + void interruptDelayedItemsLayout() const; void startAutoScroll() { // ### it would be nice to make this into a style hint one day @@ -209,7 +207,7 @@ public: } inline void executePostedLayout() const { - if (delayedPendingLayout() && state != QAbstractItemView::CollapsingState) { + if (delayedPendingLayout && state != QAbstractItemView::CollapsingState) { interruptDelayedItemsLayout(); const_cast(q_func())->doItemsLayout(); } @@ -418,7 +416,9 @@ public: QAbstractItemView::ScrollMode horizontalScrollMode; bool currentIndexSet; + bool wrapItemText; + mutable bool delayedPendingLayout; private: mutable QBasicTimer delayedLayout; diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index b2c8c51..b2def39 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -823,7 +823,7 @@ void QListView::timerEvent(QTimerEvent *e) void QListView::resizeEvent(QResizeEvent *e) { Q_D(QListView); - if (d->delayedPendingLayout()) + if (d->delayedPendingLayout) return; QSize delta = e->size() - e->oldSize(); diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 2acd160..4135ba0 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -668,7 +668,7 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto Q_D(QTreeView); // if we are going to do a complete relayout anyway, there is no need to update - if (d->delayedPendingLayout()) + if (d->delayedPendingLayout) return; // refresh the height cache here; we don't really lose anything by getting the size hint, @@ -742,7 +742,7 @@ void QTreeView::expand(const QModelIndex &index) Q_D(QTreeView); if (!d->isIndexValid(index)) return; - if (d->delayedPendingLayout()) { + if (d->delayedPendingLayout) { //A complete relayout is going to be performed, just store the expanded index, no need to layout. if (d->storeExpanded(index)) emit expanded(index); @@ -776,7 +776,7 @@ void QTreeView::collapse(const QModelIndex &index) //if the current item is now invisible, the autoscroll will expand the tree to see it, so disable the autoscroll d->delayedAutoScroll.stop(); - if (d->delayedPendingLayout()) { + if (d->delayedPendingLayout) { //A complete relayout is going to be performed, just un-store the expanded index, no need to layout. if (d->isPersistent(index) && d->expandedIndexes.remove(index)) emit collapsed(index); @@ -2431,7 +2431,7 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) { Q_D(QTreeView); // if we are going to do a complete relayout anyway, there is no need to update - if (d->delayedPendingLayout()) { + if (d->delayedPendingLayout) { QAbstractItemView::rowsInserted(parent, start, end); return; } @@ -3755,7 +3755,7 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, int start, int end, bool after) { // if we are going to do a complete relayout anyway, there is no need to update - if (delayedPendingLayout()) { + if (delayedPendingLayout) { _q_rowsRemoved(parent, start, end); return; } -- cgit v0.12 From c066afa4bc95ac92185e9fc691b9d9d27ca64387 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 16 Mar 2010 12:23:51 +0100 Subject: Implement a special case, simplified vertex shader for complex geometry When drawing text, the vertex count will most likely be so high that using a uniform-based, simpler vertex shader is faster. We implement the ability to inform the shader manager that the geometry is considered complex, so that it can choose the simpler vertex shader in these cases. Task-number: QT-2887 Reviewed-by: tom --- src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 7 ++++++- src/opengl/gl2paintengineex/qglengineshadermanager_p.h | 12 ++++++++++++ src/opengl/gl2paintengineex/qglengineshadersource_p.h | 8 ++++++++ src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 13 ++++++++++++- src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 1 + 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 8183f08..aa704b1 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -96,6 +96,7 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) code[UntransformedPositionVertexShader] = qglslUntransformedPositionVertexShader; code[PositionOnlyVertexShader] = qglslPositionOnlyVertexShader; + code[ComplexGeometryPositionOnlyVertexShader] = qglslComplexGeometryPositionOnlyVertexShader; code[PositionWithPatternBrushVertexShader] = qglslPositionWithPatternBrushVertexShader; code[PositionWithLinearGradientBrushVertexShader] = qglslPositionWithLinearGradientBrushVertexShader; code[PositionWithConicalGradientBrushVertexShader] = qglslPositionWithConicalGradientBrushVertexShader; @@ -401,6 +402,7 @@ void QGLEngineSharedShaders::cleanupCustomStage(QGLCustomShaderStage* stage) QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) : ctx(context), shaderProgNeedsChanging(true), + complexGeometry(false), srcPixelType(Qt::NoBrush), opacityMode(NoOpacity), maskType(NoMask), @@ -442,7 +444,8 @@ GLuint QGLEngineShaderManager::getUniformLocation(Uniform id) "inverse_2_fmp2_m_radius2", "invertedTextureSize", "brushTransform", - "brushTexture" + "brushTexture", + "matrix" }; if (uniformLocations.at(id) == GLuint(-1)) @@ -751,6 +754,8 @@ bool QGLEngineShaderManager::useCorrectShaderProg() requiredProgram.useTextureCoords = texCoords; requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity); requiredProgram.usePmvMatrix = true; + if (complexGeometry) + requiredProgram.positionVertexShader = QGLEngineSharedShaders::ComplexGeometryPositionOnlyVertexShader; // At this point, requiredProgram is fully populated so try to find the program in the cache currentShaderProg = sharedShaders->findProgramInCache(requiredProgram); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 3ab4ebe..d8be4c9 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -272,6 +272,7 @@ public: // UntransformedPositionVertexShader must be first in the list: UntransformedPositionVertexShader, PositionOnlyVertexShader, + ComplexGeometryPositionOnlyVertexShader, PositionWithPatternBrushVertexShader, PositionWithLinearGradientBrushVertexShader, PositionWithConicalGradientBrushVertexShader, @@ -446,6 +447,7 @@ public: InvertedTextureSize, BrushTransform, BrushTexture, + Matrix, NumUniforms }; @@ -474,6 +476,15 @@ public: void useSimpleProgram(); void useBlitProgram(); + void setHasComplexGeometry(bool hasComplexGeometry) + { + complexGeometry = hasComplexGeometry; + shaderProgNeedsChanging = true; + } + bool hasComplexGeometry() const + { + return complexGeometry; + } QGLShaderProgram* currentProgram(); // Returns pointer to the shader the manager has chosen QGLShaderProgram* simpleProgram(); // Used to draw into e.g. stencil buffers @@ -487,6 +498,7 @@ private slots: private: QGLContext* ctx; bool shaderProgNeedsChanging; + bool complexGeometry; // Current state variables which influence the choice of shader: QTransform brushTransform; diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index c88c041..3379296 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -107,6 +107,14 @@ static const char* const qglslPositionOnlyVertexShader = "\n\ gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\ }\n"; +static const char* const qglslComplexGeometryPositionOnlyVertexShader = "\n\ + uniform highp mat3 matrix; \n\ + attribute highp vec2 vertexCoordsArray; \n\ + void setPosition(void) \n\ + { \n\ + gl_Position = vec4(matrix * vec3(vertexCoordsArray, 1), 1);\n\ + } \n"; + static const char* const qglslUntransformedPositionVertexShader = "\n\ attribute highp vec4 vertexCoordsArray; \n\ void setPosition(void) \n\ diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index d68a268..b90f0c2 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -395,6 +395,7 @@ void QGL2PaintEngineExPrivate::updateMatrix() qreal(0.0001)); matrixDirty = false; + matrixUniformDirty = true; // Set the PMV matrix attribute. As we use an attributes rather than uniforms, we only // need to do this once for every matrix change and persists across all shader programs. @@ -594,6 +595,9 @@ void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) if (newMode == TextDrawingMode) { setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data()); setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data()); + shaderManager->setHasComplexGeometry(true); + } else { + shaderManager->setHasComplexGeometry(false); } if (newMode == ImageDrawingMode) { @@ -1045,6 +1049,7 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) // The shader program has changed so mark all uniforms as dirty: brushUniformsDirty = true; opacityUniformDirty = true; + matrixUniformDirty = true; } if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) @@ -1055,6 +1060,12 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) opacityUniformDirty = false; } + if (matrixUniformDirty && shaderManager->hasComplexGeometry()) { + shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Matrix), + pmvMatrix); + matrixUniformDirty = false; + } + return changed; } @@ -1631,7 +1642,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp lastMaskTextureUsed = cache->texture(); } updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); #if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) @@ -1776,6 +1786,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->mode = BrushDrawingMode; d->brushTextureDirty = true; d->brushUniformsDirty = true; + d->matrixUniformDirty = true; d->matrixDirty = true; d->compositionModeDirty = true; d->opacityUniformDirty = true; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index ed8fbbc..34d72d1 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -259,6 +259,7 @@ public: bool brushTextureDirty; bool brushUniformsDirty; bool opacityUniformDirty; + bool matrixUniformDirty; bool stencilClean; // Has the stencil not been used for clipping so far? bool useSystemClip; -- cgit v0.12 From a31aa886f29ab49bb0aa757ce2253aa4e8ef3632 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 16 Mar 2010 13:43:02 +0100 Subject: Compile Fix typo in qabstractitemview.cpp Reviewed-by: Thierry --- src/gui/itemviews/qabstractitemview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index fb6e418..dd9a7e6 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2298,7 +2298,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) case Qt::Key_Shift: case Qt::Key_Control: case Qt::Key_Delete: - case Qt::Key_BackSpace: + case Qt::Key_Backspace: event->ignore(); break; case Qt::Key_Space: -- cgit v0.12