From d6d25c3978360bd8c30b3dcce3bfa4117d37f5d8 Mon Sep 17 00:00:00 2001 From: kh Date: Fri, 24 Apr 2009 16:52:13 +0200 Subject: cleanup, no functional change --- tools/assistant/tools/assistant/centralwidget.cpp | 207 ++++++++++++---------- tools/assistant/tools/assistant/centralwidget.h | 3 + tools/assistant/tools/assistant/helpviewer.h | 2 + 3 files changed, 118 insertions(+), 94 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 633747a..aa8887c 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -72,7 +72,8 @@ QT_BEGIN_NAMESPACE namespace { - HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, const QPoint &point) + HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, + const QPoint &point) { QTabBar *tabBar = qFindChild(widget); for (int i = 0; i < tabBar->count(); ++i) { @@ -87,38 +88,32 @@ namespace { FindWidget::FindWidget(QWidget *parent) : QWidget(parent) { - QString system = QLatin1String("win"); QHBoxLayout *hboxLayout = new QHBoxLayout(this); -#ifdef Q_OS_MAC - system = QLatin1String("mac"); -#else - hboxLayout->setSpacing(6); + QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); + +#ifndef Q_OS_MAC hboxLayout->setMargin(0); + hboxLayout->setSpacing(6); + resourcePath.append(QLatin1String("win")); +#else + resourcePath.append(QLatin1String("mac")); #endif - toolClose = new QToolButton(this); - toolClose->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/closetab.png").arg(system))); - toolClose->setAutoRaise(true); + toolClose = setupToolButton(QLatin1String(""), + resourcePath + QLatin1String("/closetab.png")); hboxLayout->addWidget(toolClose); editFind = new QLineEdit(this); - editFind->setMinimumSize(QSize(150, 0)); - connect(editFind, SIGNAL(textChanged(const QString&)), - this, SLOT(updateButtons())); hboxLayout->addWidget(editFind); + editFind->setMinimumSize(QSize(150, 0)); + connect(editFind, SIGNAL(textChanged(QString)), this, SLOT(updateButtons())); - toolPrevious = new QToolButton(this); - toolPrevious->setAutoRaise(true); - toolPrevious->setText(tr("Previous")); - toolPrevious->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - toolPrevious->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/previous.png").arg(system))); + toolPrevious = setupToolButton(tr("Previous"), + resourcePath + QLatin1String("/previous.png")); hboxLayout->addWidget(toolPrevious); - toolNext = new QToolButton(this); - toolNext->setAutoRaise(true); - toolNext->setText(tr("Next")); - toolNext->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - toolNext->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/next.png").arg(system))); + toolNext = setupToolButton(tr("Next"), + resourcePath + QLatin1String("/next.png")); hboxLayout->addWidget(toolNext); checkCase = new QCheckBox(tr("Case Sensitive"), this); @@ -131,15 +126,17 @@ FindWidget::FindWidget(QWidget *parent) #endif labelWrapped = new QLabel(this); + labelWrapped->setScaledContents(true); + labelWrapped->setTextFormat(Qt::RichText); labelWrapped->setMinimumSize(QSize(0, 20)); labelWrapped->setMaximumSize(QSize(105, 20)); - labelWrapped->setTextFormat(Qt::RichText); - labelWrapped->setScaledContents(true); - labelWrapped->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); - labelWrapped->setText(tr(" Search wrapped")); + labelWrapped->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); + labelWrapped->setText(tr(" Search wrapped")); hboxLayout->addWidget(labelWrapped); - QSpacerItem *spacerItem = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + QSpacerItem *spacerItem = new QSpacerItem(20, 20, QSizePolicy::Expanding, + QSizePolicy::Minimum); hboxLayout->addItem(spacerItem); setMinimumWidth(minimumSizeHint().width()); labelWrapped->hide(); @@ -162,38 +159,54 @@ void FindWidget::updateButtons() } } +QToolButton* FindWidget::setupToolButton(const QString &text, const QString &icon) +{ + QToolButton* toolButton = new QToolButton(this); + + toolButton->setText(text); + toolButton->setAutoRaise(true); + toolButton->setIcon(QIcon(icon)); + toolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + + return toolButton; +} + + +// -- + CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) : QWidget(parent) + , lastTabPage(0) + , collectionFile(engine->collectionFile()) , findBar(0) , tabWidget(0) + , findWidget(0) , helpEngine(engine) , printer(0) + , usesDefaultCollection(parent->usesDefaultCollection()) , m_searchWidget(0) { - staticCentralWidget = this; - - lastTabPage = 0; globalActionList.clear(); - collectionFile = helpEngine->collectionFile(); - usesDefaultCollection = parent->usesDefaultCollection(); - - QString system = QLatin1String("win"); + staticCentralWidget = this; QVBoxLayout *vboxLayout = new QVBoxLayout(this); + QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); -#ifdef Q_OS_MAC - system = QLatin1String("mac"); -#else +#ifndef Q_OS_MAC vboxLayout->setMargin(0); + resourcePath.append(QLatin1String("win")); +#else + resourcePath.append(QLatin1String("mac")); #endif tabWidget = new QTabWidget(this); - connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int))); + connect(tabWidget, SIGNAL(currentChanged(int)), this, + SLOT(currentPageChanged(int))); QToolButton *newTabButton = new QToolButton(this); newTabButton->setAutoRaise(true); newTabButton->setToolTip(tr("Add new page")); - newTabButton->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/addtab.png").arg(system))); + newTabButton->setIcon(QIcon(resourcePath + QLatin1String("/addtab.png"))); tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner); connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab())); @@ -202,7 +215,7 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) closeTabButton->setEnabled(false); closeTabButton->setAutoRaise(true); closeTabButton->setToolTip(tr("Close current page")); - closeTabButton->setIcon(QIcon(QString::fromUtf8(":/trolltech/assistant/images/%1/closetab.png").arg(system))); + closeTabButton->setIcon(QIcon(resourcePath + QLatin1String("/closetab.png"))); tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner); connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeTab())); @@ -216,19 +229,20 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) vboxLayout->addWidget(findBar); findBar->hide(); findWidget->editFind->installEventFilter(this); - connect(findWidget->toolClose, SIGNAL(clicked()), findBar, SLOT(hide())); + connect(findWidget->toolClose, SIGNAL(clicked()), findBar, SLOT(hide())); connect(findWidget->toolNext, SIGNAL(clicked()), this, SLOT(findNext())); connect(findWidget->editFind, SIGNAL(returnPressed()), this, SLOT(findNext())); - connect(findWidget->editFind, SIGNAL(textChanged(const QString&)), this, SLOT(findCurrentText(const QString&))); + connect(findWidget->editFind, SIGNAL(textChanged(QString)), this, + SLOT(findCurrentText(QString))); connect(findWidget->toolPrevious, SIGNAL(clicked()), this, SLOT(findPrevious())); QTabBar *tabBar = qFindChild(tabWidget); if (tabBar) { tabBar->installEventFilter(this); tabBar->setContextMenuPolicy(Qt::CustomContextMenu); - connect(tabBar, SIGNAL(customContextMenuRequested(const QPoint&)), - this, SLOT(showTabBarContextMenu(const QPoint&))); + connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(showTabBarContextMenu(QPoint))); } QPalette p = qApp->palette(); @@ -247,17 +261,12 @@ CentralWidget::~CentralWidget() QString zoomCount; QString currentPages; - QLatin1Char sep('|'); + QLatin1Char separator('|'); for (int i = 1; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) { - currentPages.append(viewer->source().toString()).append(sep); -#if !defined(QT_NO_WEBKIT) - zoomCount.append(QString::number(viewer->textSizeMultiplier())). - append(sep); -#else - zoomCount.append(QString::number(viewer->zoom())).append(sep); -#endif + currentPages += viewer->source().toString() + separator; + zoomCount += QString::number(viewer->zoom()) + separator; } } engine.setCustomValue(QLatin1String("LastTabPage"), lastTabPage); @@ -363,8 +372,9 @@ void CentralWidget::setSource(const QUrl &url) lastTabPage = tabWidget->addTab(viewer, QString()); tabWidget->setCurrentIndex(lastTabPage); connectSignals(); - } else + } else { viewer = lastViewer; + } viewer->setSource(url); currentPageChanged(lastTabPage); @@ -375,37 +385,35 @@ void CentralWidget::setSource(const QUrl &url) void CentralWidget::setLastShownPages() { + const QLatin1String key("LastShownPages"); + QString value = helpEngine->customValue(key, QString()).toString(); + const QStringList lastShownPageList = value.split(QLatin1Char('|'), + QString::SkipEmptyParts); + + const int pageCount = lastShownPageList.count(); + if (pageCount == 0 && usesDefaultCollection) + return setSource(QUrl(QLatin1String("help"))); + #if !defined(QT_NO_WEBKIT) - QLatin1String zoom("LastPagesZoomWebView"); + const QLatin1String zoom("LastPagesZoomWebView"); #else - QLatin1String zoom("LastPagesZoomTextBrowser"); + const QLatin1String zoom("LastPagesZoomTextBrowser"); #endif - const QStringList lastShownPageList = - helpEngine->customValue(QLatin1String("LastShownPages")).toString(). - split(QLatin1Char('|'), QString::SkipEmptyParts); - - if (!lastShownPageList.isEmpty()) { - QVectorzoomList = helpEngine->customValue(zoom).toString(). - split(QLatin1Char('|'), QString::SkipEmptyParts).toVector(); - if (zoomList.isEmpty()) - zoomList.fill(QLatin1String("0.0"), lastShownPageList.size()); - else if(zoomList.count() < lastShownPageList.count()) { - zoomList.insert(zoomList.count(), - lastShownPageList.count() - zoomList.count(), QLatin1String("0.0")); - } + value = helpEngine->customValue(zoom, QString()).toString(); + QVector zoomVector = value.split(QLatin1Char('|'), + QString::SkipEmptyParts).toVector(); - QVector::const_iterator zIt = zoomList.constBegin(); - QStringList::const_iterator it = lastShownPageList.constBegin(); - for (; it != lastShownPageList.constEnd(); ++it, ++zIt) - setSourceInNewTab((*it), (*zIt).toFloat()); + const int zoomCount = zoomVector.count(); + zoomVector.insert(zoomCount, pageCount - zoomCount, QLatin1String("0.0")); - tabWidget->setCurrentIndex(helpEngine->customValue( - QLatin1String("LastTabPage"), 1).toInt()); - } else { - if (usesDefaultCollection) - setSource(QUrl(QLatin1String("help"))); - } + QVector::const_iterator zIt = zoomVector.constBegin(); + QStringList::const_iterator it = lastShownPageList.constBegin(); + for (; it != lastShownPageList.constEnd(); ++it, ++zIt) + setSourceInNewTab((*it), (*zIt).toFloat()); + + const QLatin1String lastTab("LastTabPage"); + tabWidget->setCurrentIndex(helpEngine->customValue(lastTab, 1).toInt()); } bool CentralWidget::hasSelection() const @@ -483,7 +491,8 @@ void CentralWidget::printPreview() #ifndef QT_NO_PRINTER initPrinter(); QPrintPreviewDialog preview(printer, this); - connect(&preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printPreview(QPrinter *))); + connect(&preview, SIGNAL(paintRequested(QPrinter*)), + SLOT(printPreview(QPrinter*))); preview.exec(); #endif } @@ -634,13 +643,18 @@ void CentralWidget::connectSignals() { const HelpViewer* viewer = currentHelpViewer(); if (viewer) { - connect(viewer, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); - connect(viewer, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool))); - connect(viewer, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool))); - connect(viewer, SIGNAL(sourceChanged(const QUrl&)), this, SIGNAL(sourceChanged(const QUrl&))); - connect(viewer, SIGNAL(highlighted(const QString&)), this, SIGNAL(highlighted(const QString&))); - - connect(viewer, SIGNAL(sourceChanged(const QUrl&)), this, SLOT(setTabTitle(const QUrl&))); + connect(viewer, SIGNAL(copyAvailable(bool)), this, + SIGNAL(copyAvailable(bool))); + connect(viewer, SIGNAL(forwardAvailable(bool)), this, + SIGNAL(forwardAvailable(bool))); + connect(viewer, SIGNAL(backwardAvailable(bool)), this, + SIGNAL(backwardAvailable(bool))); + connect(viewer, SIGNAL(sourceChanged(QUrl)), this, + SIGNAL(sourceChanged(QUrl))); + connect(viewer, SIGNAL(highlighted(QString)), this, + SIGNAL(highlighted(QString))); + connect(viewer, SIGNAL(sourceChanged(QUrl)), this, + SLOT(setTabTitle(QUrl))); } } @@ -700,8 +714,11 @@ void CentralWidget::currentPageChanged(int index) enabled = tabWidget->count() > 1; } - tabWidget->cornerWidget(Qt::TopRightCorner)->setEnabled(enabled); - tabWidget->cornerWidget(Qt::TopLeftCorner)->setEnabled(m_searchWidget ? enabled : true); + QWidget *widget = tabWidget->cornerWidget(Qt::TopLeftCorner); + widget->setEnabled(m_searchWidget ? enabled : true); + + widget = tabWidget->cornerWidget(Qt::TopRightCorner); + widget->setEnabled(enabled); emit currentViewerChanged(); } @@ -876,8 +893,10 @@ void CentralWidget::find(QString ttf, bool forward, bool backward) QTextDocument::FindFlags options; - if (cursor.hasSelection()) - cursor.setPosition(forward ? cursor.position() : cursor.anchor(), QTextCursor::MoveAnchor); + if (cursor.hasSelection()) { + cursor.setPosition(forward ? cursor.position() : cursor.anchor(), + QTextCursor::MoveAnchor); + } QTextCursor newCursor = cursor; @@ -971,10 +990,10 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) { if (!m_searchWidget) { m_searchWidget = new SearchWidget(searchEngine, this); - connect(m_searchWidget, SIGNAL(requestShowLink(const QUrl&)), this, - SLOT(setSourceFromSearch(const QUrl&))); - connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(const QUrl&)), this, - SLOT(setSourceFromSearchInNewTab(const QUrl&))); + connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this, + SLOT(setSourceFromSearch(QUrl))); + connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, + SLOT(setSourceFromSearchInNewTab(QUrl))); } tabWidget->insertTab(0, m_searchWidget, tr("Search")); } diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 75bd8be..a34ba65 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -83,6 +83,9 @@ private slots: void updateButtons(); private: + QToolButton* setupToolButton(const QString &text, const QString &icon); + +private: QLineEdit *editFind; QCheckBox *checkCase; QLabel *labelWrapped; diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index c66b69c..37545c7 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -94,6 +94,8 @@ public: { return pageAction(QWebPage::Back)->isEnabled(); } inline bool hasLoadFinished() const { return loadFinished; } + inline qreal zoom() const + { return textSizeMultiplier(); } public Q_SLOTS: void home(); -- cgit v0.12 From deffb8578757550e57ea3058e95a758155632226 Mon Sep 17 00:00:00 2001 From: kh Date: Fri, 24 Apr 2009 16:54:33 +0200 Subject: fixes empty tab titles after restart --- tools/assistant/tools/assistant/centralwidget.cpp | 23 +++++++++-------------- tools/assistant/tools/assistant/helpviewer.cpp | 1 + 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index aa8887c..0a94a3d 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -678,26 +678,21 @@ void CentralWidget::activateTab(bool onlyHelpViewer) void CentralWidget::setTabTitle(const QUrl& url) { - int tab = lastTabPage; - HelpViewer* viewer = currentHelpViewer(); - + Q_UNUSED(url) #if !defined(QT_NO_WEBKIT) - if (!viewer || viewer->source() != url) { - QTabBar *tabBar = qFindChild(tabWidget); - for (tab = 0; tab < tabBar->count(); ++tab) { - viewer = qobject_cast(tabWidget->widget(tab)); - if (viewer && viewer->source() == url) - break; - } + QTabBar *tabBar = qFindChild(tabWidget); + for (int tab = 0; tab < tabBar->count(); ++tab) { + HelpViewer* viewer = qobject_cast(tabWidget->widget(tab)); + if (viewer) + tabWidget->setTabText(tab, viewer->documentTitle().trimmed()); } #else - Q_UNUSED(url) -#endif - + HelpViewer* viewer = currentHelpViewer(); if (viewer) { - tabWidget->setTabText(tab, + tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle().trimmed())); } +#endif } void CentralWidget::currentPageChanged(int index) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 5ce6e14..5726136 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -393,6 +393,7 @@ void HelpViewer::mousePressEvent(QMouseEvent *event) void HelpViewer::setLoadFinished(bool ok) { loadFinished = ok; + emit sourceChanged(url()); } #else // !defined(QT_NO_WEBKIT) -- cgit v0.12 From ed21b9dafea192ddd39f1d2a4abcb54962d6dfb8 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Fri, 24 Apr 2009 17:34:28 +0200 Subject: Sometimes wrong clipping in QWidget::render() when passing a device or an untransformed painter When passing a painter to QWidget::render, we use the painter->paintEngine()->systemClip() as the "system viewport", i.e. all painting triggered by render() should be limited to this area. The only way to achieve this is by always ensuring the system clip is clipped to the same area (systemClip &= systemViewport). The problem however, was that we only did this for transformed painters. We must of course always do it when there's a systemViewport set, regardless of whether the painter is transformed or not. Auto test included. Task-number: 248852 Reviewed-by: Trond --- src/gui/kernel/qwidget.cpp | 11 +++-- src/gui/painting/qpaintengine.cpp | 4 +- src/gui/painting/qpaintengine_p.h | 12 +++-- tests/auto/qwidget/tst_qwidget.cpp | 98 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 071e1bd..e9fd28b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4709,10 +4709,13 @@ void QWidget::render(QPaintDevice *target, const QPoint &targetOffset, if (redirected) { target = redirected; offset -= redirectionOffset; - if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). - const QRegion redirectedSystemClip = redirected->paintEngine()->systemClip(); - if (!redirectedSystemClip.isEmpty()) - paintRegion &= redirectedSystemClip.translated(-offset); + } + + if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). + if (QPaintEngine *targetEngine = target->paintEngine()) { + const QRegion targetSystemClip = targetEngine->systemClip(); + if (!targetSystemClip.isEmpty()) + paintRegion &= targetSystemClip.translated(-offset); } } diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index ad09060..7de1ec4 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -949,8 +949,8 @@ void QPaintEngine::setSystemClip(const QRegion ®ion) Q_D(QPaintEngine); d->systemClip = region; // Be backward compatible and only call d->systemStateChanged() - // if we currently have a system transform set. - if (d->hasSystemTransform) { + // if we currently have a system transform/viewport set. + if (d->hasSystemTransform || d->hasSystemViewport) { d->transformSystemClip(); d->systemStateChanged(); } diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h index eeba7ec..0b5e175 100644 --- a/src/gui/painting/qpaintengine_p.h +++ b/src/gui/painting/qpaintengine_p.h @@ -83,10 +83,12 @@ public: if (systemClip.isEmpty()) return; - if (systemTransform.type() <= QTransform::TxTranslate) - systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy())); - else - systemClip = systemTransform.map(systemClip); + if (hasSystemTransform) { + if (systemTransform.type() <= QTransform::TxTranslate) + systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy())); + else + systemClip = systemTransform.map(systemClip); + } // Make sure we're inside the viewport. if (hasSystemViewport) { @@ -101,7 +103,7 @@ public: inline void setSystemTransform(const QTransform &xform) { systemTransform = xform; - if ((hasSystemTransform = !xform.isIdentity())) + if ((hasSystemTransform = !xform.isIdentity()) || hasSystemViewport) transformSystemClip(); systemStateChanged(); } diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index a052034..767553a 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -283,6 +283,8 @@ private slots: void render_task217815(); void render_windowOpacity(); void render_systemClip(); + void render_systemClip2_data(); + void render_systemClip2(); void setContentsMargins(); @@ -6897,6 +6899,102 @@ void tst_QWidget::render_systemClip() #endif } +void tst_QWidget::render_systemClip2_data() +{ + QTest::addColumn("autoFillBackground"); + QTest::addColumn("usePaintEvent"); + QTest::addColumn("expectedColor"); + + QTest::newRow("Only auto-fill background") << true << false << QColor(Qt::blue); + QTest::newRow("Only draw in paintEvent") << false << true << QColor(Qt::green); + QTest::newRow("Auto-fill background and draw in paintEvent") << true << true << QColor(Qt::green); +} + +void tst_QWidget::render_systemClip2() +{ + QFETCH(bool, autoFillBackground); + QFETCH(bool, usePaintEvent); + QFETCH(QColor, expectedColor); + + Q_ASSERT_X(expectedColor != QColor(Qt::red), Q_FUNC_INFO, + "Qt::red is the reference color for the image, pick another color"); + + class MyWidget : public QWidget + { + public: + bool usePaintEvent; + void paintEvent(QPaintEvent *) + { + if (usePaintEvent) + QPainter(this).fillRect(rect(), Qt::green); + } + }; + + MyWidget widget; + widget.usePaintEvent = usePaintEvent; + widget.setPalette(Qt::blue); + // NB! widget.setAutoFillBackground(autoFillBackground) won't do the + // trick here since the widget is a top-level. The background is filled + // regardless, unless Qt::WA_OpaquePaintEvent or Qt::WA_NoSystemBackground + // is set. We therefore use the opaque attribute to turn off auto-fill. + if (!autoFillBackground) + widget.setAttribute(Qt::WA_OpaquePaintEvent); + widget.resize(100, 100); + + QImage image(widget.size(), QImage::Format_RGB32); + image.fill(QColor(Qt::red).rgb()); + + QPaintEngine *paintEngine = image.paintEngine(); + QVERIFY(paintEngine); + + QRegion systemClip(QRegion(50, 0, 50, 10)); + systemClip += QRegion(90, 10, 10, 40); + paintEngine->setSystemClip(systemClip); + + // Render entire widget directly onto device. + widget.render(&image); + +#ifndef RENDER_DEBUG + image.save("systemclip_with_device.png"); +#endif + // All pixels within the system clip should now be + // the expectedColor, and the rest should be red. + for (int i = 0; i < image.height(); ++i) { + for (int j = 0; j < image.width(); ++j) { + if (systemClip.contains(QPoint(j, i))) + QCOMPARE(image.pixel(j, i), expectedColor.rgb()); + else + QCOMPARE(image.pixel(j, i), QColor(Qt::red).rgb()); + } + } + + // Refill image with red. + image.fill(QColor(Qt::red).rgb()); + + // Do the same with an untransformed painter. + QPainter painter(&image); + //Make sure we're using the same paint engine and has the right clip set. + paintEngine->setSystemClip(systemClip); + QCOMPARE(painter.paintEngine(), paintEngine); + QCOMPARE(paintEngine->systemClip(), systemClip); + + widget.render(&painter); + +#ifndef RENDER_DEBUG + image.save("systemclip_with_untransformed_painter.png"); +#endif + // All pixels within the system clip should now be + // the expectedColor, and the rest should be red. + for (int i = 0; i < image.height(); ++i) { + for (int j = 0; j < image.width(); ++j) { + if (systemClip.contains(QPoint(j, i))) + QCOMPARE(image.pixel(j, i), expectedColor.rgb()); + else + QCOMPARE(image.pixel(j, i), QColor(Qt::red).rgb()); + } + } +} + void tst_QWidget::setContentsMargins() { QLabel label("why does it always rain on me?"); -- cgit v0.12 From 8b5a400581b9c037d12a9f49e075b187edcb0b00 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Fri, 24 Apr 2009 19:54:44 +0200 Subject: fixed minor issue with the piechart demo The rubberband was not set on the viewport, leading to an offset when adding margins. Task-number: 251892 Reviewed-by: Alexis --- examples/itemviews/chart/pieview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/itemviews/chart/pieview.cpp b/examples/itemviews/chart/pieview.cpp index 6b62f25..48f4073 100644 --- a/examples/itemviews/chart/pieview.cpp +++ b/examples/itemviews/chart/pieview.cpp @@ -254,7 +254,7 @@ void PieView::mousePressEvent(QMouseEvent *event) QAbstractItemView::mousePressEvent(event); origin = event->pos(); if (!rubberBand) - rubberBand = new QRubberBand(QRubberBand::Rectangle, this); + rubberBand = new QRubberBand(QRubberBand::Rectangle, viewport()); rubberBand->setGeometry(QRect(origin, QSize())); rubberBand->show(); } -- cgit v0.12 From 2f074e4241113ac7e75bd7647286077bd7e49f94 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 27 Apr 2009 16:00:59 +1000 Subject: Increment Qt version number in qdoc namespaces. As we saw with the 4.5.1 release, failing to increment the namespaces when incrementing the Qt version causes some featuresof Assistant to break. Reviewed-by: Trust Me --- doc/src/known-issues.qdoc | 9 ++++----- tools/qdoc3/test/assistant.qdocconf | 2 +- tools/qdoc3/test/designer.qdocconf | 2 +- tools/qdoc3/test/linguist.qdocconf | 2 +- tools/qdoc3/test/qmake.qdocconf | 2 +- tools/qdoc3/test/qt-build-docs.qdocconf | 2 +- tools/qdoc3/test/qt.qdocconf | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/doc/src/known-issues.qdoc b/doc/src/known-issues.qdoc index 60fd63d..91e122f 100644 --- a/doc/src/known-issues.qdoc +++ b/doc/src/known-issues.qdoc @@ -60,11 +60,10 @@ \section2 Intel Compiler Support - Although it is possible to build applications against Qt 4.5.0 using Intel - CC 10, these applications will crash when run. A fix for this issue is - scheduled for Qt 4.5.1. We recommend that developers who rely on this - compiler wait until the fix is applied before upgrading to the Qt 4.5.x - series of releases. + Although it is possible to build applications against Qt 4.5.x using Intel + CC 10, these applications will crash when run. We recommend that developers + who rely on this compiler wait until a fix is available before upgrading to + the Qt 4.5.x series of releases. \section2 X11 Hardware Support diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf index 67f1ecb..a3213c6 100644 --- a/tools/qdoc3/test/assistant.qdocconf +++ b/tools/qdoc3/test/assistant.qdocconf @@ -13,7 +13,7 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Assistant qhp.Assistant.file = assistant.qhp -qhp.Assistant.namespace = com.trolltech.assistant.451 +qhp.Assistant.namespace = com.trolltech.assistant.452 qhp.Assistant.virtualFolder = qdoc qhp.Assistant.indexTitle = Qt Assistant Manual qhp.Assistant.extraFiles = classic.css images/qt-logo.png images/trolltech-logo.png diff --git a/tools/qdoc3/test/designer.qdocconf b/tools/qdoc3/test/designer.qdocconf index 3e916a2..63226f6 100644 --- a/tools/qdoc3/test/designer.qdocconf +++ b/tools/qdoc3/test/designer.qdocconf @@ -13,7 +13,7 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Designer qhp.Designer.file = designer.qhp -qhp.Designer.namespace = com.trolltech.designer.451 +qhp.Designer.namespace = com.trolltech.designer.452 qhp.Designer.virtualFolder = qdoc qhp.Designer.indexTitle = Qt Designer Manual qhp.Designer.extraFiles = classic.css images/qt-logo.png images/trolltech-logo.png diff --git a/tools/qdoc3/test/linguist.qdocconf b/tools/qdoc3/test/linguist.qdocconf index adb8c20..8e33e4b 100644 --- a/tools/qdoc3/test/linguist.qdocconf +++ b/tools/qdoc3/test/linguist.qdocconf @@ -13,7 +13,7 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Linguist qhp.Linguist.file = linguist.qhp -qhp.Linguist.namespace = com.trolltech.linguist.451 +qhp.Linguist.namespace = com.trolltech.linguist.452 qhp.Linguist.virtualFolder = qdoc qhp.Linguist.indexTitle = Qt Linguist Manual qhp.Linguist.extraFiles = classic.css images/qt-logo.png images/trolltech-logo.png diff --git a/tools/qdoc3/test/qmake.qdocconf b/tools/qdoc3/test/qmake.qdocconf index aa7e1ad..4e735b0 100644 --- a/tools/qdoc3/test/qmake.qdocconf +++ b/tools/qdoc3/test/qmake.qdocconf @@ -13,7 +13,7 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = qmake qhp.qmake.file = qmake.qhp -qhp.qmake.namespace = com.trolltech.qmake.451 +qhp.qmake.namespace = com.trolltech.qmake.452 qhp.qmake.virtualFolder = qdoc qhp.qmake.indexTitle = QMake Manual qhp.qmake.extraFiles = classic.css images/qt-logo.png images/trolltech-logo.png diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index a1baf2f..f7cd498 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -20,7 +20,7 @@ edition.DesktopLight.groups = -graphicsview-api qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.451 +qhp.Qt.namespace = com.trolltech.qt.452 qhp.Qt.virtualFolder = qdoc qhp.Qt.indexTitle = Qt Reference Documentation qhp.Qt.indexRoot = diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index 8859511..57eaf7a 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -22,7 +22,7 @@ edition.DesktopLight.groups = -graphicsview-api qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.451 +qhp.Qt.namespace = com.trolltech.qt.452 qhp.Qt.virtualFolder = qdoc qhp.Qt.indexTitle = Qt Reference Documentation qhp.Qt.indexRoot = -- cgit v0.12 From 4e356720440d6a99a9516d10e2705cd99f08fbdd Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 27 Apr 2009 16:37:53 +1000 Subject: Create the placeholder changes file for Qt 4.5.2. Reviewed-by: Trust Me --- dist/changes-4.5.2 | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 dist/changes-4.5.2 diff --git a/dist/changes-4.5.2 b/dist/changes-4.5.2 new file mode 100644 index 0000000..a772bf7 --- /dev/null +++ b/dist/changes-4.5.2 @@ -0,0 +1,123 @@ +Qt 4.5.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 4.5.0. For more details, +refer to the online documentation included in this distribution. The +documentation is also available online: + + http://doc.trolltech.com/4.5 + +The Qt version 4.5 series is binary compatible with the 4.4.x series. +Applications compiled for 4.4 will continue to run with 4.5. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Task Tracker: + + http://www.qtsoftware.com/developer/task-tracker + +Each of these identifiers can be entered in the task tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + +General Improvements +-------------------- + +- Documentation and Examples + +Third party components +---------------------- + + +**************************************************************************** +* Library * +**************************************************************************** + + +**************************************************************************** +* Database Drivers * +**************************************************************************** + + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +Qt for Linux/X11 +---------------- + + +Qt for Windows +-------------- + + +Qt for Mac OS X +--------------- + + +Qt for Embedded Linux +--------------------- + + +Qt for Windows CE +----------------- + + +**************************************************************************** +* Compiler Specific Changes * +**************************************************************************** + + +**************************************************************************** +* Tools * +**************************************************************************** + +- Build System + +- Assistant + + +- Designer + + +- Linguist + - Linguist GUI + + - lupdate + + - lrelease + + +- rcc + + +- moc + + +- uic + + +- uic3 + + +- qmake + + +- configure + + +- qtconfig + + +- qt3to4 + + +**************************************************************************** +* Plugins * +**************************************************************************** + + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + -- cgit v0.12 From 63a4d6652aa8d84282083e49217120c97bb0bfc8 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 27 Apr 2009 11:36:12 +0200 Subject: Document what QWidget::winId() returns on Mac OS X. There are different types depending on Carbon and Cocoa, and it is probably helpful to point that out. Task-number: 251001 Reviewed-by: Kavindra --- src/gui/kernel/qwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e9fd28b..eb2e9f7 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2132,6 +2132,10 @@ QWidget *QWidget::find(WId id) If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle. + On Mac OS X, the type returned depends on which framework Qt was linked + against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt + is using Cocoa, {WId} is a pointer to an NSView. + \note We recommend that you do not store this value as it is likely to change at run-time. -- cgit v0.12 From 96a27e24eec9356e45f1a6b6ff641a9afab24a39 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 27 Apr 2009 14:22:14 +0200 Subject: Make dark color schemes look better in property editor (especially schemes which have a grey color for text) Task: 252251 RevBy: Markus Goetz --- tools/designer/src/components/propertyeditor/propertyeditor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.cpp b/tools/designer/src/components/propertyeditor/propertyeditor.cpp index 63b57d8..806e1dd 100644 --- a/tools/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/tools/designer/src/components/propertyeditor/propertyeditor.cpp @@ -205,14 +205,15 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare colors.push_back(QColor(234, 191, 255)); colors.push_back(QColor(255, 191, 239)); m_colors.reserve(colors.count()); + const int darknessFactor = 250; for (int i = 0; i < colors.count(); i++) { QColor c = colors.at(i); - m_colors.push_back(qMakePair(c, c.darker(150))); + m_colors.push_back(qMakePair(c, c.darker(darknessFactor))); } QColor dynamicColor(191, 207, 255); QColor layoutColor(255, 191, 191); - m_dynamicColor = qMakePair(dynamicColor, dynamicColor.darker(150)); - m_layoutColor = qMakePair(layoutColor, layoutColor.darker(150)); + m_dynamicColor = qMakePair(dynamicColor, dynamicColor.darker(darknessFactor)); + m_layoutColor = qMakePair(layoutColor, layoutColor.darker(darknessFactor)); updateForegroundBrightness(); -- cgit v0.12 From c1ba5146a5ce2919df1529aa1202f6f3687071a0 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 27 Apr 2009 15:01:28 +0200 Subject: Ensure that QFontDialog::getFont() works on Mac OS X. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems that running the font dialog modal means that the "fontChanged" action is not fired. Which means our font is never changed. Thankfully, since it's an app modal case, we can re-sync when the OK button is clicked. Task-number: 252000 Reviewed-by: Morten Sørvig --- src/gui/dialogs/qfontdialog_mac.mm | 67 +++++++++++++++----------------------- 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm index 42be3be..50917a1 100644 --- a/src/gui/dialogs/qfontdialog_mac.mm +++ b/src/gui/dialogs/qfontdialog_mac.mm @@ -87,7 +87,6 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin NSButton *mOkButton; NSButton *mCancelButton; QFontDialogPrivate *mPriv; - NSFont *mCocoaFont; QFont *mQtFont; BOOL mPanelHackedWithButtons; CGFloat mDialogExtraWidth; @@ -119,6 +118,29 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin - (void)cleanUpAfterMyself; @end +static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) +{ + QFont newFont; + if (cocoaFont) { + int pSize = qRound([cocoaFont pointSize]); + QString family(QCFString::toQString(reinterpret_cast([cocoaFont familyName]))); + QString typeface(QCFString::toQString(reinterpret_cast([cocoaFont fontName]))); +// qDebug() << "original family" << family << "typeface" << typeface << "psize" << pSize; + int hyphenPos = typeface.indexOf(QLatin1Char('-')); + if (hyphenPos != -1) { + typeface.remove(0, hyphenPos + 1); + } else { + typeface = QLatin1String("Normal"); + } +// qDebug() << " massaged family" << family << "typeface" << typeface << "psize" << pSize; + newFont = QFontDatabase().font(family, typeface, pSize); + newFont.setUnderline(resolveFont.underline()); + newFont.setStrikeOut(resolveFont.strikeOut()); + + } + return newFont; +} + @implementation QCocoaFontPanelDelegate - (id)initWithFontPanel:(NSFontPanel *)panel stolenContentView:(NSView *)stolenContentView @@ -134,7 +156,6 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin mOkButton = okButton; mCancelButton = cancelButton; mPriv = priv; - mCocoaFont = 0; mPanelHackedWithButtons = (okButton != 0); mDialogExtraWidth = extraWidth; mDialogExtraHeight = extraHeight; @@ -155,42 +176,14 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin - (void)dealloc { - if (mCocoaFont) - [mCocoaFont release]; delete mQtFont; [super dealloc]; } - (void)changeFont:(id)sender { - Q_UNUSED(sender); - - QFont newFont; - - if (mCocoaFont) - [mCocoaFont autorelease]; NSFont *dummyFont = [NSFont userFontOfSize:12.0]; - mCocoaFont = [sender convertFont:dummyFont]; - if (mCocoaFont) { - [mCocoaFont retain]; - - int pSize = qRound([mCocoaFont pointSize]); - QString family(QCFString::toQString(reinterpret_cast([mCocoaFont familyName]))); - QString typeface(QCFString::toQString(reinterpret_cast([mCocoaFont fontName]))); -// qDebug() << "original family" << family << "typeface" << typeface << "psize" << pSize; - int hyphenPos = typeface.indexOf(QLatin1Char('-')); - if (hyphenPos != -1) { - typeface.remove(0, hyphenPos + 1); - } else { - typeface = QLatin1String("Normal"); - } -// qDebug() << " massaged family" << family << "typeface" << typeface << "psize" << pSize; - newFont = QFontDatabase().font(family, typeface, pSize); - newFont.setUnderline(mQtFont->underline()); - newFont.setStrikeOut(mQtFont->strikeOut()); - } - - [self setQtFont:newFont]; + [self setQtFont:qfontForCocoaFont([sender convertFont:dummyFont], *mQtFont)]; if (mPriv) mPriv->updateSampleFont(*mQtFont); } @@ -317,6 +310,9 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin - (void)onOkClicked { Q_ASSERT(mPanelHackedWithButtons); + NSFontManager *fontManager = [NSFontManager sharedFontManager]; + [self setQtFont:qfontForCocoaFont([fontManager convertFont:[fontManager selectedFont]], + *mQtFont)]; [[mStolenContentView window] close]; [self finishOffWithCode:NSOKButton]; } @@ -374,16 +370,7 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin mModalSession = 0; } - // temporary hack to work around bug in deleteLater() in Qt/Mac Cocoa -#if 1 - bool deleteDialog = mPriv->fontDialog()->testAttribute(Qt::WA_DeleteOnClose); - mPriv->fontDialog()->setAttribute(Qt::WA_DeleteOnClose, false); -#endif mPriv->done((code == NSOKButton) ? QDialog::Accepted : QDialog::Rejected); -#if 1 - if (deleteDialog) - delete mPriv->fontDialog(); -#endif } else { [NSApp stopModalWithCode:code]; } -- cgit v0.12 From e7fdaf47dfdf5e2f6056aa5d5b4644e74a05492a Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Mon, 27 Apr 2009 16:11:21 +0200 Subject: Doc - cleaning up some documentation for QFileDialog and obsolete documentation. getOpenFileNames() and getExistingDirectory() mentioned that the dir parameter was ignored. This is no longer the case. This bit was reviewed by nrc, the other fixes were just cleanups. Task-number: 252223 Reviewed-by: nrc --- src/gui/dialogs/qfiledialog.cpp | 263 ++++++++++++++++++++-------------------- 1 file changed, 129 insertions(+), 134 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index d786f3e..073c25b 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -1538,52 +1538,51 @@ extern QString qt_win_get_existing_directory(const QFileDialogArgs &args); #endif /*! - This is a convenience static function that returns an existing file - selected by the user. If the user presses Cancel, it returns a null - string. + This is a convenience static function that returns an existing file + selected by the user. If the user presses Cancel, it returns a null string. - \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 8 + \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 8 - The function creates a modal file dialog with the given \a parent widget. - If the parent is not 0, the dialog will be shown centered over the - parent widget. + The function creates a modal file dialog with the given \a parent widget. + If \a parent is not 0, the dialog will be shown centered over the parent + widget. - The file dialog's working directory will be set to \a dir. If \a - dir includes a file name, the file will be selected. Only files - that match the given \a filter are shown. The filter selected is - set to \a selectedFilter. The parameters \a dir, \a - selectedFilter, and \a filter may be empty strings. If you want - multiple filters, separate them with ';;', for example: + The file dialog's working directory will be set to \a dir. If \a dir + includes a file name, the file will be selected. Only files that match the + given \a filter are shown. The filter selected is set to \a selectedFilter. + The parameters \a dir, \a selectedFilter, and \a filter may be empty + strings. If you want multiple filters, separate them with ';;', for + example: - \code + \code "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" - \endcode + \endcode - The \a options argument holds various - options about how to run the dialog, see the QFileDialog::Option enum for - more information on the flags you can pass. + The \a options argument holds various options about how to run the dialog, + see the QFileDialog::Option enum for more information on the flags you can + pass. - The dialog's caption is set to \a caption. If \a caption is not - specified then a default caption will be used. + The dialog's caption is set to \a caption. If \a caption is not specified + then a default caption will be used. - Under Windows and Mac OS X, this static function will use the native - file dialog and not a QFileDialog. + On Windows and Mac OS X, this static function will use the native file + dialog and not a QFileDialog. - Note that on Windows the dialog will spin a blocking modal event loop - that will not dispatch any QTimers, and if parent is not 0 then it will - position the dialog just under the parent's title bar. + On Windows the dialog will spin a blocking modal event loop that will not + dispatch any QTimers, and if \a parent is not 0 then it will position the + dialog just below the parent's title bar. - Under Unix/X11, the normal behavior of the file dialog is to resolve - and follow symlinks. For example, if \c{/usr/tmp} is a symlink to - \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after - entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks, - the file dialog will treat symlinks as regular directories. + On Unix/X11, the normal behavior of the file dialog is to resolve and + follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, + the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If + \a options includes DontResolveSymlinks, the file dialog will treat + symlinks as regular directories. - \warning Do not delete \a parent during the execution of the dialog. - If you want to do this, you should create the dialog - yourself using one of the QFileDialog constructors. + \warning Do not delete \a parent during the execution of the dialog. If you + want to do this, you should create the dialog yourself using one of the + QFileDialog constructors. - \sa getOpenFileNames(), getSaveFileName(), getExistingDirectory() + \sa getOpenFileNames(), getSaveFileName(), getExistingDirectory() */ QString QFileDialog::getOpenFileName(QWidget *parent, const QString &caption, @@ -1626,54 +1625,53 @@ QString QFileDialog::getOpenFileName(QWidget *parent, } /*! - This is a convenience static function that will return one or more - existing files selected by the user. + This is a convenience static function that will return one or more existing + files selected by the user. - \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 9 + \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 9 - This function creates a modal file dialog with the given \a parent - widget. If the parent is not 0, the dialog will be shown centered - over the parent widget. + This function creates a modal file dialog with the given \a parent widget. + If \a parent is not 0, the dialog will be shown centered over the parent + widget. - The file dialog's working directory will be set to \a dir. If \a - dir includes a file name, the file will be selected. The filter - is set to \a filter so that only those files which match the filter - are shown. The filter selected is set to \a selectedFilter. The parameters - \a dir, \a selectedFilter and \a filter may be empty strings. If you - need multiple filters, separate them with ';;', for instance: + The file dialog's working directory will be set to \a dir. If \a dir + includes a file name, the file will be selected. The filter is set to + \a filter so that only those files which match the filter are shown. The + filter selected is set to \a selectedFilter. The parameters \a dir, + \a selectedFilter and \a filter may be empty strings. If you need multiple + filters, separate them with ';;', for instance: - \code + \code "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" - \endcode + \endcode - The dialog's caption is set to \a caption. If \a caption is not - specified then a default caption will be used. + The dialog's caption is set to \a caption. If \a caption is not specified + then a default caption will be used. - Under Windows and Mac OS X, this static function will use the native - file dialog and not a QFileDialog. On Mac OS X, the \a dir argument - is ignored, the native dialog always displays the last visited directory. + On Windows and Mac OS X, this static function will use the native file + dialog and not a QFileDialog. - Note that on Windows the dialog will spin a blocking modal event loop - that will not dispatch any QTimers, and if parent is not 0 then it will - position the dialog just under the parent's title bar. + On Windows the dialog will spin a blocking modal event loop that will not + dispatch any QTimers, and if \a parent is not 0 then it will position the + dialog just below the parent's title bar. - Under Unix/X11, the normal behavior of the file dialog is to resolve - and follow symlinks. For example, if \c{/usr/tmp} is a symlink to - \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after - entering \c{/usr/tmp}. The \a options argument holds various - options about how to run the dialog, see the QFileDialog::Option enum for - more information on the flags you can pass. + On Unix/X11, the normal behavior of the file dialog is to resolve and + follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, + the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. + The \a options argument holds various options about how to run the dialog, + see the QFileDialog::Option enum for more information on the flags you can + pass. - Note that if you want to iterate over the list of files, you should - iterate over a copy. For example: + \note If you want to iterate over the list of files, you should iterate + over a copy. For example: \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 10 - \warning Do not delete \a parent during the execution of the dialog. - If you want to do this, you should create the dialog - yourself using one of the QFileDialog constructors. + \warning Do not delete \a parent during the execution of the dialog. If you + want to do this, you should create the dialog yourself using one of the + QFileDialog constructors. - \sa getOpenFileName(), getSaveFileName(), getExistingDirectory() + \sa getOpenFileName(), getSaveFileName(), getExistingDirectory() */ QStringList QFileDialog::getOpenFileNames(QWidget *parent, const QString &caption, @@ -1717,54 +1715,54 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent, } /*! - This is a convenience static function that will return a file name - selected by the user. The file does not have to exist. + This is a convenience static function that will return a file name selected + by the user. The file does not have to exist. - It creates a modal file dialog with the given \a parent widget. If the - parent is not 0, the dialog will be shown centered over the parent - widget. + It creates a modal file dialog with the given \a parent widget. If + \a parent is not 0, the dialog will be shown centered over the parent + widget. - \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 11 + \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 11 - The file dialog's working directory will be set to \a dir. If \a - dir includes a file name, the file will be selected. Only files that - match the \a filter are shown. The filter selected is set to - \a selectedFilter. The parameters \a dir, \a selectedFilter, and - \a filter may be empty strings. Multiple filters are separated with ';;'. - For instance: + The file dialog's working directory will be set to \a dir. If \a dir + includes a file name, the file will be selected. Only files that match the + \a filter are shown. The filter selected is set to \a selectedFilter. The + parameters \a dir, \a selectedFilter, and \a filter may be empty strings. + Multiple filters are separated with ';;'. For instance: - \code + \code "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" - \endcode + \endcode - The \a options argument holds various - options about how to run the dialog, see the QFileDialog::Option enum for - more information on the flags you can pass. + The \a options argument holds various options about how to run the dialog, + see the QFileDialog::Option enum for more information on the flags you can + pass. - The default filter can be chosen by setting \a selectedFilter to the desired value. + The default filter can be chosen by setting \a selectedFilter to the + desired value. - The dialog's caption is set to \a caption. If \a caption is not - specified then a default caption will be used. + The dialog's caption is set to \a caption. If \a caption is not specified, + a default caption will be used. - Under Windows and Mac OS X, this static function will use the native - file dialog and not a QFileDialog. + On Windows and Mac OS X, this static function will use the native file + dialog and not a QFileDialog. - Note that on Windows the dialog will spin a blocking modal event loop - that will not dispatch any QTimers, and if parent is not 0 then it will - position the dialog just under the parent's title bar. - On Mac OS X, the filter argument is ignored. + On Windows the dialog will spin a blocking modal event loop that will not + dispatch any QTimers, and if \a parent is not 0 then it will position the + dialog just below the parent's title bar. On Mac OS X, with its native file + dialog, the filter argument is ignored. - Under Unix/X11, the normal behavior of the file dialog is to resolve - and follow symlinks. For example, if \c{/usr/tmp} is a symlink to - \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after - entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks, - the file dialog will treat symlinks as regular directories. + On Unix/X11, the normal behavior of the file dialog is to resolve and + follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, + the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If + \a options includes DontResolveSymlinks the file dialog will treat symlinks + as regular directories. - \warning Do not delete \a parent during the execution of the dialog. - If you want to do this, you should create the dialog - yourself using one of the QFileDialog constructors. + \warning Do not delete \a parent during the execution of the dialog. If you + want to do this, you should create the dialog yourself using one of the + QFileDialog constructors. - \sa getOpenFileName(), getOpenFileNames(), getExistingDirectory() + \sa getOpenFileName(), getOpenFileNames(), getExistingDirectory() */ QString QFileDialog::getSaveFileName(QWidget *parent, const QString &caption, @@ -1810,46 +1808,43 @@ QString QFileDialog::getSaveFileName(QWidget *parent, } /*! - This is a convenience static function that will return an existing - directory selected by the user. + This is a convenience static function that will return an existing + directory selected by the user. - \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 12 + \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 12 - This function creates a modal file dialog with the given \a parent - widget. If the parent is not 0, the dialog will be shown centered over - the parent widget. + This function creates a modal file dialog with the given \a parent widget. + If \a parent is not 0, the dialog will be shown centered over the parent + widget. - The dialog's working directory is set to \a dir, and the caption is - set to \a caption. Either of these may be an empty string in which case - the current directory and a default caption will be used - respectively. + The dialog's working directory is set to \a dir, and the caption is set to + \a caption. Either of these may be an empty string in which case the + current directory and a default caption will be used respectively. - The \a options argument holds various - options about how to run the dialog, see the QFileDialog::Option enum for - more information on the flags you can pass. Note that \l{QFileDialog::}{ShowDirsOnly} - must be set to ensure a native file dialog. + The \a options argument holds various options about how to run the dialog, + see the QFileDialog::Option enum for more information on the flags you can + pass. To ensure a native file dialog, \l{QFileDialog::}{ShowDirsOnly} must + be set. - Under Windows and Mac OS X, this static function will use the native - file dialog and not a QFileDialog. On Mac OS X, the \a dir argument - is ignored, the native dialog always displays the last visited directory. - On Windows CE, if the device has no native file dialog, a QFileDialog - will be used. + On Windows and Mac OS X, this static function will use the native file + dialog and not a QFileDialog. On Windows CE, if the device has no native + file dialog, a QFileDialog will be used. - Under Unix/X11, the normal behavior of the file dialog is to resolve - and follow symlinks. For example, if \c{/usr/tmp} is a symlink to - \c{/var/tmp}, the file dialog will change to \c{/var/tmp} after - entering \c{/usr/tmp}. If \a options includes DontResolveSymlinks, - the file dialog will treat symlinks as regular directories. + On Unix/X11, the normal behavior of the file dialog is to resolve and + follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp}, + the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If + \a options includes DontResolveSymlinks, the file dialog will treat + symlinks as regular directories. - Note that on Windows the dialog will spin a blocking modal event loop - that will not dispatch any QTimers, and if parent is not 0 then it will - position the dialog just under the parent's title bar. + On Windows the dialog will spin a blocking modal event loop that will not + dispatch any QTimers, and if \a parent is not 0 then it will position the + dialog just below the parent's title bar. - \warning Do not delete \a parent during the execution of the dialog. - If you want to do this, you should create the dialog - yourself using one of the QFileDialog constructors. + \warning Do not delete \a parent during the execution of the dialog. If you + want to do this, you should create the dialog yourself using one of the + QFileDialog constructors. - \sa getOpenFileName(), getOpenFileNames(), getSaveFileName() + \sa getOpenFileName(), getOpenFileNames(), getSaveFileName() */ QString QFileDialog::getExistingDirectory(QWidget *parent, const QString &caption, -- cgit v0.12 From ae949b9d21470a9b9bf200774c246a0b86a69ff6 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Mon, 27 Apr 2009 16:31:58 +0200 Subject: QPixmapCache:Remove the old pixmap if you insert one with the same key. If you insert a new pixmap in the cache with a key that was already in the cache then we remove the old pixmap and add the new one. This avoid to fill the memory with garbage even if the cache has a protection to avoid running out of memory. This was discovered with QraphicsView and its cache. We don't need to keep old cached pixmaps for an item. Task-number: KDE Reviewed-by: Trond --- src/gui/image/qpixmapcache.cpp | 5 +++++ tests/auto/qpixmapcache/tst_qpixmapcache.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index eedb6a3..458d6b9 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -187,6 +187,11 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) cacheKeys.insert(key, cacheKey); return true; } + qint64 oldCacheKey = cacheKeys.value(key, -1); + //If for the same key we add already a pixmap we should delete it + if (oldCacheKey != -1) + QCache::remove(oldCacheKey); + bool success = QCache::insert(cacheKey, new QDetachedPixmap(pixmap), cost); if (success) { cacheKeys.insert(key, cacheKey); diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp index c163b52..1f515ff 100644 --- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp @@ -166,6 +166,16 @@ void tst_QPixmapCache::insert() QVERIFY(estimatedNum - 1 <= num <= estimatedNum + 1); QPixmap p3; QPixmapCache::insert("null", p3); + + QPixmap c1(10, 10); + c1.fill(Qt::yellow); + QPixmapCache::insert("custom", c1); + QVERIFY(!c1.isDetached()); + QPixmap c2(10, 10); + c2.fill(Qt::red); + QPixmapCache::insert("custom", c2); + //We have deleted the old pixmap in the cache for the same key + QVERIFY(c1.isDetached()); } void tst_QPixmapCache::remove() -- cgit v0.12 From 73fefcfb67b2de42a0675eb88aaa5cb2751402e6 Mon Sep 17 00:00:00 2001 From: kh Date: Mon, 27 Apr 2009 17:30:20 +0200 Subject: fixes undefined behavior will closing all tabs Task-number: 249001, 236473 Reviewed-by: kh --- tools/assistant/tools/assistant/centralwidget.cpp | 241 ++++++++++++---------- tools/assistant/tools/assistant/centralwidget.h | 14 +- tools/assistant/tools/assistant/mainwindow.cpp | 10 +- tools/assistant/tools/assistant/mainwindow.h | 1 + tools/assistant/tools/assistant/searchwidget.cpp | 11 + tools/assistant/tools/assistant/searchwidget.h | 4 + 6 files changed, 165 insertions(+), 116 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 0a94a3d..f953ab7 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -161,7 +161,7 @@ void FindWidget::updateButtons() QToolButton* FindWidget::setupToolButton(const QString &text, const QString &icon) { - QToolButton* toolButton = new QToolButton(this); + QToolButton *toolButton = new QToolButton(this); toolButton->setText(text); toolButton->setAutoRaise(true); @@ -262,13 +262,16 @@ CentralWidget::~CentralWidget() QString zoomCount; QString currentPages; QLatin1Char separator('|'); - for (int i = 1; i < tabWidget->count(); ++i) { + int i = m_searchWidget->isAttached() ? 1 : 0; + + for (; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) { currentPages += viewer->source().toString() + separator; zoomCount += QString::number(viewer->zoom()) + separator; } } + engine.setCustomValue(QLatin1String("LastTabPage"), lastTabPage); engine.setCustomValue(QLatin1String("LastShownPages"), currentPages); #if !defined(QT_NO_WEBKIT) @@ -285,7 +288,7 @@ CentralWidget *CentralWidget::instance() void CentralWidget::newTab() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); #if !defined(QT_NO_WEBKIT) if (viewer && viewer->hasLoadFinished()) #else @@ -296,7 +299,7 @@ void CentralWidget::newTab() void CentralWidget::zoomIn() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->zoomIn(); @@ -306,7 +309,7 @@ void CentralWidget::zoomIn() void CentralWidget::zoomOut() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->zoomOut(); @@ -329,7 +332,7 @@ void CentralWidget::nextPage() void CentralWidget::resetZoom() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->resetZoom(); @@ -353,7 +356,7 @@ void CentralWidget::findPrevious() void CentralWidget::closeTab() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (!viewer|| tabWidget->count() == 1) return; @@ -363,8 +366,8 @@ void CentralWidget::closeTab() void CentralWidget::setSource(const QUrl &url) { - HelpViewer* viewer = currentHelpViewer(); - HelpViewer* lastViewer = qobject_cast(tabWidget->widget(lastTabPage)); + HelpViewer *viewer = currentHelpViewer(); + HelpViewer *lastViewer = qobject_cast(tabWidget->widget(lastTabPage)); if (!viewer && !lastViewer) { viewer = new HelpViewer(helpEngine, this); @@ -418,13 +421,13 @@ void CentralWidget::setLastShownPages() bool CentralWidget::hasSelection() const { - const HelpViewer* viewer = currentHelpViewer(); + const HelpViewer *viewer = currentHelpViewer(); return viewer ? viewer->hasSelection() : false; } QUrl CentralWidget::currentSource() const { - const HelpViewer* viewer = currentHelpViewer(); + const HelpViewer *viewer = currentHelpViewer(); if (viewer) return viewer->source(); @@ -433,7 +436,7 @@ QUrl CentralWidget::currentSource() const QString CentralWidget::currentTitle() const { - const HelpViewer* viewer = currentHelpViewer(); + const HelpViewer *viewer = currentHelpViewer(); if (viewer) return viewer->documentTitle(); @@ -442,7 +445,7 @@ QString CentralWidget::currentTitle() const void CentralWidget::copySelection() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->copy(); } @@ -465,7 +468,7 @@ void CentralWidget::initPrinter() void CentralWidget::print() { #ifndef QT_NO_PRINTER - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (!viewer) return; @@ -522,14 +525,14 @@ bool CentralWidget::isHomeAvailable() const void CentralWidget::home() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->home(); } bool CentralWidget::isForwardAvailable() const { - const HelpViewer* viewer = currentHelpViewer(); + const HelpViewer *viewer = currentHelpViewer(); if (viewer) return viewer->isForwardAvailable(); @@ -538,14 +541,14 @@ bool CentralWidget::isForwardAvailable() const void CentralWidget::forward() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->forward(); } bool CentralWidget::isBackwardAvailable() const { - const HelpViewer* viewer = currentHelpViewer(); + const HelpViewer *viewer = currentHelpViewer(); if (viewer) return viewer->isBackwardAvailable(); @@ -554,7 +557,7 @@ bool CentralWidget::isBackwardAvailable() const void CentralWidget::backward() { - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (viewer) viewer->backward(); } @@ -572,7 +575,7 @@ void CentralWidget::setGlobalActions(const QList &actions) void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) { - HelpViewer* viewer; + HelpViewer *viewer; #if defined(QT_NO_WEBKIT) viewer = currentHelpViewer(); @@ -595,20 +598,20 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) } #if !defined(QT_NO_WEBKIT) - QWebSettings* settings = QWebSettings::globalSettings(); + QWebSettings *settings = QWebSettings::globalSettings(); if (!userFont) { int fontSize = settings->fontSize(QWebSettings::DefaultFontSize); QString fontFamily = settings->fontFamily(QWebSettings::StandardFont); font = QFont(fontFamily, fontSize); } - QWebView* view = qobject_cast (viewer); + QWebView *view = qobject_cast (viewer); if (view) { settings = view->settings(); settings->setFontFamily(QWebSettings::StandardFont, font.family()); settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize()); } else if (viewer) { - viewer->setFont(font); + viewer->setFont(font); } viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); #else @@ -622,7 +625,7 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) HelpViewer *CentralWidget::newEmptyTab() { - HelpViewer* viewer = new HelpViewer(helpEngine, this); + HelpViewer *viewer = new HelpViewer(helpEngine, this); viewer->installEventFilter(this); viewer->setFocus(Qt::OtherFocusReason); #if defined(QT_NO_WEBKIT) @@ -641,7 +644,7 @@ void CentralWidget::findCurrentText(const QString &text) void CentralWidget::connectSignals() { - const HelpViewer* viewer = currentHelpViewer(); + const HelpViewer *viewer = currentHelpViewer(); if (viewer) { connect(viewer, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); @@ -676,18 +679,18 @@ void CentralWidget::activateTab(bool onlyHelpViewer) } } -void CentralWidget::setTabTitle(const QUrl& url) +void CentralWidget::setTabTitle(const QUrl &url) { Q_UNUSED(url) #if !defined(QT_NO_WEBKIT) QTabBar *tabBar = qFindChild(tabWidget); for (int tab = 0; tab < tabBar->count(); ++tab) { - HelpViewer* viewer = qobject_cast(tabWidget->widget(tab)); + HelpViewer *viewer = qobject_cast(tabWidget->widget(tab)); if (viewer) tabWidget->setTabText(tab, viewer->documentTitle().trimmed()); } #else - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); if (viewer) { tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle().trimmed())); @@ -698,61 +701,50 @@ void CentralWidget::setTabTitle(const QUrl& url) void CentralWidget::currentPageChanged(int index) { const HelpViewer *viewer = currentHelpViewer(); - - if (viewer || tabWidget->count() == 1) + if (viewer) lastTabPage = index; - bool enabled = false; - if (viewer) { - enabled = true; - if (!m_searchWidget) - enabled = tabWidget->count() > 1; - } + QWidget *widget = tabWidget->cornerWidget(Qt::TopRightCorner); + widget->setEnabled(viewer && enableTabCloseAction()); - QWidget *widget = tabWidget->cornerWidget(Qt::TopLeftCorner); - widget->setEnabled(m_searchWidget ? enabled : true); + widget = tabWidget->cornerWidget(Qt::TopLeftCorner); + widget->setEnabled(viewer ? true : false); - widget = tabWidget->cornerWidget(Qt::TopRightCorner); - widget->setEnabled(enabled); - - emit currentViewerChanged(); + emit currentViewerChanged(); } void CentralWidget::showTabBarContextMenu(const QPoint &point) { - HelpViewer* viewer = helpViewerFromTabPosition(tabWidget, point); + HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, point); if (!viewer) return; QTabBar *tabBar = qFindChild(tabWidget); QMenu menu(QLatin1String(""), tabBar); - QAction *new_page = menu.addAction(tr("Add New Page")); - QAction *close_page = menu.addAction(tr("Close This Page")); - QAction *close_pages = menu.addAction(tr("Close Other Pages")); - menu.addSeparator(); - QAction *newBookmark = menu.addAction(tr("Add Bookmark for this Page...")); + QAction *newPage = menu.addAction(tr("Add New Page")); - if (tabBar->count() == 1) { - close_page->setEnabled(false); - close_pages->setEnabled(false); - } else if (m_searchWidget && tabBar->count() == 2) { - close_pages->setEnabled(false); - } + bool enableAction = enableTabCloseAction(); + QAction *closePage = menu.addAction(tr("Close This Page")); + closePage->setEnabled(enableAction); - QAction *picked_action = menu.exec(tabBar->mapToGlobal(point)); - if (!picked_action) - return; + QAction *closePages = menu.addAction(tr("Close Other Pages")); + closePages->setEnabled(enableAction); - if (picked_action == new_page) + menu.addSeparator(); + + QAction *newBookmark = menu.addAction(tr("Add Bookmark for this Page...")); + + QAction *pickedAction = menu.exec(tabBar->mapToGlobal(point)); + if (pickedAction == newPage) setSourceInNewTab(viewer->source()); - if (picked_action == close_page) { + if (pickedAction == closePage) { tabWidget->removeTab(tabWidget->indexOf(viewer)); QTimer::singleShot(0, viewer, SLOT(deleteLater())); } - if (picked_action == close_pages) { + if (pickedAction == closePages) { int currentPage = tabWidget->indexOf(viewer); for (int i = tabBar->count() -1; i >= 0; --i) { viewer = qobject_cast(tabWidget->widget(i)); @@ -766,58 +758,68 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point) } } - if (picked_action == newBookmark) + if (pickedAction == newBookmark) emit addNewBookmark(viewer->documentTitle(), viewer->source().toString()); } bool CentralWidget::eventFilter(QObject *object, QEvent *e) { - if (currentHelpViewer() == object && e->type() == QEvent::KeyPress){ + if (e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(e); - if (ke->key() == Qt::Key_Backspace) { - HelpViewer *viewer = currentHelpViewer(); + switch (ke->key()) { + default: { + return QWidget::eventFilter(object, e); + } break; + + case Qt::Key_Escape: { + if (findWidget->editFind == object) { + findBar->hide(); + if (HelpViewer *viewer = currentHelpViewer()) + viewer->setFocus(); + } + } break; + + case Qt::Key_Backspace: { + HelpViewer *viewer = currentHelpViewer(); + if (viewer == object) { #if defined(QT_NO_WEBKIT) - if (viewer && viewer->isBackwardAvailable()) { + if (viewer->isBackwardAvailable()) { #else - if (viewer && viewer->isBackwardAvailable() && !viewer->hasFocus()) { + if (viewer->isBackwardAvailable() && !viewer->hasFocus()) { #endif - viewer->backward(); - return true; - } + viewer->backward(); + return true; + } + } + } break; } } - QTabBar *tabBar = qobject_cast(object); - bool mousRel = e->type() == QEvent::MouseButtonRelease; - bool dblClick = e->type() == QEvent::MouseButtonDblClick; - - if (tabBar && (mousRel || dblClick)) { - QMouseEvent *mouseEvent = static_cast(e); - HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, mouseEvent->pos()); - if (!m_searchWidget && tabWidget->count() <= 1) - return QWidget::eventFilter(object, e); - - if (viewer && (mouseEvent->button() == Qt::MidButton || dblClick)) { - tabWidget->removeTab(tabWidget->indexOf(viewer)); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); - currentPageChanged(tabWidget->currentIndex()); - return true; - } - } else if (object == findWidget->editFind && e->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast(e); - if (ke->key() == Qt::Key_Escape) { - findBar->hide(); - HelpViewer *hv = currentHelpViewer(); - if (hv) - hv->setFocus(); + if (QTabBar *tabBar = qobject_cast(object)) { + const bool dblClick = e->type() == QEvent::MouseButtonDblClick; + if ((e->type() == QEvent::MouseButtonRelease) || dblClick) { + QMouseEvent *mouseEvent = static_cast(e); + HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, + mouseEvent->pos()); + if (viewer) { + if ((mouseEvent->button() == Qt::MidButton) || dblClick) { + if (availableHelpViewer() > 1) { + tabWidget->removeTab(tabWidget->indexOf(viewer)); + QTimer::singleShot(0, viewer, SLOT(deleteLater())); + currentPageChanged(tabWidget->currentIndex()); + return true; + } + } + } } } + return QWidget::eventFilter(object, e); } void CentralWidget::keyPressEvent(QKeyEvent *e) { - QString text = e->text(); + const QString &text = e->text(); if (text.startsWith(QLatin1Char('/'))) { if (!findBar->isVisible()) { findBar->show(); @@ -837,7 +839,7 @@ void CentralWidget::find(QString ttf, bool forward, bool backward) QTextDocument *doc = 0; QTextBrowser *browser = 0; - HelpViewer* viewer = currentHelpViewer(); + HelpViewer *viewer = currentHelpViewer(); QPalette p = findWidget->editFind->palette(); p.setColor(QPalette::Active, QPalette::Base, Qt::white); @@ -876,7 +878,7 @@ void CentralWidget::find(QString ttf, bool forward, bool backward) } if (tabWidget->currentWidget() == m_searchWidget) { - QTextBrowser* browser = qFindChild(m_searchWidget); + QTextBrowser *browser = qFindChild(m_searchWidget); if (browser) { doc = browser->document(); cursor = browser->textCursor(); @@ -933,15 +935,6 @@ void CentralWidget::find(QString ttf, bool forward, bool backward) findWidget->editFind->setPalette(p); } -void CentralWidget::activateSearch() -{ - if (tabWidget->widget(0) != m_searchWidget) - createSearchWidget(helpEngine->searchEngine()); - - tabWidget->setCurrentWidget(m_searchWidget); - m_searchWidget->setFocus(); -} - void CentralWidget::updateBrowserFont() { QFont font = qApp->font(); @@ -952,7 +945,7 @@ void CentralWidget::updateBrowserFont() } #if !defined(QT_NO_WEBKIT) - QWebSettings* settings = QWebSettings::globalSettings(); + QWebSettings *settings = QWebSettings::globalSettings(); if (!userFont) { int fontSize = settings->fontSize(QWebSettings::DefaultFontSize); QString fontFamily = settings->fontFamily(QWebSettings::StandardFont); @@ -960,11 +953,11 @@ void CentralWidget::updateBrowserFont() } #endif - QWidget* widget = 0; + QWidget *widget = 0; for (int i = 0; i < tabWidget->count(); ++i) { widget = tabWidget->widget(i); #if !defined(QT_NO_WEBKIT) - QWebView* view = qobject_cast (widget); + QWebView *view = qobject_cast (widget); if (view) { settings = view->settings(); settings->setFontFamily(QWebSettings::StandardFont, font.family()); @@ -991,11 +984,41 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) SLOT(setSourceFromSearchInNewTab(QUrl))); } tabWidget->insertTab(0, m_searchWidget, tr("Search")); + m_searchWidget->setAttached(true); +} + +void CentralWidget::activateSearchWidget() +{ + if (!m_searchWidget->isAttached()) + createSearchWidget(helpEngine->searchEngine()); + + tabWidget->setCurrentWidget(m_searchWidget); + m_searchWidget->setFocus(); } void CentralWidget::removeSearchWidget() { - tabWidget->removeTab(0); + if (m_searchWidget && m_searchWidget->isAttached()) { + tabWidget->removeTab(0); + m_searchWidget->setAttached(false); + } +} + +int CentralWidget::availableHelpViewer() const +{ + int count = tabWidget->count(); + if (m_searchWidget && m_searchWidget->isAttached()) + count--; + return count; +} + +bool CentralWidget::enableTabCloseAction() const +{ + int minTabCount = 1; + if (m_searchWidget && m_searchWidget->isAttached()) + minTabCount = 2; + + return (tabWidget->count() > minTabCount); } QString CentralWidget::quoteTabTitle(const QString &title) const @@ -1026,7 +1049,7 @@ CentralWidget::highlightSearchTerms() if (!viewer) return; - QHelpSearchEngine* searchEngine = helpEngine->searchEngine(); + QHelpSearchEngine *searchEngine = helpEngine->searchEngine(); QList queryList = searchEngine->query(); QStringList terms; diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index a34ba65..2c28091 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -116,10 +116,14 @@ public: void setGlobalActions(const QList &actions); HelpViewer *currentHelpViewer() const; void activateTab(bool onlyHelpViewer = false); - void activateSearch(); + void createSearchWidget(QHelpSearchEngine *searchEngine); + void activateSearchWidget(); void removeSearchWidget(); + int availableHelpViewer() const; + bool enableTabCloseAction() const; + void closeTabAt(int index); QMap currentSourceFileList() const; @@ -170,7 +174,7 @@ private slots: void setSourceFromSearchInNewTab(const QUrl &url); private: - void connectSignals(); + void connectSignals(); bool eventFilter(QObject *object, QEvent *e); void find(QString ttf, bool forward, bool backward); void initPrinter(); @@ -183,13 +187,13 @@ private: QList globalActionList; QWidget *findBar; - QTabWidget* tabWidget; + QTabWidget *tabWidget; FindWidget *findWidget; QHelpEngine *helpEngine; QPrinter *printer; bool usesDefaultCollection; - - SearchWidget* m_searchWidget; + + SearchWidget *m_searchWidget; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 6e22413..426a828 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -535,6 +535,8 @@ void MainWindow::setupActions() SLOT(copyAvailable(bool))); connect(m_centralWidget, SIGNAL(currentViewerChanged()), this, SLOT(updateNavigationItems())); + connect(m_centralWidget, SIGNAL(currentViewerChanged()), this, + SLOT(updateTabCloseAction())); connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), this, SLOT(updateNavigationItems())); connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), this, @@ -697,10 +699,14 @@ void MainWindow::updateNavigationItems() m_printAction->setEnabled(hasCurrentViewer); m_nextAction->setEnabled(m_centralWidget->isForwardAvailable()); m_backAction->setEnabled(m_centralWidget->isBackwardAvailable()); - m_closeTabAction->setEnabled(hasCurrentViewer); m_newTabAction->setEnabled(hasCurrentViewer); } +void MainWindow::updateTabCloseAction() +{ + m_closeTabAction->setEnabled(m_centralWidget->enableTabCloseAction()); +} + void MainWindow::showTopicChooser(const QMap &links, const QString &keyword) { @@ -871,7 +877,7 @@ void MainWindow::activateCurrentCentralWidgetTab() void MainWindow::showSearch() { - m_centralWidget->activateSearch(); + m_centralWidget->activateSearchWidget(); } void MainWindow::hideSearch() diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 1bd8005..7d08a74 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -104,6 +104,7 @@ private slots: void showAboutDialog(); void copyAvailable(bool yes); void updateNavigationItems(); + void updateTabCloseAction(); void showNewAddress(const QUrl &url); void addNewBookmark(const QString &title, const QString &url); void showTopicChooser(const QMap &links, const QString &keyword); diff --git a/tools/assistant/tools/assistant/searchwidget.cpp b/tools/assistant/tools/assistant/searchwidget.cpp index 677e18e..c40a9c4 100644 --- a/tools/assistant/tools/assistant/searchwidget.cpp +++ b/tools/assistant/tools/assistant/searchwidget.cpp @@ -62,6 +62,7 @@ QT_BEGIN_NAMESPACE SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) : QWidget(parent) , zoomCount(0) + , attached(false) , searchEngine(engine) { QVBoxLayout *vLayout = new QVBoxLayout(this); @@ -122,6 +123,16 @@ void SearchWidget::resetZoom() } } +bool SearchWidget::isAttached() const +{ + return attached; +} + +void SearchWidget::setAttached(bool state) +{ + attached = state; +} + void SearchWidget::search() const { QList query = searchEngine->queryWidget()->query(); diff --git a/tools/assistant/tools/assistant/searchwidget.h b/tools/assistant/tools/assistant/searchwidget.h index 22fe80d..34eb86f 100644 --- a/tools/assistant/tools/assistant/searchwidget.h +++ b/tools/assistant/tools/assistant/searchwidget.h @@ -65,6 +65,9 @@ public: void zoomOut(); void resetZoom(); + bool isAttached() const; + void setAttached(bool state); + signals: void requestShowLink(const QUrl &url); void requestShowLinkInNewTab(const QUrl &url); @@ -81,6 +84,7 @@ private: private: int zoomCount; + bool attached; QHelpSearchEngine *searchEngine; QHelpSearchResultWidget *resultWidget; }; -- cgit v0.12 From 8ebe882b077fffedc3ff80fb80d2e181d5e56ab8 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Mon, 27 Apr 2009 17:16:59 +0200 Subject: Fixes wrong QPaintEvent::region() in QGLWidget::paintEvent. QGLWidget does not support partial updates unless the context is single buffered and auto-fill background is disabled. The problem was that QPaintEvent::region() returned the requested update region without taking into account the limitation of QGLWidget. If QGLWidget doesn't support partial updates, it means everything has to be updated, and QPaintEvent::region() must return the whole widget rect. Auto test included. Task-number: 241785 Reviewed-by: Trond --- src/gui/kernel/qwidget.cpp | 1 + src/gui/kernel/qwidget_p.h | 1 + src/gui/painting/qbackingstore.cpp | 11 +++++-- src/opengl/qgl.cpp | 4 +++ tests/auto/qgl/tst_qgl.cpp | 61 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index eb2e9f7..f612601 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -183,6 +183,7 @@ QWidgetPrivate::QWidgetPrivate(int version) : ,inDirtyList(0) ,isScrolled(0) ,isMoved(0) + ,usesDoubleBufferedGLContext(0) #ifdef Q_WS_WIN ,noPaintOnScreen(0) #endif diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 423e833..db78682 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -536,6 +536,7 @@ public: uint inDirtyList : 1; uint isScrolled : 1; uint isMoved : 1; + uint usesDoubleBufferedGLContext : 1; #ifdef Q_WS_WIN uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine() diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index fbac811a..34df6c9 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -1517,13 +1517,20 @@ void QWidgetPrivate::repaint_sys(const QRegion &rgn) extra->staticContentsSize = data.crect.size(); } + QPaintEngine *engine = q->paintEngine(); + // QGLWidget does not support partial updates if: + // 1) The context is double buffered + // 2) The context is single buffered and auto-fill background is enabled. + const bool noPartialUpdateSupport = (engine && engine->type() == QPaintEngine::OpenGL) + && (usesDoubleBufferedGLContext || q->autoFillBackground()); + QRegion toBePainted(noPartialUpdateSupport ? q->rect() : rgn); + #ifdef Q_WS_MAC // No difference between update() and repaint() on the Mac. - update_sys(rgn); + update_sys(toBePainted); return; #endif - QRegion toBePainted(rgn); toBePainted &= clipRect(); clipToEffectiveMask(toBePainted); if (toBePainted.isEmpty()) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index b4a0e5c..8ffee87 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2398,6 +2398,10 @@ bool QGLContext::create(const QGLContext* shareContext) return false; reset(); d->valid = chooseContext(shareContext); + if (d->valid && d->paintDevice->devType() == QInternal::Widget) { + QWidgetPrivate *wd = qt_widget_private(static_cast(d->paintDevice)); + wd->usesDoubleBufferedGLContext = d->glFormat.doubleBuffer(); + } if (d->sharing) // ok, we managed to share qgl_share_reg()->addShare(this, shareContext); return d->valid; diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index a64dfc4..f982e6d 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -66,6 +66,8 @@ private slots: void getSetCheck(); void openGLVersionCheck(); void graphicsViewClipping(); + void partialGLWidgetUpdates_data(); + void partialGLWidgetUpdates(); }; tst_QGL::tst_QGL() @@ -404,5 +406,64 @@ void tst_QGL::graphicsViewClipping() #endif } +void tst_QGL::partialGLWidgetUpdates_data() +{ + QTest::addColumn("doubleBufferedContext"); + QTest::addColumn("autoFillBackground"); + QTest::addColumn("supportsPartialUpdates"); + + QTest::newRow("Double buffered context") << true << true << false; + QTest::newRow("Double buffered context without auto-fill background") << true << false << false; + QTest::newRow("Single buffered context") << false << true << false; + QTest::newRow("Single buffered context without auto-fill background") << false << false << true; +} + +void tst_QGL::partialGLWidgetUpdates() +{ +#ifdef QT_NO_OPENGL + QSKIP("QGL not yet supported", SkipAll); +#else + if (!QGLFormat::hasOpenGL()) + QSKIP("QGL not supported on this platform", SkipAll); + + QFETCH(bool, doubleBufferedContext); + QFETCH(bool, autoFillBackground); + QFETCH(bool, supportsPartialUpdates); + + class MyGLWidget : public QGLWidget + { + public: + QRegion paintEventRegion; + void paintEvent(QPaintEvent *e) + { + paintEventRegion = e->region(); + } + }; + + QGLFormat format = QGLFormat::defaultFormat(); + format.setDoubleBuffer(doubleBufferedContext); + QGLFormat::setDefaultFormat(format); + + MyGLWidget widget; + widget.setFixedSize(150, 150); + widget.setAutoFillBackground(autoFillBackground); + widget.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&widget); +#endif + QTest::qWait(200); + + if (widget.format().doubleBuffer() != doubleBufferedContext) + QSKIP("Platform does not support requested format", SkipAll); + + widget.paintEventRegion = QRegion(); + widget.repaint(50, 50, 50, 50); + if (supportsPartialUpdates) + QCOMPARE(widget.paintEventRegion, QRegion(50, 50, 50, 50)); + else + QCOMPARE(widget.paintEventRegion, QRegion(widget.rect())); +#endif +} + QTEST_MAIN(tst_QGL) #include "tst_qgl.moc" -- cgit v0.12 From 572d3b04aacfd211ea930ac5460562d8b3f6232b Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Mon, 27 Apr 2009 18:07:00 +0200 Subject: Stabilize auto test added in 8ebe882b077fffedc3ff80fb80d2e181d5e56ab8 QWidget::repaint() is not immediate on the Mac; it has to go through the event loop. --- tests/auto/qgl/tst_qgl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index f982e6d..69141f3 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -458,6 +458,10 @@ void tst_QGL::partialGLWidgetUpdates() widget.paintEventRegion = QRegion(); widget.repaint(50, 50, 50, 50); +#ifdef Q_WS_MAC + // repaint() is not immediate on the Mac; it has to go through the event loop. + QTest::qWait(200); +#endif if (supportsPartialUpdates) QCOMPARE(widget.paintEventRegion, QRegion(50, 50, 50, 50)); else -- cgit v0.12 From 01fa23555b7af91806dc77b8abb194ae72ad6362 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 28 Apr 2009 11:06:20 +1000 Subject: Use PVR2DGetFrameBuffer to map screen 0 Some PowerVR chipsets are unstable if mmap/PVR2DMemWrap is used to map screen 0 instead of using PVR2DGetFrameBuffer. This change makes the driver use PVR2DGetFrameBuffer for screen 0 and mmap/PVR2DMemWrap for all other screens. Reviewed-by: Julian de Bhal --- .../gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c | 68 +++++++++++++++------- .../gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h | 2 + 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c index 5c37253..4771d14 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c @@ -72,7 +72,7 @@ static int pvrQwsInitFbScreen(int screen) /* Bail out if already initialized, or the number is incorrect */ if (screen < 0 || screen >= PVRQWS_MAX_SCREENS) return 0; - if (pvrQwsDisplay.screens[screen].mapped) + if (pvrQwsDisplay.screens[screen].initialized) return 1; /* Open the framebuffer and fetch its properties */ @@ -125,26 +125,33 @@ static int pvrQwsInitFbScreen(int screen) start = fix.smem_start; length = var.xres_virtual * var.yres_virtual * bytesPerPixel; - /* Map the framebuffer region into memory */ - mapped = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (!mapped || mapped == (void *)(-1)) { - perror("mmap"); - close(fd); - return 0; - } - - /* Allocate a PVR2D memory region for the framebuffer */ - memInfo = 0; - if (pvrQwsDisplay.context) { - pageAddresses[0] = start & 0xFFFFF000; - pageAddresses[1] = 0; - if (PVR2DMemWrap - (pvrQwsDisplay.context, mapped, PVR2D_WRAPFLAG_CONTIGUOUS, - length, pageAddresses, &memInfo) != PVR2D_OK) { - munmap(mapped, length); + if (screen == 0) { + /* We use PVR2DGetFrameBuffer to map the first screen. + On some chipsets it is more reliable than using PVR2DMemWrap */ + mapped = 0; + memInfo = 0; + } else { + /* Other screens: map the framebuffer region into memory */ + mapped = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (!mapped || mapped == (void *)(-1)) { + perror("mmap"); close(fd); return 0; } + + /* Allocate a PVR2D memory region for the framebuffer */ + memInfo = 0; + if (pvrQwsDisplay.context) { + pageAddresses[0] = start & 0xFFFFF000; + pageAddresses[1] = 0; + if (PVR2DMemWrap + (pvrQwsDisplay.context, mapped, PVR2D_WRAPFLAG_CONTIGUOUS, + length, pageAddresses, &memInfo) != PVR2D_OK) { + munmap(mapped, length); + close(fd); + return 0; + } + } } /* We don't need the file descriptor any more */ @@ -158,11 +165,17 @@ static int pvrQwsInitFbScreen(int screen) pvrQwsDisplay.screens[screen].screenStride = stride; pvrQwsDisplay.screens[screen].pixelFormat = format; pvrQwsDisplay.screens[screen].bytesPerPixel = bytesPerPixel; - pvrQwsDisplay.screens[screen].frameBuffer = memInfo; pvrQwsDisplay.screens[screen].screenDrawable = 0; - pvrQwsDisplay.screens[screen].mapped = mapped; + if (mapped) { + /* Don't set these fields if mapped is 0, because PVR2DGetFrameBuffer + may have already been called and set them */ + pvrQwsDisplay.screens[screen].frameBuffer = memInfo; + pvrQwsDisplay.screens[screen].mapped = mapped; + } pvrQwsDisplay.screens[screen].mappedLength = length; pvrQwsDisplay.screens[screen].screenStart = start; + pvrQwsDisplay.screens[screen].needsUnmap = (mapped != 0); + pvrQwsDisplay.screens[screen].initialized = 1; return 1; } @@ -209,7 +222,7 @@ static int pvrQwsAddDrawable(void) /* Create the PVR2DMEMINFO blocks for the active framebuffers */ for (screen = 0; screen < PVRQWS_MAX_SCREENS; ++screen) { - if (pvrQwsDisplay.screens[screen].mapped) { + if (screen != 0 && pvrQwsDisplay.screens[screen].mapped) { pageAddresses[0] = pvrQwsDisplay.screens[screen].screenStart & 0xFFFFF000; pageAddresses[1] = 0; @@ -224,6 +237,17 @@ static int pvrQwsAddDrawable(void) return 0; } pvrQwsDisplay.screens[screen].frameBuffer = memInfo; + } else if (screen == 0) { + if (PVR2DGetFrameBuffer + (pvrQwsDisplay.context, + PVR2D_FB_PRIMARY_SURFACE, &memInfo) != PVR2D_OK) { + fprintf(stderr, "QWSWSEGL: could not get the primary framebuffer surface\n"); + PVR2DDestroyDeviceContext(pvrQwsDisplay.context); + pvrQwsDisplay.context = 0; + return 0; + } + pvrQwsDisplay.screens[screen].frameBuffer = memInfo; + pvrQwsDisplay.screens[screen].mapped = memInfo->pBase; } } @@ -330,7 +354,7 @@ void pvrQwsDisplayClose(void) pvrQwsDestroyDrawableForced(info->screenDrawable); if (info->frameBuffer) PVR2DMemFree(pvrQwsDisplay.context, info->frameBuffer); - if (info->mapped) + if (info->mapped && info->needsUnmap) munmap(info->mapped, info->mappedLength); } diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h index d6c42a6..4f3ea90 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h @@ -76,6 +76,8 @@ typedef struct { void *mapped; int mappedLength; unsigned long screenStart; + int needsUnmap; + int initialized; } PvrQwsScreenInfo; -- cgit v0.12 From 3c12dd749ff0d9747af416db68ba2447d36bf8aa Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 28 Apr 2009 09:11:13 +0200 Subject: Changed doc.trolltech.com links to doc.qtsoftware.com Reviewed-by: David Boddie --- tools/qdoc3/test/assistant.qdocconf | 2 +- tools/qdoc3/test/carbide-eclipse-integration.qdocconf | 2 +- tools/qdoc3/test/designer.qdocconf | 2 +- tools/qdoc3/test/eclipse-integration.qdocconf | 2 +- tools/qdoc3/test/jambi.qdocconf | 2 +- tools/qdoc3/test/linguist.qdocconf | 2 +- tools/qdoc3/test/qmake.qdocconf | 2 +- tools/qdoc3/test/qt-build-docs.qdocconf | 2 +- tools/qdoc3/test/qt-inc.qdocconf | 2 +- tools/qdoc3/test/qt.qdocconf | 2 +- tools/qdoc3/test/standalone-eclipse-integration.qdocconf | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf index a3213c6..b6313fa 100644 --- a/tools/qdoc3/test/assistant.qdocconf +++ b/tools/qdoc3/test/assistant.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qt Assistant description = Qt Assistant Manual -url = http://doc.trolltech.com/4.5 +url = http://doc.qtsoftware.com/4.5 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index diff --git a/tools/qdoc3/test/carbide-eclipse-integration.qdocconf b/tools/qdoc3/test/carbide-eclipse-integration.qdocconf index 7fe489e..aee5e17 100644 --- a/tools/qdoc3/test/carbide-eclipse-integration.qdocconf +++ b/tools/qdoc3/test/carbide-eclipse-integration.qdocconf @@ -7,6 +7,6 @@ macro.TheEclipseIntegration = Carbide.c++ HTML.footer = "


\n" \ "\n" \ "\n" \ - "\n" \ + "\n" \ "\n" \ "
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)TrademarksTrademarks
Carbide.c++
" diff --git a/tools/qdoc3/test/designer.qdocconf b/tools/qdoc3/test/designer.qdocconf index 63226f6..8d9a49e 100644 --- a/tools/qdoc3/test/designer.qdocconf +++ b/tools/qdoc3/test/designer.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qt Designer description = Qt Designer Manual -url = http://doc.trolltech.com/4.5 +url = http://doc.qtsoftware.com/4.5 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index diff --git a/tools/qdoc3/test/eclipse-integration.qdocconf b/tools/qdoc3/test/eclipse-integration.qdocconf index 1fdaa1b..d9e4ac7 100644 --- a/tools/qdoc3/test/eclipse-integration.qdocconf +++ b/tools/qdoc3/test/eclipse-integration.qdocconf @@ -8,6 +8,6 @@ outputdir = $QTDIR/../qteclipsetools/main/doc/html project = Qt Eclipse Integration description = "Qt Eclipse Integration" -url = http://doc.trolltech.com/eclipse-integration-4.4 +url = http://doc.qtsoftware.com/qt-eclipse-1.5 HTML.{postheader,address} = "" diff --git a/tools/qdoc3/test/jambi.qdocconf b/tools/qdoc3/test/jambi.qdocconf index 5288b22..101b33a 100644 --- a/tools/qdoc3/test/jambi.qdocconf +++ b/tools/qdoc3/test/jambi.qdocconf @@ -3,7 +3,7 @@ include(macros.qdocconf) project = Qt Jambi description = Qt Jambi Reference Documentation -url = http://doc.trolltech.com/qtjambi +url = http://doc.qtsoftware.com/qtjambi version = 4.4.0_01 diff --git a/tools/qdoc3/test/linguist.qdocconf b/tools/qdoc3/test/linguist.qdocconf index 8e33e4b..177a54c 100644 --- a/tools/qdoc3/test/linguist.qdocconf +++ b/tools/qdoc3/test/linguist.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qt Linguist description = Qt Linguist Manual -url = http://doc.trolltech.com/4.5 +url = http://doc.qtsoftware.com/4.5 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index diff --git a/tools/qdoc3/test/qmake.qdocconf b/tools/qdoc3/test/qmake.qdocconf index 4e735b0..20b0acf 100644 --- a/tools/qdoc3/test/qmake.qdocconf +++ b/tools/qdoc3/test/qmake.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = QMake description = QMake Manual -url = http://doc.trolltech.com/4.5 +url = http://doc.qtsoftware.com/4.5 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index f7cd498..a05786b 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qt description = Qt Reference Documentation -url = http://doc.trolltech.com/4.5 +url = http://doc.qtsoftware.com/4.5 edition.Console.modules = QtCore QtDBus QtNetwork QtScript QtSql QtXml \ QtXmlPatterns QtTest diff --git a/tools/qdoc3/test/qt-inc.qdocconf b/tools/qdoc3/test/qt-inc.qdocconf index 7255a67..d6cb0e6 100644 --- a/tools/qdoc3/test/qt-inc.qdocconf +++ b/tools/qdoc3/test/qt-inc.qdocconf @@ -3,7 +3,7 @@ include(macros.qdocconf) project = Qt description = Qt Reference Documentation -url = http://doc.trolltech.com/4.5 +url = http://doc.qtsoftware.com/4.5 edition.Console = QtCore QtNetwork QtSql QtXml QtScript QtTest edition.Desktop = QtCore QtGui QtNetwork QtOpenGL QtSql QtSvg QtXml QtScript \ diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index 57eaf7a..964869c 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -8,7 +8,7 @@ project = Qt versionsym = version = %VERSION% description = Qt Reference Documentation -url = http://doc.trolltech.com/4.5 +url = http://doc.qtsoftware.com/4.5 edition.Console.modules = QtCore QtDBus QtNetwork QtScript QtSql QtXml \ QtXmlPatterns QtTest diff --git a/tools/qdoc3/test/standalone-eclipse-integration.qdocconf b/tools/qdoc3/test/standalone-eclipse-integration.qdocconf index 08b6070..127b578 100644 --- a/tools/qdoc3/test/standalone-eclipse-integration.qdocconf +++ b/tools/qdoc3/test/standalone-eclipse-integration.qdocconf @@ -6,6 +6,6 @@ macro.TheEclipseIntegration = The Qt Eclipse Integration HTML.footer = "


\n" \ "\n" \ "\n" \ - "\n" \ + "\n" \ "\n" \ "
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)TrademarksTrademarks
Qt Eclipse Integration 1.4.3
" -- cgit v0.12 From 484d54532a773cf90ebf8c9c2c4f4d839b1b3744 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Apr 2009 09:12:34 +0200 Subject: Fix stylesheet test when button color != window color --- tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index aa63753..24ccecf 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -605,8 +605,9 @@ void tst_QStyleSheetStyle::palettePropagation() QVERIFY(COLOR(gb) == Qt::red); QVERIFY(COLOR(pb) == APPCOLOR(pb)); // palette shouldn't propagate gb.setStyleSheet("QGroupBox * { color: red }"); + QVERIFY(COLOR(pb) == Qt::red); - QVERIFY(COLOR(gb) == APPCOLOR(pb)); + QVERIFY(COLOR(gb) == APPCOLOR(gb)); QWidget window; window.setStyleSheet("* { color: white; }"); -- cgit v0.12 From e372dc629927b60943568e9bbadb79fbaafab3a8 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 28 Apr 2009 09:16:01 +0200 Subject: Fix crash in uic regarding setting QIcon The regression was intruduced in change 04c01e15. Task: 252333 RevBy: Friedemann Kleint --- src/tools/uic/cpp/cppwriteinitialization.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 3d702dd..47566ad 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1650,19 +1650,19 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) if (i->hasElementNormalOff()) m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::Off);\n"; if (i->hasElementNormalOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::On);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOn()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::On);\n"; if (i->hasElementDisabledOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n"; if (i->hasElementDisabledOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::On);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOn()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::On);\n"; if (i->hasElementActiveOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::Off);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::Off);\n"; if (i->hasElementActiveOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::On);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOn()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::On);\n"; if (i->hasElementSelectedOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::Off);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::Off);\n"; if (i->hasElementSelectedOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::On);\n"; + m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOn()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::On);\n"; } else { // pre-4.4 legacy m_output << m_indent << "const QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n"; } -- cgit v0.12 From 0f0dbd09f7bf2ef9d69d1e559ace961d9b236d3b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 28 Apr 2009 10:16:04 +0200 Subject: When minimizing/restoring an item view it could jump to its currently selected item Task-number: 250446 Reviewed-by: ogoffart --- src/gui/itemviews/qabstractitemview.cpp | 2 +- tests/auto/qlistview/tst_qlistview.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 55b3a03..975decc 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1380,7 +1380,7 @@ bool QAbstractItemView::event(QEvent *event) d->executePostedLayout(); //make sure we set the layout properly break; case QEvent::Show: - { + if (d->delayedPendingLayout) { d->executePostedLayout(); //make sure we set the layout properly const QModelIndex current = currentIndex(); if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll)) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 2e7f412..c372475 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -105,6 +105,7 @@ private slots: void task203585_selectAll(); void task228566_infiniteRelayout(); void task248430_crashWith0SizedItem(); + void task250446_scrollChanged(); }; // Testing get/set functions @@ -1528,5 +1529,32 @@ void tst_QListView::task248430_crashWith0SizedItem() QTest::qWait(100); } +void tst_QListView::task250446_scrollChanged() +{ + QStandardItemModel model(200, 1); + QListView view; + view.setModel(&model); + QModelIndex index = model.index(0, 0); + QVERIFY(index.isValid()); + view.setCurrentIndex(index); + view.show(); + QTest::qWait(100); + const int scrollValue = view.verticalScrollBar()->maximum(); + view.verticalScrollBar()->setValue(scrollValue); + QCOMPARE(view.verticalScrollBar()->value(), scrollValue); + QCOMPARE(view.currentIndex(), index); + + view.showMinimized(); + QTest::qWait(100); + QCOMPARE(view.verticalScrollBar()->value(), scrollValue); + QCOMPARE(view.currentIndex(), index); + + view.showNormal(); + QTest::qWait(100); + QCOMPARE(view.verticalScrollBar()->value(), scrollValue); + QCOMPARE(view.currentIndex(), index); +} + + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 From 0901f3f8055240d97def42d59e6a76e0b299e985 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 28 Apr 2009 10:54:11 +0200 Subject: Fix a crash with a proxy model applied on the QFileDialog. The problem was located in _q_enterDirectory, this method take a QModelIndex that can be a model index from the treeview/listview (so it comes from the proxy that is applied) and from the side bar where there is always no proxy applied. Previously we were trying to convert from a proxy index to a source index the value that come from the sidebar which is already a source model index. Now, we just check if the model index is coming from the proxy and in that case we convert it otherwise this model index come from the source. Task-number: 252068 Reviewed-by: jasplin Reviewed-by: ogoffart --- src/gui/dialogs/qfiledialog.cpp | 2 +- tests/auto/qfiledialog/tst_qfiledialog.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 073c25b..abb13c0 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -2793,7 +2793,7 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index) { Q_Q(QFileDialog); // My Computer or a directory - QModelIndex sourceIndex = mapToSource(index); + QModelIndex sourceIndex = index.model() == proxyModel ? mapToSource(index) : index; QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString(); if (path.isEmpty() || model->isDir(sourceIndex)) { q->setDirectory(path); diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 13b13d6..689f73d 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -1602,6 +1602,19 @@ void tst_QFiledialog::task227304_proxyOnFileDialog() QTest::keyClick(list, Qt::Key_Return); QTest::qWait(200); + dialog->close(); + fd.close(); + + QNonNativeFileDialog fd2(0, "I should not crash with a proxy", QDir::tempPath(), 0); + QSortFilterProxyModel *pm = new QSortFilterProxyModel; + fd2.setProxyModel(pm); + fd2.show(); + QSidebar *sidebar = qFindChild(&fd2, "sidebar"); + sidebar->setFocus(); + sidebar->selectUrl(QUrl::fromLocalFile(QDir::homePath())); + QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center()); + QTest::qWait(250); + //We shouldn't crash } void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() -- cgit v0.12 From 20217d3521a9e59a0730a0eb63d09ffb1c236bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 28 Apr 2009 10:55:31 +0200 Subject: Fixed rendering of bitmap fonts on X11 with Xrender and fontconfig. It seems the Xrender PictStandardA1 mask format doesn't work with XLFD bitmap fonts wrapped in a fontconfig structure. Task-number: 252328 Reviewed-by: Samuel --- src/gui/painting/qpaintengine_x11.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 39ce59f..4b2fbca 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -2352,7 +2352,9 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti) GlyphSet glyphSet = set->id; const QColor &pen = d->cpen.color(); ::Picture src = X11->getSolidFill(d->scrn, pen); - XRenderPictFormat *maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format); + XRenderPictFormat *maskFormat = 0; + if (ft->xglyph_format != PictStandardA1) + maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format); enum { t_min = SHRT_MIN, t_max = SHRT_MAX }; -- cgit v0.12 From c1691ab1f69919c51f8c66732bbc38bae39329df Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 28 Apr 2009 11:41:06 +0200 Subject: Fixed showing messageboxes on small screens. On small screens use the whole screen width when adjusting the size of the messagebox. Task-number: 251925 Reviewed-by: Brad --- src/gui/dialogs/qmessagebox.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 456b480..5e59501 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -280,6 +280,9 @@ void QMessageBoxPrivate::updateSize() int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width()); #else int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this + // on small screens allows the messagebox be the same size as the screen + if (screenSize.width() <= 1024) + hardLimit = screenSize.width(); #endif #ifdef Q_WS_MAC int softLimit = qMin(screenSize.width()/2, 420); -- cgit v0.12 From d851374c7894ac62367d885e7c24650d8635d2e8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 23 Apr 2009 17:06:45 +0200 Subject: performance improvement of isUncRoot in qfsfileengine_win.cpp We always called QStringList::split in this function, which was just expensive. Reviewed-by: mauricek --- src/corelib/io/qfsfileengine_win.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 522be20..63506c2 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -346,8 +346,15 @@ bool QFSFileEnginePrivate::uncListSharesOnServer(const QString &server, QStringL static bool isUncRoot(const QString &server) { QString localPath = QDir::toNativeSeparators(server); - QStringList parts = localPath.split(QLatin1Char('\\'), QString::SkipEmptyParts); - return localPath.startsWith(QLatin1String("\\\\")) && parts.count() <= 1; + if (!localPath.startsWith(QLatin1String("\\\\"))) + return false; + + int idx = localPath.indexOf(QLatin1Char('\\'), 2); + if (idx == -1 || idx + 1 == localPath.length()) + return true; + + localPath = localPath.right(localPath.length() - idx - 1).trimmed(); + return localPath.isEmpty(); } static bool isUncPath(const QString &path) -- cgit v0.12 From 8ec06f944915a56ef7ad3f1a9416b16271055fb9 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 28 Apr 2009 11:33:56 +0200 Subject: Cocoa: qwidget auto test fails (windowMoveResize) The test fails because, in cocoa, when resizing a window to zero (either w or h), cocoa will also move the window up in the corner (!). So the fix is to issue an extra move back to it's true location after the resize. The faulty cocoa move is issued inside the resize callback, so we choose to not update the window location anymore from a pure resize callback. Task-number: 251895 Reviewed-by: Trenton Schulz --- src/gui/kernel/qcocoawindowdelegate_mac.mm | 17 ++++++++--------- src/gui/kernel/qwidget_mac.mm | 25 +++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm index 03b2fce..fa325f4 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac.mm +++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm @@ -194,7 +194,6 @@ static void cleanupCocoaWindowDelegate() { NSWindow *window = [notification object]; QWidget *qwidget = m_windowHash->value(window); - // Just here to handle the is zoomed method. QWidgetData *widgetData = qt_qwidget_data(qwidget); if (!(qwidget->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) && [window isZoomed]) { widgetData->window_state = widgetData->window_state | Qt::WindowMaximized; @@ -202,7 +201,6 @@ static void cleanupCocoaWindowDelegate() & ~Qt::WindowMaximized)); qt_sendSpontaneousEvent(qwidget, &e); } - [self checkForMove:[window frame] forWidget:qwidget]; NSRect rect = [[window contentView] frame]; const QSize newSize(rect.size.width, rect.size.height); const QSize &oldSize = widgetData->crect.size(); @@ -212,12 +210,18 @@ static void cleanupCocoaWindowDelegate() } } -- (void)checkForMove:(const NSRect &)newRect forWidget:(QWidget *)qwidget +- (void)windowDidMove:(NSNotification *)notification { - // newRect's origin is bottom left. + // The code underneath needs to translate the window location + // from bottom left (which is the origin used by Cocoa) to + // upper left (which is the origin used by Qt): + NSWindow *window = [notification object]; + NSRect newRect = [window frame]; + QWidget *qwidget = m_windowHash->value(window); QPoint qtPoint = flipPoint(NSMakePoint(newRect.origin.x, newRect.origin.y + newRect.size.height)).toPoint(); const QRect &oldRect = qwidget->frameGeometry(); + if (qtPoint.x() != oldRect.x() || qtPoint.y() != oldRect.y()) { QWidgetData *widgetData = qt_qwidget_data(qwidget); QRect oldCRect = widgetData->crect; @@ -233,11 +237,6 @@ static void cleanupCocoaWindowDelegate() } } -- (void)windowDidMove:(NSNotification *)notification -{ - [self windowDidResize:notification]; -} - -(BOOL)windowShouldClose:(id)windowThatWantsToClose { QWidget *qwidget = m_windowHash->value(windowThatWantsToClose); diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index a00f969..5abaaf8 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4039,7 +4039,11 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) QMacCocoaAutoReleasePool pool; bool realWindow = isRealWindow(); - if (realWindow && !(w == 0 && h == 0) && !q->testAttribute(Qt::WA_DontShowOnScreen)) { + if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen) +#ifndef QT_MAC_USE_COCOA + && !(w == 0 && h == 0) +#endif + ){ applyMaxAndMinSizeConstraints(w, h); topData()->isSetGeometry = 1; topData()->isMove = isMove; @@ -4054,7 +4058,24 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) fStrut.top() + fStrut.bottom() + h)); NSRect cocoaFrameRect = NSMakeRect(frameRect.x(), flipYCoordinate(frameRect.bottom() + 1), frameRect.width(), frameRect.height()); - [window setFrame:cocoaFrameRect display:NO]; + + QPoint currTopLeft = data.crect.topLeft(); + if (currTopLeft.x() == x && currTopLeft.y() == y + && cocoaFrameRect.size.width != 0 + && cocoaFrameRect.size.height != 0) { + [window setFrame:cocoaFrameRect display:NO]; + } else { + // The window is moved and resized (or resized to zero). + // Since Cocoa usually only sends us a resize callback after + // setting a window frame, we issue an explicit move as + // well. To stop Cocoa from optimize away the move (since the move + // would have the same origin as the setFrame call) we shift the + // window back and forth inbetween. + cocoaFrameRect.origin.y += 1; + [window setFrame:cocoaFrameRect display:NO]; + cocoaFrameRect.origin.y -= 1; + [window setFrameOrigin:cocoaFrameRect.origin]; + } #endif topData()->isSetGeometry = 0; } else { -- cgit v0.12 From 5d6a56fd14cb21d9955c49305993f7b7527a27c6 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 27 Apr 2009 17:11:43 +0200 Subject: Don't send extra events when using the scroll wheel in Cocoa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Argh! Copy and paste is evil, not only was the test was wrong, We sent the event twice and the second time we sent the wrong value. Task-number: 250668 Reviewed-by: Morten Sørvig --- src/gui/kernel/qcocoaview_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index fae4821..ff36ca1 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -807,10 +807,10 @@ extern "C" { QWheelEvent qwe(qlocal, qglobal, deltaY, buttons, keyMods, Qt::Vertical); qt_sendSpontaneousEvent(qwidget, &qwe); wheelOK = qwe.isAccepted(); - if (wheelOK && QApplicationPrivate::focus_widget + if (!wheelOK && QApplicationPrivate::focus_widget && QApplicationPrivate::focus_widget != qwidget) { QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal, - deltaZ, buttons, keyMods, Qt::Vertical); + deltaY, buttons, keyMods, Qt::Vertical); qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2); wheelOK = qwe2.isAccepted(); } -- cgit v0.12 From 49708c6e6ac8e6641b1dfdf3ec2ebf347a8ca98f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Apr 2009 14:07:24 +0200 Subject: Fix regression in QSelectionModel::rowIntersectsSelection and QSelectionModel::columnsIntersectsSelection The documentation says "if one is selected" inside the row/column, so we need to look over if we find one which is selected Task-number: 252069 Reviewed-by: Marius Bugge Monsen --- src/gui/itemviews/qitemselectionmodel.cpp | 20 +++++----- .../tst_qitemselectionmodel.cpp | 46 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index 1a3ae2d..8baefdf 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -1313,11 +1313,11 @@ bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &par int left = sel.at(i).left(); int right = sel.at(i).right(); if (top <= row && bottom >= row) { - Qt::ItemFlags leftFlags = d->model->index(row, left, parent).flags(); - Qt::ItemFlags rightFlags = d->model->index(row, right, parent).flags(); - if ((leftFlags & Qt::ItemIsSelectable) && (leftFlags & Qt::ItemIsEnabled) - && (rightFlags & Qt::ItemIsSelectable) && (rightFlags & Qt::ItemIsEnabled)) - return true; + for (int j = left; j <= right; j++) { + const Qt::ItemFlags flags = d->model->index(row, j, parent).flags(); + if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) + return true; + } } } @@ -1342,11 +1342,11 @@ bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelInde int top = sel.at(i).top(); int bottom = sel.at(i).bottom(); if (left <= column && right >= column) { - Qt::ItemFlags topFlags = d->model->index(top, column, parent).flags(); - Qt::ItemFlags bottomFlags = d->model->index(bottom, column, parent).flags(); - if ((topFlags & Qt::ItemIsSelectable) && (topFlags & Qt::ItemIsEnabled) - && (bottomFlags & Qt::ItemIsSelectable) && (bottomFlags & Qt::ItemIsEnabled)) - return true; + for (int j = top; j <= bottom; j++) { + const Qt::ItemFlags flags = d->model->index(j, column, parent).flags(); + if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) + return true; + } } } diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 15b36b8..9bd1ce3 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -89,6 +89,7 @@ private slots: void merge_data(); void merge(); void task119433_isRowSelected(); + void task252069_rowIntersectsSelection(); private: QAbstractItemModel *model; @@ -2140,6 +2141,51 @@ void tst_QItemSelectionModel::task119433_isRowSelected() QVERIFY(sel.isRowSelected(0, QModelIndex())); } +void tst_QItemSelectionModel::task252069_rowIntersectsSelection() +{ + QStandardItemModel m; + for (int i=0; i<8; ++i) { + for (int j=0; j<8; ++j) { + QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i)); + if ((i % 2 == 0 && j == 0) || + (j % 2 == 0 && i == 0) || + j == 5 || i == 5 ) { + item->setEnabled(false); + //item->setSelectable(false); + } + m.setItem(i, j, item); + } + } + + QItemSelectionModel selected(&m); + //nothing is selected + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); + selected.select(m.index(2, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows); + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); + selected.select(m.index(0, 5), QItemSelectionModel::Select | QItemSelectionModel::Columns); + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); +} QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" -- cgit v0.12 From 2f2811f24268d9f34e2725e1aca4212a6ffdd81f Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 28 Apr 2009 17:49:24 +0200 Subject: Changed include file name to lowercase to be able to crosscompile win32-g++ version from a Linux machine. Reviewed-by: trustme --- qmake/project.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index eef32db..00bb2f0 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -57,7 +57,7 @@ #include #include #elif defined(Q_OS_WIN32) -#include +#include #endif #include #include -- cgit v0.12 From cde40ce4a211816bf4222fa5487139c416f7b165 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 28 Apr 2009 19:11:51 +0200 Subject: Fix documentation about native dialogs It basically says that on KDE and GNOME the native dialogs are called. It fix a mistake about a regular instantiation on QFileDialog object on Windows. --- src/gui/dialogs/qfiledialog.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index abb13c0..2f524cb 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -96,9 +96,8 @@ Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook order to select one or many files or a directory. The easiest way to create a QFileDialog is to use the static - functions. On Windows, these static functions will call the native - Windows file dialog, and on Mac OS X these static function will call - the native Mac OS X file dialog. + functions. On Windows, Mac OS X, KDE and GNOME, these static functions will + call the native file dialog when possible. \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 0 @@ -216,7 +215,7 @@ Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook are resolved. \value DontConfirmOverwrite Don't ask for confirmation if an existing file is selected. By default confirmation is requested. - \value DontUseNativeDialog Don't use the native file dialog. By default on Mac OS X and Windows, + \value DontUseNativeDialog Don't use the native file dialog. By default on Mac OS X, the native file dialog is used unless you use a subclass of QFileDialog that contains the Q_OBJECT macro. \value ReadOnly Indicates that the model is readonly. -- cgit v0.12 From b4caab9d25d1a2a6f95bf4bd15094475586ccf6a Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 10:22:57 -0700 Subject: Cleaned up constness errors All these drawing functions really shouldn't be const even if some of them can be. They should never be called from const functions and when/if they change pen/brush stuff they cease being able to be const. Also make sure fillRegion() uses the right brush. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index ba5d71a..83c2039 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -270,14 +270,14 @@ public: inline bool dfbCanHandleClip() const; inline bool isSimpleBrush(const QBrush &brush) const; - void drawLines(const QLine *lines, int count) const; - void drawLines(const QLineF *lines, int count) const; + void drawLines(const QLine *lines, int count); + void drawLines(const QLineF *lines, int count); - void fillRegion(const QRegion &r) const; - void fillRects(const QRect *rects, int count) const; - void drawRects(const QRect *rects, int count) const; - void fillRects(const QRectF *rects, int count) const; - void drawRects(const QRectF *rects, int count) const; + void fillRegion(const QRegion &r); + void fillRects(const QRect *rects, int count); + void drawRects(const QRect *rects, int count); + void fillRects(const QRectF *rects, int count); + void drawRects(const QRectF *rects, int count); void drawPixmap(const QRectF &dest, @@ -545,7 +545,7 @@ void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) surface->SetDrawingFlags(surface, DFBSurfaceDrawingFlags(drawingFlags)); } -void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) const +void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) { for (int i = 0; i < n; ++i) { const QLine l = transform.map(lines[i]); @@ -553,7 +553,7 @@ void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) const } } -void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) const +void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) { for (int i = 0; i < n; ++i) { const QLine l = transform.map(lines[i]).toLine(); @@ -561,14 +561,16 @@ void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) const } } -void QDirectFBPaintEnginePrivate::fillRegion(const QRegion ®ion) const +void QDirectFBPaintEnginePrivate::fillRegion(const QRegion ®ion) { + Q_ASSERT(isSimpleBrush(q->state()->brush)); + setDFBColor(q->state()->brush.color()); const QVector rects = region.rects(); const int n = rects.size(); fillRects(rects.constData(), n); } -void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) const +void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) { for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]); @@ -577,7 +579,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) const } } -void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) const +void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) { for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]).toRect(); @@ -586,7 +588,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) const } } -void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) const +void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) { for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]); @@ -595,7 +597,7 @@ void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) const } } -void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) const +void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) { for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]).toRect(); -- cgit v0.12 From de14db188ada5e00980a152dadb13d38438a7fa2 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 10:46:34 -0700 Subject: Make the disable/warn on fallbacks more flexible Allow programmers to select which operations they want to warn on/disable and which not to. To warn for DRAW_PIXMAP only you can do this: DEFINES += QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=DRAW_PIXMAP To include fillRect you can do: DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=DRAW_PIXMAP|FILL_RECT\" Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/directfb.pro | 37 ++++----- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 97 ++++++++++++++-------- 2 files changed, 82 insertions(+), 52 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index 1ee9030..67f5d61 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -14,30 +14,29 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers #DEFINES += QT_NO_DIRECTFB_KEYBOARD #DEFINES += QT_DIRECTFB_TIMING #DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION -#DEFINES += QT_DIRECTFB_WARN_ON_RASTERFALLBACKS -#DEFINES += QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS +#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" +#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target -HEADERS = \ - qdirectfbscreen.h \ - qdirectfbsurface.h \ - qdirectfbpaintengine.h \ - qdirectfbpaintdevice.h \ - qdirectfbpixmap.h \ - qdirectfbkeyboard.h \ - qdirectfbmouse.h +HEADERS = qdirectfbscreen.h \ + qdirectfbsurface.h \ + qdirectfbpaintengine.h \ + qdirectfbpaintdevice.h \ + qdirectfbpixmap.h \ + qdirectfbkeyboard.h \ + qdirectfbmouse.h -SOURCES = \ - qdirectfbscreen.cpp \ - qdirectfbscreenplugin.cpp \ - qdirectfbsurface.cpp \ - qdirectfbpaintengine.cpp \ - qdirectfbpaintdevice.cpp \ - qdirectfbpixmap.cpp \ - qdirectfbkeyboard.cpp \ - qdirectfbmouse.cpp +SOURCES = qdirectfbscreen.cpp \ + qdirectfbscreenplugin.cpp \ + qdirectfbsurface.cpp \ + qdirectfbpaintengine.cpp \ + qdirectfbpaintdevice.cpp \ + qdirectfbpixmap.cpp \ + qdirectfbkeyboard.cpp \ + qdirectfbmouse.cpp QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB LIBS += $$QT_LIBS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 83c2039..c4dae2e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -54,6 +54,27 @@ #include #include +#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#define VOID_ARG() static_cast(false) +enum PaintOperation { + DRAW_RECTS = 0x0001, + DRAW_LINES = 0x0002, + DRAW_IMAGE = 0x0004, + DRAW_PIXMAP = 0x0008, + DRAW_TILED_PIXMAP = 0x0010, + STROKE_PATH = 0x0020, + DRAW_PATH = 0x0040, + DRAW_POINTS = 0x0080, + DRAW_ELLIPSE = 0x0100, + DRAW_POLYGON = 0x0200, + DRAW_TEXT = 0x0400, + FILL_PATH = 0x0800, + FILL_RECT = 0x1000, + DRAW_COLORSPANS = 0x2000, + ALL = 0xffff +}; +#endif + #ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS template inline const T *ptr(const T &t) { return &t; } template <> inline const bool* ptr(const bool &) { return 0; } @@ -98,24 +119,31 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * #endif #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS -#define RASTERFALLBACK(one, two, three) rasterFallbackWarn("Disabled raster engine operation", \ - __FUNCTION__, state()->painter->device(), \ - d_func()->matrixScale, d_func()->matrixRotShear, \ - d_func()->simplePen, d_func()->dfbCanHandleClip(), \ - d_func()->forceRasterPrimitives, \ - #one, one, #two, two, #three, three); \ - return; +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ + rasterFallbackWarn("Disabled raster engine operation", \ + __FUNCTION__, state()->painter->device(), \ + d_func()->matrixScale, d_func()->matrixRotShear, \ + d_func()->simplePen, d_func()->dfbCanHandleClip(), \ + d_func()->forceRasterPrimitives, \ + #one, one, #two, two, #three, three); \ + if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ + return; #elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS -#define RASTERFALLBACK(one, two, three) return; +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ + return; #elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS -#define RASTERFALLBACK(one, two, three) rasterFallbackWarn("Falling back to raster engine for", \ - __FUNCTION__, state()->painter->device(), \ - d_func()->matrixScale, d_func()->matrixRotShear, \ - d_func()->simplePen, d_func()->dfbCanHandleClip(), \ - d_func()->forceRasterPrimitives, \ - #one, one, #two, two, #three, three); +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ + rasterFallbackWarn("Falling back to raster engine for", \ + __FUNCTION__, state()->painter->device(), \ + d_func()->matrixScale, d_func()->matrixRotShear, \ + d_func()->simplePen, d_func()->dfbCanHandleClip(), \ + d_func()->forceRasterPrimitives, \ + #one, one, #two, two, #three, three); #else -#define RASTERFALLBACK(one, two, three) +#define RASTERFALLBACK(op, one, two, three) #endif static inline uint ALPHA_MUL(uint x, uint a) @@ -892,7 +920,7 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simplePen || d->forceRasterPrimitives || !d->isSimpleBrush(brush)) { - RASTERFALLBACK(rectCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); return; @@ -918,6 +946,7 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simplePen || d->forceRasterPrimitives || !d->isSimpleBrush(brush)) { + RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); return; @@ -940,7 +969,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { - RASTERFALLBACK(lineCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); return; @@ -958,7 +987,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { - RASTERFALLBACK(lineCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); return; @@ -984,7 +1013,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN) #endif { - RASTERFALLBACK(r, image.size(), sr); + RASTERFALLBACK(DRAW_IMAGE, r, image.size(), sr); d->lock(); QRasterPaintEngine::drawImage(r, image, sr, flags); return; @@ -1008,11 +1037,11 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { - // not using RASTERFALLBACK since this is the way we do bitmaps? + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear) { - RASTERFALLBACK(r, pixmap.size(), sr); + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); const QImage *img = static_cast(pixmap.pixmapData())->buffer(); d->lock(); QRasterPaintEngine::drawImage(r, *img, sr); @@ -1034,10 +1063,11 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, Q_D(QDirectFBPaintEngine); d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { + RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp); } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()) { - RASTERFALLBACK(r, pixmap.size(), sp); + RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); const QImage *img = static_cast(pixmap.pixmapData())->buffer(); d->lock(); QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); @@ -1053,6 +1083,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen) { + RASTERFALLBACK(STROKE_PATH, path, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::stroke(path, pen); @@ -1060,7 +1091,7 @@ void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen) void QDirectFBPaintEngine::drawPath(const QPainterPath &path) { - RASTERFALLBACK(path.boundingRect(), static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_PATH, path, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPath(path); @@ -1068,7 +1099,7 @@ void QDirectFBPaintEngine::drawPath(const QPainterPath &path) void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) { - RASTERFALLBACK(pointCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPoints(points, pointCount); @@ -1076,7 +1107,7 @@ void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) { - RASTERFALLBACK(pointCount, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPoints(points, pointCount); @@ -1084,7 +1115,7 @@ void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) { - RASTERFALLBACK(rect, static_cast(false), static_cast(false)); + RASTERFALLBACK(DRAW_ELLIPSE, rect, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawEllipse(rect); @@ -1093,7 +1124,7 @@ void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) { - RASTERFALLBACK(pointCount, mode, static_cast(false)); + RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPolygon(points, pointCount, mode); @@ -1102,7 +1133,7 @@ void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) { - RASTERFALLBACK(pointCount, mode, static_cast(false)); + RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPolygon(points, pointCount, mode); @@ -1111,7 +1142,7 @@ void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, void QDirectFBPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) { - RASTERFALLBACK(p, textItem.text(), static_cast(false)); + RASTERFALLBACK(DRAW_TEXT, p, textItem.text(), VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawTextItem(p, textItem); @@ -1119,7 +1150,7 @@ void QDirectFBPaintEngine::drawTextItem(const QPointF &p, void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush) { - RASTERFALLBACK(path, brush, static_cast(false)); + RASTERFALLBACK(FILL_PATH, path, brush, VOID_ARG()); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::fill(path, brush); @@ -1153,7 +1184,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) break; } } - RASTERFALLBACK(rect, brush, static_cast(false)); + RASTERFALLBACK(FILL_RECT, rect, brush, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, brush); } @@ -1163,7 +1194,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->dfbCanHandleClip() || d->matrixRotShear || d->forceRasterPrimitives) { - RASTERFALLBACK(rect, color, static_cast(false)); + RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, color); } else { @@ -1180,7 +1211,7 @@ void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count, { Q_D(QDirectFBPaintEngine); if (d->forceRasterPrimitives) { - RASTERFALLBACK(count, color, static_cast(false)); + RASTERFALLBACK(DRAW_COLORSPANS, count, color, VOID_ARG()); d->lock(); QRasterPaintEngine::drawColorSpans(spans, count, color); } else { -- cgit v0.12 From 2e9071afbf86ca3143552a3eed75418328b5ce6c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 27 Apr 2009 20:36:29 -0700 Subject: Added an option for ignoring the system clip This is currently the only way I can make QGraphicsView not have to fall back to the raster engine for all operations. It seems the QRegion passed to the paintEvent of QGraphicsView also is set as the systemClip which in the end makes the QRasterPaintEngine's clipRegion equal the systemClip. By exporting QWS_DISPLAY=directfb:ignoresystemclip you can now draw without having a complex clip and therefore take advantage of hw acceleration with DirectFB. Reviewed-By: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 23 ++++++++++++---------- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 9 +++++++++ src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 1 + 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index c4dae2e..101c4b7 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -337,6 +337,7 @@ private: bool dirtyClip; bool dfbHandledClip; + bool ignoreSystemClip; QDirectFBPaintDevice *dfbDevice; QDirectFBPaintEngine *q; @@ -350,6 +351,7 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p dfbHandledClip(false), dfbDevice(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); + ignoreSystemClip = QDirectFBScreen::instance()->ignoreSystemClip(); surfaceCache = new SurfaceCache; static int cacheLimit = qgetenv("QT_DIRECTFB_IMAGECACHE").toInt(); if (cacheLimit > 0) @@ -774,23 +776,24 @@ void QDirectFBPaintEnginePrivate::updateClip() if (!dirtyClip) return; - if (!clip() || !clip()->enabled) { + const QClipData *clipData = clip(); + if (!clipData || !clipData->enabled) { surface->SetClip(surface, NULL); dfbHandledClip = true; - } - else if (clip()->hasRectClip) { + } else if (clipData->hasRectClip) { const DFBRegion r = { - clip()->clipRect.x(), - clip()->clipRect.y(), - clip()->clipRect.x() + clip()->clipRect.width(), - clip()->clipRect.y() + clip()->clipRect.height() + clipData->clipRect.x(), + clipData->clipRect.y(), + clipData->clipRect.x() + clipData->clipRect.width(), + clipData->clipRect.y() + clipData->clipRect.height() }; surface->SetClip(surface, &r); - dfbHandledClip = true; - } - else + } else if (clipData->hasRegionClip && ignoreSystemClip && clipData->clipRegion == systemClip) { + dfbHandledClip = true; + } else { dfbHandledClip = false; + } dirtyClip = false; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 3e54e7f..177df1d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -81,6 +81,7 @@ public: QDirectFBKeyboardHandler *keyboard; #endif bool videoonly; + bool ignoreSystemClip; QImage::Format alphaPixmapFormat; }; @@ -97,6 +98,7 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen) , keyboard(0) #endif , videoonly(false) + , ignoreSystemClip(false) , alphaPixmapFormat(QImage::Format_Invalid) { #ifndef QT_NO_QWS_SIGNALHANDLER @@ -826,6 +828,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec) if (displayArgs.contains(QLatin1String("videoonly"))) d_ptr->videoonly = true; + if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) + d_ptr->ignoreSystemClip = true; + #ifndef QT_NO_DIRECTFB_WM if (displayArgs.contains(QLatin1String("fullscreen"))) #endif @@ -1256,3 +1261,7 @@ uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFla return reinterpret_cast(mem); } +bool QDirectFBScreen::ignoreSystemClip() const +{ + return d_ptr->ignoreSystemClip; +} diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 8dd38dc..08c9ac1 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -109,6 +109,7 @@ public: void releaseDFBSurface(IDirectFBSurface* surface); bool preferVideoOnly() const; + bool ignoreSystemClip() const; static int depth(DFBSurfacePixelFormat format); -- cgit v0.12 From 69051b4e49f16ea0d25db99ba42c557095a61a99 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 11:17:25 -0700 Subject: Fold boolean options into flags Instead of having multiple bool QDirectFBScreen::.* getters I added DirectFBFlags QDirectFBScreen::directFBFlags() function. Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 2 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 23 ++++++++-------------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 14 ++++++++++--- .../gfxdrivers/directfb/qdirectfbsurface.cpp | 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 101c4b7..9e6f821 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -351,7 +351,7 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p dfbHandledClip(false), dfbDevice(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); - ignoreSystemClip = QDirectFBScreen::instance()->ignoreSystemClip(); + ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; surfaceCache = new SurfaceCache; static int cacheLimit = qgetenv("QT_DIRECTFB_IMAGECACHE").toInt(); if (cacheLimit > 0) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 177df1d..4b8af41 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -80,8 +80,7 @@ public: #ifndef QT_NO_DIRECTFB_KEYBOARD QDirectFBKeyboardHandler *keyboard; #endif - bool videoonly; - bool ignoreSystemClip; + QDirectFBScreen::DirectFBFlags directFBFlags; QImage::Format alphaPixmapFormat; }; @@ -97,8 +96,7 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen) #ifndef QT_NO_DIRECTFB_KEYBOARD , keyboard(0) #endif - , videoonly(false) - , ignoreSystemClip(false) + , directFBFlags(QDirectFBScreen::NoFlags) , alphaPixmapFormat(QImage::Format_Invalid) { #ifndef QT_NO_QWS_SIGNALHANDLER @@ -227,7 +225,7 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription return 0; } - if (d_ptr->videoonly && !(desc->flags & DSDESC_PREALLOCATED)) { + if (d_ptr->directFBFlags & VideoOnly && !(desc->flags & DSDESC_PREALLOCATED)) { // Add the video only capability. This means the surface will be created in video ram DFBSurfaceDescription voDesc = *desc; if (!(voDesc.flags & DSDESC_CAPS)) { @@ -347,11 +345,10 @@ void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface *surface) //qDebug("Released surface at %p. New count = %d", surface, d_ptr->allocatedSurfaces.count()); } -bool QDirectFBScreen::preferVideoOnly() const +QDirectFBScreen::DirectFBFlags QDirectFBScreen::directFBFlags() const { - return d_ptr->videoonly; + return d_ptr->directFBFlags; } - IDirectFB* QDirectFBScreen::dfb() { return d_ptr->dfb; @@ -825,11 +822,11 @@ bool QDirectFBScreen::connect(const QString &displaySpec) if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) printDirectFBInfo(d_ptr->dfb); - if (displayArgs.contains(QLatin1String("videoonly"))) - d_ptr->videoonly = true; + if (displayArgs.contains(QLatin1String("videoonly"), Qt::CaseInsensitive)) + d_ptr->directFBFlags |= VideoOnly; if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) - d_ptr->ignoreSystemClip = true; + d_ptr->directFBFlags |= IgnoreSystemClip; #ifndef QT_NO_DIRECTFB_WM if (displayArgs.contains(QLatin1String("fullscreen"))) @@ -1261,7 +1258,3 @@ uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFla return reinterpret_cast(mem); } -bool QDirectFBScreen::ignoreSystemClip() const -{ - return d_ptr->ignoreSystemClip; -} diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 08c9ac1..8e75277 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -59,6 +59,16 @@ public: QDirectFBScreen(int display_id); ~QDirectFBScreen(); + enum DirectFBFlag { + NoFlags = 0x00, + VideoOnly = 0x01, + IgnoreSystemClip = 0x02 + }; + + Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); + + DirectFBFlags directFBFlags() const; + bool connect(const QString &displaySpec); void disconnect(); bool initDevice(); @@ -108,9 +118,6 @@ public: SurfaceCreationOptions options); void releaseDFBSurface(IDirectFBSurface* surface); - bool preferVideoOnly() const; - bool ignoreSystemClip() const; - static int depth(DFBSurfacePixelFormat format); static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format); @@ -139,6 +146,7 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions); +Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::DirectFBFlags); inline bool QDirectFBScreen::isPremultiplied(QImage::Format format) { diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 8ed308c..257efeb 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -110,7 +110,7 @@ void QDirectFBSurface::createWindow() |DWDESC_PIXELFORMAT); description.surface_caps = DSCAPS_NONE; - if (screen->preferVideoOnly()) + if (screen->directFBFlags() & QDirectFBScreen::VideoOnly) description.surface_caps = DFBSurfaceCapabilities(description.surface_caps|DSCAPS_VIDEOONLY); const QImage::Format format = screen->pixelFormat(); description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); -- cgit v0.12 From d7be4d1cd394c04f85647b6de823a33aa7b2d900 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 15:44:01 -0700 Subject: Fixed cursors with QT_NO_DIRECTFB_PREALLOCATED Refactor cursor management code to do. No need to change the cooperative level four times for each show/hide. Simplify code a little. Also we used to disable the cursor when we wanted to hide it which meant that we no longer received mouse events. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 150 ++++++++++----------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 4b8af41..0374e58 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -538,16 +538,12 @@ class Q_GUI_EXPORT QDirectFBScreenCursor : public QScreenCursor { public: QDirectFBScreenCursor(); - ~QDirectFBScreenCursor(); - - void set(const QImage &image, int hotx, int hoty); - void move(int x, int y); - void show(); - void hide(); - + virtual void set(const QImage &image, int hotx, int hoty); + virtual void move(int x, int y); + virtual void show(); + virtual void hide(); private: IDirectFBDisplayLayer *layer; - bool implicitHide; }; QDirectFBScreenCursor::QDirectFBScreenCursor() @@ -557,116 +553,120 @@ QDirectFBScreenCursor::QDirectFBScreenCursor() qFatal("QDirectFBScreenCursor: DirectFB not initialized"); layer = QDirectFBScreen::instance()->dfbDisplayLayer(); - - if (layer) - layer->SetCooperativeLevel(layer, DLSCL_SHARED); // XXX: hw: remove? - else - qFatal("QDirectFBScreenCursor: Unable to get primary display layer!"); - - enable = true; - hwaccel = true; - implicitHide = false; - supportsAlpha = true; - - set(QImage(), 0, 0); -} - -QDirectFBScreenCursor::~QDirectFBScreenCursor() -{ -} - -void QDirectFBScreenCursor::show() -{ + Q_ASSERT(layer); DFBResult result; result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::show: " + DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " "Unable to set cooperative level", result); } result = layer->EnableCursor(layer, 1); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::show: " + DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " "Unable to enable cursor", result); } + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); if (result != DFB_OK) { DirectFBError("QDirectFBScreenCursor::show: " - "Unable to reset cooperative level", result); + "Unable to set cooperative level", result); } - implicitHide = false; + + layer->SetCooperativeLevel(layer, DLSCL_SHARED); + + enable = false; + hwaccel = true; + supportsAlpha = true; +} + +void QDirectFBScreenCursor::move(int x, int y) +{ + layer->WarpCursor(layer, x, y); } void QDirectFBScreenCursor::hide() { - DFBResult result; - result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::hide: " - "Unable to set cooperative level", result); - } - result = layer->EnableCursor(layer, 0); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::hide: " - "Unable to disable cursor", result); - } - result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::hide: " - "Unable to reset cooperative level", result); + if (enable) { + QScreenCursor::hide(); + DFBResult result; + result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cooperative level", result); + } + result = layer->SetCursorOpacity(layer, 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cursor opacity", result); + } + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::hide: " + "Unable to set cooperative level", result); + } } - implicitHide = true; } -void QDirectFBScreenCursor::move(int x, int y) +void QDirectFBScreenCursor::show() { - layer->WarpCursor(layer, x, y); + if (!enable) { + QScreenCursor::show(); + DFBResult result; + result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cooperative level", result); + } + result = layer->SetCursorOpacity(layer, 255); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cursor shape", result); + } + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cooperative level", result); + } + } } void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty) { - if (image.isNull() && isVisible()) { - hide(); - implicitHide = true; - } else if (!image.isNull() && implicitHide) { - show(); - } - cursor = image.convertToFormat(QDirectFBScreen::instance()->alphaPixmapFormat()); + QDirectFBScreen *screen = QDirectFBScreen::instance(); + if (!screen) + return; - if (!image.isNull()) { - Q_ASSERT(cursor.numColors() == 0); + if (image.isNull()) { + cursor = QImage(); + hide(); + } else { + cursor = image.convertToFormat(screen->alphaPixmapFormat()); size = cursor.size(); hotspot = QPoint(hotx, hoty); - - DFBSurfaceDescription description; - description = QDirectFBScreen::getSurfaceDescription(cursor); - - IDirectFBSurface *surface; - surface = QDirectFBScreen::instance()->createDFBSurface(&description, - QDirectFBScreen::TrackSurface); + IDirectFBSurface *surface = screen->createDFBSurface(cursor, QDirectFBScreen::DontTrackSurface); if (!surface) { qWarning("QDirectFBScreenCursor::set: Unable to create surface"); return; } DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::set: " + DirectFBError("QDirectFBScreenCursor::show: " "Unable to set cooperative level", result); } result = layer->SetCursorShape(layer, surface, hotx, hoty); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::set: Unable to set cursor shape", - result); + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cursor shape", result); } - + surface->Release(surface); result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::set: " - "Unable to reset cooperative level", result); + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cooperative level", result); } - - if (surface) - QDirectFBScreen::instance()->releaseDFBSurface(surface); + show(); } + } #endif // QT_NO_DIRECTFB_LAYER -- cgit v0.12 From a2397ff9d22c9e66453601226ddb6fc506ea05c0 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 19:15:11 -0700 Subject: Cleaned up mouse/cursor code The enabling/disabling of the Cursor belongs in the QDirectFBMouseHandler class and not in the QDirectFBScreenCursor. Even if we use the Qt software cursor we need the events to come in from the mouse handler. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp | 41 +++++++++++++++------- src/plugins/gfxdrivers/directfb/qdirectfbmouse.h | 1 - .../gfxdrivers/directfb/qdirectfbscreen.cpp | 19 ---------- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index f4d9b46..b999dd2 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -56,9 +56,7 @@ public: QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler *h); ~QDirectFBMouseHandlerPrivate(); - void suspend(); - void resume(); - + void setEnabled(bool on); private: QDirectFBMouseHandler *handler; IDirectFBEventBuffer *eventBuffer; @@ -130,7 +128,7 @@ QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler mouseNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); - resume(); + setEnabled(true); } QDirectFBMouseHandlerPrivate::~QDirectFBMouseHandlerPrivate() @@ -139,15 +137,32 @@ QDirectFBMouseHandlerPrivate::~QDirectFBMouseHandlerPrivate() eventBuffer->Release(eventBuffer); } -void QDirectFBMouseHandlerPrivate::suspend() +void QDirectFBMouseHandlerPrivate::setEnabled(bool on) { - mouseNotifier->setEnabled(false); -} + if (mouseNotifier->isEnabled() != on) { +#ifndef QT_NO_DIRECTFB_LAYER + DFBResult result; + result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " + "Unable to set cooperative level", result); + } + result = layer->EnableCursor(layer, on ? 1 : 0); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " + "Unable to enable cursor", result); + } -void QDirectFBMouseHandlerPrivate::resume() -{ - eventBuffer->Reset(eventBuffer); - mouseNotifier->setEnabled(true); + result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); + if (result != DFB_OK) { + DirectFBError("QDirectFBScreenCursor::show: " + "Unable to set cooperative level", result); + } + + layer->SetCooperativeLevel(layer, DLSCL_SHARED); +#endif + mouseNotifier->setEnabled(on); + } } void QDirectFBMouseHandlerPrivate::readMouseData() @@ -260,12 +275,12 @@ QDirectFBMouseHandler::~QDirectFBMouseHandler() void QDirectFBMouseHandler::suspend() { - d->suspend(); + d->setEnabled(false); } void QDirectFBMouseHandler::resume() { - d->resume(); + d->setEnabled(true); } #include "qdirectfbmouse.moc" diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h index e81a4ba..d2eccfc 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h @@ -61,7 +61,6 @@ public: void suspend(); void resume(); - protected: QDirectFBMouseHandlerPrivate *d; }; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 0374e58..b01e1be 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -554,25 +554,6 @@ QDirectFBScreenCursor::QDirectFBScreenCursor() layer = QDirectFBScreen::instance()->dfbDisplayLayer(); Q_ASSERT(layer); - DFBResult result; - result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " - "Unable to set cooperative level", result); - } - result = layer->EnableCursor(layer, 1); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: " - "Unable to enable cursor", result); - } - - result = layer->SetCooperativeLevel(layer, DLSCL_SHARED); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreenCursor::show: " - "Unable to set cooperative level", result); - } - - layer->SetCooperativeLevel(layer, DLSCL_SHARED); enable = false; hwaccel = true; -- cgit v0.12 From 063d9a01fee83a2753063ff5117d8d84cf219aa3 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 28 Apr 2009 19:17:19 -0700 Subject: Remove superfluous call to base class Make code more readable by not chaining to QScreenCursor for hide/show. Since hwaccel is true we don't need the exposeRegion call anyway. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index b01e1be..a53b1c0 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -568,7 +568,7 @@ void QDirectFBScreenCursor::move(int x, int y) void QDirectFBScreenCursor::hide() { if (enable) { - QScreenCursor::hide(); + enable = false; DFBResult result; result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { @@ -591,7 +591,7 @@ void QDirectFBScreenCursor::hide() void QDirectFBScreenCursor::show() { if (!enable) { - QScreenCursor::show(); + enable = true; DFBResult result; result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE); if (result != DFB_OK) { -- cgit v0.12 From 341fc0e32f715e9227c3329d8eb24f15fd550723 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 29 Apr 2009 13:07:46 +1000 Subject: Fix compile failure on Visual C++ 6. No need to be excessively clever here. Reviewed-by: Trust Me --- tools/assistant/tools/assistant/centralwidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index f953ab7..4390a10 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -394,8 +394,10 @@ void CentralWidget::setLastShownPages() QString::SkipEmptyParts); const int pageCount = lastShownPageList.count(); - if (pageCount == 0 && usesDefaultCollection) - return setSource(QUrl(QLatin1String("help"))); + if (pageCount == 0 && usesDefaultCollection) { + setSource(QUrl(QLatin1String("help"))); + return; + } #if !defined(QT_NO_WEBKIT) const QLatin1String zoom("LastPagesZoomWebView"); -- cgit v0.12 From e378783811b2ace2379becefd1e479ce840f2850 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 29 Apr 2009 13:42:38 +1000 Subject: Fixes performance degradation from precision fix in 4.5.1 Alleviates the performance hit of querying the database except when necessary, try and use XSQLVAR as much as possible, except for floating point fields. Task-number: 252426 --- src/sql/drivers/ibase/qsql_ibase.cpp | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index 0705722..9eeb41d 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -1270,27 +1270,27 @@ QSqlRecord QIBaseResult::record() const v = d->sqlda->sqlvar[i]; QSqlField f(QString::fromLatin1(v.aliasname, v.aliasname_length).simplified(), qIBaseTypeName2(v.sqltype, v.sqlscale < 0)); - QSqlQuery q(new QIBaseResult(d->db)); - q.setForwardOnly(true); - q.exec(QLatin1String("select b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE, b.RDB$FIELD_LENGTH, a.RDB$NULL_FLAG " - "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b " - "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE " - "AND a.RDB$RELATION_NAME = '") + QString::fromAscii(v.relname, v.relname_length).toUpper() + QLatin1String("' " - "AND a.RDB$FIELD_NAME = '") + QString::fromAscii(v.sqlname, v.sqlname_length).toUpper() + QLatin1String("' ")); - if(q.first()) { - if(v.sqlscale < 0) { - f.setLength(q.value(0).toInt()); - f.setPrecision(qAbs(q.value(1).toInt())); - } else { - f.setLength(q.value(2).toInt()); - f.setPrecision(0); + f.setLength(v.sqllen); + f.setPrecision(qAbs(v.sqlscale)); + f.setRequiredStatus((v.sqltype & 1) == 0 ? QSqlField::Required : QSqlField::Optional); + if(v.sqlscale < 0) { + QSqlQuery q(new QIBaseResult(d->db)); + q.setForwardOnly(true); + q.exec(QLatin1String("select b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE, b.RDB$FIELD_LENGTH, a.RDB$NULL_FLAG " + "FROM RDB$RELATION_FIELDS a, RDB$FIELDS b " + "WHERE b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE " + "AND a.RDB$RELATION_NAME = '") + QString::fromAscii(v.relname, v.relname_length).toUpper() + QLatin1String("' " + "AND a.RDB$FIELD_NAME = '") + QString::fromAscii(v.sqlname, v.sqlname_length).toUpper() + QLatin1String("' ")); + if(q.first()) { + if(v.sqlscale < 0) { + f.setLength(q.value(0).toInt()); + f.setPrecision(qAbs(q.value(1).toInt())); + } else { + f.setLength(q.value(2).toInt()); + f.setPrecision(0); + } + f.setRequiredStatus(q.value(3).toBool() ? QSqlField::Required : QSqlField::Optional); } - f.setRequiredStatus(q.value(3).toBool() ? QSqlField::Required : QSqlField::Optional); - } - else { - f.setLength(0); - f.setPrecision(0); - f.setRequiredStatus(QSqlField::Unknown); } f.setSqlType(v.sqltype); rec.append(f); -- cgit v0.12 From 822114e976d7c6644f060ac366c08c92da1a4779 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 29 Apr 2009 14:26:29 +1000 Subject: Try and clean up ODBC 64/32 bit type disparity It seems that after approx version 2.7.0, microsoft changed the ODBC types of certain functions, to cater for 64bit architectures. This tries to be a little bit smarter about which types are used in which places. --- src/sql/drivers/odbc/qsql_odbc.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 2a83fe6..4e90777 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -70,18 +70,16 @@ QT_BEGIN_NAMESPACE #endif // newer platform SDKs use SQLLEN instead of SQLINTEGER -#if defined(SQLLEN) || defined(Q_OS_WIN64) +//#if defined(SQLLEN) || defined(Q_OS_WIN64) +#if ODBCVER >= 0x0270 # define QSQLLEN SQLLEN -#else -# define QSQLLEN SQLINTEGER -#endif - -#if defined(SQLULEN) || defined(Q_OS_WIN64) # define QSQLULEN SQLULEN #else +# define QSQLLEN SQLINTEGER # define QSQLULEN SQLUINTEGER #endif + static const int COLNAMESIZE = 256; //Map Qt parameter types to ODBC types static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT }; -- cgit v0.12 From b66bb091dced94ab5a587b5370344762d40dbebb Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Tue, 28 Apr 2009 17:59:42 -0400 Subject: QNetworkAccessManager: do not segfault when using a network cache Don't setfault when setting 0 for the network cache such as when you want to disable it. Reviewed-by: Peter Hartmann --- src/network/access/qnetworkaccessmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 11e1e46..bcbeef1 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -477,7 +477,8 @@ void QNetworkAccessManager::setCache(QAbstractNetworkCache *cache) if (d->networkCache != cache) { delete d->networkCache; d->networkCache = cache; - d->networkCache->setParent(this); + if (d->networkCache) + d->networkCache->setParent(this); } } -- cgit v0.12 From 382cd313a63e2f9eb357690e2023be79e45f7bc2 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 29 Apr 2009 18:52:09 +1000 Subject: Fix broken link in documentation. Reviewed-by: Trust Me --- doc/src/activeqt.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/activeqt.qdoc b/doc/src/activeqt.qdoc index 3919823..473f815 100644 --- a/doc/src/activeqt.qdoc +++ b/doc/src/activeqt.qdoc @@ -82,7 +82,7 @@ Designer}. The ActiveQt modules are part of the \l{Qt Full Framework Edition} and - the \l{Open Source Versions}. + the \l{Open Source Versions of Qt}. \sa {QAxContainer Module}, {QAxServer Module} */ -- cgit v0.12 From d07de7568cdfb1889e4b64fcbe3fcbfa120ae264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 29 Apr 2009 11:57:32 +0200 Subject: Get rid of an unnecessary image copy when grabbing a GL framebuffer. Task-number: Related to 241466 Reviewed-by: Samuel --- src/opengl/qgl.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8ffee87..04bc611 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1327,13 +1327,21 @@ QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include // This is an old legacy fix for PowerPC based Macs, which // we shouldn't remove while (p < end) { - *p = 0xFF000000 | (*p>>8); + *p = 0xff000000 | (*p>>8); ++p; } } } else { // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB - img = img.rgbSwapped(); + for (int y = 0; y < h; y++) { + uint *q = (uint*)img.scanLine(y); + for (int x=0; x < w; ++x) { + const uint pixel = *q; + *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); + q++; + } + } + } return img.mirrored(); } -- cgit v0.12 From 660907a80e8a3f23f70cd5039407c0cc679af9f3 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Wed, 29 Apr 2009 12:55:44 +0200 Subject: Mac: Fixes a crash in tst_QWidget::updateOnDestroyedSignal Addendum to change 9b674ddcea7c0ff7912f185474b7d98bc83bd39f. The problem was that QWidget::paintEngine() (pure virtual) was called while being in the destructor. The use-case itself (see above change) is very very corner case, but still, it shouldn't crash. Reviewed-by: bnilsen --- src/gui/painting/qbackingstore.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 34df6c9..8fb7a12 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -1510,6 +1510,9 @@ void QWidgetPrivate::invalidateBuffer(const QRect &rect) void QWidgetPrivate::repaint_sys(const QRegion &rgn) { + if (data.in_destructor) + return; + Q_Q(QWidget); if (q->testAttribute(Qt::WA_StaticContents)) { if (!extra) -- cgit v0.12 From 77a0de016ed8afc60a3d8b961b65b94b37d87036 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 29 Apr 2009 14:41:52 +0200 Subject: Fix a crash in case of setting invalid point size Asserts are replaced with warnings and the call is ignored. Task-number: 252414, 252416, 252502 Reviewed-by: Simon Hausmann --- src/gui/text/qfont.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 43f5b1e..24ff10b 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -890,7 +890,10 @@ int QFont::pointSize() const */ void QFont::setPointSize(int pointSize) { - Q_ASSERT_X (pointSize > 0, "QFont::setPointSize", "point size must be greater than 0"); + if (pointSize <= 0) { + qWarning("QFont::setPointSize: Point size <= 0 (%d), must be greater than 0", pointSize); + return; + } detach(); @@ -909,7 +912,10 @@ void QFont::setPointSize(int pointSize) */ void QFont::setPointSizeF(qreal pointSize) { - Q_ASSERT_X(pointSize > 0.0, "QFont::setPointSizeF", "point size must be greater than 0"); + if (pointSize <= 0) { + qWarning("QFont::setPointSizeF: Point size <= 0 (%d), must be greater than 0", pointSize); + return; + } detach(); -- cgit v0.12 From e7cf829c91716ceeb878309a29ef452681dedb09 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Wed, 29 Apr 2009 17:12:53 +0200 Subject: Corrected description of the QLayout::takeAt() function An item is not deleted when removed from the index. The remaining items get a new index. I changed deleted to removed. Tasknumber: 252547 Rev-by: janarve --- src/gui/kernel/qlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp index aa46249..1d5a70d 100644 --- a/src/gui/kernel/qlayout.cpp +++ b/src/gui/kernel/qlayout.cpp @@ -1239,7 +1239,7 @@ bool QLayout::activate() Must be implemented in subclasses to remove the layout item at \a index from the layout, and return the item. If there is no such item, the function must do nothing and return 0. Items are numbered - consecutively from 0. If an item is deleted, other items will be + consecutively from 0. If an item is removed, other items will be renumbered. The following code fragment shows a safe way to remove all items -- cgit v0.12 From d5d8ea9f879e67a7603f47a9a7b6facc489a01d8 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Wed, 29 Apr 2009 17:14:58 +0200 Subject: Corrected typo Changed smae to same Taks number:251646 --- doc/src/layout.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/layout.qdoc b/doc/src/layout.qdoc index 38163c8..55dfd8b 100644 --- a/doc/src/layout.qdoc +++ b/doc/src/layout.qdoc @@ -371,7 +371,7 @@ should store the value in a local variable if you need it again later within in the same function. \o You should not call QLayoutItem::setGeometry() twice on the same - item in the smae function. This call can be very expensive if the + item in the same function. This call can be very expensive if the item has several child widgets, because the layout manager must do a complete layout every time. Instead, calculate the geometry and then set it. (This does not only apply to layouts, you should do -- cgit v0.12 From 3c9fe1670ca0145a131764c26811f9d86ccd714e Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Wed, 29 Apr 2009 17:18:06 +0200 Subject: Corrected bugs in the flow layout example Corrected bugs in the example and added markers for snippets in the documentation. Task-number: 250616 Rev-by: Geir Vattekar --- examples/layouts/flowlayout/flowlayout.cpp | 27 ++++++++++++++++++++++++--- examples/layouts/flowlayout/flowlayout.h | 3 ++- examples/layouts/flowlayout/window.cpp | 3 ++- examples/layouts/flowlayout/window.h | 3 ++- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/examples/layouts/flowlayout/flowlayout.cpp b/examples/layouts/flowlayout/flowlayout.cpp index c4032d0..263911d 100644 --- a/examples/layouts/flowlayout/flowlayout.cpp +++ b/examples/layouts/flowlayout/flowlayout.cpp @@ -42,7 +42,7 @@ #include #include "flowlayout.h" - +//! [1] FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) { @@ -54,19 +54,25 @@ FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) { setContentsMargins(margin, margin, margin, margin); } +//! [1] +//! [2] FlowLayout::~FlowLayout() { QLayoutItem *item; while ((item = takeAt(0))) delete item; } +//! [2] +//! [3] void FlowLayout::addItem(QLayoutItem *item) { itemList.append(item); } +//! [3] +//! [4] int FlowLayout::horizontalSpacing() const { if (m_hSpace >= 0) { @@ -84,7 +90,9 @@ int FlowLayout::verticalSpacing() const return smartSpacing(QStyle::PM_LayoutVerticalSpacing); } } +//! [4] +//! [5] int FlowLayout::count() const { return itemList.size(); @@ -102,12 +110,16 @@ QLayoutItem *FlowLayout::takeAt(int index) else return 0; } +//! [5] +//! [6] Qt::Orientations FlowLayout::expandingDirections() const { return 0; } +//! [6] +//! [7] bool FlowLayout::hasHeightForWidth() const { return true; @@ -118,7 +130,9 @@ int FlowLayout::heightForWidth(int width) const int height = doLayout(QRect(0, 0, width, 0), true); return height; } +//! [7] +//! [8] void FlowLayout::setGeometry(const QRect &rect) { QLayout::setGeometry(rect); @@ -140,7 +154,9 @@ QSize FlowLayout::minimumSize() const size += QSize(2*margin(), 2*margin()); return size; } +//! [8] +//! [9] int FlowLayout::doLayout(const QRect &rect, bool testOnly) const { int left, top, right, bottom; @@ -149,7 +165,9 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const int x = effectiveRect.x(); int y = effectiveRect.y(); int lineHeight = 0; +//! [9] +//! [10] QLayoutItem *item; foreach (item, itemList) { QWidget *wid = item->widget(); @@ -161,6 +179,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const if (spaceY == -1) spaceY = wid->style()->layoutSpacing( QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); +//! [10] +//! [11] int nextX = x + item->sizeHint().width() + spaceX; if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { x = effectiveRect.x(); @@ -177,7 +197,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const } return y + lineHeight - rect.y() + bottom; } - +//! [11] +//! [12] int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const { QObject *parent = this->parent(); @@ -190,4 +211,4 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const return static_cast(parent)->spacing(); } } - +//! [12] diff --git a/examples/layouts/flowlayout/flowlayout.h b/examples/layouts/flowlayout/flowlayout.h index 9940e55..bab7f36 100644 --- a/examples/layouts/flowlayout/flowlayout.h +++ b/examples/layouts/flowlayout/flowlayout.h @@ -45,7 +45,7 @@ #include #include #include - +//! [0] class FlowLayout : public QLayout { public: @@ -74,5 +74,6 @@ private: int m_hSpace; int m_vSpace; }; +//! [0] #endif diff --git a/examples/layouts/flowlayout/window.cpp b/examples/layouts/flowlayout/window.cpp index 51d9886..b7d9eae 100644 --- a/examples/layouts/flowlayout/window.cpp +++ b/examples/layouts/flowlayout/window.cpp @@ -43,7 +43,7 @@ #include "flowlayout.h" #include "window.h" - +//! [1] Window::Window() { FlowLayout *flowLayout = new FlowLayout; @@ -57,3 +57,4 @@ Window::Window() setWindowTitle(tr("Flow Layout")); } +//! [1] \ No newline at end of file diff --git a/examples/layouts/flowlayout/window.h b/examples/layouts/flowlayout/window.h index ffd60af..77f8b6f 100644 --- a/examples/layouts/flowlayout/window.h +++ b/examples/layouts/flowlayout/window.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QLabel; QT_END_NAMESPACE - +//! [0] class Window : public QWidget { Q_OBJECT @@ -55,5 +55,6 @@ class Window : public QWidget public: Window(); }; +//! [0] #endif -- cgit v0.12 From 48d9f395a2d2d0e9e4ff61b69c8c7e725aa3e3fd Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Wed, 29 Apr 2009 17:20:04 +0200 Subject: Documented the flow layout example. Wrote documentation for the flowlayout class. Task-number: 252548 Rev-by: Geir Vattekar Rev-by: janarve --- doc/src/examples/flowlayout.qdoc | 117 ++++++++++++++++++++++++++++++++-- doc/src/images/flowlayout-example.png | Bin 5054 -> 29350 bytes 2 files changed, 113 insertions(+), 4 deletions(-) diff --git a/doc/src/examples/flowlayout.qdoc b/doc/src/examples/flowlayout.qdoc index 557ba39..5fdafe2 100644 --- a/doc/src/examples/flowlayout.qdoc +++ b/doc/src/examples/flowlayout.qdoc @@ -43,8 +43,117 @@ \example layouts/flowlayout \title Flow Layout Example - The Flow Layout example demonstrates a custom layout that arranges child widgets from - left to right and top to bottom in a top-level widget. + The Flow Layout example demonstrates a custom layout that arranges child + widgets from left to right and top to bottom in a top-level widget. - \image flowlayout-example.png -*/ + \image flowlayout-example.png Screenshot of the Flow Layout example + + The items are first laid out horizontally and then vertically when each line + in the layout runs out of space. + + The Flowlayout class mainly uses QLayout and QWidgetItem, while the + Window uses QWidget and QLabel. We will only document the definition + and implementation of \cFlowLayout below. + + \section1 FlowLayout Class Definition + + The \c FlowLayout class inherits QLayout. It is a custom layout class + that arranges its child widgets horizontally and vertically. + + \snippet examples/layouts/flowlayout/flowlayout.h 0 + + We reimplement functions inherited from QLayout. These functions add items to + the layout and handle their orientation and geometry. + + We also declare two private methods, \c doLayout() and \c smartSpacing(). + \c doLayout() lays out the layout items, while the \c + smartSpacing() function calculates the spacing between them. + + \section1 FlowLayout Class Implementation + + We start off by looking at the constructor: + + \snippet examples/layouts/flowlayout/flowlayout.cpp 1 + + In the constructor we call \c setContentsMargins() to set the left, top, + right and bottom margin. By default, QLayout uses values provided by + the current style (see QStyle::PixelMetric). + + \snippet examples/layouts/flowlayout/flowlayout.cpp 2 + + In this example we reimplement \c addItem(), which is a pure virtual + function. When using \c addItem() the ownership of the layout items is + transferred to the layout, and it is therefore the layout's + responsibility to delete them. + + \snippet examples/layouts/flowlayout/flowlayout.cpp 3 + + \c addItem() is implemented to add items to the layout. + + \snippet examples/layouts/flowlayout/flowlayout.cpp 4 + + We implement \c horizontalSpacing() and \c verticalSpacing() to get + hold of the spacing between the widgets inside the layout. If the value + is less than or equal to 0, this value will be used. If not, + \c smartSpacing() will be called to calculate the spacing. + + \snippet examples/layouts/flowlayout/flowlayout.cpp 5 + + We then implement \c count() to return the number of items in the + layout. To navigate the list of items we use \c itemAt() and + takeAt() to remove and return items from the list. If an item is + removed, the remaining items will be renumbered. All three + functions are pure virtual functions from QLayout. + + \snippet examples/layouts/flowlayout/flowlayout.cpp 6 + + \c expandingDirections() returns the \l{Qt::Orientation}s in which the + layout can make use of more space than its \c sizeHint(). + + \snippet examples/layouts/flowlayout/flowlayout.cpp 7 + + To adjust to widgets of which height is dependent on width, we implement \c + heightForWidth(). The function \c hasHeightForWidth() is used to test for this + dependency, and \c heightForWidth() passes the width on to \c doLayout() which + in turn uses the width as an argument for the layout rect, i.e., the bounds in + which the items are laid out. This rect does not include the layout margin(). + + \snippet examples/layouts/flowlayout/flowlayout.cpp 8 + + \c setGeometry() is normally used to do the actual layout, i.e., calculate + the geometry of the layout's items. In this example, it calls \c doLayout() + and passes the layout rect. + + \c sizeHint() returns the preferred size of the layout and \c minimumSize() + returns the minimum size of the layout. + + \snippet examples/layouts/flowlayout/flowlayout.cpp 9 + + \c doLayout() handles the layout if \c horizontalSpacing() or \c + verticalSpacing() don't return the default value. It uses + \c getContentsMargins() to calculate the area available to the + layout items. + + \snippet examples/layouts/flowlayout/flowlayout.cpp 10 + + It then sets the proper amount of spacing for each widget in the + layout, based on the current style. + + \snippet examples/layouts/flowlayout/flowlayout.cpp 11 + + The position of each item in the layout is then calculated by + adding the items width and the line height to the initial x and y + coordinates. This in turn lets us find out whether the next item + will fit on the current line or if it must be moved down to the next. + We also find the height of the current line based on the widgets height. + + \snippet examples/layouts/flowlayout/flowlayout.cpp 12 + + \c smartSpacing() is designed to get the default spacing for either + the top-level layouts or the sublayouts. The default spacing for + top-level layouts, when the parent is a QWidget, will be determined + by querying the style. The default spacing for sublayouts, when + the parent is a QLayout, will be determined by querying the spacing + of the parent layout. + +*/ \ No newline at end of file diff --git a/doc/src/images/flowlayout-example.png b/doc/src/images/flowlayout-example.png index 27660d6..61abe1f 100644 Binary files a/doc/src/images/flowlayout-example.png and b/doc/src/images/flowlayout-example.png differ -- cgit v0.12 From 5a9623cb54c598aa4226883076fb413ef88215e5 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Wed, 29 Apr 2009 16:42:07 +0200 Subject: Wrong clip in QWidget::render(QPainter *, ...) when using Qt::(Replace|No)Clip. The problem was that we didn't take the painter's clip into account when setting the system viewport ("hard clip"). We only used the system clip, but we have to use system clip + painter clip, which is the current engine clip. Unfortunately, we have to calculate it again since there's no cross-platform way of retrieving it. This was only a problem with Qt::(Replace|No)Clip, since we in all other cases combine the old clip with the new one. (Uber cool) auto test included. Task-number: 250482 Reviewed-by: Samuel --- src/gui/kernel/qwidget.cpp | 9 +++- tests/auto/qwidget/tst_qwidget.cpp | 102 +++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index f612601..fb9c8cb 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4824,8 +4824,13 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, const QRegion oldSystemClip = enginePriv->systemClip; const QRegion oldSystemViewport = enginePriv->systemViewport; - // This ensures that transformed system clips are inside the current system clip. - enginePriv->setSystemViewport(oldSystemClip); + // This ensures that all painting triggered by render() is clipped to the current engine clip. + if (painter->hasClipping()) { + const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion()); + enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip); + } else { + enginePriv->setSystemViewport(oldSystemClip); + } render(target, targetOffset, toBePainted, renderFlags); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 767553a..72ffcc3 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -285,6 +285,8 @@ private slots: void render_systemClip(); void render_systemClip2_data(); void render_systemClip2(); + void render_systemClip3_data(); + void render_systemClip3(); void setContentsMargins(); @@ -6995,6 +6997,106 @@ void tst_QWidget::render_systemClip2() } } +void tst_QWidget::render_systemClip3_data() +{ + QTest::addColumn("size"); + QTest::addColumn("useSystemClip"); + + // Reference: http://en.wikipedia.org/wiki/Flag_of_Norway + QTest::newRow("Norwegian Civil Flag") << QSize(220, 160) << false; + QTest::newRow("Norwegian War Flag") << QSize(270, 160) << true; +} + +// This test ensures that the current engine clip (systemClip + painter clip) +// is preserved after QPainter::setClipRegion(..., Qt::ReplaceClip); +void tst_QWidget::render_systemClip3() +{ + QFETCH(QSize, size); + QFETCH(bool, useSystemClip); + + // Calculate the inner/outer cross of the flag. + QRegion outerCross(0, 0, size.width(), size.height()); + outerCross -= QRect(0, 0, 60, 60); + outerCross -= QRect(100, 0, size.width() - 100, 60); + outerCross -= QRect(0, 100, 60, 60); + outerCross -= QRect(100, 100, size.width() - 100, 60); + + QRegion innerCross(0, 0, size.width(), size.height()); + innerCross -= QRect(0, 0, 70, 70); + innerCross -= QRect(90, 0, size.width() - 90, 70); + innerCross -= QRect(0, 90, 70, 70); + innerCross -= QRect(90, 90, size.width() - 90, 70); + + const QRegion redArea(QRegion(0, 0, size.width(), size.height()) - outerCross); + const QRegion whiteArea(outerCross - innerCross); + const QRegion blueArea(innerCross); + QRegion systemClip; + + // Okay, here's the image that should look like a Norwegian civil/war flag in the end. + QImage flag(size, QImage::Format_ARGB32); + flag.fill(QColor(Qt::transparent).rgba()); + + if (useSystemClip) { + QPainterPath warClip(QPoint(size.width(), 0)); + warClip.lineTo(size.width() - 110, 60); + warClip.lineTo(size.width(), 80); + warClip.lineTo(size.width() - 110, 100); + warClip.lineTo(size.width(), 160); + warClip.closeSubpath(); + systemClip = QRegion(0, 0, size.width(), size.height()) - QRegion(warClip.toFillPolygon().toPolygon()); + flag.paintEngine()->setSystemClip(systemClip); + } + + QPainter painter(&flag); + painter.fillRect(QRect(QPoint(), size), Qt::red); // Fill image background with red. + painter.setClipRegion(outerCross); // Limit widget painting to inside the outer cross. + + // Here's the widget that's supposed to draw the inner/outer cross of the flag. + // The outer cross (white) should be drawn when the background is auto-filled, and + // the inner cross (blue) should be drawn in the paintEvent. + class MyWidget : public QWidget + { public: + void paintEvent(QPaintEvent *) + { + QPainter painter(this); + // Be evil and try to paint outside the outer cross. This should not be + // possible since the shared painter is clipped to the outer cross. + painter.setClipRect(0, 0, 60, 60, Qt::ReplaceClip); + painter.fillRect(rect(), Qt::green); + painter.setClipRegion(clip, Qt::ReplaceClip); + painter.fillRect(rect(), Qt::blue); + } + QRegion clip; + }; + + MyWidget widget; + widget.clip = innerCross; + widget.setFixedSize(size); + widget.setPalette(Qt::white); + widget.setAutoFillBackground(true); + widget.render(&painter); + +#ifdef RENDER_DEBUG + flag.save("flag.png"); +#endif + + // Let's make sure we got a Norwegian flag. + for (int i = 0; i < flag.height(); ++i) { + for (int j = 0; j < flag.width(); ++j) { + const QPoint pixel(j, i); + const QRgb pixelValue = flag.pixel(pixel); + if (useSystemClip && !systemClip.contains(pixel)) + QCOMPARE(pixelValue, QColor(Qt::transparent).rgba()); + else if (redArea.contains(pixel)) + QCOMPARE(pixelValue, QColor(Qt::red).rgba()); + else if (whiteArea.contains(pixel)) + QCOMPARE(pixelValue, QColor(Qt::white).rgba()); + else + QCOMPARE(pixelValue, QColor(Qt::blue).rgba()); + } + } +} + void tst_QWidget::setContentsMargins() { QLabel label("why does it always rain on me?"); -- cgit v0.12 From 5969625334270892e39b6b43f4da735b830abdbe Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Wed, 29 Apr 2009 17:33:10 +0200 Subject: Speed-up QPainter::clipRegion(). We can speed up the calculation by using rect intersections if possible, i.e. QRegion &= QRect instead of QRegion &= QRegion. Then we'll get rid of one QRegion construction and the intersection itself is slightly faster. Reviewed-by: Samuel --- src/gui/painting/qpainter.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 65d87fa..759bd7e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2398,7 +2398,6 @@ QRegion QPainter::clipRegion() const // ### Falcon: Use QPainterPath for (int i=0; istate->clipInfo.size(); ++i) { const QPainterClipInfo &info = d->state->clipInfo.at(i); - QRegion other; switch (info.clipType) { case QPainterClipInfo::RegionClip: { @@ -2451,15 +2450,20 @@ QRegion QPainter::clipRegion() const lastWasNothing = false; continue; } - if (info.operation == Qt::IntersectClip) - region &= QRegion(info.rect) * matrix; - else if (info.operation == Qt::UniteClip) + if (info.operation == Qt::IntersectClip) { + // Use rect intersection if possible. + if (matrix.type() <= QTransform::TxScale) + region &= matrix.mapRect(info.rect); + else + region &= matrix.map(QRegion(info.rect)); + } else if (info.operation == Qt::UniteClip) { region |= QRegion(info.rect) * matrix; - else if (info.operation == Qt::NoClip) { + } else if (info.operation == Qt::NoClip) { lastWasNothing = true; region = QRegion(); - } else + } else { region = QRegion(info.rect) * matrix; + } break; } @@ -2470,15 +2474,20 @@ QRegion QPainter::clipRegion() const lastWasNothing = false; continue; } - if (info.operation == Qt::IntersectClip) - region &= QRegion(info.rectf.toRect()) * matrix; - else if (info.operation == Qt::UniteClip) + if (info.operation == Qt::IntersectClip) { + // Use rect intersection if possible. + if (matrix.type() <= QTransform::TxScale) + region &= matrix.mapRect(info.rectf.toRect()); + else + region &= matrix.map(QRegion(info.rectf.toRect())); + } else if (info.operation == Qt::UniteClip) { region |= QRegion(info.rectf.toRect()) * matrix; - else if (info.operation == Qt::NoClip) { + } else if (info.operation == Qt::NoClip) { lastWasNothing = true; region = QRegion(); - } else + } else { region = QRegion(info.rectf.toRect()) * matrix; + } break; } } -- cgit v0.12 From 21958b48caca3423320f3e5e0e83096ca46b4d40 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Wed, 29 Apr 2009 17:34:48 +0200 Subject: QTransform::map(const QRegion&) cut-off for single rect regions. Avoid QRegion<->QPainterPath conversion if possible. Reviewed-by: Samuel --- src/gui/painting/qtransform.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index af27fd5..2383272 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1317,12 +1317,16 @@ QRegion QTransform::map(const QRegion &r) const TransformationType t = type(); if (t == TxNone) return r; + if (t == TxTranslate) { QRegion copy(r); copy.translate(qRound(affine._dx), qRound(affine._dy)); return copy; } + if (t == TxScale && r.numRects() == 1) + return QRegion(mapRect(r.boundingRect())); + QPainterPath p = map(qt_regionToPath(r)); return p.toFillPolygon(QTransform()).toPolygon(); } -- cgit v0.12 From 073b7ce298b0e079f310ec22dee44a9fc0af9ee6 Mon Sep 17 00:00:00 2001 From: Bjoern Erik Nilsen Date: Wed, 29 Apr 2009 18:19:13 +0200 Subject: Stabilize tst_QWidget::render_systemClip2 and remove wrong ifdef We only want to dump images *if* RENDER_DEBUG is defined. --- tests/auto/qwidget/tst_qwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 72ffcc3..dee48a3 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -6956,7 +6956,7 @@ void tst_QWidget::render_systemClip2() // Render entire widget directly onto device. widget.render(&image); -#ifndef RENDER_DEBUG +#ifdef RENDER_DEBUG image.save("systemclip_with_device.png"); #endif // All pixels within the system clip should now be @@ -6972,17 +6972,17 @@ void tst_QWidget::render_systemClip2() // Refill image with red. image.fill(QColor(Qt::red).rgb()); + paintEngine->setSystemClip(systemClip); // Do the same with an untransformed painter. QPainter painter(&image); //Make sure we're using the same paint engine and has the right clip set. - paintEngine->setSystemClip(systemClip); QCOMPARE(painter.paintEngine(), paintEngine); QCOMPARE(paintEngine->systemClip(), systemClip); widget.render(&painter); -#ifndef RENDER_DEBUG +#ifdef RENDER_DEBUG image.save("systemclip_with_untransformed_painter.png"); #endif // All pixels within the system clip should now be -- cgit v0.12 From 2c6fdd89086977708850043a075b2b880bd22c9e Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 30 Apr 2009 10:11:43 +0200 Subject: QApplication::setStyle() can cause a crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QApplication::setStyle() caused a crash if called before constructing the QApplication instance for custom styles. The reason was that polish tried to create a pixmap (which is not allowed before qApp is running). This fix checks that qApp exists. Polish will anyway be called again when qApp gets constructed. Task-number: 243697 Reviewed-by: Bjørn Erik Nilsen --- src/gui/styles/qmacstyle_mac.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 398e11d..c973b41 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -2146,8 +2146,11 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint /*! \reimp */ void QMacStyle::polish(QPalette &pal) { - if (qt_mac_backgroundPattern == 0) + if (!qt_mac_backgroundPattern) { + if (!qApp) + return; qt_mac_backgroundPattern = new QPixmap(d->generateBackgroundPattern()); + } QColor pc(Qt::black); pc = qcolorForTheme(kThemeBrushDialogBackgroundActive); -- cgit v0.12 From c70eae8288cccb92e54e3c73f0ca257af033178a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 30 Apr 2009 12:07:59 +0200 Subject: Fixes a possible issue in itemviws where we would not scroll to the current item on show Task-number: 252534 Reviewed-by: ogoffart --- src/gui/itemviews/qabstractitemview.cpp | 26 ++++++++++++++++---------- src/gui/itemviews/qabstractitemview_p.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 975decc..83e05b4 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -88,6 +88,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() autoScroll(true), autoScrollMargin(16), autoScrollCount(0), + shouldScrollToCurrentOnShow(false), alternatingColors(false), textElideMode(Qt::ElideRight), verticalScrollMode(QAbstractItemView::ScrollPerItem), @@ -1380,8 +1381,9 @@ bool QAbstractItemView::event(QEvent *event) d->executePostedLayout(); //make sure we set the layout properly break; case QEvent::Show: - if (d->delayedPendingLayout) { - d->executePostedLayout(); //make sure we set the layout properly + d->executePostedLayout(); //make sure we set the layout properly + if (d->shouldScrollToCurrentOnShow) { + d->shouldScrollToCurrentOnShow = false; const QModelIndex current = currentIndex(); if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll)) scrollTo(current); @@ -3163,14 +3165,18 @@ void QAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelI d->updateDirtyRegion(); } } - if (isVisible() && current.isValid() && !d->autoScrollTimer.isActive()) { - if (d->autoScroll) - scrollTo(current); - d->setDirtyRegion(visualRect(current)); - d->updateDirtyRegion(); - edit(current, CurrentChanged, 0); - if (current.row() == (d->model->rowCount(d->root) - 1)) - d->_q_fetchMore(); + if (current.isValid() && !d->autoScrollTimer.isActive()) { + if (isVisible()) { + if (d->autoScroll) + scrollTo(current); + d->setDirtyRegion(visualRect(current)); + d->updateDirtyRegion(); + edit(current, CurrentChanged, 0); + if (current.row() == (d->model->rowCount(d->root) - 1)) + d->_q_fetchMore(); + } else { + d->shouldScrollToCurrentOnShow = d->autoScroll; + } } } diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 37fe4a2..16bd1ab 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -359,6 +359,7 @@ public: QBasicTimer autoScrollTimer; int autoScrollMargin; int autoScrollCount; + bool shouldScrollToCurrentOnShow; //used to know if we should scroll to current on show event bool alternatingColors; -- cgit v0.12 From db6f14776a298201e68e1d3646bb99b740c12867 Mon Sep 17 00:00:00 2001 From: jasplin Date: Thu, 30 Apr 2009 11:30:51 +0200 Subject: Fixed busy indicator for a QProgressBar with a style sheet applied to it. For a progress bar with a style sheet applied to it, this fix ensures that the timer event is passed to the event handler that updates the busy indicator animation state. Essentially, the bug was that the decision that the event was processed by the proxy style object (baseStyle()) was based only on the return value from the event() function. In this case it is necessary to check that the event was accepted as well. Reviewed-by: ogoffart Reviewed-by: brad Task-number: 252283 --- src/gui/styles/qstylesheetstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 49ac57a..058660e 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -5842,7 +5842,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c bool QStyleSheetStyle::event(QEvent *e) { - return baseStyle()->event(e) || ParentStyle::event(e); + return (baseStyle()->event(e) && e->isAccepted()) || ParentStyle::event(e); } void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const -- cgit v0.12 From 9cb0419bd9559b5c9e0a95711a81391556306e51 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 30 Apr 2009 13:10:04 +0200 Subject: Correcting typo Missed a whitespace - corrected it. No task --- doc/src/examples/flowlayout.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/examples/flowlayout.qdoc b/doc/src/examples/flowlayout.qdoc index 5fdafe2..3e7ec22 100644 --- a/doc/src/examples/flowlayout.qdoc +++ b/doc/src/examples/flowlayout.qdoc @@ -53,7 +53,7 @@ The Flowlayout class mainly uses QLayout and QWidgetItem, while the Window uses QWidget and QLabel. We will only document the definition - and implementation of \cFlowLayout below. + and implementation of \c FlowLayout below. \section1 FlowLayout Class Definition @@ -156,4 +156,4 @@ the parent is a QLayout, will be determined by querying the spacing of the parent layout. -*/ \ No newline at end of file +*/ -- cgit v0.12 From ea80a3dc8acdb95c0c217b3574718c88c7a36e9f Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 30 Apr 2009 15:31:55 +0200 Subject: New autotest for Windows Mobile: tst_windowsmobile This autotest tests some Windows Mobile 5.0 specific thing like the native menubar and the integration into the window manager by taking and comparing screenshots. This should prevent nasty regressions we had. This autotest makes only sense on Windows Mobile 5.0 in 480x640 Reviewed-by: maurice --- tests/auto/windowsmobile/test/ddhelper.cpp | 121 +++++++++++++ tests/auto/windowsmobile/test/ddhelper.h | 21 +++ tests/auto/windowsmobile/test/test.pro | 24 +++ .../windowsmobile/test/testQMenuBar_current.png | Bin 0 -> 23702 bytes .../test/testSimpleWidget_current.png | Bin 0 -> 21940 bytes .../auto/windowsmobile/test/tst_windowsmobile.cpp | 191 +++++++++++++++++++++ tests/auto/windowsmobile/test/windowsmobile.qrc | 6 + tests/auto/windowsmobile/testQMenuBar/main.cpp | 72 ++++++++ .../windowsmobile/testQMenuBar/testQMenuBar.pro | 2 + tests/auto/windowsmobile/windowsmobile.pro | 9 + 10 files changed, 446 insertions(+) create mode 100644 tests/auto/windowsmobile/test/ddhelper.cpp create mode 100644 tests/auto/windowsmobile/test/ddhelper.h create mode 100644 tests/auto/windowsmobile/test/test.pro create mode 100644 tests/auto/windowsmobile/test/testQMenuBar_current.png create mode 100644 tests/auto/windowsmobile/test/testSimpleWidget_current.png create mode 100644 tests/auto/windowsmobile/test/tst_windowsmobile.cpp create mode 100644 tests/auto/windowsmobile/test/windowsmobile.qrc create mode 100644 tests/auto/windowsmobile/testQMenuBar/main.cpp create mode 100644 tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro create mode 100644 tests/auto/windowsmobile/windowsmobile.pro diff --git a/tests/auto/windowsmobile/test/ddhelper.cpp b/tests/auto/windowsmobile/test/ddhelper.cpp new file mode 100644 index 0000000..5955cd3 --- /dev/null +++ b/tests/auto/windowsmobile/test/ddhelper.cpp @@ -0,0 +1,121 @@ + +#ifdef Q_OS_WINCE_WM + +#include +#include + +static LPDIRECTDRAW g_pDD = NULL; // DirectDraw object +static LPDIRECTDRAWSURFACE g_pDDSSurface = NULL; // DirectDraw primary surface + +static DDSCAPS ddsCaps; +static DDSURFACEDESC ddsSurfaceDesc; +static void *buffer = NULL; + +static int width = 0; +static int height = 0; +static int pitch = 0; +static int bitCount = 0; +static int windowId = 0; + +static bool initialized = false; +static bool locked = false; + +void q_lock() +{ + if (locked) { + qWarning("Direct Painter already locked (QDirectPainter::lock())"); + return; + } + locked = true; + + + memset(&ddsSurfaceDesc, 0, sizeof(ddsSurfaceDesc)); + ddsSurfaceDesc.dwSize = sizeof(ddsSurfaceDesc); + + HRESULT h = g_pDDSSurface->Lock(0, &ddsSurfaceDesc, DDLOCK_WRITEONLY, 0); + if (h != DD_OK) + qDebug() << "GetSurfaceDesc failed!"; + + width = ddsSurfaceDesc.dwWidth; + height = ddsSurfaceDesc.dwHeight; + bitCount = ddsSurfaceDesc.ddpfPixelFormat.dwRGBBitCount; + pitch = ddsSurfaceDesc.lPitch; + buffer = ddsSurfaceDesc.lpSurface; +} + +void q_unlock() +{ + if( !locked) { + qWarning("Direct Painter not locked (QDirectPainter::unlock()"); + return; + } + g_pDDSSurface->Unlock(0); + locked = false; +} + +void q_initDD() +{ + if (initialized) + return; + + DirectDrawCreate(NULL, &g_pDD, NULL); + + HRESULT h; + h = g_pDD->SetCooperativeLevel(0, DDSCL_NORMAL); + + if (h != DD_OK) + qDebug() << "cooperation level failed"; + + h = g_pDD->TestCooperativeLevel(); + if (h != DD_OK) + qDebug() << "cooperation level failed test"; + + DDSURFACEDESC ddsd; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + + ddsd.dwFlags = DDSD_CAPS; + + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + + h = g_pDD->CreateSurface(&ddsd, &g_pDDSSurface, NULL); + + if (h != DD_OK) + qDebug() << "CreateSurface failed!"; + + if (g_pDDSSurface->GetCaps(&ddsCaps) != DD_OK) + qDebug() << "GetCaps failed"; + + q_lock(); + q_unlock(); + initialized = true; +} + +uchar* q_frameBuffer() +{ + return (uchar*) buffer; +} + +int q_screenDepth() +{ + return bitCount; +} + +int q_screenWidth() +{ + return width; +} + +int q_screenHeight() +{ + return height; +} + +int q_linestep() +{ + return pitch; +} + +#endif //Q_OS_WINCE_WM + + diff --git a/tests/auto/windowsmobile/test/ddhelper.h b/tests/auto/windowsmobile/test/ddhelper.h new file mode 100644 index 0000000..3dfa9e6 --- /dev/null +++ b/tests/auto/windowsmobile/test/ddhelper.h @@ -0,0 +1,21 @@ +#ifndef __DDHELPER__ +#define __DDHELPER__ + +extern uchar* q_frameBuffer(); + +extern int q_screenDepth(); + +extern int q_screenWidth(); + +extern int q_screenHeight(); + +extern int q_linestep(); + +extern void q_initDD(); + +extern void q_unlock(); + +extern void q_lock(); + +#endif //__DDHELPER__ + diff --git a/tests/auto/windowsmobile/test/test.pro b/tests/auto/windowsmobile/test/test.pro new file mode 100644 index 0000000..2420bf1 --- /dev/null +++ b/tests/auto/windowsmobile/test/test.pro @@ -0,0 +1,24 @@ + +load(qttest_p4) + +HEADERS += ddhelper.h +SOURCES += tst_windowsmobile.cpp ddhelper.cpp +RESOURCES += windowsmobile.qrc + +TARGET = tst_windowsmobile + +wincewm*: { + addFiles.sources = \ + ../testQMenuBar/*.exe + + + addFiles.path = "\Program Files\tst_windowsmobile" + DEPLOYMENT += addFiles +} + +wincewm*: { + LIBS += Ddraw.lib +} + + + diff --git a/tests/auto/windowsmobile/test/testQMenuBar_current.png b/tests/auto/windowsmobile/test/testQMenuBar_current.png new file mode 100644 index 0000000..d03e69a Binary files /dev/null and b/tests/auto/windowsmobile/test/testQMenuBar_current.png differ diff --git a/tests/auto/windowsmobile/test/testSimpleWidget_current.png b/tests/auto/windowsmobile/test/testSimpleWidget_current.png new file mode 100644 index 0000000..5cbc2bb Binary files /dev/null and b/tests/auto/windowsmobile/test/testSimpleWidget_current.png differ diff --git a/tests/auto/windowsmobile/test/tst_windowsmobile.cpp b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp new file mode 100644 index 0000000..391e206 --- /dev/null +++ b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + + + +class tst_WindowsMobile : public QObject +{ + Q_OBJECT +public: + tst_WindowsMobile() + { +#ifdef Q_OS_WINCE_WM + q_initDD(); +#endif + } + +#ifdef Q_OS_WINCE_WM + private slots: + void testMainWindowAndMenuBar(); + void testSimpleWidget(); +#endif +}; + +#ifdef Q_OS_WINCE_WM + +bool qt_wince_is_platform(const QString &platformString) { + TCHAR tszPlatform[64]; + if (SystemParametersInfo(SPI_GETPLATFORMTYPE, + sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0)) + if (0 == _tcsicmp(reinterpret_cast (platformString.utf16()), tszPlatform)) + return true; + return false; +} + +bool qt_wince_is_smartphone() { + return qt_wince_is_platform(QString::fromLatin1("Smartphone")); +} + +void openMenu() +{ + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,450,630,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,450,630,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,55535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,55535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,58535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,58535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,40535,55535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,40535,55535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,32535,55535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,32535,55535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,65535,65535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,50535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,50535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,55535,40535,0,0); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,55535,40535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE,48535,45535,0,0); + QTest::qWait(2000); + ::mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE,48535,45535,0,0); +} + +void compareScreenshots(const QString &image1, const QString &image2) +{ + if (qt_wince_is_smartphone()) + QSKIP("This test is only for Windows Mobile", SkipAll); + QImage screenShot(image1); + QImage original(image2); + + //ignore the clock + QPainter p1(&screenShot); + QPainter p2(&original); + p1.fillRect(310, 6, 400, 34, Qt::black); + p2.fillRect(310, 6, 400, 34, Qt::black); + + QVERIFY(original == screenShot); +} + +void takeScreenShot(const QString filename) +{ + q_lock(); + QImage image = QImage(( uchar *) q_frameBuffer(), q_screenWidth(), + q_screenHeight(), q_screenWidth() * q_screenDepth() / 8, QImage::Format_RGB16); + image.save(filename, "PNG"); + q_unlock(); +} + +void tst_WindowsMobile::testMainWindowAndMenuBar() +{ + QProcess process; + process.start("testQMenuBar.exe"); + QCOMPARE(process.state(), QProcess::Running); + QTest::qWait(6000); + openMenu(); + QTest::qWait(1000); + takeScreenShot("testQMenuBar_current.png"); + process.close(); + compareScreenshots("testQMenuBar_current.png", ":/testQMenuBar_current.png"); +} + +void tst_WindowsMobile::testSimpleWidget() +{ + QMenuBar menubar; + menubar.show(); + QWidget maximized; + QPalette pal = maximized.palette(); + pal.setColor(QPalette::Background, Qt::red); + maximized.setPalette(pal); + maximized.showMaximized(); + QWidget widget; + widget.setGeometry(100, 100, 200, 200); + widget.setWindowTitle("Widget"); + widget.show(); + qApp->processEvents(); + QTest::qWait(1000); + + QWidget widget2; + widget2.setGeometry(100, 380, 300, 200); + widget2.setWindowTitle("Widget 2"); + widget2.setWindowFlags(Qt::Popup); + widget2.show(); + + qApp->processEvents(); + QTest::qWait(1000); + takeScreenShot("testSimpleWidget_current.png"); + compareScreenshots("testSimpleWidget_current.png", ":/testSimpleWidget_current.png"); +} + + +#endif //Q_OS_WINCE_WM + + +QTEST_MAIN(tst_WindowsMobile) +#include "tst_windowsmobile.moc" + diff --git a/tests/auto/windowsmobile/test/windowsmobile.qrc b/tests/auto/windowsmobile/test/windowsmobile.qrc new file mode 100644 index 0000000..5d6f614 --- /dev/null +++ b/tests/auto/windowsmobile/test/windowsmobile.qrc @@ -0,0 +1,6 @@ + + + testQMenuBar_current.png + testSimpleWidget_current.png + + diff --git a/tests/auto/windowsmobile/testQMenuBar/main.cpp b/tests/auto/windowsmobile/testQMenuBar/main.cpp new file mode 100644 index 0000000..4a3b3b2 --- /dev/null +++ b/tests/auto/windowsmobile/testQMenuBar/main.cpp @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include +#include + +int main(int argc, char * argv[]) +{ + int widgetNum = 20; + + QList widgets; + QApplication app(argc, argv); + + QMainWindow mainWindow; + mainWindow.setWindowTitle("Test"); + QMenu *fileMenu = mainWindow.menuBar()->addMenu("File"); + QMenu *editMenu = mainWindow.menuBar()->addMenu("Edit"); + QMenu *viewMenu = mainWindow.menuBar()->addMenu("View"); + QMenu *toolsMenu = mainWindow.menuBar()->addMenu("Tools"); + QMenu *optionsMenu = mainWindow.menuBar()->addMenu("Options"); + QMenu *helpMenu = mainWindow.menuBar()->addMenu("Help"); + + qApp->processEvents(); + + fileMenu->addAction("Open"); + QAction *close = fileMenu->addAction("Close"); + fileMenu->addSeparator(); + fileMenu->addAction("Exit"); + + close->setEnabled(false); + + editMenu->addAction("Cut"); + editMenu->addAction("Pase"); + editMenu->addAction("Copy"); + editMenu->addSeparator(); + editMenu->addAction("Find"); + + viewMenu->addAction("Hide"); + viewMenu->addAction("Show"); + viewMenu->addAction("Explore"); + QAction *visible = viewMenu->addAction("Visible"); + visible->setCheckable(true); + visible->setChecked(true); + + toolsMenu->addMenu("Hammer"); + toolsMenu->addMenu("Caliper"); + toolsMenu->addMenu("Helm"); + + optionsMenu->addMenu("Settings"); + optionsMenu->addMenu("Standard"); + optionsMenu->addMenu("Extended"); + + QMenu *subMenu = helpMenu->addMenu("Help"); + subMenu->addAction("Index"); + subMenu->addSeparator(); + subMenu->addAction("Vodoo Help"); + helpMenu->addAction("Contens"); + helpMenu->addSeparator(); + helpMenu->addAction("About"); + + QToolBar toolbar; + mainWindow.addToolBar(&toolbar); + toolbar.addAction(QIcon(qApp->style()->standardPixmap(QStyle::SP_FileIcon)), QString("textAction")); + + QTextEdit textEdit; + mainWindow.setCentralWidget(&textEdit); + + mainWindow.showMaximized(); + + app.exec(); +} diff --git a/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro b/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro new file mode 100644 index 0000000..6dd288b --- /dev/null +++ b/tests/auto/windowsmobile/testQMenuBar/testQMenuBar.pro @@ -0,0 +1,2 @@ +SOURCES += main.cpp +DESTDIR = ./ diff --git a/tests/auto/windowsmobile/windowsmobile.pro b/tests/auto/windowsmobile/windowsmobile.pro new file mode 100644 index 0000000..2e6b444 --- /dev/null +++ b/tests/auto/windowsmobile/windowsmobile.pro @@ -0,0 +1,9 @@ + +TEMPLATE = subdirs + +wincewm* { + SUBDIRS = testQMenuBar +} + SUBDIRS += test + + -- cgit v0.12 From 1a18308b311f031d001e3b3e98ffb61e840a6d8c Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 30 Apr 2009 14:35:46 +0200 Subject: QNetworkCookieJar: allow cookies with wrong domain attribute According to the (old) cookie RFC 2109, the domain attribute must always contain a leading dot. Some servers do not have that, but all browsers accept those cookies anyway, so we should do that as well. Reviewed-by: Olivier Reviewed-by: Denis Task-number: 228974 --- src/network/access/qnetworkcookie.cpp | 9 ++++----- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 01a743b..aaa5075 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -976,14 +976,14 @@ QList QNetworkCookie::parseCookies(const QByteArray &cookieStrin cookie.setExpirationDate(dt); } else if (field.first == "domain") { QByteArray rawDomain = field.second; - QString maybeLeadingDot; if (rawDomain.startsWith('.')) { - maybeLeadingDot = QLatin1Char('.'); rawDomain = rawDomain.mid(1); } - QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain))); - cookie.setDomain(maybeLeadingDot + normalizedDomain); + // always add the dot, there are some servers that forget the + // leading dot. This is actually forbidden according to RFC 2109, + // but all browsers accept it anyway so we do that as well + cookie.setDomain(QLatin1Char('.') + normalizedDomain); } else if (field.first == "max-age") { bool ok = false; int secs = field.second.toInt(&ok); @@ -1184,7 +1184,6 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList &cookieLis cookie.expirationDate() < now; // validate the cookie & set the defaults if unset - // (RFC 2965: "The request-URI MUST path-match the Path attribute of the cookie.") if (cookie.path().isEmpty()) cookie.setPath(defaultPath); else if (!isParentPath(pathAndFileName, cookie.path())) diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 36a4b45..4ee5b9f 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -234,7 +234,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("path-with-utf8-2") << "a=b;path=/R%C3%A9sum%C3%A9" << cookie; cookie.setPath(QString()); - cookie.setDomain("trolltech.com"); + cookie.setDomain(".trolltech.com"); QTest::newRow("plain-domain1") << "a=b;domain=trolltech.com" << cookie; QTest::newRow("plain-domain2") << "a=b; domain=trolltech.com " << cookie; QTest::newRow("plain-domain3") << "a=b;domain=TROLLTECH.COM" << cookie; @@ -246,7 +246,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("dot-domain3") << "a=b; domain=.TROLLTECH.COM" << cookie; QTest::newRow("dot-domain4") << "a=b; Domain = .TROLLTECH.COM" << cookie; - cookie.setDomain(QString::fromUtf8("d\303\270gn\303\245pent.troll.no")); + cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no")); QTest::newRow("idn-domain1") << "a=b;domain=xn--dgnpent-gxa2o.troll.no" << cookie; QTest::newRow("idn-domain2") << "a=b;domain=d\303\270gn\303\245pent.troll.no" << cookie; QTest::newRow("idn-domain3") << "a=b;domain=XN--DGNPENT-GXA2O.TROLL.NO" << cookie; @@ -259,7 +259,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("dot-idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie; QTest::newRow("dot-idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie; - cookie.setDomain("trolltech.com"); + cookie.setDomain(".trolltech.com"); cookie.setPath("/"); QTest::newRow("two-fields") << "a=b;domain=trolltech.com;path=/" << cookie; QTest::newRow("two-fields2") << "a=b; domain=trolltech.com; path=/" << cookie; @@ -662,7 +662,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data() QTest::newRow("complex-1") << "c=d, a=, foo=bar; path=/" << list; cookie.setName("baz"); - cookie.setDomain("trolltech.com"); + cookie.setDomain(".trolltech.com"); list.prepend(cookie); QTest::newRow("complex-2") << "baz=bar; path=/; domain=trolltech.com, c=d,a=,foo=bar; path=/" << list; -- cgit v0.12 From 5f7cd6ca85b2cb2dc996f260694255d31670766e Mon Sep 17 00:00:00 2001 From: Bill King Date: Fri, 1 May 2009 14:24:13 +1000 Subject: Apparently this is the best way to determine which to use Best as I can determine via trial and error. It should make vc6 compile again though. --- src/sql/drivers/odbc/qsql_odbc.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 4e90777..9932463 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -70,13 +70,12 @@ QT_BEGIN_NAMESPACE #endif // newer platform SDKs use SQLLEN instead of SQLINTEGER -//#if defined(SQLLEN) || defined(Q_OS_WIN64) -#if ODBCVER >= 0x0270 -# define QSQLLEN SQLLEN -# define QSQLULEN SQLULEN -#else +#if defined(WIN32) && (_MSC_VER < 1300) # define QSQLLEN SQLINTEGER # define QSQLULEN SQLUINTEGER +#else +# define QSQLLEN SQLLEN +# define QSQLULEN SQLULEN #endif -- cgit v0.12 From 1569eaba5eaf99c810d4f205e890b68d069f189b Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 08:31:32 -0700 Subject: Fixed possible crash in QDirectFBPaintEngine::clip d->clip() might return 0 at this point so make sure we check before accessing it. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 9e6f821..364c6e1 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -906,7 +906,7 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); d->setClipDirty(); - if (!d->clip()->hasRectClip && d->clip()->enabled) { + if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); if (bottom.y() >= d->lastLockedHeight) d->lock(); -- cgit v0.12 From ab03f0095a09fa961e53f741294ca8a890e1827f Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 09:42:53 -0700 Subject: Improved readability of the flip code Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 257efeb..09b7a30 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -371,18 +371,13 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, } else { if (region.numRects() > 1) { const QVector rects = region.rects(); - DFBSurfaceFlipFlags tmpFlags = flipFlags; - if (flipFlags & DSFLIP_WAIT) - tmpFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); + const DFBSurfaceFlipFlags nonWaitFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); for (int i=0; iFlip(dfbSurface, &dfbReg, - i + 1 < rects.size() - ? tmpFlags - : flipFlags); + dfbSurface->Flip(dfbSurface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags); } } else { const QRect r = region.boundingRect(); -- cgit v0.12 From 793ea1535f131b4ada2e0049f60cf5e24ad35a7b Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 10:08:44 -0700 Subject: Cleaned up surface creation code Since I am taking a copy of the description anyway it makes sense to just pass this light-weight object in as a copy rather than a const pointer. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 19 ++++------- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 39 +++++++++++----------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 2 +- .../gfxdrivers/directfb/qdirectfbsurface.cpp | 2 +- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 364c6e1..14d2146 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -189,11 +189,10 @@ CachedImage::CachedImage(const QImage &image) : s(0) { IDirectFBSurface *tmpSurface = 0; - DFBSurfaceDescription description; - description = QDirectFBScreen::getSurfaceDescription(image); + DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(image); QDirectFBScreen* screen = QDirectFBScreen::instance(); - tmpSurface = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + tmpSurface = screen->createDFBSurface(description, QDirectFBScreen::TrackSurface); if (!tmpSurface) { qWarning("CachedImage CreateSurface failed!"); return; @@ -205,7 +204,7 @@ CachedImage::CachedImage(const QImage &image) description.flags = DFBSurfaceDescriptionFlags(description.flags & ~DSDESC_PREALLOCATED); - s = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + s = screen->createDFBSurface(description, QDirectFBScreen::TrackSurface); if (!s) qWarning("QDirectFBPaintEngine failed caching image"); @@ -237,10 +236,8 @@ IDirectFBSurface* SurfaceCache::getSurface(const uint *buf, int size) clear(); - DFBSurfaceDescription description; - description = QDirectFBScreen::getSurfaceDescription(buf, size); - - surface = QDirectFBScreen::instance()->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size); + surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface); if (!surface) qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface"); @@ -736,10 +733,8 @@ void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest, } if (!imgSurface) { - DFBSurfaceDescription description; - - description = QDirectFBScreen::getSurfaceDescription(image); - imgSurface = QDirectFBScreen::instance()->createDFBSurface(&description, + DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(image); + imgSurface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::DontTrackSurface); if (!imgSurface) { qWarning("QDirectFBPaintEnginePrivate::drawImage"); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index a53b1c0..e2324ff 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -155,8 +155,7 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCr return surface; } - DFBSurfaceDescription desc = QDirectFBScreen::getSurfaceDescription(img); - IDirectFBSurface *surface = createDFBSurface(&desc, options); + IDirectFBSurface *surface = createDFBSurface(QDirectFBScreen::getSurfaceDescription(img), options); #ifdef QT_NO_DIRECTFB_PREALLOCATED if (surface) { int bpl; @@ -211,11 +210,11 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, return 0; desc.width = size.width(); desc.height = size.height(); - return createDFBSurface(&desc, options); + return createDFBSurface(desc, options); } -IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription *desc, SurfaceCreationOptions options) +IDirectFBSurface* QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options) { DFBResult result; IDirectFBSurface* newSurface = 0; @@ -225,39 +224,39 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(const DFBSurfaceDescription return 0; } - if (d_ptr->directFBFlags & VideoOnly && !(desc->flags & DSDESC_PREALLOCATED)) { + if (d_ptr->directFBFlags & VideoOnly && !(desc.flags & DSDESC_PREALLOCATED)) { // Add the video only capability. This means the surface will be created in video ram - DFBSurfaceDescription voDesc = *desc; - if (!(voDesc.flags & DSDESC_CAPS)) { - voDesc.caps = DSCAPS_VIDEOONLY; - voDesc.flags = DFBSurfaceDescriptionFlags(voDesc.flags | DSDESC_CAPS); + if (!(desc.flags & DSDESC_CAPS)) { + desc.caps = DSCAPS_VIDEOONLY; + desc.flags = DFBSurfaceDescriptionFlags(desc.flags | DSDESC_CAPS); } else { - voDesc.caps = DFBSurfaceCapabilities(voDesc.caps | DSCAPS_VIDEOONLY); + desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_VIDEOONLY); } - result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &voDesc, &newSurface); + result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface); if (result != DFB_OK #ifdef QT_NO_DEBUG - && (desc->flags & DSDESC_CAPS) && (desc->caps & DSCAPS_PRIMARY) + && (desc.flags & DSDESC_CAPS) && (desc.caps & DSCAPS_PRIMARY) #endif ) { qWarning("QDirectFBScreen::createDFBSurface() Failed to create surface in video memory!\n" " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s", - desc->flags, desc->caps, desc->width, desc->height, - desc->pixelformat, DFB_PIXELFORMAT_INDEX(desc->pixelformat), - desc->preallocated[0].data, desc->preallocated[0].pitch, + desc.flags, desc.caps, desc.width, desc.height, + desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat), + desc.preallocated[0].data, desc.preallocated[0].pitch, DirectFBErrorString(result)); } + desc.caps = DFBSurfaceCapabilities(desc.caps & ~DSCAPS_VIDEOONLY); } if (!newSurface) - result = d_ptr->dfb->CreateSurface(d_ptr->dfb, desc, &newSurface); + result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface); if (result != DFB_OK) { qWarning("QDirectFBScreen::createDFBSurface() Failed!\n" " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s", - desc->flags, desc->caps, desc->width, desc->height, - desc->pixelformat, DFB_PIXELFORMAT_INDEX(desc->pixelformat), - desc->preallocated[0].data, desc->preallocated[0].pitch, + desc.flags, desc.caps, desc.width, desc.height, + desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat), + desc.preallocated[0].data, desc.preallocated[0].pitch, DirectFBErrorString(result)); return 0; } @@ -830,7 +829,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) description.caps = DFBSurfaceCapabilities(caps); // We don't track the primary surface as it's released in disconnect - d_ptr->dfbSurface = createDFBSurface(&description, DontTrackSurface); + d_ptr->dfbSurface = createDFBSurface(description, DontTrackSurface); if (!d_ptr->dfbSurface) { DirectFBError("QDirectFBScreen: error creating primary surface", result); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 8e75277..5e948ee 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -103,7 +103,7 @@ public: TrackSurface = 1 }; Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption); - IDirectFBSurface *createDFBSurface(const DFBSurfaceDescription *desc, + IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options); IDirectFBSurface *createDFBSurface(const QImage &image, SurfaceCreationOptions options); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 09b7a30..6167980 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -184,7 +184,7 @@ void QDirectFBSurface::setGeometry(const QRect &rect, const QRegion &mask) description.height = rect.height(); QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, screen->pixelFormat()); - dfbSurface = screen->createDFBSurface(&description, false); + dfbSurface = screen->createDFBSurface(description, false); forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32); } else { Q_ASSERT(dfbSurface); -- cgit v0.12 From a8692a079d0509fcfc45843dc68518007df27fbb Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 10:20:53 -0700 Subject: Extended surface capabilities Clean up code and make it possible to set more DFBSurfaceCapabilities on the primary surface. Also allow users to force systemonly for the surfaces. --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 34 ++++++++++++++++++---- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 3 +- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index e2324ff..858a958 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -214,10 +214,10 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, } -IDirectFBSurface* QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options) +IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options) { - DFBResult result; - IDirectFBSurface* newSurface = 0; + DFBResult result = DFB_OK; + IDirectFBSurface *newSurface = 0; if (!d_ptr->dfb) { qWarning("QDirectFBScreen::createDFBSurface() - not connected"); @@ -247,6 +247,8 @@ IDirectFBSurface* QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, } desc.caps = DFBSurfaceCapabilities(desc.caps & ~DSCAPS_VIDEOONLY); } + if (d_ptr->directFBFlags & SystemOnly) + desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_SYSTEMONLY); if (!newSurface) result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface); @@ -805,6 +807,14 @@ bool QDirectFBScreen::connect(const QString &displaySpec) if (displayArgs.contains(QLatin1String("videoonly"), Qt::CaseInsensitive)) d_ptr->directFBFlags |= VideoOnly; + if (displayArgs.contains(QLatin1String("systemonly"), Qt::CaseInsensitive)) { + if (d_ptr->directFBFlags & VideoOnly) { + qWarning("QDirectFBScreen: error. videoonly and systemonly are mutually exclusive"); + } else { + d_ptr->directFBFlags |= SystemOnly; + } + } + if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) d_ptr->directFBFlags |= IgnoreSystemClip; @@ -819,9 +829,23 @@ bool QDirectFBScreen::connect(const QString &displaySpec) description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_WIDTH); if (::setIntOption(displayArgs, QLatin1String("height"), &description.height)) description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_HEIGHT); + uint caps = DSCAPS_PRIMARY|DSCAPS_DOUBLE; - if (displayArgs.contains(QLatin1String("static_alloc"))) - caps |= DSCAPS_STATIC_ALLOC; + struct { + const char *name; + const DFBSurfaceCapabilities cap; + } const capabilities[] = { + { "static_alloc", DSCAPS_STATIC_ALLOC }, + { "triplebuffer", DSCAPS_TRIPLE }, + { "interlaced", DSCAPS_INTERLACED }, + { "separated", DSCAPS_SEPARATED }, +// { "depthbuffer", DSCAPS_DEPTH }, // only makes sense with TextureTriangles which are not supported + { 0, DSCAPS_NONE } + }; + for (int i=0; capabilities[i].name; ++i) { + if (displayArgs.contains(QString::fromLatin1(capabilities[i].name), Qt::CaseInsensitive)) + caps |= capabilities[i].cap; + } if (displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive)) { caps |= DSCAPS_PREMULTIPLIED; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 5e948ee..6b3a975 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -62,7 +62,8 @@ public: enum DirectFBFlag { NoFlags = 0x00, VideoOnly = 0x01, - IgnoreSystemClip = 0x02 + SystemOnly = 0x02, + IgnoreSystemClip = 0x04 }; Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); -- cgit v0.12 From 8895643e1bd4b784a614bc8f275bb2e63dc2d9f8 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 1 May 2009 11:07:49 -0700 Subject: Improve debug output (in debug mode only) Print out detailed information about acceleration mask, blitting flags and drawing flags when passing debug. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 85 +++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 858a958..4ce549d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -739,6 +739,84 @@ QPixmapData* QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType typ return new QDirectFBPixmapData(type); } +#ifdef QT_NO_DEBUG +struct FlagDescription; +static const FlagDescription *accelerationDescriptions = 0; +static const FlagDescription *blitDescriptions = 0; +static const FlagDescription *drawDescriptions = 0; +#else +struct FlagDescription { + const char *name; + uint flag; +}; + +static const FlagDescription accelerationDescriptions[] = { + { "DFXL_NONE ", DFXL_NONE }, + { "DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE }, + { "DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE }, + { "DFXL_DRAWLINE", DFXL_DRAWLINE }, + { "DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE }, + { "DFXL_BLIT", DFXL_BLIT }, + { "DFXL_STRETCHBLIT", DFXL_STRETCHBLIT }, + { "DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES }, + { "DFXL_DRAWSTRING", DFXL_DRAWSTRING }, + { 0, 0 } +}; + +static const FlagDescription blitDescriptions[] = { + { "DSBLIT_NOFX", DSBLIT_NOFX }, + { "DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL }, + { "DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA }, + { "DSBLIT_COLORIZE", DSBLIT_COLORIZE }, + { "DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY }, + { "DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY }, + { "DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY }, + { "DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY }, + { "DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY }, + { "DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE }, + { "DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR }, + { "DSBLIT_XOR", DSBLIT_XOR }, + { "DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION }, + { 0, 0 } +}; + +static const FlagDescription drawDescriptions[] = { + { "DSDRAW_NOFX", DSDRAW_NOFX }, + { "DSDRAW_BLEND", DSDRAW_BLEND }, + { "DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY }, + { "DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY }, + { "DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY }, + { "DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY }, + { "DSDRAW_XOR", DSDRAW_XOR }, + { 0, 0 } +}; +#endif + + + +static const QByteArray flagDescriptions(uint mask, const FlagDescription *flags) +{ +#ifdef QT_NO_DEBUG + Q_UNUSED(mask); + Q_UNUSED(flags); + return QByteArray(""); +#else + if (!mask) + return flags[0].name; + + QStringList list; + for (int i=1; flags[i].name; ++i) { + if (mask & flags[i].flag) { + list.append(QString::fromLatin1(flags[i].name)); + } + } + Q_ASSERT(!list.isEmpty()); + return (QLatin1Char(' ') + list.join(QLatin1String("|"))).toLatin1(); +#endif +} + + + static void printDirectFBInfo(IDirectFB *fb) { DFBResult result; @@ -751,10 +829,13 @@ static void printDirectFBInfo(IDirectFB *fb) } qDebug("Device: %s (%s), Driver: %s v%i.%i (%s)\n" - " acceleration: 0x%x, blit: 0x%x, draw: 0x%0x video: %i\n", + " acceleration: 0x%x%s,\nblit: 0x%x%s,\ndraw: 0x%0x%s\nvideo: %iKB\n", dev.name, dev.vendor, dev.driver.name, dev.driver.major, dev.driver.minor, dev.driver.vendor, dev.acceleration_mask, - dev.blitting_flags, dev.drawing_flags, dev.video_memory); + ::flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), + dev.blitting_flags, ::flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), + dev.drawing_flags, ::flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), + (dev.video_memory >> 10)); } static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value) -- cgit v0.12 From 111b2c3e40cc475d561d578663565e603963d6e3 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Sat, 2 May 2009 14:01:08 -0700 Subject: Beautified code Qt's coding style => Object *ptr, not Object* ptr Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 20 ++++++++++---------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 14 +++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 4ce549d..f8aaa5f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -84,7 +84,7 @@ public: QImage::Format alphaPixmapFormat; }; -QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen* screen) +QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen) : QWSGraphicsSystem(screen), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE) #ifndef QT_NO_DIRECTFB_LAYER , dfbLayer(0) @@ -113,7 +113,7 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() delete keyboard; #endif - foreach (IDirectFBSurface* surf, allocatedSurfaces) + foreach (IDirectFBSurface *surf, allocatedSurfaces) surf->Release(surf); allocatedSurfaces.clear(); @@ -137,7 +137,7 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() // creates a preallocated surface with the same format as the image if // possible. -IDirectFBSurface* QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCreationOptions options) +IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &img, SurfaceCreationOptions options) { if (img.isNull()) // assert? return 0; @@ -350,18 +350,18 @@ QDirectFBScreen::DirectFBFlags QDirectFBScreen::directFBFlags() const { return d_ptr->directFBFlags; } -IDirectFB* QDirectFBScreen::dfb() +IDirectFB *QDirectFBScreen::dfb() { return d_ptr->dfb; } -IDirectFBSurface* QDirectFBScreen::dfbSurface() +IDirectFBSurface *QDirectFBScreen::dfbSurface() { return d_ptr->dfbSurface; } #ifndef QT_NO_DIRECTFB_LAYER -IDirectFBDisplayLayer* QDirectFBScreen::dfbDisplayLayer() +IDirectFBDisplayLayer *QDirectFBScreen::dfbDisplayLayer() { return d_ptr->dfbLayer; } @@ -731,7 +731,7 @@ void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args) } } -QPixmapData* QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const +QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const { if (type == QPixmapData::BitmapType) return QWSGraphicsSystem::createPixmapData(type); @@ -1025,7 +1025,7 @@ void QDirectFBScreen::disconnect() d_ptr->dfbSurface->Release(d_ptr->dfbSurface); d_ptr->dfbSurface = 0; - foreach (IDirectFBSurface* surf, d_ptr->allocatedSurfaces) + foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces) surf->Release(surf); d_ptr->allocatedSurfaces.clear(); @@ -1094,7 +1094,7 @@ void QDirectFBScreen::blank(bool on) (on ? DSPM_ON : DSPM_SUSPEND)); } -QWSWindowSurface* QDirectFBScreen::createSurface(QWidget *widget) const +QWSWindowSurface *QDirectFBScreen::createSurface(QWidget *widget) const { #ifdef QT_NO_DIRECTFB_WM if (QApplication::type() == QApplication::GuiServer) { @@ -1107,7 +1107,7 @@ QWSWindowSurface* QDirectFBScreen::createSurface(QWidget *widget) const #endif } -QWSWindowSurface* QDirectFBScreen::createSurface(const QString &key) const +QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const { if (key == QLatin1String("directfb")) { return new QDirectFBSurface(d_ptr->flipFlags, const_cast(this)); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 6b3a975..8859d58 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -83,19 +83,19 @@ public: void setMode(int width, int height, int depth); void blank(bool on); - QWSWindowSurface* createSurface(QWidget *widget) const; - QWSWindowSurface* createSurface(const QString &key) const; + QWSWindowSurface *createSurface(QWidget *widget) const; + QWSWindowSurface *createSurface(const QString &key) const; - static inline QDirectFBScreen* instance() { + static inline QDirectFBScreen *instance() { QScreen *inst = QScreen::instance(); Q_ASSERT(!inst || inst->classId() == QScreen::DirectFBClass); return static_cast(inst); } - IDirectFB* dfb(); - IDirectFBSurface* dfbSurface(); + IDirectFB *dfb(); + IDirectFBSurface *dfbSurface(); #ifndef QT_NO_DIRECTFB_LAYER - IDirectFBDisplayLayer* dfbDisplayLayer(); + IDirectFBDisplayLayer *dfbDisplayLayer(); #endif // Track surface creation/release so we can release all on exit @@ -117,7 +117,7 @@ public: IDirectFBSurface *copyToDFBSurface(const QImage &image, QImage::Format format, SurfaceCreationOptions options); - void releaseDFBSurface(IDirectFBSurface* surface); + void releaseDFBSurface(IDirectFBSurface *surface); static int depth(DFBSurfacePixelFormat format); -- cgit v0.12 From bdcdb798d2cc4dc48079622a9c3cbe61be82e80b Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Sun, 3 May 2009 17:34:21 -0700 Subject: Implemented an option to tune flipping export QWS_DISPLAY=directfb:boundingrectflip to enable calling Flip on the bounding rect of the dirtied area rather than each dirty rectangle. This could be faster if you update many small rectangles. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 ++++ src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 3 ++- src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp | 6 ++++-- src/plugins/gfxdrivers/directfb/qdirectfbsurface.h | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index f8aaa5f..c1b75c5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -896,6 +896,10 @@ bool QDirectFBScreen::connect(const QString &displaySpec) } } + if (displayArgs.contains(QLatin1String("boundingrectflip"), Qt::CaseInsensitive)) { + d_ptr->directFBFlags |= BoundingRectFlip; + } + if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) d_ptr->directFBFlags |= IgnoreSystemClip; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 8859d58..42d0ebe 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -63,7 +63,8 @@ public: NoFlags = 0x00, VideoOnly = 0x01, SystemOnly = 0x02, - IgnoreSystemClip = 0x04 + IgnoreSystemClip = 0x04, + BoundingRectFlip = 0x08 }; Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index 6167980..beb9b5f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -50,13 +50,14 @@ //#define QT_DIRECTFB_DEBUG_SURFACES 1 -QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen* scr) +QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) : QDirectFBPaintDevice(scr) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif , engine(0) , flipFlags(flip) + , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { setSurfaceFlags(Opaque | Buffered); #ifdef QT_DIRECTFB_TIMING @@ -72,6 +73,7 @@ QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *sc #endif , engine(0) , flipFlags(flip) + , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) { onscreen = widget->testAttribute(Qt::WA_PaintOnScreen); if (onscreen) @@ -369,7 +371,7 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, if (!(flipFlags & DSFLIP_BLIT)) { dfbSurface->Flip(dfbSurface, 0, flipFlags); } else { - if (region.numRects() > 1) { + if (!boundingRectFlip && region.numRects() > 1) { const QVector rects = region.rects(); const DFBSurfaceFlipFlags nonWaitFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); for (int i=0; i bufferImages; DFBSurfaceFlipFlags flipFlags; + bool boundingRectFlip; #ifdef QT_DIRECTFB_TIMING int frames; QTime timer; -- cgit v0.12 From 279a45131ba60fad9f429c7c429271da5b9cc9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Mon, 4 May 2009 09:44:08 +0200 Subject: Make comment explaning the Mac deployment target setting clearer. --- configure | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure b/configure index b582d85..07a9415 100755 --- a/configure +++ b/configure @@ -6004,10 +6004,11 @@ if [ "$CFG_EXCEPTIONS" = "no" ]; then QMAKE_CONFIG="$QMAKE_CONFIG exceptions_off" fi -# On Mac, set the minimum deployment target using Xarch when that is supported (10.5 and up). -# On 10.4 the deployment version is set to 10.3 globally using the QMAKE_MACOSX_DEPLOYMENT_TARGET env. variable -# "-cocoa" on the command line means Cocoa is used in 32-bit mode also, in this case fall back on -# QMAKE_MACOSX_DEPLOYMENT_TARGET which will be set to 10.5. +# On Mac, set the minimum deployment target for the different architechtures +# using the Xarch compiler option when supported (10.5 and up). On 10.4 the +# deployment version is set to 10.3 globally using the QMAKE_MACOSX_DEPLOYMENT_TARGET +# env. variable. "-cocoa" on the command line means Cocoa is used in 32-bit mode also, +# in this case fall back on QMAKE_MACOSX_DEPLOYMENT_TARGET which will be set to 10.5. if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ] && [ "$COMMANDLINE_MAC_COCOA" != "yes" ]; then if echo "$CFG_MAC_ARCHS" | grep '\' > /dev/null 2>&1; then QMakeVar add QMAKE_CFLAGS "-Xarch_i386 -mmacosx-version-min=10.4" -- cgit v0.12 From aa077a8bd3ee3a134629ef6ac2367b7f11593724 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 4 May 2009 10:44:53 +0200 Subject: Do not crash when passing wrong indexes to QSortFilterProxyModel::indexFomSource and *ToSource Show a warning instead Task-number: 252507 Reviewed-by: Marius Bugge Monsen --- src/gui/itemviews/qsortfilterproxymodel.cpp | 9 +++++++++ .../tst_qsortfilterproxymodel.cpp | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index 91431c4..43feda8 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -144,6 +144,7 @@ public: const QModelIndex &proxy_index) const { Q_ASSERT(proxy_index.isValid()); + Q_ASSERT(proxy_index.model() == q_func()); const void *p = proxy_index.internalPointer(); Q_ASSERT(p); QMap::const_iterator it = @@ -311,6 +312,10 @@ QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &pro { if (!proxy_index.isValid()) return QModelIndex(); // for now; we may want to be able to set a root index later + if (proxy_index.model() != q_func()) { + qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource"; + return QModelIndex(); + } IndexMap::const_iterator it = index_to_iterator(proxy_index); Mapping *m = it.value(); if ((proxy_index.row() >= m->source_rows.size()) || (proxy_index.column() >= m->source_columns.size())) @@ -324,6 +329,10 @@ QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &sou { if (!source_index.isValid()) return QModelIndex(); // for now; we may want to be able to set a root index later + if (source_index.model() != model) { + qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource"; + return QModelIndex(); + } QModelIndex source_parent = source_index.parent(); IndexMap::const_iterator it = create_mapping(source_parent); Mapping *m = it.value(); diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 18aa5fc..bd66fdf 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -133,6 +133,7 @@ private slots: void task248868_dynamicSorting(); void task250023_fetchMore(); void task251296_hiddenChildren(); + void task252507_mapFromToSource(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -2612,6 +2613,7 @@ class QtTestModel: public QAbstractItemModel return fetched.contains(parent) ? rows : 0; } int columnCount(const QModelIndex& parent = QModelIndex()) const { + Q_UNUSED(parent); return cols; } @@ -2717,6 +2719,22 @@ void tst_QSortFilterProxyModel::task251296_hiddenChildren() QCOMPARE(proxy.data(indexC).toString(), QString::fromLatin1("C VISIBLE")); } +void tst_QSortFilterProxyModel::task252507_mapFromToSource() +{ + QtTestModel source(10,10); + source.fetchMore(QModelIndex()); + QSortFilterProxyModel proxy; + proxy.setSourceModel(&source); + QCOMPARE(proxy.mapFromSource(source.index(5, 4)), proxy.index(5, 4)); + QCOMPARE(proxy.mapToSource(proxy.index(3, 2)), source.index(3, 2)); + QCOMPARE(proxy.mapFromSource(QModelIndex()), QModelIndex()); + QCOMPARE(proxy.mapToSource(QModelIndex()), QModelIndex()); + + QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapToSource "); + QCOMPARE(proxy.mapToSource(source.index(2, 3)), QModelIndex()); + QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapFromSource "); + QCOMPARE(proxy.mapFromSource(proxy.index(6, 2)), QModelIndex()); +} QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" -- cgit v0.12 From e223a450ce57a7dc627e0eac14cea019f99fe601 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 4 May 2009 13:13:51 +0200 Subject: Added comment to clearify the use of indexes. Added a comment about the use of negative indexes. Task-number: 249344 Rev-by: Marius Storm-Olsen --- src/corelib/tools/qlistdata.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/tools/qlistdata.cpp b/src/corelib/tools/qlistdata.cpp index d7c39a7..d40b6b6 100644 --- a/src/corelib/tools/qlistdata.cpp +++ b/src/corelib/tools/qlistdata.cpp @@ -764,6 +764,10 @@ void **QListData::erase(void **xi) This function requires the value type to have an implementation of \c operator==(). + Note that QList uses 0-based indexes, just like C++ arrays. Negative + indexes are not supported with the exception of the value mentioned + above. + \sa lastIndexOf(), contains() */ @@ -780,6 +784,10 @@ void **QListData::erase(void **xi) This function requires the value type to have an implementation of \c operator==(). + Note that QList uses 0-based indexes, just like C++ arrays. Negative + indexes are not supported with the exception of the value mentioned + above. + \sa indexOf() */ -- cgit v0.12 From f51ce7c1b349b31f61df48786148c8b3525e2a2c Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Mon, 4 May 2009 13:30:07 +0200 Subject: Doc - Clarifying how to override a Widget's size hint in the Getting to Know Qt Designer document. Task-number: 165435 Reviewed-by: Friedemann Kleint --- doc/src/designer-manual.qdoc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/src/designer-manual.qdoc b/doc/src/designer-manual.qdoc index e10a5be..03b74e6 100644 --- a/doc/src/designer-manual.qdoc +++ b/doc/src/designer-manual.qdoc @@ -344,10 +344,14 @@ of a QLineEdit or the width and height of item view widgets. This is where the widget size constraints -- \l{QWidget::minimumSize()}{minimumSize} and \l{QWidget::maximumSize()}{maximumSize} constraints come into play. These - are properties you can set in the property editor. Alternatively, to use - the current size as a size constraint value, choose one of the - \gui{Size Constraint} options from the widget's context menu. The layout - will then ensure that those constraints are met. + are properties you can set in the property editor. For example, to override + the default \l{QWidget::}{sizeHint()}, simply set + \l{QWidget::minimumSize()}{minimumSize} and \l{QWidget::maximumSize()} + {maximumSize} to the same value. Alternatively, to use the current size as + a size constraint value, choose one of the \gui{Size Constraint} options + from the widget's context menu. The layout will then ensure that those + constraints are met. To control the size of your widgets via code, you can + reimplement \l{QWidget::}{sizeHint()} in your code. The screenshot below shows the breakdown of a basic user interface designed using a grid. The coordinates on the screenshot show the position of each -- cgit v0.12 From 80aef133fd2c8da3cc1a6607c1c044eaca768169 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 26 Apr 2009 17:21:24 +0200 Subject: Greatly reduced the complexity of the boilerplate function. I found out that all I needed to load the proper libraries was to add a string to the ".interp" section of the ELF executable containing the path to ld.so Reviewed-By: Marius Storm-Olsen --- src/corelib/global/qlibraryinfo.cpp | 107 ++++++------------------------------ 1 file changed, 17 insertions(+), 90 deletions(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index ada08c7..29e356e 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -485,100 +485,27 @@ QT_END_NAMESPACE #if defined(Q_CC_GNU) && defined(Q_OS_LINUX) && !defined(QT_LINUXBASE) && !defined(QT_BOOTSTRAPPED) -# include -# include - -static const char boilerplate[] = - "This is the QtCore library version " QT_VERSION_STR "\n" - "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n" - "Contact: Qt Software Information (qt-info@nokia.com)\n" - "\n" - "Build key: " QT_BUILD_KEY; - -extern "C" { -void qt_core_init_boilerplate() __attribute__((noreturn)); -} +# include +# include -# if defined(QT_ARCH_I386) -#define sysinit() (void)0 -#define syswrite(msg, len) \ - ({ int res; \ - asm volatile ("movl %%ebx, %%edi\n" \ - "movl $1, %%ebx\n" \ - "int $0x80\n" \ - "movl %%edi, %%ebx\n" \ - : "=a" (res) : "0" (SYS_write), "c" (msg), "d" (len) : "edi"); res; }) -#define sysexit(c) \ - asm ("xor %%ebx, %%ebx\n" \ - "int $0x80\n" \ - : : "a" (SYS_exit)); _exit(c) - -# elif defined(QT_ARCH_X86_64) -#define sysinit() (void)0 -#define syswrite(msg, len) \ - ({ int res; \ - asm volatile ("syscall\n" \ - : "=a" (res) : "0" (SYS_write), "D" (1), "S" (msg), "d" (len) : "rcx"); res; }) -#define sysexit(c) \ - asm ("syscall\n" \ - : : "a" (SYS_exit), "D" (0)); _exit(c) - -# elif defined(QT_ARCH_IA64) -#define sysinit() \ - asm volatile ("{.mlx\n" \ - " nop.m 0\n" \ - " movl r2 = @pcrel(boilerplate);;" \ - "}\n" \ - "{.mii\n" \ - " mov r10 = @ltoffx(boilerplate)\n" \ - " mov r1 = ip\n" \ - " adds r2 = -16, r2\n;;\n" \ - "}\n" \ - " add r1 = r2, r1;;\n" \ - " sub r1 = r1, r10;;\n" \ - : : : "r2", "r10") -#define syswrite(msg, len) \ - ({ const char *_msg = msg; \ - asm ("mov out0=%1\n" \ - "mov out1=%2\n" \ - "mov out2=%3\n" \ - ";;\n" \ - "mov r15=%0\n" \ - "break 0x100000;;\n" \ - : : "I" (SYS_write), "I" (1), "r" (_msg), "r" (len)); }) -#define sysexit(c) \ - asm ("mov out0=%1\n" \ - ";;\n" \ - "mov r15=%0\n" \ - "break 0x100000;;\n" \ - : : "I" (SYS_exit), "O" (0)); write(1, 0, 0); _exit(c) -# else -#define sysinit() (void)0 -#define syswrite(msg, len) (msg); (len) -#define sysexit(c) __builtin_exit(c) -# endif - -#define sysputs(msg) syswrite(msg, -1 + sizeof(msg)) -#define sysendl() syswrite("\n", 1) -#define print_qt_configure(_which) \ - ({const char *which = _which; \ - which += 12; \ - int len = 0; \ - while (which[len]) ++len; \ - syswrite(which, len); }) +extern const char qt_core_interpreter[] __attribute__((section(".interp"))) + = "/lib/ld-linux.so.2"; +extern "C" void qt_core_init_boilerplate() { - sysinit(); - sysputs(boilerplate); - sysputs("\nInstallation prefix: "); - print_qt_configure(qt_configure_prefix_path_str); - sysputs("\nLibrary path: "); - print_qt_configure(qt_configure_libraries_path_str); - sysputs("\nInclude path: "); - print_qt_configure(qt_configure_headers_path_str); - sysendl(); - sysexit(0); + printf("This is the QtCore library version " QT_VERSION_STR "\n" + "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n" + "Contact: Qt Software Information (qt-info@nokia.com)\n" + "\n" + "Build key: " QT_BUILD_KEY "\n" + "Installation prefix: %s\n" + "Library path: %s\n" + "Include path: %s\n", + qt_configure_prefix_path_str + 12, + qt_configure_libraries_path_str + 12, + qt_configure_headers_path_str + 12); + exit(0); } #endif -- cgit v0.12 From 237b4b8c8e9b5184578b4776c5f1f554c0d8efb5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 4 May 2009 11:48:46 +0200 Subject: Fixed D-Bus socket write notifications, broken since d47c05b1 Shame on me: copy/paste from socketRead to socketWrite, I didn't change the DBUS_WATCH_READABLE to DBUS_WATCH_WRITABLE. Reviewed-by: Trust Me --- src/dbus/qdbusintegrator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 8c701f5..2c27381 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1102,7 +1102,7 @@ void QDBusConnectionPrivate::socketWrite(int fd) } for (int i = 0; i < pendingWatches.size(); ++i) - if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_READABLE)) + if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_WRITABLE)) qDebug("OUT OF MEM"); } -- cgit v0.12 From ea91eb38d81e37bd12d6abc2604f025ac1d254ce Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 4 May 2009 13:54:47 +0200 Subject: Ensure that we send the Apple Events even when Cocoa isn't ready. In general, Cocoa handles the the Apple Events for us. However, this is time between creating the NSApplication and Cocoa has set everything up, usually after the event loop is running. This means that until that time, the events are dropped on the floor :-/. The workaround is to use the same handler that we use for Carbon, but to only have it enabled for until Cocoa is ready to handle things. This will result in not stepping on the toes when used in a plugin (if it does, we can conditionalize it). Task-number: 252795 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qapplication_mac.mm | 32 ++++++++++++++++--------- src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 2 ++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 5f8c572..69302ec 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -194,8 +194,8 @@ static bool appNoGrab = false; // mouse/keyboard grabbing #ifndef QT_MAC_USE_COCOA static EventHandlerRef app_proc_handler = 0; static EventHandlerUPP app_proc_handlerUPP = 0; -static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL; #endif +static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL; static EventHandlerRef tablet_proximity_handler = 0; static EventHandlerUPP tablet_proximity_UPP = 0; bool QApplicationPrivate::native_modal_dialog_active; @@ -951,7 +951,6 @@ void qt_mac_event_release(QWidget *w) } } -#ifndef QT_MAC_USE_COCOA struct QMacAppleEventTypeSpec { AEEventClass mac_class; AEEventID mac_id; @@ -959,6 +958,7 @@ struct QMacAppleEventTypeSpec { { kCoreEventClass, kAEQuitApplication }, { kCoreEventClass, kAEOpenDocuments } }; +#ifndef QT_MAC_USE_COCOA /* watched events */ static EventTypeSpec app_events[] = { { kEventClassQt, kEventQtRequestWindowChange }, @@ -1156,13 +1156,13 @@ void qt_init(QApplicationPrivate *priv, int) qt_init_app_proc_handler(); } +#endif if (!app_proc_ae_handlerUPP) { app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor); for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) AEInstallEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, app_proc_ae_handlerUPP, SRefCon(qApp), true); } -#endif if (QApplicationPrivate::app_style) { QEvent ev(QEvent::Style); @@ -1210,6 +1210,17 @@ void qt_init(QApplicationPrivate *priv, int) } +void qt_release_apple_event_handler() +{ + if(app_proc_ae_handlerUPP) { + for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) + AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, + app_proc_ae_handlerUPP, true); + DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP); + app_proc_ae_handlerUPP = 0; + } +} + /***************************************************************************** qt_cleanup() - cleans up when the application is finished *****************************************************************************/ @@ -1223,15 +1234,8 @@ void qt_cleanup() DisposeEventHandlerUPP(app_proc_handlerUPP); app_proc_handlerUPP = 0; } - if(app_proc_ae_handlerUPP) { - for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) - AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, - app_proc_ae_handlerUPP, true); - DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP); - app_proc_ae_handlerUPP = NULL; - } #endif - + qt_release_apple_event_handler(); qt_release_tablet_proximity_handler(); if (tablet_proximity_UPP) DisposeEventHandlerUPP(tablet_proximity_UPP); @@ -2367,6 +2371,12 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event #endif } +// In Carbon this is your one stop for apple events. +// In Cocoa, it ISN'T. This is the catch-all Apple Event handler that exists +// for the time between instantiating the NSApplication, but before the +// NSApplication has installed it's OWN Apple Event handler. When Cocoa has +// that set up, we remove this. So, if you are debugging problems, you likely +// want to check out QCocoaApplicationDelegate instead. OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, AppleEvent *, long handlerRefcon) { QApplication *app = (QApplication *)handlerRefcon; diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 6571068..dad15d9 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -204,6 +204,8 @@ static void cleanupCocoaApplicationDelegate() { Q_UNUSED(aNotification); inLaunch = false; + extern void qt_release_apple_event_handler(); //qapplication_mac.mm + qt_release_apple_event_handler(); } - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames -- cgit v0.12 From c368a8ed6badab846c8e63c26d48b95788c12163 Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Mon, 4 May 2009 14:01:07 +0200 Subject: Added an assert so that QColormap usage without a QApplication asserts. Task-number: 252668 Reviewed-by: Samuel --- src/gui/painting/qcolormap_win.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qcolormap_win.cpp b/src/gui/painting/qcolormap_win.cpp index d61b933..7d36582 100644 --- a/src/gui/painting/qcolormap_win.cpp +++ b/src/gui/painting/qcolormap_win.cpp @@ -138,7 +138,11 @@ void QColormap::cleanup() } QColormap QColormap::instance(int) -{ return QColormap(); } +{ + Q_ASSERT_X(screenMap, "QColormap", + "A QApplication object needs to be constructed before QColormap is used."); + return QColormap(); +} QColormap::QColormap() : d(screenMap) -- cgit v0.12 From 2ed015b8a0ffad63f0f59b0e2255057f416895fb Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 4 May 2009 14:24:45 +0200 Subject: Added a check that X11 timestamp goes forward only. Got a case somehow with a timestamp of the mouse event that is less than the timestamp we already had, so we need to make sure time only goes forward. Reviewed-by: Brad --- src/gui/kernel/qapplication_x11.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index f1fb001..15149a5 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -3169,43 +3169,48 @@ int QApplication::x11ProcessEvent(XEvent* event) #ifdef ALIEN_DEBUG //qDebug() << "QApplication::x11ProcessEvent:" << event->type; #endif + Time time = 0, userTime = 0; switch (event->type) { case ButtonPress: pressed_window = event->xbutton.window; - X11->userTime = event->xbutton.time; + userTime = event->xbutton.time; // fallthrough intended case ButtonRelease: - X11->time = event->xbutton.time; + time = event->xbutton.time; break; case MotionNotify: - X11->time = event->xmotion.time; + time = event->xmotion.time; break; case XKeyPress: - X11->userTime = event->xkey.time; + userTime = event->xkey.time; // fallthrough intended case XKeyRelease: - X11->time = event->xkey.time; + time = event->xkey.time; break; case PropertyNotify: - X11->time = event->xproperty.time; + time = event->xproperty.time; break; case EnterNotify: case LeaveNotify: - X11->time = event->xcrossing.time; + time = event->xcrossing.time; break; case SelectionClear: - X11->time = event->xselectionclear.time; + time = event->xselectionclear.time; break; default: - break; - } #ifndef QT_NO_XFIXES - if (X11->use_xfixes && event->type == (X11->xfixes_eventbase + XFixesSelectionNotify)) { - XFixesSelectionNotifyEvent *req = - reinterpret_cast(event); - X11->time = req->selection_timestamp; - } + if (X11->use_xfixes && event->type == (X11->xfixes_eventbase + XFixesSelectionNotify)) { + XFixesSelectionNotifyEvent *req = + reinterpret_cast(event); + time = req->selection_timestamp; + } #endif + break; + } + if (time > X11->time) + X11->time = time; + if (userTime > X11->userTime) + X11->userTime = userTime; QETWidget *widget = (QETWidget*)QWidget::find((WId)event->xany.window); -- cgit v0.12 From 0820be4a16f8213ba02e2a2f9fe5df4d1ec6a818 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 4 May 2009 15:20:15 +0200 Subject: Added function that was removed on the way from Qt3 to Qt4 QMimeSource::serialNumber was removed in Qt 4. This was not documented in Porting to Qt 4 Task-number:250575 Rev-By: Trenton Schulz --- doc/src/porting4.qdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/porting4.qdoc b/doc/src/porting4.qdoc index c8a9e2b..b93e139 100644 --- a/doc/src/porting4.qdoc +++ b/doc/src/porting4.qdoc @@ -457,6 +457,7 @@ \row \o QToolButton::offIconSet \o Use the \l{QIcon::Off}{off component} of QAbstractButton::icon instead. \row \o QToolButton::onIconSet \o Use the \l{QIcon::On}{on component} of QAbstractButton::icon instead. \row \o QWidget::microFocusHint \o N/A + \row \o QMimeSource::serialNumber () \o N/A \endtable \omit -- cgit v0.12 From a5c1161fb6bb2a24cebc104bc2a9b8def0a6e466 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 30 Apr 2009 16:59:37 +0200 Subject: QNetworkCookieJar: do not allow cookies for domains like ".com" the domain attribute in cookies must always contain one embedded dot, according to RFC 2109 section 4.3.2 Reviewed-by: Thiago Task-number: 251467 --- src/network/access/qnetworkcookie.cpp | 7 +++++++ tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index aaa5075..82c9344 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -1197,6 +1197,13 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList &cookieLis || isParentDomain(defaultDomain, domain))) { continue; // not accepted } + + // reject if domain is like ".com" + // (i.e., reject if domain does not contain embedded dots, see RFC 2109 section 4.3.2) + // this is just a rudimentary check and does not cover all cases + if (domain.lastIndexOf(QLatin1Char('.')) == 0) + continue; // not accepted + } QList::Iterator it = d->allCookies.begin(), diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index e87a3bf..7aa1d24 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -171,6 +171,17 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() result.clear(); result += finalCookie; QTest::newRow("defaults-2") << preset << cookie << "http://www.foo.tld" << result << true; + + // security test: do not accept cookie domains like ".com" nor ".com." (see RFC 2109 section 4.3.2) + result.clear(); + preset.clear(); + cookie.setDomain(".com"); + QTest::newRow("rfc2109-4.3.2-ex3") << preset << cookie << "http://x.foo.com" << result << false; + + result.clear(); + preset.clear(); + cookie.setDomain(".com."); + QTest::newRow("rfc2109-4.3.2-ex3-2") << preset << cookie << "http://x.foo.com" << result << false; } void tst_QNetworkCookieJar::setCookiesFromUrl() -- cgit v0.12 From 885adf0541e4b709bf5a3774361e85db2a35fc47 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 4 May 2009 10:38:37 -0700 Subject: Lock for read only when possible From benchmarking I've established that surface->Lock(DSLF_READ) is faster than surface->Lock(DSLF_WRITE) which is faster than surface->Lock(DSLF_READ|DSLF_WRITE). This patch will make us Lock for read only, when possible. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 21 +++++++++++++-------- .../gfxdrivers/directfb/qdirectfbpaintdevice.h | 7 +++++-- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 4 ++-- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 12 +++++++++--- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 3 ++- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 6 +++--- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 2 +- .../gfxdrivers/directfb/qdirectfbsurface.cpp | 2 +- src/plugins/gfxdrivers/directfb/qdirectfbsurface.h | 8 ++++---- 9 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 924090c..9796280 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -56,15 +56,20 @@ IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const } -void QDirectFBPaintDevice::lockDirectFB() +void QDirectFBPaintDevice::lockDirectFB(uint flags) { - if (lockedImage) - return; // Already locked - - if (uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, DSLF_WRITE, &bpl)) { + if (lockedImage) { + if (lockFlags & flags) + return; + unlockDirectFB(); + } + if (uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl)) { const QSize s = size(); lockedImage = new QImage(mem, s.width(), s.height(), bpl, QDirectFBScreen::getImageFormat(dfbSurface)); + lockFlags = flags; + } else { + lockFlags = 0; } } @@ -80,10 +85,10 @@ void QDirectFBPaintDevice::unlockDirectFB() } -void* QDirectFBPaintDevice::memory() const +void *QDirectFBPaintDevice::memory() const { QDirectFBPaintDevice* that = const_cast(this); - that->lockDirectFB(); + that->lockDirectFB(DSLF_READ|DSLF_WRITE); Q_ASSERT(that->lockedImage); return that->lockedImage->bits(); } @@ -101,7 +106,7 @@ int QDirectFBPaintDevice::bytesPerLine() const // Can only get the stride when we lock the surface Q_ASSERT(!lockedImage); QDirectFBPaintDevice* that = const_cast(this); - that->lockDirectFB(); + that->lockDirectFB(DSLF_READ); Q_ASSERT(bpl != -1); } return bpl; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index a11064b..1709d69 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -58,7 +58,7 @@ public: IDirectFBSurface *directFBSurface() const; - void lockDirectFB(); + void lockDirectFB(uint flags); void unlockDirectFB(); inline bool forceRasterPrimitives() const { return forceRaster; } @@ -76,7 +76,9 @@ protected: dfbSurface(0), lockedImage(0), screen(scr), - forceRaster(false) {} + forceRaster(false), + lockFlags(0) + {} inline int dotsPerMeterX() const { @@ -92,6 +94,7 @@ protected: QDirectFBScreen *screen; int bpl; bool forceRaster; + uint lockFlags; private: Q_DISABLE_COPY(QDirectFBPaintDevice) }; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 14d2146..e9e2b1f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -1040,7 +1040,7 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, QRasterPaintEngine::drawPixmap(r, pixmap, sr); } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); - const QImage *img = static_cast(pixmap.pixmapData())->buffer(); + const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); d->lock(); QRasterPaintEngine::drawImage(r, *img, sr); } else { @@ -1066,7 +1066,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp); } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); - const QImage *img = static_cast(pixmap.pixmapData())->buffer(); + const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); d->lock(); QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); data->fromImage(*img, Qt::AutoColor); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index ea9bb3a..f7c428b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -357,7 +357,7 @@ QImage QDirectFBPixmapData::toImage() const return img->copy(); } -QPaintEngine* QDirectFBPixmapData::paintEngine() const +QPaintEngine *QDirectFBPixmapData::paintEngine() const { if (!engine) { // QDirectFBPixmapData is also a QCustomRasterPaintDevice, so pass @@ -368,10 +368,15 @@ QPaintEngine* QDirectFBPixmapData::paintEngine() const return engine; } +QImage *QDirectFBPixmapData::buffer() +{ + lockDirectFB(DSLF_READ|DSLF_WRITE); + return lockedImage; +} -QImage* QDirectFBPixmapData::buffer() +QImage * QDirectFBPixmapData::buffer(uint lockFlags) { - lockDirectFB(); + lockDirectFB(lockFlags); return lockedImage; } @@ -381,3 +386,4 @@ void QDirectFBPixmapData::invalidate() alpha = false; format = QImage::Format_Invalid; } + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index 6cfafcd..697e5ce 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -69,7 +69,8 @@ public: Qt::TransformationMode mode) const; QImage toImage() const; QPaintEngine* paintEngine() const; - QImage *buffer(); + virtual QImage *buffer(); + QImage *buffer(uint lockFlags); // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);} diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index c1b75c5..9ec5f5f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1336,12 +1336,12 @@ bool QDirectFBScreen::initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *d return true; } -uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl) +uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, uint flags, int *bpl) { void *mem; - const DFBResult result = surface->Lock(surface, flags, static_cast(&mem), bpl); + const DFBResult result = surface->Lock(surface, static_cast(flags), static_cast(&mem), bpl); if (result != DFB_OK) { - DirectFBError("QDirectFBPixmapData::lockSurface()", result); + DirectFBError("QDirectFBScreen::lockSurface()", result); } return reinterpret_cast(mem); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 42d0ebe..e91a06b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -137,7 +137,7 @@ public: const QImage &image); #endif - static uchar *lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl = 0); + static uchar *lockSurface(IDirectFBSurface *surface, uint flags, int *bpl = 0); private: void compose(const QRegion &r); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index beb9b5f..827e10d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -423,7 +423,7 @@ void QDirectFBSurface::endPaint(const QRegion &) } -QImage* QDirectFBSurface::buffer(const QWidget *widget) +QImage *QDirectFBSurface::buffer(const QWidget *widget) { if (!lockedImage) return 0; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h index 54c14a5..c554096 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h @@ -58,7 +58,7 @@ QT_BEGIN_HEADER QT_MODULE(Gui) -class QDirectFBSurface: public QWSWindowSurface, public QDirectFBPaintDevice +class QDirectFBSurface : public QWSWindowSurface, public QDirectFBPaintDevice { public: QDirectFBSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr); @@ -79,15 +79,15 @@ public: QRegion move(const QPoint &offset, const QRegion &newClip); QImage image() const { return QImage(); } - QPaintDevice* paintDevice() { return this; } - QPaintEngine* paintEngine() const; + QPaintDevice *paintDevice() { return this; } + QPaintEngine *paintEngine() const; void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); void beginPaint(const QRegion &); void endPaint(const QRegion &); - QImage* buffer(const QWidget *widget); + QImage *buffer(const QWidget *widget); private: #ifndef QT_NO_DIRECTFB_WM -- cgit v0.12 From f8f5fe02590da7e67829caf118ba73d455192ec8 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 4 May 2009 11:45:15 -0700 Subject: Rename QDirectFBSurface to QDirectFBWindowSurface This helps avoid confusion between IDirectFBSurface and QDirectFBSurface. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/directfb.pro | 4 +- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 2 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 12 +- .../gfxdrivers/directfb/qdirectfbsurface.cpp | 449 --------------------- src/plugins/gfxdrivers/directfb/qdirectfbsurface.h | 112 ----- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 449 +++++++++++++++++++++ .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 112 +++++ 7 files changed, 570 insertions(+), 570 deletions(-) delete mode 100644 src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp delete mode 100644 src/plugins/gfxdrivers/directfb/qdirectfbsurface.h create mode 100644 src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp create mode 100644 src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index 67f5d61..abdb78f 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -22,7 +22,7 @@ target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target HEADERS = qdirectfbscreen.h \ - qdirectfbsurface.h \ + qdirectfbwindowsurface.h \ qdirectfbpaintengine.h \ qdirectfbpaintdevice.h \ qdirectfbpixmap.h \ @@ -31,7 +31,7 @@ HEADERS = qdirectfbscreen.h \ SOURCES = qdirectfbscreen.cpp \ qdirectfbscreenplugin.cpp \ - qdirectfbsurface.cpp \ + qdirectfbwindowsurface.cpp \ qdirectfbpaintengine.cpp \ qdirectfbpaintdevice.cpp \ qdirectfbpixmap.cpp \ diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index e9e2b1f..92f717e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -43,7 +43,7 @@ #ifndef QT_NO_DIRECTFB -#include "qdirectfbsurface.h" +#include "qdirectfbwindowsurface.h" #include "qdirectfbscreen.h" #include "qdirectfbpixmap.h" #include diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 9ec5f5f..59f5934 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qdirectfbscreen.h" -#include "qdirectfbsurface.h" +#include "qdirectfbwindowsurface.h" #include "qdirectfbpixmap.h" #include "qdirectfbmouse.h" #include "qdirectfbkeyboard.h" @@ -1102,19 +1102,19 @@ QWSWindowSurface *QDirectFBScreen::createSurface(QWidget *widget) const { #ifdef QT_NO_DIRECTFB_WM if (QApplication::type() == QApplication::GuiServer) { - return new QDirectFBSurface(d_ptr->flipFlags, const_cast(this), widget); + return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast(this), widget); } else { return QScreen::createSurface(widget); } #else - return new QDirectFBSurface(d_ptr->flipFlags, const_cast(this), widget); + return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast(this), widget); #endif } QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const { if (key == QLatin1String("directfb")) { - return new QDirectFBSurface(d_ptr->flipFlags, const_cast(this)); + return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast(this)); } return QScreen::createSurface(key); } @@ -1147,7 +1147,7 @@ void QDirectFBScreen::compose(const QRegion ®ion) const QPoint offset = win->requestedRegion().boundingRect().topLeft(); if (surface->key() == QLatin1String("directfb")) { - QDirectFBSurface *s = static_cast(surface); + QDirectFBWindowSurface *s = static_cast(surface); blit(s->directFBSurface(), offset, r); } else { blit(surface->image(), offset, r); @@ -1196,7 +1196,7 @@ void QDirectFBScreen::compose(const QRegion ®ion) const QPoint offset = win->requestedRegion().boundingRect().topLeft(); if (surface->key() == QLatin1String("directfb")) { - QDirectFBSurface *s = static_cast(surface); + QDirectFBWindowSurface *s = static_cast(surface); blit(s->directFBSurface(), offset, r); } else { blit(surface->image(), offset, r); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp deleted file mode 100644 index 827e10d..0000000 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ /dev/null @@ -1,449 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdirectfbsurface.h" -#include "qdirectfbscreen.h" -#include "qdirectfbpaintengine.h" - -#include -#include -#include - - -//#define QT_DIRECTFB_DEBUG_SURFACES 1 - -QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) - : QDirectFBPaintDevice(scr) -#ifndef QT_NO_DIRECTFB_WM - , dfbWindow(0) -#endif - , engine(0) - , flipFlags(flip) - , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) -{ - setSurfaceFlags(Opaque | Buffered); -#ifdef QT_DIRECTFB_TIMING - frames = 0; - timer.start(); -#endif -} - -QDirectFBSurface::QDirectFBSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget) - : QWSWindowSurface(widget), QDirectFBPaintDevice(scr) -#ifndef QT_NO_DIRECTFB_WM - , dfbWindow(0) -#endif - , engine(0) - , flipFlags(flip) - , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) -{ - onscreen = widget->testAttribute(Qt::WA_PaintOnScreen); - if (onscreen) - setSurfaceFlags(Opaque | RegionReserved); - else - setSurfaceFlags(Opaque | Buffered); -#ifdef QT_DIRECTFB_TIMING - frames = 0; - timer.start(); -#endif -} - -QDirectFBSurface::~QDirectFBSurface() -{ -} - -bool QDirectFBSurface::isValid() const -{ - return true; -} - -#ifndef QT_NO_DIRECTFB_WM -void QDirectFBSurface::createWindow() -{ -#ifdef QT_NO_DIRECTFB_LAYER -#warning QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM -#else - IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); - if (!layer) - qFatal("QDirectFBWindowSurface: Unable to get primary display layer!"); - - DFBWindowDescription description; - description.caps = DFBWindowCapabilities(DWCAPS_NODECORATION); - description.flags = DFBWindowDescriptionFlags(DWDESC_CAPS - |DWDESC_SURFACE_CAPS - |DWDESC_PIXELFORMAT); - - description.surface_caps = DSCAPS_NONE; - if (screen->directFBFlags() & QDirectFBScreen::VideoOnly) - description.surface_caps = DFBSurfaceCapabilities(description.surface_caps|DSCAPS_VIDEOONLY); - const QImage::Format format = screen->pixelFormat(); - description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); - if (QDirectFBScreen::isPremultiplied(format)) - description.surface_caps = DFBSurfaceCapabilities(DSCAPS_PREMULTIPLIED|description.caps); - - DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow); - if (result != DFB_OK) - DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result); - - if (dfbSurface) - dfbSurface->Release(dfbSurface); - - dfbWindow->GetSurface(dfbWindow, &dfbSurface); - forceRaster = (format == QImage::Format_RGB32); -#endif -} -#endif // QT_NO_DIRECTFB_WM - -void QDirectFBSurface::setGeometry(const QRect &rect, const QRegion &mask) -{ - if (rect.isNull()) { -#ifndef QT_NO_DIRECTFB_WM - if (dfbWindow) { - dfbWindow->Release(dfbWindow); - dfbWindow = 0; - } -#endif - if (dfbSurface && dfbSurface != screen->dfbSurface()) { - dfbSurface->Release(dfbSurface); - dfbSurface = 0; - } - } else if (rect != geometry()) { - DFBResult result = DFB_OK; - - // If we're in a resize, the surface shouldn't be locked - Q_ASSERT((lockedImage == 0) || (rect.size() == geometry().size())); - - if (onscreen) { - IDirectFBSurface *primarySurface = screen->dfbSurface(); - Q_ASSERT(primarySurface); - if (dfbSurface && dfbSurface != primarySurface) - dfbSurface->Release(dfbSurface); - - if (rect == screen->region().boundingRect()) { - dfbSurface = primarySurface; - } else { - const DFBRectangle r = { rect.x(), rect.y(), - rect.width(), rect.height() }; - result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface); - } - forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32); - } else { - const bool isResize = rect.size() != geometry().size(); -#ifdef QT_NO_DIRECTFB_WM - if (isResize) { - if (dfbSurface) - dfbSurface->Release(dfbSurface); - - IDirectFB *dfb = screen->dfb(); - if (!dfb) { - qFatal("QDirectFBWindowSurface::setGeometry(): " - "Unable to get DirectFB handle!"); - } - - DFBSurfaceDescription description; - description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | - DSDESC_HEIGHT | - DSDESC_PIXELFORMAT); - description.width = rect.width(); - description.height = rect.height(); - QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, - screen->pixelFormat()); - dfbSurface = screen->createDFBSurface(description, false); - forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32); - } else { - Q_ASSERT(dfbSurface); - } -#else - const QRect oldRect = geometry(); - const bool isMove = oldRect.isEmpty() || - rect.topLeft() != oldRect.topLeft(); - - if (!dfbWindow) - createWindow(); - - if (isResize && isMove) - result = dfbWindow->SetBounds(dfbWindow, rect.x(), rect.y(), - rect.width(), rect.height()); - else if (isResize) - result = dfbWindow->Resize(dfbWindow, - rect.width(), rect.height()); - else if (isMove) - result = dfbWindow->MoveTo(dfbWindow, rect.x(), rect.y()); -#endif - } - - if (result != DFB_OK) - DirectFBErrorFatal("QDirectFBSurface::setGeometry()", result); - } - - QWSWindowSurface::setGeometry(rect, mask); -} - -QByteArray QDirectFBSurface::permanentState() const -{ - QByteArray array; -#ifdef QT_NO_DIRECTFB_WM - array.resize(sizeof(SurfaceFlags) + sizeof(IDirectFBSurface*)); -#else - array.resize(sizeof(SurfaceFlags)); -#endif - char *ptr = array.data(); - - *reinterpret_cast(ptr) = surfaceFlags(); - ptr += sizeof(SurfaceFlags); - -#ifdef QT_NO_DIRECTFB_WM - *reinterpret_cast(ptr) = dfbSurface; -#endif - return array; -} - -void QDirectFBSurface::setPermanentState(const QByteArray &state) -{ - SurfaceFlags flags; - const char *ptr = state.constData(); - - flags = *reinterpret_cast(ptr); - setSurfaceFlags(flags); - -#ifdef QT_NO_DIRECTFB_WM - ptr += sizeof(SurfaceFlags); - dfbSurface = *reinterpret_cast(ptr); -#endif -} - -bool QDirectFBSurface::scroll(const QRegion ®ion, int dx, int dy) -{ - if (!dfbSurface || !(flipFlags & DSFLIP_BLIT)) - return false; - - const QVector rects = region.rects(); - const int n = rects.size(); - - QVarLengthArray dfbRects(n); - QVarLengthArray dfbPoints(n); - - for (int i = 0; i < n; ++i) { - const QRect r = rects.at(i); - dfbRects[i].x = r.x(); - dfbRects[i].y = r.y(); - dfbRects[i].w = r.width(); - dfbRects[i].h = r.height(); - dfbPoints[i].x = r.x() + dx; - dfbPoints[i].y = r.y() + dy; - } - - dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); - dfbSurface->BatchBlit(dfbSurface, dfbSurface, - dfbRects.data(), dfbPoints.data(), n); - dfbSurface->ReleaseSource(dfbSurface); - return true; -} - -bool QDirectFBSurface::move(const QPoint &offset) -{ - QWSWindowSurface::move(offset); - -#ifdef QT_NO_DIRECTFB_WM - return true; // buffered -#else - if (!dfbWindow) - return false; - - DFBResult status = dfbWindow->Move(dfbWindow, offset.x(), offset.y()); - return (status == DFB_OK); -#endif -} - -QRegion QDirectFBSurface::move(const QPoint &offset, const QRegion &newClip) -{ -#ifdef QT_NO_DIRECTFB_WM - return QWSWindowSurface::move(offset, newClip); -#else - Q_UNUSED(offset); - Q_UNUSED(newClip); - - // DirectFB handles the entire move, so there's no need to blit. - return QRegion(); -#endif -} - -QPaintEngine* QDirectFBSurface::paintEngine() const -{ - if (!engine) { - QDirectFBSurface *that = const_cast(this); - that->engine = new QDirectFBPaintEngine(that); - return that->engine; - } - return engine; -} - -// hw: XXX: copied from QWidgetPrivate::isOpaque() -inline bool isWidgetOpaque(const QWidget *w) -{ - if (w->testAttribute(Qt::WA_OpaquePaintEvent) - || w->testAttribute(Qt::WA_PaintOnScreen)) - return true; - - const QPalette &pal = w->palette(); - - if (w->autoFillBackground()) { - const QBrush &autoFillBrush = pal.brush(w->backgroundRole()); - if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) - return true; - } - - if (!w->testAttribute(Qt::WA_NoSystemBackground)) { - const QBrush &windowBrush = w->palette().brush(QPalette::Window); - if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) - return true; - } - - return false; -} -void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, - const QPoint &offset) -{ - Q_UNUSED(widget); -#ifdef QT_NO_DIRECTFB_WM - Q_UNUSED(region); - Q_UNUSED(offset); -#endif - - QWidget *win = window(); - - // hw: make sure opacity information is updated before compositing - const bool opaque = isWidgetOpaque(win); - if (opaque != isOpaque()) { - SurfaceFlags flags = Buffered; - if (opaque) - flags |= Opaque; - setSurfaceFlags(flags); - } - -#ifndef QT_NO_DIRECTFB_WM - const quint8 winOpacity = quint8(win->windowOpacity() * 255); - quint8 opacity; - - if (dfbWindow) { - dfbWindow->GetOpacity(dfbWindow, &opacity); - if (winOpacity != opacity) - dfbWindow->SetOpacity(dfbWindow, winOpacity); - } - if (!(flipFlags & DSFLIP_BLIT)) { - dfbSurface->Flip(dfbSurface, 0, flipFlags); - } else { - if (!boundingRectFlip && region.numRects() > 1) { - const QVector rects = region.rects(); - const DFBSurfaceFlipFlags nonWaitFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); - for (int i=0; iFlip(dfbSurface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags); - } - } else { - const QRect r = region.boundingRect(); - const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(), - r.x() + r.width() + offset.x(), - r.y() + r.height() + offset.y() }; - dfbSurface->Flip(dfbSurface, &dfbReg, flipFlags); - } - } -#endif -#ifdef QT_DIRECTFB_TIMING - enum { Secs = 3 }; - ++frames; - if (timer.elapsed() >= Secs * 1000) { - qDebug("%d fps", int(double(frames) / double(Secs))); - frames = 0; - timer.restart(); - } -#endif -} - - -void QDirectFBSurface::beginPaint(const QRegion &) -{ -} - -void QDirectFBSurface::endPaint(const QRegion &) -{ -#ifdef QT_DIRECTFB_DEBUG_SURFACES - if (bufferImages.count()) { - qDebug("QDirectFBSurface::endPaint() this=%p", this); - - foreach(QImage* bufferImg, bufferImages) - qDebug(" Deleting buffer image %p", bufferImg); - } -#endif - - qDeleteAll(bufferImages); - bufferImages.clear(); - unlockDirectFB(); -} - - -QImage *QDirectFBSurface::buffer(const QWidget *widget) -{ - if (!lockedImage) - return 0; - - const QRect rect = QRect(offset(widget), widget->size()) - & lockedImage->rect(); - if (rect.isEmpty()) - return 0; - - QImage *img = new QImage(lockedImage->scanLine(rect.y()) - + rect.x() * (lockedImage->depth() / 8), - rect.width(), rect.height(), - lockedImage->bytesPerLine(), - lockedImage->format()); - bufferImages.append(img); - -#ifdef QT_DIRECTFB_DEBUG_SURFACES - qDebug("QDirectFBSurface::buffer() Created & returned %p", img); -#endif - - return img; -} - diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h deleted file mode 100644 index c554096..0000000 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDIRECFBWINDOWSURFACE_H -#define QDIRECFBWINDOWSURFACE_H - -#include "qdirectfbpaintengine.h" -#include "qdirectfbpaintdevice.h" -#include "qdirectfbscreen.h" - -#include -#include -#include - -#ifdef QT_DIRECTFB_TIMING -#include -#endif - -QT_BEGIN_HEADER - -QT_MODULE(Gui) - -class QDirectFBSurface : public QWSWindowSurface, public QDirectFBPaintDevice -{ -public: - QDirectFBSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr); - QDirectFBSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr, QWidget *widget); - ~QDirectFBSurface(); - - bool isValid() const; - - void setGeometry(const QRect &rect, const QRegion &mask); - - QString key() const { return QLatin1String("directfb"); } - QByteArray permanentState() const; - void setPermanentState(const QByteArray &state); - - bool scroll(const QRegion &area, int dx, int dy); - - bool move(const QPoint &offset); - QRegion move(const QPoint &offset, const QRegion &newClip); - - QImage image() const { return QImage(); } - QPaintDevice *paintDevice() { return this; } - QPaintEngine *paintEngine() const; - - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - - void beginPaint(const QRegion &); - void endPaint(const QRegion &); - - QImage *buffer(const QWidget *widget); - -private: -#ifndef QT_NO_DIRECTFB_WM - void createWindow(); - IDirectFBWindow *dfbWindow; -#endif - QDirectFBPaintEngine *engine; - - bool onscreen; - - QList bufferImages; - DFBSurfaceFlipFlags flipFlags; - bool boundingRectFlip; -#ifdef QT_DIRECTFB_TIMING - int frames; - QTime timer; -#endif -}; - -QT_END_HEADER - -#endif // QDIRECFBWINDOWSURFACE_H diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp new file mode 100644 index 0000000..f1e3c84 --- /dev/null +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -0,0 +1,449 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdirectfbwindowsurface.h" +#include "qdirectfbscreen.h" +#include "qdirectfbpaintengine.h" + +#include +#include +#include + + +//#define QT_DIRECTFB_DEBUG_SURFACES 1 + +QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) + : QDirectFBPaintDevice(scr) +#ifndef QT_NO_DIRECTFB_WM + , dfbWindow(0) +#endif + , engine(0) + , flipFlags(flip) + , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) +{ + setSurfaceFlags(Opaque | Buffered); +#ifdef QT_DIRECTFB_TIMING + frames = 0; + timer.start(); +#endif +} + +QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget) + : QWSWindowSurface(widget), QDirectFBPaintDevice(scr) +#ifndef QT_NO_DIRECTFB_WM + , dfbWindow(0) +#endif + , engine(0) + , flipFlags(flip) + , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) +{ + onscreen = widget->testAttribute(Qt::WA_PaintOnScreen); + if (onscreen) + setSurfaceFlags(Opaque | RegionReserved); + else + setSurfaceFlags(Opaque | Buffered); +#ifdef QT_DIRECTFB_TIMING + frames = 0; + timer.start(); +#endif +} + +QDirectFBWindowSurface::~QDirectFBWindowSurface() +{ +} + +bool QDirectFBWindowSurface::isValid() const +{ + return true; +} + +#ifndef QT_NO_DIRECTFB_WM +void QDirectFBWindowSurface::createWindow() +{ +#ifdef QT_NO_DIRECTFB_LAYER +#warning QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM +#else + IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); + if (!layer) + qFatal("QDirectFBWindowSurface: Unable to get primary display layer!"); + + DFBWindowDescription description; + description.caps = DFBWindowCapabilities(DWCAPS_NODECORATION); + description.flags = DFBWindowDescriptionFlags(DWDESC_CAPS + |DWDESC_SURFACE_CAPS + |DWDESC_PIXELFORMAT); + + description.surface_caps = DSCAPS_NONE; + if (screen->directFBFlags() & QDirectFBScreen::VideoOnly) + description.surface_caps = DFBSurfaceCapabilities(description.surface_caps|DSCAPS_VIDEOONLY); + const QImage::Format format = screen->pixelFormat(); + description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); + if (QDirectFBScreen::isPremultiplied(format)) + description.surface_caps = DFBSurfaceCapabilities(DSCAPS_PREMULTIPLIED|description.caps); + + DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow); + if (result != DFB_OK) + DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result); + + if (dfbSurface) + dfbSurface->Release(dfbSurface); + + dfbWindow->GetSurface(dfbWindow, &dfbSurface); + forceRaster = (format == QImage::Format_RGB32); +#endif +} +#endif // QT_NO_DIRECTFB_WM + +void QDirectFBWindowSurface::setGeometry(const QRect &rect, const QRegion &mask) +{ + if (rect.isNull()) { +#ifndef QT_NO_DIRECTFB_WM + if (dfbWindow) { + dfbWindow->Release(dfbWindow); + dfbWindow = 0; + } +#endif + if (dfbSurface && dfbSurface != screen->dfbSurface()) { + dfbSurface->Release(dfbSurface); + dfbSurface = 0; + } + } else if (rect != geometry()) { + DFBResult result = DFB_OK; + + // If we're in a resize, the surface shouldn't be locked + Q_ASSERT((lockedImage == 0) || (rect.size() == geometry().size())); + + if (onscreen) { + IDirectFBSurface *primarySurface = screen->dfbSurface(); + Q_ASSERT(primarySurface); + if (dfbSurface && dfbSurface != primarySurface) + dfbSurface->Release(dfbSurface); + + if (rect == screen->region().boundingRect()) { + dfbSurface = primarySurface; + } else { + const DFBRectangle r = { rect.x(), rect.y(), + rect.width(), rect.height() }; + result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface); + } + forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32); + } else { + const bool isResize = rect.size() != geometry().size(); +#ifdef QT_NO_DIRECTFB_WM + if (isResize) { + if (dfbSurface) + dfbSurface->Release(dfbSurface); + + IDirectFB *dfb = screen->dfb(); + if (!dfb) { + qFatal("QDirectFBWindowSurface::setGeometry(): " + "Unable to get DirectFB handle!"); + } + + DFBSurfaceDescription description; + description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | + DSDESC_HEIGHT | + DSDESC_PIXELFORMAT); + description.width = rect.width(); + description.height = rect.height(); + QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, + screen->pixelFormat()); + dfbSurface = screen->createDFBSurface(description, false); + forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32); + } else { + Q_ASSERT(dfbSurface); + } +#else + const QRect oldRect = geometry(); + const bool isMove = oldRect.isEmpty() || + rect.topLeft() != oldRect.topLeft(); + + if (!dfbWindow) + createWindow(); + + if (isResize && isMove) + result = dfbWindow->SetBounds(dfbWindow, rect.x(), rect.y(), + rect.width(), rect.height()); + else if (isResize) + result = dfbWindow->Resize(dfbWindow, + rect.width(), rect.height()); + else if (isMove) + result = dfbWindow->MoveTo(dfbWindow, rect.x(), rect.y()); +#endif + } + + if (result != DFB_OK) + DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result); + } + + QWSWindowSurface::setGeometry(rect, mask); +} + +QByteArray QDirectFBWindowSurface::permanentState() const +{ + QByteArray array; +#ifdef QT_NO_DIRECTFB_WM + array.resize(sizeof(SurfaceFlags) + sizeof(IDirectFBSurface*)); +#else + array.resize(sizeof(SurfaceFlags)); +#endif + char *ptr = array.data(); + + *reinterpret_cast(ptr) = surfaceFlags(); + ptr += sizeof(SurfaceFlags); + +#ifdef QT_NO_DIRECTFB_WM + *reinterpret_cast(ptr) = dfbSurface; +#endif + return array; +} + +void QDirectFBWindowSurface::setPermanentState(const QByteArray &state) +{ + SurfaceFlags flags; + const char *ptr = state.constData(); + + flags = *reinterpret_cast(ptr); + setSurfaceFlags(flags); + +#ifdef QT_NO_DIRECTFB_WM + ptr += sizeof(SurfaceFlags); + dfbSurface = *reinterpret_cast(ptr); +#endif +} + +bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) +{ + if (!dfbSurface || !(flipFlags & DSFLIP_BLIT)) + return false; + + const QVector rects = region.rects(); + const int n = rects.size(); + + QVarLengthArray dfbRects(n); + QVarLengthArray dfbPoints(n); + + for (int i = 0; i < n; ++i) { + const QRect r = rects.at(i); + dfbRects[i].x = r.x(); + dfbRects[i].y = r.y(); + dfbRects[i].w = r.width(); + dfbRects[i].h = r.height(); + dfbPoints[i].x = r.x() + dx; + dfbPoints[i].y = r.y() + dy; + } + + dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); + dfbSurface->BatchBlit(dfbSurface, dfbSurface, + dfbRects.data(), dfbPoints.data(), n); + dfbSurface->ReleaseSource(dfbSurface); + return true; +} + +bool QDirectFBWindowSurface::move(const QPoint &offset) +{ + QWSWindowSurface::move(offset); + +#ifdef QT_NO_DIRECTFB_WM + return true; // buffered +#else + if (!dfbWindow) + return false; + + DFBResult status = dfbWindow->Move(dfbWindow, offset.x(), offset.y()); + return (status == DFB_OK); +#endif +} + +QRegion QDirectFBWindowSurface::move(const QPoint &offset, const QRegion &newClip) +{ +#ifdef QT_NO_DIRECTFB_WM + return QWSWindowSurface::move(offset, newClip); +#else + Q_UNUSED(offset); + Q_UNUSED(newClip); + + // DirectFB handles the entire move, so there's no need to blit. + return QRegion(); +#endif +} + +QPaintEngine* QDirectFBWindowSurface::paintEngine() const +{ + if (!engine) { + QDirectFBWindowSurface *that = const_cast(this); + that->engine = new QDirectFBPaintEngine(that); + return that->engine; + } + return engine; +} + +// hw: XXX: copied from QWidgetPrivate::isOpaque() +inline bool isWidgetOpaque(const QWidget *w) +{ + if (w->testAttribute(Qt::WA_OpaquePaintEvent) + || w->testAttribute(Qt::WA_PaintOnScreen)) + return true; + + const QPalette &pal = w->palette(); + + if (w->autoFillBackground()) { + const QBrush &autoFillBrush = pal.brush(w->backgroundRole()); + if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) + return true; + } + + if (!w->testAttribute(Qt::WA_NoSystemBackground)) { + const QBrush &windowBrush = w->palette().brush(QPalette::Window); + if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) + return true; + } + + return false; +} +void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion ®ion, + const QPoint &offset) +{ + Q_UNUSED(widget); +#ifdef QT_NO_DIRECTFB_WM + Q_UNUSED(region); + Q_UNUSED(offset); +#endif + + QWidget *win = window(); + + // hw: make sure opacity information is updated before compositing + const bool opaque = isWidgetOpaque(win); + if (opaque != isOpaque()) { + SurfaceFlags flags = Buffered; + if (opaque) + flags |= Opaque; + setSurfaceFlags(flags); + } + +#ifndef QT_NO_DIRECTFB_WM + const quint8 winOpacity = quint8(win->windowOpacity() * 255); + quint8 opacity; + + if (dfbWindow) { + dfbWindow->GetOpacity(dfbWindow, &opacity); + if (winOpacity != opacity) + dfbWindow->SetOpacity(dfbWindow, winOpacity); + } + if (!(flipFlags & DSFLIP_BLIT)) { + dfbSurface->Flip(dfbSurface, 0, flipFlags); + } else { + if (!boundingRectFlip && region.numRects() > 1) { + const QVector rects = region.rects(); + const DFBSurfaceFlipFlags nonWaitFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); + for (int i=0; iFlip(dfbSurface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags); + } + } else { + const QRect r = region.boundingRect(); + const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(), + r.x() + r.width() + offset.x(), + r.y() + r.height() + offset.y() }; + dfbSurface->Flip(dfbSurface, &dfbReg, flipFlags); + } + } +#endif +#ifdef QT_DIRECTFB_TIMING + enum { Secs = 3 }; + ++frames; + if (timer.elapsed() >= Secs * 1000) { + qDebug("%d fps", int(double(frames) / double(Secs))); + frames = 0; + timer.restart(); + } +#endif +} + + +void QDirectFBWindowSurface::beginPaint(const QRegion &) +{ +} + +void QDirectFBWindowSurface::endPaint(const QRegion &) +{ +#ifdef QT_DIRECTFB_DEBUG_SURFACES + if (bufferImages.count()) { + qDebug("QDirectFBWindowSurface::endPaint() this=%p", this); + + foreach(QImage* bufferImg, bufferImages) + qDebug(" Deleting buffer image %p", bufferImg); + } +#endif + + qDeleteAll(bufferImages); + bufferImages.clear(); + unlockDirectFB(); +} + + +QImage *QDirectFBWindowSurface::buffer(const QWidget *widget) +{ + if (!lockedImage) + return 0; + + const QRect rect = QRect(offset(widget), widget->size()) + & lockedImage->rect(); + if (rect.isEmpty()) + return 0; + + QImage *img = new QImage(lockedImage->scanLine(rect.y()) + + rect.x() * (lockedImage->depth() / 8), + rect.width(), rect.height(), + lockedImage->bytesPerLine(), + lockedImage->format()); + bufferImages.append(img); + +#ifdef QT_DIRECTFB_DEBUG_SURFACES + qDebug("QDirectFBWindowSurface::buffer() Created & returned %p", img); +#endif + + return img; +} + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h new file mode 100644 index 0000000..75998c4 --- /dev/null +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDIRECFBWINDOWSURFACE_H +#define QDIRECFBWINDOWSURFACE_H + +#include "qdirectfbpaintengine.h" +#include "qdirectfbpaintdevice.h" +#include "qdirectfbscreen.h" + +#include +#include +#include + +#ifdef QT_DIRECTFB_TIMING +#include +#endif + +QT_BEGIN_HEADER + +QT_MODULE(Gui) + +class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice +{ +public: + QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr); + QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr, QWidget *widget); + ~QDirectFBWindowSurface(); + + bool isValid() const; + + void setGeometry(const QRect &rect, const QRegion &mask); + + QString key() const { return QLatin1String("directfb"); } + QByteArray permanentState() const; + void setPermanentState(const QByteArray &state); + + bool scroll(const QRegion &area, int dx, int dy); + + bool move(const QPoint &offset); + QRegion move(const QPoint &offset, const QRegion &newClip); + + QImage image() const { return QImage(); } + QPaintDevice *paintDevice() { return this; } + QPaintEngine *paintEngine() const; + + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + + void beginPaint(const QRegion &); + void endPaint(const QRegion &); + + QImage *buffer(const QWidget *widget); + +private: +#ifndef QT_NO_DIRECTFB_WM + void createWindow(); + IDirectFBWindow *dfbWindow; +#endif + QDirectFBPaintEngine *engine; + + bool onscreen; + + QList bufferImages; + DFBSurfaceFlipFlags flipFlags; + bool boundingRectFlip; +#ifdef QT_DIRECTFB_TIMING + int frames; + QTime timer; +#endif +}; + +QT_END_HEADER + +#endif // QDIRECFBWINDOWSURFACE_H -- cgit v0.12 From 4287f0e94a643c9c7cf8bced6722163026e1a6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Tue, 5 May 2009 11:26:45 +0200 Subject: Make the Mac configure tests consistent when configuring for multiple architechtures. For example, ./configure -arch x86_64 -arch ppc requires D-Bus compiled for x86_64 and ppc in order to enable it. Task-number: 249881 Reviewed-by: nrc --- config.tests/unix/compile.test | 9 ++++++- configure | 60 ++++++++++++++++++++++++------------------ 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/config.tests/unix/compile.test b/config.tests/unix/compile.test index b5afa18..ff51c91 100755 --- a/config.tests/unix/compile.test +++ b/config.tests/unix/compile.test @@ -14,6 +14,8 @@ shift 7 LFLAGS="" INCLUDEPATH="" CXXFLAGS="" +MAC_ARCH_CXXFLAGS="" +MAC_ARCH_LFLAGS="" while [ "$#" -gt 0 ]; do PARAM=$1 case $PARAM in @@ -21,6 +23,11 @@ while [ "$#" -gt 0 ]; do LFLAGS="$LFLAGS -framework \"$2\"" shift ;; + -arch) + MAC_ARCH_CXXFLAGS="$MAC_ARCH_CXXFLAGS -arch $2" + MAC_ARCH_LFLAGS="$MAC_ARCH_LFLAGS -arch $2" + shift + ;; -F*|-m*|-x*) LFLAGS="$LFLAGS $PARAM" CXXFLAGS="$CXXFLAGS $PARAM" @@ -53,7 +60,7 @@ test -d "$OUTDIR/$TEST" || mkdir -p "$OUTDIR/$TEST" cd "$OUTDIR/$TEST" make distclean >/dev/null 2>&1 -"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "LIBS*=$LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile" +"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile" if [ "$VERBOSE" = "yes" ]; then make diff --git a/configure b/configure index 07a9415..e007782 100755 --- a/configure +++ b/configure @@ -668,6 +668,7 @@ CFG_INOTIFY=auto CFG_RPATH=yes CFG_FRAMEWORK=auto CFG_MAC_ARCHS= +MAC_ARCHS_COMMANDLINE= CFG_MAC_DWARF2=auto CFG_MAC_XARCH=auto CFG_MAC_CARBON=yes @@ -2698,8 +2699,9 @@ if [ "$QT_CROSS_COMPILE" = "yes" ]; then fi fi -# check -arch arguments for validity. +# process CFG_MAC_ARCHS if [ "$PLATFORM_MAC" = "yes" ]; then +# check -arch arguments for validity. ALLOWED="x86 ppc x86_64 ppc64 i386" for i in $CFG_MAC_ARCHS do @@ -2711,6 +2713,14 @@ if [ "$PLATFORM_MAC" = "yes" ]; then # replace "i386" with "x86" to support configuring with -arch i386 as an alias for x86. CFG_MAC_ARCHS="${CFG_MAC_ARCHS/i386/x86}" + +# Build commmand line arguments we can pass to the compiler during configure tests +# by prefixing each arch with "-arch". + CFG_MAC_ARCHS_GCC_FORMAT="${CFG_MAC_ARCHS/x86/i386}" + CFG_MAC_ARCHS_GCC_FORMAT="${CFG_MAC_ARCHS/i386_64/x86_64}" + for ARCH in $CFG_MAC_ARCHS_GCC_FORMAT; do + MAC_ARCHS_COMMANDLINE="$MAC_ARCHS_COMMANDLINE -arch $ARCH" + done fi # find the default framework value @@ -4247,7 +4257,7 @@ if [ "$CFG_ZLIB" = "no" ]; then ZLIB_FORCED=yes fi if [ "$CFG_ZLIB" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/zlib "zlib" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/zlib "zlib" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_ZLIB=system else CFG_ZLIB=yes @@ -4264,7 +4274,7 @@ if [ "$CFG_JPEG" = "auto" ]; then fi # detect jpeg if [ "$CFG_LIBJPEG" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libjpeg "libjpeg" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libjpeg "libjpeg" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_LIBJPEG=system else CFG_LIBJPEG=qt @@ -4291,7 +4301,7 @@ fi # detect tiff if [ "$CFG_LIBTIFF" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libtiff "libtiff" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libtiff "libtiff" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_LIBTIFF=system else CFG_LIBTIFF=qt @@ -4308,7 +4318,7 @@ if [ "$CFG_MNG" = "auto" ]; then fi # detect mng if [ "$CFG_LIBMNG" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libmng "libmng" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libmng "libmng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_LIBMNG=system else CFG_LIBMNG=qt @@ -4317,7 +4327,7 @@ fi # detect png if [ "$CFG_LIBPNG" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libpng "libpng" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/libpng "libpng" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_LIBPNG=system else CFG_LIBPNG=qt @@ -4356,13 +4366,13 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do QT_CFLAGS_MYSQL="" fi else - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql_r "MySQL (thread-safe)" $QT_LFLAGS_MYSQL_R $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql_r "MySQL (thread-safe)" $QT_LFLAGS_MYSQL_R $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then QMakeVar add CONFIG use_libmysqlclient_r if [ "$CFG_SQL_mysql" = "auto" ]; then CFG_SQL_mysql=plugin fi QT_LFLAGS_MYSQL="$QT_LFLAGS_MYSQL_R" - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql "MySQL (thread-unsafe)" $QT_LFLAGS_MYSQL $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS; then + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/mysql "MySQL (thread-unsafe)" $QT_LFLAGS_MYSQL $L_FLAGS $QT_CFLAGS_MYSQL $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_mysql" = "auto" ]; then CFG_SQL_mysql=plugin fi @@ -4391,7 +4401,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do fi [ -z "$QT_CFLAGS_PSQL" ] || QT_CFLAGS_PSQL="-I$QT_CFLAGS_PSQL" [ -z "$QT_LFLAGS_PSQL" ] || QT_LFLAGS_PSQL="-L$QT_LFLAGS_PSQL" - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/psql "PostgreSQL" $QT_LFLAGS_PSQL $L_FLAGS $QT_CFLAGS_PSQL $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/psql "PostgreSQL" $QT_LFLAGS_PSQL $L_FLAGS $QT_CFLAGS_PSQL $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_psql" = "auto" ]; then CFG_SQL_psql=plugin fi @@ -4412,7 +4422,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; odbc) if [ "$CFG_SQL_odbc" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_odbc" = "auto" ]; then CFG_SQL_odbc=plugin fi @@ -4431,7 +4441,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; oci) if [ "$CFG_SQL_oci" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/oci "OCI" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/oci "OCI" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_oci" = "auto" ]; then CFG_SQL_oci=plugin fi @@ -4450,7 +4460,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; tds) if [ "$CFG_SQL_tds" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tds "TDS" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/tds "TDS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_tds" = "auto" ]; then CFG_SQL_tds=plugin fi @@ -4469,7 +4479,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; db2) if [ "$CFG_SQL_db2" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/db2 "DB2" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/db2 "DB2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_db2" = "auto" ]; then CFG_SQL_db2=plugin fi @@ -4488,7 +4498,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; ibase) if [ "$CFG_SQL_ibase" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ibase "InterBase" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ibase "InterBase" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_ibase" = "auto" ]; then CFG_SQL_ibase=plugin fi @@ -4507,7 +4517,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; sqlite2) if [ "$CFG_SQL_sqlite2" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite2 "SQLite2" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite2 "SQLite2" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_sqlite2" = "auto" ]; then CFG_SQL_sqlite2=plugin fi @@ -4532,7 +4542,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do QT_CFLAGS_SQLITE=`$PKG_CONFIG --cflags sqlite3 2>/dev/null` QT_LFLAGS_SQLITE=`$PKG_CONFIG --libs sqlite3 2>/dev/null` fi - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $L_FLAGS $QT_CFLAGS_SQLITE $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/sqlite "SQLite" $QT_LFLAGS_SQLITE $L_FLAGS $QT_CFLAGS_SQLITE $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_SQL_sqlite" = "auto" ]; then CFG_SQL_sqlite=plugin fi @@ -4569,7 +4579,7 @@ done # auto-detect NIS support if [ "$CFG_NIS" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/nis "NIS" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/nis "NIS" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_NIS=yes else if [ "$CFG_NIS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then @@ -4586,7 +4596,7 @@ fi # auto-detect CUPS support if [ "$CFG_CUPS" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/cups "Cups" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/cups "Cups" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_CUPS=yes else if [ "$CFG_CUPS" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then @@ -4605,9 +4615,9 @@ fi if [ "$CFG_ICONV" != "no" ]; then if [ "$PLATFORM_QWS" = "yes" ]; then CFG_ICONV=no - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS; then + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_ICONV=yes - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/gnu-libiconv" "GNU libiconv" $L_FLAGS $I_FLAGS $l_FLAGS; then + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/gnu-libiconv" "GNU libiconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_ICONV=gnu else if [ "$CFG_ICONV" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then @@ -4628,7 +4638,7 @@ if [ "$CFG_DBUS" != "no" ]; then QT_CFLAGS_DBUS=`$PKG_CONFIG --cflags dbus-1 2>/dev/null` QT_LIBS_DBUS=`$PKG_CONFIG --libs dbus-1 2>/dev/null` fi - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/dbus "D-Bus" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DBUS $QT_LIBS_DBUS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/dbus "D-Bus" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DBUS $QT_LIBS_DBUS $MAC_ARCHS_COMMANDLINE; then [ "$CFG_DBUS" = "auto" ] && CFG_DBUS=yes QMakeVar set QT_CFLAGS_DBUS "$QT_CFLAGS_DBUS" QMakeVar set QT_LIBS_DBUS "$QT_LIBS_DBUS" @@ -4661,7 +4671,7 @@ if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then QT_CFLAGS_GLIB=`$PKG_CONFIG --cflags glib-2.0 gthread-2.0 2>/dev/null` QT_LIBS_GLIB=`$PKG_CONFIG --libs glib-2.0 gthread-2.0 2>/dev/null` fi - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/glib "Glib" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_GLIB $QT_LIBS_GLIB $X11TESTS_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/glib "Glib" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_GLIB $QT_LIBS_GLIB $X11TESTS_FLAGS ; then CFG_GLIB=yes QMakeVar set QT_CFLAGS_GLIB "$QT_CFLAGS_GLIB" QMakeVar set QT_LIBS_GLIB "$QT_LIBS_GLIB" @@ -5188,7 +5198,7 @@ fi # QWS [ "x$CFG_EMBEDDED" != "xno" ] && CFG_LIBFREETYPE="$CFG_QWS_FREETYPE" [ "x$PLATFORM_MAC" = "xyes" ] && CFG_LIBFREETYPE=no if [ "$CFG_LIBFREETYPE" = "auto" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/freetype "FreeType" $L_FLAGS $I_FLAGS $l_FLAGS ; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/freetype "FreeType" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_LIBFREETYPE=system else CFG_LIBFREETYPE=yes @@ -5305,7 +5315,7 @@ fi # find if the platform supports IPv6 if [ "$CFG_IPV6" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6 "IPv6" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/ipv6 "IPv6" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then CFG_IPV6=yes else if [ "$CFG_IPV6" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then @@ -5436,7 +5446,7 @@ fi # detect OpenSSL if [ "$CFG_OPENSSL" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/openssl "OpenSSL" $L_FLAGS $I_FLAGS $l_FLAGS; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/openssl "OpenSSL" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_ARCHS_COMMANDLINE; then if [ "$CFG_OPENSSL" = "auto" ]; then CFG_OPENSSL=yes fi -- cgit v0.12 From 8d96a5510cb433371a0e8686f20f1a39c0a286d3 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 5 May 2009 12:26:48 +0200 Subject: On Windows loosing focus should result in clearing focus if widget is embedded somewhere. If a widget is embedded to non-Qt window on Windows, then we should still clear the focus whenever we receive WM_KILLFOCUS since we won't get WM_ACTIVATEAPP in this case. This is an addition to 6ed196051d0f19bfe2d045eaf12f5f5ca30670d0 Task-number: 251259 Reviewed-by: Thierry --- src/gui/kernel/qapplication_win.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index fae0335..bc32c14 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2432,10 +2432,12 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam widget = (QETWidget*)qApp->focusWidget(); HWND focus = ::GetFocus(); //if there is a current widget and the new widget belongs to the same toplevel window + //or if the current widget was embedded into non-qt window (i.e. we won't get WM_ACTIVATEAPP) //then we clear the focus on the widget //in case the new widget belongs to a different widget hierarchy, clearing the focus //will be handled because the active window will change - if (widget && ::IsChild(widget->window()->internalWinId(), focus)) { + const bool embedded = widget && ((QETWidget*)widget->window())->topData()->embedded; + if (widget && (embedded || ::IsChild(widget->window()->internalWinId(), focus))) { widget->clearFocus(); result = true; } else { -- cgit v0.12 From 0600097e58946f8af280349eebc01bc3415f0d61 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 5 May 2009 13:24:11 +0200 Subject: QListView in icon mode could crash when removing the last element Task-number: 252292 Reviewed-by: ogoffart --- src/gui/itemviews/qlistview.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 07f0a38..48f53a0 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1997,14 +1997,15 @@ bool QListViewPrivate::doItemsLayout(int delta) int first = batchStartRow(); int last = qMin(first + delta - 1, max); - if (max < 0 || last < first) - return true; // nothing to do - if (first == 0) { layoutChildren(); // make sure the viewport has the right size prepareItemsLayout(); } + if (max < 0 || last < first) { + return true; // nothing to do + } + QListViewLayoutInfo info; info.bounds = layoutBounds; info.grid = gridSize(); -- cgit v0.12 From ce9379739616cd716371b073521f6bbf01e0ce61 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 5 May 2009 14:05:03 +0200 Subject: Revert "Fix tabbar issues with Oxygen style" The patch has some issues with text eliding which are not really possible to solve properly without providing the elidemode to the styleoption. Under these circumstances it seems better just to fix the problem in Oxygen itself which has already been patched when compiled with 4.5. This reverts commit d7072b5577e3c07e984885cf05d5f9b217c6f473. --- src/gui/styles/qcommonstyle.cpp | 73 ++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 819965b..3cae08a 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -1779,46 +1779,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, case CE_TabBarTab: if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { drawControl(CE_TabBarTabShape, tab, p, widget); - - QStyleOptionTabV3 tabV3(*tab); - QRect labelRect = tabV3.rect; - QSize &left= tabV3.leftButtonSize; - QSize &right = tabV3.rightButtonSize; - const int spacing = 6 + 2; - - // left widget - if (!left.isEmpty()) { - if (tabV3.shape == QTabBar::RoundedEast || tabV3.shape == QTabBar::TriangularEast ) - labelRect.setTop(labelRect.top() + spacing + left.height()); - else if (tabV3.shape == QTabBar::RoundedWest|| tabV3.shape == QTabBar::TriangularWest) - labelRect.setBottom(labelRect.bottom() - spacing - left.height()); - else - labelRect.setLeft(labelRect.left() + spacing + left.width()); - } - - // right widget - if (!right.isEmpty()) { - if (tabV3.shape == QTabBar::RoundedEast || tabV3.shape == QTabBar::TriangularEast ) - labelRect.setBottom(labelRect.bottom() - spacing - right.height()); - else if (tabV3.shape == QTabBar::RoundedWest|| tabV3.shape == QTabBar::TriangularWest) - labelRect.setTop(labelRect.top() + spacing + right.height()); - else - labelRect.setRight(labelRect.right() - spacing - right.width()); - } - - tabV3.rect = visualRect(opt->direction, opt->rect, labelRect); - drawControl(CE_TabBarTabLabel, &tabV3, p, widget); - if (tabV3.state & State_HasFocus) { - const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth); - int x1, x2; - x1 = tab->rect.left(); - x2 = tab->rect.right() - 1; - QStyleOptionFocusRect fropt; - fropt.QStyleOption::operator=(*tab); - fropt.rect.setRect(x1 + 1 + OFFSET, tab->rect.y() + OFFSET, - x2 - x1 - 2*OFFSET, tab->rect.height() - 2*OFFSET); - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); - } + drawControl(CE_TabBarTabLabel, tab, p, widget); } break; case CE_TabBarTabShape: @@ -2020,8 +1981,12 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, (tabV2.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); - int offset = 6; + int offset = 4; int left = opt->rect.left(); + if (tabV2.leftButtonSize.isEmpty()) + offset += 2; + else + left += tabV2.leftButtonSize.width() + (6 + 2) + 2; QRect iconRect = QRect(left + offset, tr.center().y() - tabIcon.height() / 2, tabIconSize.width(), tabIconSize.height()); if (!verticalTabs) @@ -2032,6 +1997,20 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); if (verticalTabs) p->restore(); + + if (tabV2.state & State_HasFocus) { + const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth); + + int x1, x2; + x1 = tabV2.rect.left(); + x2 = tabV2.rect.right() - 1; + + QStyleOptionFocusRect fropt; + fropt.QStyleOption::operator=(*tab); + fropt.rect.setRect(x1 + 1 + OFFSET, tabV2.rect.y() + OFFSET, + x2 - x1 - 2*OFFSET, tabV2.rect.height() - 2*OFFSET); + drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + } } break; #endif // QT_NO_TABBAR @@ -2879,6 +2858,12 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, tr.setRight(tr.right() - horizontalShift); } + // left widget + if (!tabV2.leftButtonSize.isEmpty()) { + tr.setLeft(tr.left() + 6 + 2 + + (verticalTabs ? tabV2.leftButtonSize.height() : tabV2.leftButtonSize.width())); + } + // icon if (!tabV2.icon.isNull()) { QSize iconSize = tabV2.iconSize; @@ -2900,6 +2885,12 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, tr.setLeft(tr.left() + tabIconSize.width() + offset + 2); } + // right widget + if (!tabV2.rightButtonSize.isEmpty()) { + tr.setRight(tr.right() - 6 - 2 - + (verticalTabs ? tabV2.rightButtonSize.height() : tabV2.rightButtonSize.width())); + } + if (!verticalTabs) tr = visualRect(opt->direction, opt->rect, tr); r = tr; -- cgit v0.12 From 8be2b24705da4bce99b3a3d588aedcfe2eb3f886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Tue, 5 May 2009 14:29:44 +0200 Subject: Fix memory leak in QFuture The held results were not cleared by QFutureInterface::operator=(QFutureInterface) Add call to resultStore().clear(), similar to the destructor. This needs to be done in the header since we know the template type here. Task-number: 252208 Reviewed-by: brad --- src/corelib/concurrent/qfutureinterface.h | 2 ++ tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp | 31 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/corelib/concurrent/qfutureinterface.h b/src/corelib/concurrent/qfutureinterface.h index 85d03c9..345bebe 100644 --- a/src/corelib/concurrent/qfutureinterface.h +++ b/src/corelib/concurrent/qfutureinterface.h @@ -165,6 +165,8 @@ public: QFutureInterface &operator=(const QFutureInterface &other) { + if (referenceCountIsOne()) + resultStore().clear(); QFutureInterfaceBase::operator=(other); return *this; } diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp index 139eb6e..116f46e 100644 --- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -74,6 +74,7 @@ private slots: void incrementalResults(); void noDetatch(); void stlContainers(); + void qFutureAssignmentLeak(); void stressTest(); public slots: void throttling(); @@ -2323,6 +2324,36 @@ void tst_map::stlContainers() #endif } +InstanceCounter ic_fn(const InstanceCounter & ic) +{ + return InstanceCounter(ic); +}; + +// Verify that held results are deleted when a future is +// assigned over with operator == +void tst_map::qFutureAssignmentLeak() +{ + currentInstanceCount = 0; + peakInstanceCount = 0; + QFuture future; + { + QList list; + for (int i=0;i<1000;++i) + list += InstanceCounter(); + future = QtConcurrent::mapped(list, ic_fn); + future.waitForFinished(); + + future = QtConcurrent::mapped(list, ic_fn); + future.waitForFinished(); + + future = QtConcurrent::mapped(list, ic_fn); + future.waitForFinished(); + } + + QCOMPARE(int(currentInstanceCount), 1000); + future = QFuture(); + QCOMPARE(int(currentInstanceCount), 0); +} inline void increment(int &num) { -- cgit v0.12 From 8806c32f45242c9d12c6799c2c762775da58b698 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 5 May 2009 09:31:04 +0200 Subject: Support rotated displays with 15 and 16 bit BGR pixel formats. To avoid increasing code size for an uncommon case, the code is #ifdef QT_QWS_ROTATE_BGR Task-number: 250299 Reviewed-by: Tom --- src/gui/embedded/qscreentransformed_qws.cpp | 12 ++++++++++++ src/gui/embedded/qscreenvfb_qws.cpp | 3 +++ src/gui/painting/qmemrotate.cpp | 28 ++++++++++++++++++++++++++++ src/gui/painting/qmemrotate_p.h | 8 ++++++++ 4 files changed, 51 insertions(+) diff --git a/src/gui/embedded/qscreentransformed_qws.cpp b/src/gui/embedded/qscreentransformed_qws.cpp index 46ac1d1..e22ea1f 100644 --- a/src/gui/embedded/qscreentransformed_qws.cpp +++ b/src/gui/embedded/qscreentransformed_qws.cpp @@ -400,7 +400,19 @@ void QTransformedScreen::blit(const QImage &image, const QPoint &topLeft, #endif #if defined(QT_QWS_DEPTH_16) || defined(QT_QWS_DEPTH_15) || defined(QT_QWS_DEPTH_12) case 16: +#if defined QT_QWS_ROTATE_BGR + if (pixelType() == BGRPixel && image.depth() == 16) { + SET_BLIT_FUNC(qbgr565, quint16, trans, func); + break; + } //fall-through here!!! +#endif case 15: +#if defined QT_QWS_ROTATE_BGR + if (pixelType() == BGRPixel && image.format() == QImage::Format_RGB555) { + SET_BLIT_FUNC(qbgr555, qrgb555, trans, func); + break; + } //fall-through here!!! +#endif case 12: if (image.depth() == 16) SET_BLIT_FUNC(quint16, quint16, trans, func); diff --git a/src/gui/embedded/qscreenvfb_qws.cpp b/src/gui/embedded/qscreenvfb_qws.cpp index abbe73b..accfe1f 100644 --- a/src/gui/embedded/qscreenvfb_qws.cpp +++ b/src/gui/embedded/qscreenvfb_qws.cpp @@ -310,6 +310,9 @@ bool QVFbScreen::connect(const QString &displaySpec) connected = this; + if (qgetenv("QT_QVFB_BGR").toInt()) + pixeltype = BGRPixel; + return true; } diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp index 4058143..471f544 100644 --- a/src/gui/painting/qmemrotate.cpp +++ b/src/gui/painting/qmemrotate.cpp @@ -528,6 +528,26 @@ void qt_memrotate270(const srctype *src, int w, int h, int sstride, \ qt_memrotate270_template(src, w, h, sstride, dest, dstride); \ } +#define QT_IMPL_SIMPLE_MEMROTATE(srctype, desttype) \ +void qt_memrotate90(const srctype *src, int w, int h, int sstride, \ + desttype *dest, int dstride) \ +{ \ + qt_memrotate90_tiled_unpacked(src, w, h, sstride, dest, dstride); \ +} \ +void qt_memrotate180(const srctype *src, int w, int h, int sstride, \ + desttype *dest, int dstride) \ +{ \ + qt_memrotate180_template(src, w, h, sstride, dest, dstride); \ +} \ +void qt_memrotate270(const srctype *src, int w, int h, int sstride, \ + desttype *dest, int dstride) \ +{ \ + qt_memrotate270_tiled_unpacked(src, w, h, sstride, dest, dstride); \ +} + + + + QT_IMPL_MEMROTATE(quint32, quint32) QT_IMPL_MEMROTATE(quint32, quint16) QT_IMPL_MEMROTATE(quint16, quint32) @@ -539,6 +559,14 @@ QT_IMPL_MEMROTATE(quint32, quint8) QT_IMPL_MEMROTATE(quint16, quint8) QT_IMPL_MEMROTATE(qrgb444, quint8) QT_IMPL_MEMROTATE(quint8, quint8) + +#if defined(QT_QWS_ROTATE_BGR) +QT_IMPL_SIMPLE_MEMROTATE(quint16, qbgr565) +QT_IMPL_SIMPLE_MEMROTATE(quint32, qbgr565) +QT_IMPL_SIMPLE_MEMROTATE(qrgb555, qbgr555) +QT_IMPL_SIMPLE_MEMROTATE(quint32, qbgr555) +#endif + #ifdef QT_QWS_DEPTH_GENERIC QT_IMPL_MEMROTATE(quint32, qrgb_generic16) QT_IMPL_MEMROTATE(quint16, qrgb_generic16) diff --git a/src/gui/painting/qmemrotate_p.h b/src/gui/painting/qmemrotate_p.h index c1eb93e..87cfb1a 100644 --- a/src/gui/painting/qmemrotate_p.h +++ b/src/gui/painting/qmemrotate_p.h @@ -92,6 +92,14 @@ QT_DECL_MEMROTATE(quint32, quint8); QT_DECL_MEMROTATE(quint16, quint8); QT_DECL_MEMROTATE(qrgb444, quint8); QT_DECL_MEMROTATE(quint8, quint8); + +#ifdef QT_QWS_ROTATE_BGR +QT_DECL_MEMROTATE(quint16, qbgr565); +QT_DECL_MEMROTATE(quint32, qbgr565); +QT_DECL_MEMROTATE(qrgb555, qbgr555); +QT_DECL_MEMROTATE(quint32, qbgr555); +#endif + #ifdef QT_QWS_DEPTH_GENERIC QT_DECL_MEMROTATE(quint32, qrgb_generic16); QT_DECL_MEMROTATE(quint16, qrgb_generic16); -- cgit v0.12 From 2a1eed4c718c8fa4a69351691aa466339d280126 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 5 May 2009 15:00:47 +0200 Subject: Fix regression in drawing parts of pixmaps on Panther. The width of a pixmap is NOT the same as the bytes per row. We may have been able to do that in the past, but it doesn't work in the general case. I also took the liberty to introduce a QCFType to automatically handling the free in the general case. Task-number: 252176 Reviewed-by: sroedal --- src/gui/painting/qpaintengine_mac.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp index 0644a02..5889388 100644 --- a/src/gui/painting/qpaintengine_mac.cpp +++ b/src/gui/painting/qpaintengine_mac.cpp @@ -996,15 +996,14 @@ void QCoreGraphicsPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, co } else if (differentSize) { #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { - CGImageRef img = (CGImageRef)pm.macCGHandle(); + QCFType img = pm.toMacCGImageRef(); image = CGImageCreateWithImageInRect(img, CGRectMake(qRound(sr.x()), qRound(sr.y()), qRound(sr.width()), qRound(sr.height()))); - CGImageRelease(img); } else #endif { const int sx = qRound(sr.x()), sy = qRound(sr.y()), sw = qRound(sr.width()), sh = qRound(sr.height()); const QMacPixmapData *pmData = static_cast(pm.data); - quint32 *pantherData = pmData->pixels + (sy * pm.width() + sx); + quint32 *pantherData = pmData->pixels + sy * (pmData->bytesPerRow / 4) + sx; QCFType provider = CGDataProviderCreateWithData(0, pantherData, sw*sh*pmData->bytesPerRow, 0); image = CGImageCreate(sw, sh, 8, 32, pmData->bytesPerRow, macGenericColorSpace(), -- cgit v0.12 From d89d1eb47e69c2c2dc1121ef92fd08ef983e3e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 5 May 2009 15:31:10 +0200 Subject: Fixed bug where 0-opacity would cause images to be drawn fully opaque. The bug appears in the raster paint engine and only in release mode as the cause of the bug is in the MMX and SSE blend functions which are disabled in debug. To prevent it simply we return early if we detect that we have an opacity of 0. Reviewed-by: Trond --- src/gui/painting/qpaintengine_raster.cpp | 2 +- tests/auto/qpainter/tst_qpainter.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index ba1e27c..e249b3e 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1022,7 +1022,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt, int alpha, const QRect &sr) { - if (!clip.isValid()) + if (alpha == 0 || !clip.isValid()) return; Q_ASSERT(img.depth() >= 8); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index c81bf67..87f9c13 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -225,6 +225,8 @@ private slots: void extendedBlendModes(); + void zeroOpacity(); + private: void fillData(); QColor baseColor( int k, int intensity=255 ); @@ -4150,5 +4152,21 @@ void tst_QPainter::extendedBlendModes() QVERIFY(testCompositionMode(191, 191, 96, QPainter::CompositionMode_Exclusion)); } +void tst_QPainter::zeroOpacity() +{ + QImage source(1, 1, QImage::Format_ARGB32_Premultiplied); + source.fill(0xffffffff); + + QImage target(1, 1, QImage::Format_RGB32); + target.fill(0xff000000); + + QPainter p(&target); + p.setOpacity(0.0); + p.drawImage(0, 0, source); + p.end(); + + QCOMPARE(target.pixel(0, 0), 0xff000000); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" -- cgit v0.12 From fde7475bcf9c10522a8170e6eb8fb9a8fadc21cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 5 May 2009 15:36:30 +0200 Subject: Ensured correct rounding of scaled image drawing at non-integer coords. Images coordinates should simply be rounded and are not to be subject to the aliased coordinate delta. The patch also adds a tiny delta in QSpanData::setupMatrix() to ensure coordinates for fetching from source images are rounded the opposite direction of the target rectangle. This removes a lot of artifacts when trying to do border-image based drawing on non-integer coordinates. A new qps test for border-image drawing is included. Task-number: 251561 Reviewed-by: Trond --- src/gui/painting/qpaintengine_raster.cpp | 14 +++- src/gui/painting/qpainter.cpp | 63 +++++++++----- tests/arthur/common/images.qrc | 1 + tests/arthur/common/images/borderimage.png | Bin 0 -> 826 bytes tests/arthur/data/qps/borderimage.qps | 129 +++++++++++++++++++++++++++++ tests/arthur/data/qps/borderimage_qps.png | Bin 0 -> 88788 bytes 6 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 tests/arthur/common/images/borderimage.png create mode 100644 tests/arthur/data/qps/borderimage.qps create mode 100644 tests/arthur/data/qps/borderimage_qps.png diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index e249b3e..788b722 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2664,7 +2664,13 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe QRectF rr = r; rr.translate(s->matrix.dx(), s->matrix.dy()); - fillRect_normalized(toRect_normalized(rr), &d->image_filler, d); + + const int x1 = qRound(rr.x()); + const int y1 = qRound(rr.y()); + const int x2 = qRound(rr.right()); + const int y2 = qRound(rr.bottom()); + + fillRect_normalized(QRect(x1, y1, x2-x1, y2-y1), &d->image_filler, d); } } @@ -5147,7 +5153,11 @@ void QSpanData::adjustSpanMethods() void QSpanData::setupMatrix(const QTransform &matrix, int bilin) { - QTransform inv = matrix.inverted(); + QTransform delta; + // make sure we round off correctly in qdrawhelper.cpp + delta.translate(1.0 / 65536, 1.0 / 65536); + + QTransform inv = (delta * matrix).inverted(); m11 = inv.m11(); m12 = inv.m12(); m13 = inv.m13(); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 759bd7e..afc4211 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5142,6 +5142,11 @@ void QPainter::drawConvexPolygon(const QPointF *points, int pointCount) d->engine->drawPolygon(points, pointCount, QPaintEngine::ConvexMode); } +static inline QPointF roundInDeviceCoordinates(const QPointF &p, const QTransform &m) +{ + return m.inverted().map(QPointF(m.map(p).toPoint())); +} + /*! \fn void QPainter::drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source) @@ -5210,11 +5215,12 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) { save(); - // If there is no scaling or transformation involved we have to make sure we use the + // If there is no rotation involved we have to make sure we use the // antialiased and not the aliased coordinate system by rounding the coordinates. - if (d->state->matrix.type() <= QTransform::TxTranslate) { - x = qRound(x + d->state->matrix.dx()) - d->state->matrix.dx(); - y = qRound(y + d->state->matrix.dy()) - d->state->matrix.dy(); + if (d->state->matrix.type() <= QTransform::TxScale) { + const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); + x = p.x(); + y = p.y(); } translate(x, y); setBackgroundMode(Qt::TransparentMode); @@ -5324,16 +5330,21 @@ void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) || ((sw != w || sh != h) && !d->engine->hasFeature(QPaintEngine::PixmapTransform))) { save(); - // If there is no scaling or transformation involved we have to make sure we use the + // If there is no rotation involved we have to make sure we use the // antialiased and not the aliased coordinate system by rounding the coordinates. + if (d->state->matrix.type() <= QTransform::TxScale) { + const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); + x = p.x(); + y = p.y(); + } + if (d->state->matrix.type() <= QTransform::TxTranslate && sw == w && sh == h) { - x = qRound(x + d->state->matrix.dx()) - d->state->matrix.dx(); - y = qRound(y + d->state->matrix.dy()) - d->state->matrix.dy(); sx = qRound(sx); sy = qRound(sy); sw = qRound(sw); sh = qRound(sh); } + translate(x, y); scale(w / sw, h / sh); setBackgroundMode(Qt::TransparentMode); @@ -5483,11 +5494,12 @@ void QPainter::drawImage(const QPointF &p, const QImage &image) || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) { save(); - // If there is no scaling or transformation involved we have to make sure we use the + // If there is no rotation involved we have to make sure we use the // antialiased and not the aliased coordinate system by rounding the coordinates. - if (d->state->matrix.type() <= QTransform::TxTranslate) { - x = qRound(x + d->state->matrix.dx()) - d->state->matrix.dx(); - y = qRound(y + d->state->matrix.dy()) - d->state->matrix.dy(); + if (d->state->matrix.type() <= QTransform::TxScale) { + const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); + x = p.x(); + y = p.y(); } translate(x, y); setBackgroundMode(Qt::TransparentMode); @@ -5586,11 +5598,15 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR || (d->state->opacity != 1.0 && !d->engine->hasFeature(QPaintEngine::ConstantOpacity))) { save(); - // If there is no scaling or transformation involved we have to make sure we use the + // If there is no rotation involved we have to make sure we use the // antialiased and not the aliased coordinate system by rounding the coordinates. + if (d->state->matrix.type() <= QTransform::TxScale) { + const QPointF p = roundInDeviceCoordinates(QPointF(x, y), d->state->matrix); + x = p.x(); + y = p.y(); + } + if (d->state->matrix.type() <= QTransform::TxTranslate && sw == w && sh == h) { - x = qRound(x + d->state->matrix.dx()) - d->state->matrix.dx(); - y = qRound(y + d->state->matrix.dy()) - d->state->matrix.dy(); sx = qRound(sx); sy = qRound(sy); sw = qRound(sw); @@ -6333,17 +6349,18 @@ void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPo setBrush(QBrush(d->state->pen.color(), pixmap)); setPen(Qt::NoPen); - // If there is no scaling or transformation involved we have to make sure we use the + // If there is no rotation involved we have to make sure we use the // antialiased and not the aliased coordinate system by rounding the coordinates. - if (d->state->matrix.type() <= QTransform::TxTranslate) { - qreal x = qRound(r.x() + d->state->matrix.dx()) - d->state->matrix.dx(); - qreal y = qRound(r.y() + d->state->matrix.dy()) - d->state->matrix.dy(); - qreal w = qRound(r.width()); - qreal h = qRound(r.height()); - sx = qRound(sx); - sy = qRound(sy); + if (d->state->matrix.type() <= QTransform::TxScale) { + const QPointF p = roundInDeviceCoordinates(r.topLeft(), d->state->matrix); + + if (d->state->matrix.type() <= QTransform::TxTranslate) { + sx = qRound(sx); + sy = qRound(sy); + } + setBrushOrigin(QPointF(r.x()-sx, r.y()-sy)); - drawRect(QRectF(x, y, w, h)); + drawRect(QRectF(p, r.size())); } else { setBrushOrigin(QPointF(r.x()-sx, r.y()-sy)); drawRect(r); diff --git a/tests/arthur/common/images.qrc b/tests/arthur/common/images.qrc index 8e94760..060b52c 100644 --- a/tests/arthur/common/images.qrc +++ b/tests/arthur/common/images.qrc @@ -3,6 +3,7 @@ images/alpha.png images/border.png + images/borderimage.png images/dome_argb32.png images/dome_indexed.png images/dome_mono_palette.png diff --git a/tests/arthur/common/images/borderimage.png b/tests/arthur/common/images/borderimage.png new file mode 100644 index 0000000..f7f6b66 Binary files /dev/null and b/tests/arthur/common/images/borderimage.png differ diff --git a/tests/arthur/data/qps/borderimage.qps b/tests/arthur/data/qps/borderimage.qps new file mode 100644 index 0000000..747a74d --- /dev/null +++ b/tests/arthur/data/qps/borderimage.qps @@ -0,0 +1,129 @@ +image_load borderimage.png borderimage + +translate -128 -128 +begin_block draw_border + +# top +drawImage borderimage 0 0 16 16 0 0 16 16 +drawImage borderimage 16 0 36 16 16 0 32 16 +drawImage borderimage 52 0 16 16 48 0 16 16 + +# sides +drawImage borderimage 0 16 16 16 0 16 16 32 +drawImage borderimage 52 16 16 16 48 16 16 32 + +#bottom +drawImage borderimage 0 32 16 16 0 48 16 16 +drawImage borderimage 16 32 36 16 16 48 32 16 +drawImage borderimage 52 32 16 16 48 48 16 16 + +end_block draw_border + +resetMatrix + +begin_block draw_column + +translate 1 1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border +translate 0.1 64.1 +repeat_block draw_border + +end_block draw_column + +setRenderHint Antialiasing + +resetMatrix +translate 72 0 + +repeat_block draw_column + +resetMatrix +scale 1.25 1.25 +translate 144 0 + +repeat_block draw_border + +resetMatrix +scale 1.25 1.25 +translate 246 0 +rotate 30 + +repeat_block draw_border + +setRenderHint SmoothPixmapTransform + +resetMatrix +scale 1.25 1.25 +translate 144 120 + +repeat_block draw_border + +resetMatrix +scale 1.25 1.25 +translate 246 120 +rotate 30 + +repeat_block draw_border + +resetMatrix +translate 215 260 +scale 3.55 3.55 +rotate 30 + +repeat_block draw_border + +resetMatrix +setRenderHint SmoothPixmapTransform off +setRenderHint Antialiasing off + +translate 480 627 +rotate 180 +repeat_block draw_column + +resetMatrix +setRenderHint Antialiasing + +translate 552 627 +rotate 180 +repeat_block draw_column + +resetMatrix +setRenderHint Antialiasing off + +setPen red + +drawRect 0 0 70 680 +drawText 10 670 "aa off" + +drawRect 72 0 70 680 +drawText 80 670 "aa on" + +drawRect 409 0 70 680 +drawText 419 650 "rot 180" +drawText 419 670 "aa off" + +drawRect 481 0 70 680 +drawText 491 650 "rot 180" +drawText 491 670 "aa on" + +drawRect 164 0 224 124 +drawText 174 114 "smoothpixmaptransform off" + +drawRect 164 128 224 134 +drawText 174 252 "smoothpixmaptransform on" diff --git a/tests/arthur/data/qps/borderimage_qps.png b/tests/arthur/data/qps/borderimage_qps.png new file mode 100644 index 0000000..89a8eba Binary files /dev/null and b/tests/arthur/data/qps/borderimage_qps.png differ -- cgit v0.12 From c412508f2def8163b6b0d5821e3ffe1de4e4f99d Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 31 Mar 2009 15:13:31 +0200 Subject: Add headers required for building PowerVR driver The PowerVR driver on Qt for Embedded Linux needs to use Imagination Techologies' proprietary pvr2d & wsegl APIs. These are the headers for those APIs, allowing the powervr driver to be built. Ideally, these headers would be provided as part of the SDK supplied by chipset vendors. For now, we include these headers to let people get going with the driver. Licence headers were approved by legal for inclusion into Qt, after some negotiation with ImgTec (who have also approved their inclusion into Qt). The headers have also passed a scan by Talko, provided the licence headers aren't touched. Reviewed-by: Paul --- src/3rdparty/README | 5 + src/3rdparty/powervr/pvr2d.h | 502 ++++++++++++++++++++++++++++++++++ src/3rdparty/powervr/wsegl.h | 240 ++++++++++++++++ src/plugins/gfxdrivers/powervr/README | 7 +- 4 files changed, 751 insertions(+), 3 deletions(-) create mode 100644 src/3rdparty/powervr/pvr2d.h create mode 100644 src/3rdparty/powervr/wsegl.h diff --git a/src/3rdparty/README b/src/3rdparty/README index 2be1036..ef05674 100644 --- a/src/3rdparty/README +++ b/src/3rdparty/README @@ -20,3 +20,8 @@ have been removed: Some patches are applied from time to time. Recent patches can be found in the patches subdirectory. + + +The pvr2d.h & wsegl.h in the powervr directory are required for building +the PowerVR plugin on Qt for Embedded Linux. These headers are for SGX +based SoCs, but may also work on MBX SoCs. diff --git a/src/3rdparty/powervr/pvr2d.h b/src/3rdparty/powervr/pvr2d.h new file mode 100644 index 0000000..14823e0 --- /dev/null +++ b/src/3rdparty/powervr/pvr2d.h @@ -0,0 +1,502 @@ +/*!**************************************************************************** +@File pvr2d.h +@Title PVR2D external header file +@Author Imagination Technologies +@Copyright Copyright (c) by Imagination Technologies Limited. + This specification is protected by copyright laws and contains + material proprietary to Imagination Technologies Limited. + You may use and distribute this specification free of charge for implementing + the functionality therein, without altering or removing any trademark, copyright, + or other notice from the specification. +@Platform Generic +@Description PVR2D definitions for PVR2D clients +******************************************************************************/ + + +/****************************************************************************** +Modifications :- +$Log: pvr2d.h $ +******************************************************************************/ + +#ifndef _PVR2D_H_ +#define _PVR2D_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* PVR2D Platform-specific definitions */ +#define PVR2D_EXPORT +#define PVR2D_IMPORT + + +#define PVR2D_REV_MAJOR 2 +#define PVR2D_REV_MINOR 1 + +typedef enum +{ + PVR2D_FALSE = 0, + PVR2D_TRUE +} PVR2D_BOOL; + + +/* error codes */ +typedef enum +{ + PVR2D_OK = 0, + PVR2DERROR_INVALID_PARAMETER = -1, + PVR2DERROR_DEVICE_UNAVAILABLE = -2, + PVR2DERROR_INVALID_CONTEXT = -3, + PVR2DERROR_MEMORY_UNAVAILABLE = -4, + PVR2DERROR_DEVICE_NOT_PRESENT = -5, + PVR2DERROR_IOCTL_ERROR = -6, + PVR2DERROR_GENERIC_ERROR = -7, + PVR2DERROR_BLT_NOTCOMPLETE = -8, + PVR2DERROR_HW_FEATURE_NOT_SUPPORTED = -9, + PVR2DERROR_NOT_YET_IMPLEMENTED = -10, + PVR2DERROR_MAPPING_FAILED = -11 +}PVR2DERROR; + + +/* pixel formats */ +typedef enum +{ + PVR2D_1BPP = 0, + PVR2D_RGB565, + PVR2D_ARGB4444, + PVR2D_RGB888, + PVR2D_ARGB8888, + PVR2D_ARGB1555, + PVR2D_ALPHA8, + PVR2D_ALPHA4, + PVR2D_PAL2, + PVR2D_PAL4, + PVR2D_PAL8, + PVR2D_VGAEMU + +}PVR2DFORMAT; + + +/* wrap surface type */ +typedef enum +{ + PVR2D_WRAPFLAG_NONCONTIGUOUS = 0, + PVR2D_WRAPFLAG_CONTIGUOUS = 1, + +}PVR2DWRAPFLAGS; + +/* flags for control information of additional blits */ +typedef enum +{ + PVR2D_BLIT_DISABLE_ALL = 0x0000, /* disable all additional controls */ + PVR2D_BLIT_CK_ENABLE = 0x0001, /* enable colour key */ + PVR2D_BLIT_GLOBAL_ALPHA_ENABLE = 0x0002, /* enable standard global alpha */ + PVR2D_BLIT_PERPIXEL_ALPHABLEND_ENABLE = 0x0004, /* enable per-pixel alpha bleding */ + PVR2D_BLIT_PAT_SURFACE_ENABLE = 0x0008, /* enable pattern surf (disable fill) */ + PVR2D_BLIT_FULLY_SPECIFIED_ALPHA_ENABLE = 0x0010, /* enable fully specified alpha */ + PVR2D_BLIT_ROT_90 = 0x0020, /* apply 90 degree rotation to the blt */ + PVR2D_BLIT_ROT_180 = 0x0040, /* apply 180 degree rotation to the blt */ + PVR2D_BLIT_ROT_270 = 0x0080, /* apply 270 degree rotation to the blt */ + PVR2D_BLIT_COPYORDER_TL2BR = 0x0100, /* copy order overrides */ + PVR2D_BLIT_COPYORDER_BR2TL = 0x0200, + PVR2D_BLIT_COPYORDER_TR2BL = 0x0400, + PVR2D_BLIT_COPYORDER_BL2TR = 0x0800, + PVR2D_BLIT_COLKEY_SOURCE = 0x1000, /* Key colour is on the source surface */ + PVR2D_BLIT_COLKEY_DEST = 0x2000 /* Key colour is on the destination surface */ + +} PVR2DBLITFLAGS; + +/* standard alpha-blending functions, AlphaBlendingFunc field of PVR2DBLTINFO */ +typedef enum +{ + PVR2D_ALPHA_OP_SRC_DSTINV = 1, /* source alpha : Cdst = Csrc*Asrc + Cdst*(1-Asrc) */ + PVR2D_ALPHA_OP_SRCP_DSTINV = 2 /* premultiplied source alpha : Cdst = Csrc + Cdst*(1-Asrc) */ +} PVR2D_ALPHABLENDFUNC; + +/* blend ops for fully specified alpha */ +typedef enum +{ + PVR2D_BLEND_OP_ZERO = 0, + PVR2D_BLEND_OP_ONE = 1, + PVR2D_BLEND_OP_SRC = 2, + PVR2D_BLEND_OP_DST = 3, + PVR2D_BLEND_OP_GLOBAL = 4, + PVR2D_BLEND_OP_SRC_PLUS_GLOBAL = 5, + PVR2D_BLEND_OP_DST_PLUS_GLOBAL = 6 +}PVR2D_BLEND_OP; + + +typedef void* PVR2D_HANDLE; + + +/* Fully specified alpha blend : pAlpha field of PVR2DBLTINFO structure */ +/* a fully specified Alpha Blend operation is defined as */ +/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (ALPHA_3 * DST (ALPHA)) */ +/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (ALPHA_4 * DST (RGB)) */ +/* if the pre-multiplication stage is enabled then the equations become the following: */ +/* PRE_MUL = ((SRC(A)) * (Global Alpha Value)) */ +/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (PRE_MUL * DST (ALPHA)) */ +/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (PRE_MUL * DST (RGB)) */ +/* if the transparent source alpha stage is enabled then a source alpha of zero forces the */ +/* source to be transparent for that pixel regardless of the blend equation being used. */ +typedef struct _PVR2D_ALPHABLT +{ + PVR2D_BLEND_OP eAlpha1; + PVR2D_BOOL bAlpha1Invert; + PVR2D_BLEND_OP eAlpha2; + PVR2D_BOOL bAlpha2Invert; + PVR2D_BLEND_OP eAlpha3; + PVR2D_BOOL bAlpha3Invert; + PVR2D_BLEND_OP eAlpha4; + PVR2D_BOOL bAlpha4Invert; + PVR2D_BOOL bPremulAlpha; /* enable pre-multiplication stage */ + PVR2D_BOOL bTransAlpha; /* enable transparent source alpha stage */ + PVR2D_BOOL bUpdateAlphaLookup; /* enable and update the 1555-Lookup alpha table */ + unsigned char uAlphaLookup0; /* 8 bit alpha when A=0 in a 1555-Lookup surface */ + unsigned char uAlphaLookup1; /* 8 bit alpha when A=1 in a 1555-Lookup surface */ + unsigned char uGlobalRGB; /* Global Alpha Value for RGB, 0=transparent 255=opaque */ + unsigned char uGlobalA; /* Global Alpha Value for Alpha */ + +} PVR2D_ALPHABLT, *PPVR2D_ALPHABLT; + + +/* surface memory info structure */ +typedef struct _PVR2DMEMINFO +{ + void *pBase; + unsigned long ui32MemSize; + unsigned long ui32DevAddr; + unsigned long ulFlags; + void *hPrivateData; + void *hPrivateMapData; + +}PVR2DMEMINFO, *PPVR2DMEMINFO; + + +#define PVR2D_MAX_DEVICE_NAME 20 + +typedef struct _PVR2DDEVICEINFO +{ + unsigned long ulDevID; + char szDeviceName[PVR2D_MAX_DEVICE_NAME]; +}PVR2DDEVICEINFO; + + +typedef struct _PVR2DISPLAYINFO +{ + unsigned long ulMaxFlipChains; + unsigned long ulMaxBuffersInChain; + PVR2DFORMAT eFormat; + unsigned long ulWidth; + unsigned long ulHeight; + long lStride; + unsigned long ulMinFlipInterval; + unsigned long ulMaxFlipInterval; + +}PVR2DDISPLAYINFO; + + +typedef struct _PVR2DBLTINFO +{ + unsigned long CopyCode; /* rop code */ + unsigned long Colour; /* fill colour */ + unsigned long ColourKey; /* colour key */ + unsigned char GlobalAlphaValue; /* global alpha blending */ + unsigned char AlphaBlendingFunc; /* per-pixel alpha-blending function */ + + PVR2DBLITFLAGS BlitFlags; /* additional blit control information */ + + PVR2DMEMINFO *pDstMemInfo; /* destination memory */ + unsigned long DstOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */ + long DstStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ + long DstX, DstY; /* pixel offset from start of dest surface to start of blt rectangle */ + long DSizeX,DSizeY; /* blt size */ + PVR2DFORMAT DstFormat; /* dest format */ + unsigned long DstSurfWidth; /* size of dest surface in pixels */ + unsigned long DstSurfHeight; /* size of dest surface in pixels */ + + PVR2DMEMINFO *pSrcMemInfo; /* source mem, (source fields are also used for patterns) */ + unsigned long SrcOffset; /* byte offset from start of allocation to src/pat surface pixel 0,0 */ + long SrcStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ + long SrcX, SrcY; /* pixel offset from start of surface to start of source rectangle */ + /* for patterns this is the start offset within the pattern */ + long SizeX,SizeY; /* source rectangle size or pattern size in pixels */ + PVR2DFORMAT SrcFormat; /* source/pattern format */ + PVR2DMEMINFO *pPalMemInfo; /* source/pattern palette memory containing argb8888 colour table */ + unsigned long PalOffset; /* byte offset from start of allocation to start of palette */ + unsigned long SrcSurfWidth; /* size of source surface in pixels */ + unsigned long SrcSurfHeight; /* size of source surface in pixels */ + + PVR2DMEMINFO *pMaskMemInfo; /* mask memory, 1bpp format implied */ + unsigned long MaskOffset; /* byte offset from start of allocation to mask surface pixel 0,0 */ + long MaskStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ + long MaskX, MaskY; /* mask rect top left (mask size = blt size) */ + unsigned long MaskSurfWidth; /* size of mask surface in pixels */ + unsigned long MaskSurfHeight; /* size of mask surface in pixels */ + + PPVR2D_ALPHABLT pAlpha; /* fully specified alpha blend */ + +}PVR2DBLTINFO, *PPVR2DBLTINFO; + +typedef struct _PVR2DRECT +{ + long left, top; + long right, bottom; +} PVR2DRECT; + +typedef struct +{ + PVR2DMEMINFO *pSurfMemInfo; /* surface memory */ + unsigned long SurfOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */ + long Stride; /* signed stride */ + PVR2DFORMAT Format; + unsigned long SurfWidth; /* surface size in pixels */ + unsigned long SurfHeight; + +} PVR2D_SURFACE, *PPVR2D_SURFACE; + +typedef struct +{ + unsigned long *pUseCode; /* USSE code */ + unsigned long UseCodeSize; /* usse code size in bytes */ + +} PVR2D_USECODE, *PPVR2D_USECODE; + +typedef struct +{ + PVR2D_SURFACE sDst; /* destination surface */ + PVR2D_SURFACE sSrc; /* source surface */ + PVR2DRECT rcDest; /* destination rectangle */ + PVR2DRECT rcSource; /* source rectangle */ + PVR2D_HANDLE hUseCode; /* custom USE code (NULL implies source copy) */ + unsigned long UseParams[2]; /* per-blt params for use code */ + +} PVR2D_3DBLT, *PPVR2D_3DBLT; + + +#define MAKE_COPY_BLIT(src,soff,dest,doff,sx,sy,dx,dy,sz) + +typedef void* PVR2DCONTEXTHANDLE; +typedef void* PVR2DFLIPCHAINHANDLE; + + +// CopyCode field of PVR2DBLTINFO structure: +// the CopyCode field of the PVR2DBLTINFO structure should contain a rop3 or rop4 code. +// a rop3 is an 8 bit code that describes a blt with three inputs : source dest and pattern +// rop4 is a 16 bit code that describes a blt with four inputs : source dest pattern and mask +// common rop3 codes are defined below +// a colour fill blt is processed in the pattern channel as a constant colour with a rop code of 0xF0 +// PVR2D_BLIT_PAT_SURFACE_ENABLE defines whether the pattern channel is a surface or a fill colour. +// a rop4 is defined by two rop3 codes, and the 1 bit-per-pixel mask surface defines which is used. +// a common rop4 is 0xAAF0 which is the mask copy blt used for text glyphs. +// CopyCode is taken to be a rop4 when pMaskMemInfo is non zero, otherwise it is assumed to be a rop3 +// use the PVR2DMASKROP4 macro below to construct a rop4 from two rop3's +// rop3a is the rop used when mask pixel = 1, and rop3b when mask = 0 +#define PVR2DROP4(rop3b, rop3a) ((rop3b<<8)|rop3a) + +/* common rop codes */ +#define PVR2DROPclear 0x00 /* 0 (whiteness) */ +#define PVR2DROPset 0xFF /* 1 (blackness) */ +#define PVR2DROPnoop 0xAA /* dst (used for masked blts) */ + +/* source and dest rop codes */ +#define PVR2DROPand 0x88 /* src AND dst */ +#define PVR2DROPandReverse 0x44 /* src AND NOT dst */ +#define PVR2DROPcopy 0xCC /* src (used for source copy and alpha blts) */ +#define PVR2DROPandInverted 0x22 /* NOT src AND dst */ +#define PVR2DROPxor 0x66 /* src XOR dst */ +#define PVR2DROPor 0xEE /* src OR dst */ +#define PVR2DROPnor 0x11 /* NOT src AND NOT dst */ +#define PVR2DROPequiv 0x99 /* NOT src XOR dst */ +#define PVR2DROPinvert 0x55 /* NOT dst */ +#define PVR2DROPorReverse 0xDD /* src OR NOT dst */ +#define PVR2DROPcopyInverted 0x33 /* NOT src */ +#define PVR2DROPorInverted 0xBB /* NOT src OR dst */ +#define PVR2DROPnand 0x77 /* NOT src OR NOT dst */ + +/* pattern rop codes */ +#define PVR2DPATROPand 0xA0 /* pat AND dst */ +#define PVR2DPATROPandReverse 0x50 /* pat AND NOT dst */ +#define PVR2DPATROPcopy 0xF0 /* pat (used for solid color fills and pattern blts) */ +#define PVR2DPATROPandInverted 0x0A /* NOT pat AND dst */ +#define PVR2DPATROPxor 0x5A /* pat XOR dst */ +#define PVR2DPATROPor 0xFA /* pat OR dst */ +#define PVR2DPATROPnor 0x05 /* NOT pat AND NOT dst */ +#define PVR2DPATROPequiv 0xA5 /* NOT pat XOR dst */ +#define PVR2DPATROPinvert 0x55 /* NOT dst */ +#define PVR2DPATROPorReverse 0xF5 /* pat OR NOT dst */ +#define PVR2DPATROPcopyInverted 0x0F /* NOT pat */ +#define PVR2DPATROPorInverted 0xAF /* NOT pat OR dst */ +#define PVR2DPATROPnand 0x5F /* NOT pat OR NOT dst */ + +/* common rop4 codes */ +#define PVR2DROP4MaskedCopy PVR2DROP4(PVR2DROPnoop,PVR2DROPcopy) /* masked source copy blt (used for rounded window corners etc) */ +#define PVR2DROP4MaskedFill PVR2DROP4(PVR2DROPnoop,PVR2DPATROPcopy) /* masked colour fill blt (used for text) */ + +/* Legacy support */ +#define PVR2DROP3_PATMASK PVR2DPATROPcopy +#define PVR2DROP3_SRCMASK PVR2DROPcopy + +/* pixmap memory alignment */ +#define PVR2D_ALIGNMENT_4 4 /* DWORD alignment */ +#define PVR2D_ALIGNMENT_ANY 0 /* no alignment */ +#define PVR2D_ALIGNMENT_PALETTE 16 /* 16 byte alignment is required for palettes */ + +/* Heap number for PVR2DGetFrameBuffer */ +#define PVR2D_FB_PRIMARY_SURFACE 0 + +#define PVR2D_PRESENT_PROPERTY_SRCSTRIDE (1 << 0) +#define PVR2D_PRESENT_PROPERTY_DSTSIZE (1 << 1) +#define PVR2D_PRESENT_PROPERTY_DSTPOS (1 << 2) +#define PVR2D_PRESENT_PROPERTY_CLIPRECTS (1 << 3) +#define PVR2D_PRESENT_PROPERTY_INTERVAL (1 << 4) + + +#define PVR2D_CREATE_FLIPCHAIN_SHARED (1 << 0) +#define PVR2D_CREATE_FLIPCHAIN_QUERY (1 << 1) + +/* Functions that the library exports */ + +PVR2D_IMPORT +int PVR2DEnumerateDevices(PVR2DDEVICEINFO *pDevInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DCreateDeviceContext(unsigned long ulDevID, + PVR2DCONTEXTHANDLE* phContext, + unsigned long ulFlags); + +PVR2D_IMPORT +PVR2DERROR PVR2DDestroyDeviceContext(PVR2DCONTEXTHANDLE hContext); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetDeviceInfo(PVR2DCONTEXTHANDLE hContext, + PVR2DDISPLAYINFO *pDisplayInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetScreenMode(PVR2DCONTEXTHANDLE hContext, + PVR2DFORMAT *pFormat, + long *plWidth, + long *plHeight, + long *plStride, + int *piRefreshRate); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetFrameBuffer(PVR2DCONTEXTHANDLE hContext, + int nHeap, + PVR2DMEMINFO **ppsMemInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DMemAlloc(PVR2DCONTEXTHANDLE hContext, + unsigned long ulBytes, + unsigned long ulAlign, + unsigned long ulFlags, + PVR2DMEMINFO **ppsMemInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DMemWrap(PVR2DCONTEXTHANDLE hContext, + void *pMem, + unsigned long ulFlags, + unsigned long ulBytes, + unsigned long alPageAddress[], + PVR2DMEMINFO **ppsMemInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DMemMap(PVR2DCONTEXTHANDLE hContext, + unsigned long ulFlags, + void *hPrivateMapData, + PVR2DMEMINFO **ppsDstMem); + +PVR2D_IMPORT +PVR2DERROR PVR2DMemFree(PVR2DCONTEXTHANDLE hContext, + PVR2DMEMINFO *psMemInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DBlt(PVR2DCONTEXTHANDLE hContext, + PVR2DBLTINFO *pBltInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DBltClipped(PVR2DCONTEXTHANDLE hContext, + PVR2DBLTINFO *pBltInfo, + unsigned long ulNumClipRects, + PVR2DRECT *pClipRects); + +PVR2D_IMPORT +PVR2DERROR PVR2DQueryBlitsComplete(PVR2DCONTEXTHANDLE hContext, + PVR2DMEMINFO *pMemInfo, + unsigned int uiWaitForComplete); + +PVR2D_IMPORT +PVR2DERROR PVR2DSetPresentBltProperties(PVR2DCONTEXTHANDLE hContext, + unsigned long ulPropertyMask, + long lSrcStride, + unsigned long ulDstWidth, + unsigned long ulDstHeight, + long lDstXPos, + long lDstYPos, + unsigned long ulNumClipRects, + PVR2DRECT *pClipRects, + unsigned long ulSwapInterval); + +PVR2D_IMPORT +PVR2DERROR PVR2DPresentBlt(PVR2DCONTEXTHANDLE hContext, + PVR2DMEMINFO *pMemInfo, + long lRenderID); + +PVR2D_IMPORT +PVR2DERROR PVR2DCreateFlipChain(PVR2DCONTEXTHANDLE hContext, + unsigned long ulFlags, + unsigned long ulNumBuffers, + unsigned long ulWidth, + unsigned long ulHeight, + PVR2DFORMAT eFormat, + long *plStride, + unsigned long *pulFlipChainID, + PVR2DFLIPCHAINHANDLE *phFlipChain); + +PVR2D_IMPORT +PVR2DERROR PVR2DDestroyFlipChain(PVR2DCONTEXTHANDLE hContext, + PVR2DFLIPCHAINHANDLE hFlipChain); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetFlipChainBuffers(PVR2DCONTEXTHANDLE hContext, + PVR2DFLIPCHAINHANDLE hFlipChain, + unsigned long *pulNumBuffers, + PVR2DMEMINFO *psMemInfo[]); + +PVR2D_IMPORT +PVR2DERROR PVR2DSetPresentFlipProperties(PVR2DCONTEXTHANDLE hContext, + PVR2DFLIPCHAINHANDLE hFlipChain, + unsigned long ulPropertyMask, + long lDstXPos, + long lDstYPos, + unsigned long ulNumClipRects, + PVR2DRECT *pClipRects, + unsigned long ulSwapInterval); + +PVR2D_IMPORT +PVR2DERROR PVR2DPresentFlip(PVR2DCONTEXTHANDLE hContext, + PVR2DFLIPCHAINHANDLE hFlipChain, + PVR2DMEMINFO *psMemInfo, + long lRenderID); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetAPIRev(long *lRevMajor, long *lRevMinor); + +PVR2D_IMPORT +PVR2DERROR PVR2DLoadUseCode (const PVR2DCONTEXTHANDLE hContext, const unsigned char *pUseCode, + const unsigned long UseCodeSize, PVR2D_HANDLE *pUseCodeHandle); +PVR2D_IMPORT +PVR2DERROR PVR2DFreeUseCode (const PVR2DCONTEXTHANDLE hContext, const PVR2D_HANDLE hUseCodeHandle); + +PVR2D_IMPORT +PVR2DERROR PVR2DBlt3D (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT pBlt3D); + +#ifdef __cplusplus +} +#endif + +#endif /* _PVR2D_H_ */ + +/****************************************************************************** + End of file (pvr2d.h) +******************************************************************************/ diff --git a/src/3rdparty/powervr/wsegl.h b/src/3rdparty/powervr/wsegl.h new file mode 100644 index 0000000..e82c968 --- /dev/null +++ b/src/3rdparty/powervr/wsegl.h @@ -0,0 +1,240 @@ +/****************************************************************************** + Name : wsegl.h + Copyright : Copyright (c) Imagination Technologies Limited. + This specification is protected by copyright laws and contains + material proprietary to Imagination Technologies Limited. + You may use and distribute this specification free of charge for implementing + the functionality therein, without altering or removing any trademark, copyright, + or other notice from the specification. + Platform : ANSI +*****************************************************************************/ + + +#if !defined(__WSEGL_H__) +#define __WSEGL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +// WSEGL Platform-specific definitions +*/ +#define WSEGL_EXPORT +#define WSEGL_IMPORT + +/* +// WSEGL API Version Number +*/ + +#define WSEGL_VERSION 1 +#define WSEGL_DEFAULT_DISPLAY 0 +#define WSEGL_DEFAULT_NATIVE_ENGINE 0 + +#define WSEGL_FALSE 0 +#define WSEGL_TRUE 1 +#define WSEGL_NULL 0 + +#define WSEGL_UNREFERENCED_PARAMETER(param) (param) = (param) + +/* +// WSEGL handles +*/ +typedef void *WSEGLDisplayHandle; +typedef void *WSEGLDrawableHandle; + +/* +// Display capability type +*/ +typedef enum WSEGLCapsType_TAG +{ + WSEGL_NO_CAPS = 0, + WSEGL_CAP_MIN_SWAP_INTERVAL = 1, /* System default value = 1 */ + WSEGL_CAP_MAX_SWAP_INTERVAL = 2, /* System default value = 1 */ + WSEGL_CAP_WINDOWS_USE_HW_SYNC = 3, /* System default value = 0 (FALSE) */ + WSEGL_CAP_PIXMAPS_USE_HW_SYNC = 4, /* System default value = 0 (FALSE) */ + +} WSEGLCapsType; + +/* +// Display capability +*/ +typedef struct WSEGLCaps_TAG +{ + WSEGLCapsType eCapsType; + unsigned long ui32CapsValue; + +} WSEGLCaps; + +/* +// Drawable type +*/ +#define WSEGL_NO_DRAWABLE 0x0 +#define WSEGL_DRAWABLE_WINDOW 0x1 +#define WSEGL_DRAWABLE_PIXMAP 0x2 + + +/* +// Pixel format of display/drawable +*/ +typedef enum WSEGLPixelFormat_TAG +{ + WSEGL_PIXELFORMAT_565 = 0, + WSEGL_PIXELFORMAT_4444 = 1, + WSEGL_PIXELFORMAT_8888 = 2, + WSEGL_PIXELFORMAT_1555 = 3 + +} WSEGLPixelFormat; + +/* +// Transparent of display/drawable +*/ +typedef enum WSEGLTransparentType_TAG +{ + WSEGL_OPAQUE = 0, + WSEGL_COLOR_KEY = 1, + +} WSEGLTransparentType; + +/* +// Display/drawable configuration +*/ +typedef struct WSEGLConfig_TAG +{ + /* + // Type of drawables this configuration applies to - + // OR'd values of drawable types. + */ + unsigned long ui32DrawableType; + + /* Pixel format */ + WSEGLPixelFormat ePixelFormat; + + /* Native Renderable - set to WSEGL_TRUE if native renderable */ + unsigned long ulNativeRenderable; + + /* FrameBuffer Level Parameter */ + unsigned long ulFrameBufferLevel; + + /* Native Visual ID */ + unsigned long ulNativeVisualID; + + /* Native Visual */ + void *hNativeVisual; + + /* Transparent Type */ + WSEGLTransparentType eTransparentType; + + /* Transparent Color - only used if transparent type is COLOR_KEY */ + unsigned long ulTransparentColor; /* packed as 0x00RRGGBB */ + + +} WSEGLConfig; + +/* +// WSEGL errors +*/ +typedef enum WSEGLError_TAG +{ + WSEGL_SUCCESS = 0, + WSEGL_CANNOT_INITIALISE = 1, + WSEGL_BAD_NATIVE_DISPLAY = 2, + WSEGL_BAD_NATIVE_WINDOW = 3, + WSEGL_BAD_NATIVE_PIXMAP = 4, + WSEGL_BAD_NATIVE_ENGINE = 5, + WSEGL_BAD_DRAWABLE = 6, + WSEGL_BAD_CONFIG = 7, + WSEGL_OUT_OF_MEMORY = 8 + +} WSEGLError; + +/* +// Drawable orientation (in degrees anti-clockwise) +*/ +typedef enum WSEGLRotationAngle_TAG +{ + WSEGL_ROTATE_0 = 0, + WSEGL_ROTATE_90 = 1, + WSEGL_ROTATE_180 = 2, + WSEGL_ROTATE_270 = 3 + +} WSEGLRotationAngle; + +/* +// Drawable information required by OpenGL-ES driver +*/ +typedef struct WSEGLDrawableParams_TAG +{ + /* Width in pixels of the drawable */ + unsigned long ui32Width; + + /* Height in pixels of the drawable */ + unsigned long ui32Height; + + /* Stride in pixels of the drawable */ + unsigned long ui32Stride; + + /* Pixel format of the drawable */ + WSEGLPixelFormat ePixelFormat; + + /* User space cpu virtual address of the drawable */ + void *pvLinearAddress; + + /* HW address of the drawable */ + unsigned long ui32HWAddress; + + /* Private data for the drawable */ + void *hPrivateData; + +} WSEGLDrawableParams; + + +/* +// Table of function pointers that is returned by WSEGL_GetFunctionTablePointer() +// +// The first entry in the table is the version number of the wsegl.h header file that +// the module has been written against, and should therefore be set to WSEGL_VERSION +*/ +typedef struct WSEGL_FunctionTable_TAG +{ + unsigned long ui32WSEGLVersion; + + WSEGLError (*pfnWSEGL_IsDisplayValid)(NativeDisplayType); + + WSEGLError (*pfnWSEGL_InitialiseDisplay)(NativeDisplayType, WSEGLDisplayHandle *, const WSEGLCaps **, WSEGLConfig **); + + WSEGLError (*pfnWSEGL_CloseDisplay)(WSEGLDisplayHandle); + + WSEGLError (*pfnWSEGL_CreateWindowDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativeWindowType, WSEGLRotationAngle *); + + WSEGLError (*pfnWSEGL_CreatePixmapDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativePixmapType, WSEGLRotationAngle *); + + WSEGLError (*pfnWSEGL_DeleteDrawable)(WSEGLDrawableHandle); + + WSEGLError (*pfnWSEGL_SwapDrawable)(WSEGLDrawableHandle, unsigned long); + + WSEGLError (*pfnWSEGL_SwapControlInterval)(WSEGLDrawableHandle, unsigned long); + + WSEGLError (*pfnWSEGL_WaitNative)(WSEGLDrawableHandle, unsigned long); + + WSEGLError (*pfnWSEGL_CopyFromDrawable)(WSEGLDrawableHandle, NativePixmapType); + + WSEGLError (*pfnWSEGL_CopyFromPBuffer)(void *, unsigned long, unsigned long, unsigned long, WSEGLPixelFormat, NativePixmapType); + + WSEGLError (*pfnWSEGL_GetDrawableParameters)(WSEGLDrawableHandle, WSEGLDrawableParams *, WSEGLDrawableParams *); + + +} WSEGL_FunctionTable; + + +WSEGL_IMPORT const WSEGL_FunctionTable *WSEGL_GetFunctionTablePointer(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __WSEGL_H__ */ + +/****************************************************************************** + End of file (wsegl.h) +******************************************************************************/ diff --git a/src/plugins/gfxdrivers/powervr/README b/src/plugins/gfxdrivers/powervr/README index ec02efb..3eac1b9 100644 --- a/src/plugins/gfxdrivers/powervr/README +++ b/src/plugins/gfxdrivers/powervr/README @@ -29,9 +29,10 @@ strictly Unix-style markers. *************************************************************************** * IMPORTANT: To build the QScreen plugin and the WSEGL library it depends * -* on, the pvr2d.h, wsegl.h headers for your platform are required. These * -* can be obtained either through your platform provider or directly from * -* Imagination Technologies. * +* on, the pvr2d.h, wsegl.h headers for your platform are required. You * +* can find a copy of these headers in src/3rdparty/powervr for SGX based * +* platforms like the TI OMAP3xxx. They may also work on MBX platforms too * +* depending on how old your libEGL is. * *************************************************************************** -- cgit v0.12 From c962ddaf8932545c96cc83c03d939bf90efcc223 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 3 Apr 2009 13:26:38 +0200 Subject: Add QMAKE_INCDIR_POWERVR to specify the location of pvr2d.h & wsegl.h Allow setting of a QMAKE_INCDIR_POWERVR in the mkspec to specify where the pvr2d.h & wsegl.h files are located. Set to src/3rdparty/powervr to use the headers distributed with Qt (for SGX-based SoCs). Reviewed-by: Trustme --- src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro | 2 ++ src/plugins/gfxdrivers/powervr/README | 4 ++-- src/plugins/gfxdrivers/powervr/powervr.pri | 2 ++ src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro | 7 +++++-- 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 src/plugins/gfxdrivers/powervr/powervr.pri diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro b/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro index b62894d..9331d0a 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro @@ -22,3 +22,5 @@ LIBS += -lpvr2d DESTDIR = $$QMAKE_LIBDIR_QT target.path = $$[QT_INSTALL_LIBS] INSTALLS += target + +include(../powervr.pri) \ No newline at end of file diff --git a/src/plugins/gfxdrivers/powervr/README b/src/plugins/gfxdrivers/powervr/README index 3eac1b9..4dce87f 100644 --- a/src/plugins/gfxdrivers/powervr/README +++ b/src/plugins/gfxdrivers/powervr/README @@ -32,10 +32,10 @@ strictly Unix-style markers. * on, the pvr2d.h, wsegl.h headers for your platform are required. You * * can find a copy of these headers in src/3rdparty/powervr for SGX based * * platforms like the TI OMAP3xxx. They may also work on MBX platforms too * -* depending on how old your libEGL is. * +* depending on how old your libEGL is. You can tell Qt where to find * +* these headers by setting QMAKE_INCDIR_POWERVR in the mkspec. * *************************************************************************** - When you start a Qt/Embedded application, you should modify the QWS_DISPLAY environment variable to use the "powervr" driver instead of "LinuxFb". For example, if your original QWS_DISPLAY variable was: diff --git a/src/plugins/gfxdrivers/powervr/powervr.pri b/src/plugins/gfxdrivers/powervr/powervr.pri new file mode 100644 index 0000000..9df8c0e --- /dev/null +++ b/src/plugins/gfxdrivers/powervr/powervr.pri @@ -0,0 +1,2 @@ + +INCLUDEPATH += $$QMAKE_INCDIR_POWERVR diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro index 691cd2d..675be85 100644 --- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro +++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro @@ -9,9 +9,10 @@ DEFINES += QT_QWS_CLIENTBLIT INCLUDEPATH += ../QWSWSEGL + HEADERS = \ - pvreglscreen.h \ - pvreglwindowsurface.h + pvreglscreen.h \ + pvreglwindowsurface.h SOURCES = \ pvreglscreenplugin.cpp \ @@ -22,3 +23,5 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target + +include(../powervr.pri) \ No newline at end of file -- cgit v0.12 From 91938f0be5f8ba17f669b547b92941eb7063b9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Tue, 5 May 2009 16:57:07 +0200 Subject: Make command-quit not terminate the program on Qt/Cocoa. Instead instigate the quit by calling QApplication::quit(), using the code that was already in place. This allows QApplication::exec() to return normally and prevents resrouce leaks for objects created on the stack in main(). Reviewed-by: nrc --- src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index dad15d9..9a24645 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -183,21 +183,24 @@ static void cleanupCocoaApplicationDelegate() { Q_UNUSED(sender); // The reflection delegate gets precedence - NSApplicationTerminateReply reply = NSTerminateCancel; if (reflectionDelegate && [reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) { return [reflectionDelegate applicationShouldTerminate:sender]; } if (qtPrivate->canQuit()) { - reply = NSTerminateNow; if (!startedQuit) { startedQuit = true; qAppInstance()->quit(); startedQuit = false; } } - return reply; + + // Prevent Cocoa from terminating the application, since this simply + // exits the program whithout allowing QApplication::exec() to return. + // The call to QApplication::quit() above will instead quit the + // application from the Qt side. + return NSTerminateCancel; } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification -- cgit v0.12 From 7eee0583f9cc395e4c6609a1ee1748b3144c96ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 5 May 2009 17:08:56 +0200 Subject: Syntax error on configure script Reported downstream to Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525570 Reviewed-by: Alexis Reviewed-by: Thiago --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index e007782..24e755e 100755 --- a/configure +++ b/configure @@ -279,7 +279,7 @@ if [ "$COMMERCIAL_USER" = "ask" ]; then if [ "$commercial" = "c" ]; then COMMERCIAL_USER="yes" break - else [ "$commercial" = "o" ]; + elif [ "$commercial" = "o" ]; then COMMERCIAL_USER="no" break fi -- cgit v0.12 From 3bb955831373ab3fcce8e5496fa80bec9d446cdf Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 5 May 2009 08:25:05 -0700 Subject: Improved debug output Format the debug info on blitting, drawing and acceleration capabilities better. Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 60 +++++++++++----------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 59f5934..ab60214 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -751,43 +751,43 @@ struct FlagDescription { }; static const FlagDescription accelerationDescriptions[] = { - { "DFXL_NONE ", DFXL_NONE }, - { "DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE }, - { "DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE }, - { "DFXL_DRAWLINE", DFXL_DRAWLINE }, - { "DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE }, - { "DFXL_BLIT", DFXL_BLIT }, - { "DFXL_STRETCHBLIT", DFXL_STRETCHBLIT }, - { "DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES }, - { "DFXL_DRAWSTRING", DFXL_DRAWSTRING }, + { " DFXL_NONE ", DFXL_NONE }, + { " DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE }, + { " DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE }, + { " DFXL_DRAWLINE", DFXL_DRAWLINE }, + { " DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE }, + { " DFXL_BLIT", DFXL_BLIT }, + { " DFXL_STRETCHBLIT", DFXL_STRETCHBLIT }, + { " DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES }, + { " DFXL_DRAWSTRING", DFXL_DRAWSTRING }, { 0, 0 } }; static const FlagDescription blitDescriptions[] = { - { "DSBLIT_NOFX", DSBLIT_NOFX }, - { "DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL }, - { "DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA }, - { "DSBLIT_COLORIZE", DSBLIT_COLORIZE }, - { "DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY }, - { "DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY }, - { "DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY }, - { "DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY }, - { "DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY }, - { "DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE }, - { "DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR }, - { "DSBLIT_XOR", DSBLIT_XOR }, - { "DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION }, + { " DSBLIT_NOFX", DSBLIT_NOFX }, + { " DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL }, + { " DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA }, + { " DSBLIT_COLORIZE", DSBLIT_COLORIZE }, + { " DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY }, + { " DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY }, + { " DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY }, + { " DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY }, + { " DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY }, + { " DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE }, + { " DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR }, + { " DSBLIT_XOR", DSBLIT_XOR }, + { " DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION }, { 0, 0 } }; static const FlagDescription drawDescriptions[] = { - { "DSDRAW_NOFX", DSDRAW_NOFX }, - { "DSDRAW_BLEND", DSDRAW_BLEND }, - { "DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY }, - { "DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY }, - { "DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY }, - { "DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY }, - { "DSDRAW_XOR", DSDRAW_XOR }, + { " DSDRAW_NOFX", DSDRAW_NOFX }, + { " DSDRAW_BLEND", DSDRAW_BLEND }, + { " DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY }, + { " DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY }, + { " DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY }, + { " DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY }, + { " DSDRAW_XOR", DSDRAW_XOR }, { 0, 0 } }; #endif @@ -829,7 +829,7 @@ static void printDirectFBInfo(IDirectFB *fb) } qDebug("Device: %s (%s), Driver: %s v%i.%i (%s)\n" - " acceleration: 0x%x%s,\nblit: 0x%x%s,\ndraw: 0x%0x%s\nvideo: %iKB\n", + "acceleration: 0x%x%s\nblit: 0x%x%s\ndraw: 0x%0x%s\nvideo: %iKB\n", dev.name, dev.vendor, dev.driver.name, dev.driver.major, dev.driver.minor, dev.driver.vendor, dev.acceleration_mask, ::flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), -- cgit v0.12 From fcb702ca8641026fc6af85171061de49248adc17 Mon Sep 17 00:00:00 2001 From: mae Date: Mon, 4 May 2009 13:32:02 +0200 Subject: QTextEdit::ExtraSelection failure with style sheets the feature has to handle text with and without background, and extra selections with and without background, or even only with underline style. Trouble is that you sometimes want to accumulate styles, for example spell checking wiggly underline plus search result highlights or background markup from the css stylesheet. Task-number: 252310 --- src/gui/text/qtextformat.h | 6 ++++++ src/gui/text/qtextlayout.cpp | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index 0571d75..8eaeeb1 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -232,6 +232,12 @@ public: ImageWidth = 0x5010, ImageHeight = 0x5011, + // internal + /* + SuppressText = 0x5012, + SuppressBackground = 0x513 + */ + // selection properties FullWidthSelection = 0x06000, diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 434d1ca..3222237 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -61,6 +61,8 @@ QT_BEGIN_NAMESPACE #define ObjectSelectionBrush (QTextFormat::ForegroundBrush + 1) +#define SuppressText 0x5012 +#define SuppressBackground 0x513 static inline QFixed leadingSpaceWidth(QTextEngine *eng, const QScriptLine &line) { @@ -1143,6 +1145,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVectorrestore(); - if (selection.format.foreground().style() != Qt::NoBrush) // i.e. we have drawn text - excludedRegion += region; + if (noText) + needsTextButNoBackground += region; + else + needsTextButNoBackground -= region; + excludedRegion += region; + } + + if (!needsTextButNoBackground.isEmpty()){ + p->save(); + p->setClipPath(needsTextButNoBackground, Qt::IntersectClip); + FormatRange selection; + selection.start = 0; + selection.length = INT_MAX; + selection.format.setProperty(SuppressBackground, true); + for (int line = firstLine; line < lastLine; ++line) { + QTextLine l(line, d); + l.draw(p, position, &selection); + } + p->restore(); } if (!excludedRegion.isEmpty()) { @@ -1912,14 +1936,17 @@ static void drawMenuText(QPainter *p, QFixed x, QFixed y, const QScriptItem &si, static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const QTextCharFormat &chf, const QRectF &r) { QBrush c = chf.foreground(); - if (c.style() == Qt::NoBrush) + if (c.style() == Qt::NoBrush) { p->setPen(defaultPen); + } QBrush bg = chf.background(); - if (bg.style() != Qt::NoBrush) + if (bg.style() != Qt::NoBrush && !chf.property(SuppressBackground).toBool()) p->fillRect(r, bg); - if (c.style() != Qt::NoBrush) + if (c.style() != Qt::NoBrush) { p->setPen(QPen(c, 0)); + } + } /*! @@ -1933,7 +1960,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR const QScriptLine &line = eng->lines[i]; QPen pen = p->pen(); - bool noText = (selection && selection->format.foreground().style() == Qt::NoBrush); + bool noText = (selection && selection->format.property(SuppressText).toBool()); if (!line.length) { if (selection -- cgit v0.12 From 5ad7b6b07ec7727c04abbf96faf540a5d3f0c04c Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 5 May 2009 14:22:21 +0200 Subject: Extend change 759338df758ad16cdfd9521b270f7e379bbfa57c to cover extra selections with different foreground but no background The main concern is to avoid double painting. With anti-aliasing turned on by default, we can not draw a piece of text on top of the same piece of text without artefacts. Task-number: 252310 --- src/gui/text/qtextlayout.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 3222237..fa624ef 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1145,7 +1145,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVectorsave(); - p->setClipPath(region, Qt::IntersectClip); - selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush)); - // don't just clear the property, set an empty brush that overrides a potential - // background brush specified in the text - selection.format.setProperty(QTextFormat::BackgroundBrush, QBrush()); - selection.format.clearProperty(QTextFormat::OutlinePen); + bool hasText = (selection.format.foreground().style() != Qt::NoBrush); + bool hasBackground= (selection.format.background().style() != Qt::NoBrush); + + if (hasBackground) { + selection.format.setProperty(ObjectSelectionBrush, selection.format.property(QTextFormat::BackgroundBrush)); + // don't just clear the property, set an empty brush that overrides a potential + // background brush specified in the text + selection.format.setProperty(QTextFormat::BackgroundBrush, QBrush()); + selection.format.clearProperty(QTextFormat::OutlinePen); + } - bool noText = (selection.format.foreground().style() == Qt::NoBrush); + selection.format.setProperty(SuppressText, !hasText); + + if (hasText && !hasBackground && !(textDoneRegion & region).isEmpty()) + continue; - selection.format.setProperty(SuppressText, noText); + p->save(); + p->setClipPath(region, Qt::IntersectClip); for (int line = firstLine; line < lastLine; ++line) { QTextLine l(line, d); @@ -1224,13 +1231,17 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVectorrestore(); - if (noText) - needsTextButNoBackground += region; - else - needsTextButNoBackground -= region; + if (hasText) { + textDoneRegion += region; + } else { + if (hasBackground) + textDoneRegion -= region; + } + excludedRegion += region; } + QPainterPath needsTextButNoBackground = excludedRegion - textDoneRegion; if (!needsTextButNoBackground.isEmpty()){ p->save(); p->setClipPath(needsTextButNoBackground, Qt::IntersectClip); -- cgit v0.12 From c3cc3f8b66486d5bdb555e17dc86e7eb911f8a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 5 May 2009 17:39:01 +0200 Subject: Fix infinite recursion with QT3_SUPPORT Forward setDesktopBackground to setBackground as is mentioned in the docs. Reviewed-by: Paul --- src/gui/embedded/qwindowsystem_qws.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/embedded/qwindowsystem_qws.cpp b/src/gui/embedded/qwindowsystem_qws.cpp index dffebf2..fdcd193 100644 --- a/src/gui/embedded/qwindowsystem_qws.cpp +++ b/src/gui/embedded/qwindowsystem_qws.cpp @@ -4044,7 +4044,7 @@ void QWSServer::setDesktopBackground(const QImage &img) */ void QWSServer::setDesktopBackground(const QColor &c) { - setDesktopBackground(QBrush(c)); + setBackground(QBrush(c)); } #endif //QT3_SUPPORT -- cgit v0.12 From b7495c9dc896c5c66f01b24ff1d25d2b1e468c90 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 5 May 2009 18:07:24 +0200 Subject: Fix line encoding on PowerVR headers Reviewed-by: Paul --- src/3rdparty/powervr/pvr2d.h | 1004 +++++++++++++++++++++--------------------- src/3rdparty/powervr/wsegl.h | 480 ++++++++++---------- 2 files changed, 742 insertions(+), 742 deletions(-) diff --git a/src/3rdparty/powervr/pvr2d.h b/src/3rdparty/powervr/pvr2d.h index 14823e0..07f28c7 100644 --- a/src/3rdparty/powervr/pvr2d.h +++ b/src/3rdparty/powervr/pvr2d.h @@ -1,502 +1,502 @@ -/*!**************************************************************************** -@File pvr2d.h -@Title PVR2D external header file -@Author Imagination Technologies -@Copyright Copyright (c) by Imagination Technologies Limited. - This specification is protected by copyright laws and contains - material proprietary to Imagination Technologies Limited. - You may use and distribute this specification free of charge for implementing - the functionality therein, without altering or removing any trademark, copyright, - or other notice from the specification. -@Platform Generic -@Description PVR2D definitions for PVR2D clients -******************************************************************************/ - - -/****************************************************************************** -Modifications :- -$Log: pvr2d.h $ -******************************************************************************/ - -#ifndef _PVR2D_H_ -#define _PVR2D_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* PVR2D Platform-specific definitions */ -#define PVR2D_EXPORT -#define PVR2D_IMPORT - - -#define PVR2D_REV_MAJOR 2 -#define PVR2D_REV_MINOR 1 - -typedef enum -{ - PVR2D_FALSE = 0, - PVR2D_TRUE -} PVR2D_BOOL; - - -/* error codes */ -typedef enum -{ - PVR2D_OK = 0, - PVR2DERROR_INVALID_PARAMETER = -1, - PVR2DERROR_DEVICE_UNAVAILABLE = -2, - PVR2DERROR_INVALID_CONTEXT = -3, - PVR2DERROR_MEMORY_UNAVAILABLE = -4, - PVR2DERROR_DEVICE_NOT_PRESENT = -5, - PVR2DERROR_IOCTL_ERROR = -6, - PVR2DERROR_GENERIC_ERROR = -7, - PVR2DERROR_BLT_NOTCOMPLETE = -8, - PVR2DERROR_HW_FEATURE_NOT_SUPPORTED = -9, - PVR2DERROR_NOT_YET_IMPLEMENTED = -10, - PVR2DERROR_MAPPING_FAILED = -11 -}PVR2DERROR; - - -/* pixel formats */ -typedef enum -{ - PVR2D_1BPP = 0, - PVR2D_RGB565, - PVR2D_ARGB4444, - PVR2D_RGB888, - PVR2D_ARGB8888, - PVR2D_ARGB1555, - PVR2D_ALPHA8, - PVR2D_ALPHA4, - PVR2D_PAL2, - PVR2D_PAL4, - PVR2D_PAL8, - PVR2D_VGAEMU - -}PVR2DFORMAT; - - -/* wrap surface type */ -typedef enum -{ - PVR2D_WRAPFLAG_NONCONTIGUOUS = 0, - PVR2D_WRAPFLAG_CONTIGUOUS = 1, - -}PVR2DWRAPFLAGS; - -/* flags for control information of additional blits */ -typedef enum -{ - PVR2D_BLIT_DISABLE_ALL = 0x0000, /* disable all additional controls */ - PVR2D_BLIT_CK_ENABLE = 0x0001, /* enable colour key */ - PVR2D_BLIT_GLOBAL_ALPHA_ENABLE = 0x0002, /* enable standard global alpha */ - PVR2D_BLIT_PERPIXEL_ALPHABLEND_ENABLE = 0x0004, /* enable per-pixel alpha bleding */ - PVR2D_BLIT_PAT_SURFACE_ENABLE = 0x0008, /* enable pattern surf (disable fill) */ - PVR2D_BLIT_FULLY_SPECIFIED_ALPHA_ENABLE = 0x0010, /* enable fully specified alpha */ - PVR2D_BLIT_ROT_90 = 0x0020, /* apply 90 degree rotation to the blt */ - PVR2D_BLIT_ROT_180 = 0x0040, /* apply 180 degree rotation to the blt */ - PVR2D_BLIT_ROT_270 = 0x0080, /* apply 270 degree rotation to the blt */ - PVR2D_BLIT_COPYORDER_TL2BR = 0x0100, /* copy order overrides */ - PVR2D_BLIT_COPYORDER_BR2TL = 0x0200, - PVR2D_BLIT_COPYORDER_TR2BL = 0x0400, - PVR2D_BLIT_COPYORDER_BL2TR = 0x0800, - PVR2D_BLIT_COLKEY_SOURCE = 0x1000, /* Key colour is on the source surface */ - PVR2D_BLIT_COLKEY_DEST = 0x2000 /* Key colour is on the destination surface */ - -} PVR2DBLITFLAGS; - -/* standard alpha-blending functions, AlphaBlendingFunc field of PVR2DBLTINFO */ -typedef enum -{ - PVR2D_ALPHA_OP_SRC_DSTINV = 1, /* source alpha : Cdst = Csrc*Asrc + Cdst*(1-Asrc) */ - PVR2D_ALPHA_OP_SRCP_DSTINV = 2 /* premultiplied source alpha : Cdst = Csrc + Cdst*(1-Asrc) */ -} PVR2D_ALPHABLENDFUNC; - -/* blend ops for fully specified alpha */ -typedef enum -{ - PVR2D_BLEND_OP_ZERO = 0, - PVR2D_BLEND_OP_ONE = 1, - PVR2D_BLEND_OP_SRC = 2, - PVR2D_BLEND_OP_DST = 3, - PVR2D_BLEND_OP_GLOBAL = 4, - PVR2D_BLEND_OP_SRC_PLUS_GLOBAL = 5, - PVR2D_BLEND_OP_DST_PLUS_GLOBAL = 6 -}PVR2D_BLEND_OP; - - -typedef void* PVR2D_HANDLE; - - -/* Fully specified alpha blend : pAlpha field of PVR2DBLTINFO structure */ -/* a fully specified Alpha Blend operation is defined as */ -/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (ALPHA_3 * DST (ALPHA)) */ -/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (ALPHA_4 * DST (RGB)) */ -/* if the pre-multiplication stage is enabled then the equations become the following: */ -/* PRE_MUL = ((SRC(A)) * (Global Alpha Value)) */ -/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (PRE_MUL * DST (ALPHA)) */ -/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (PRE_MUL * DST (RGB)) */ -/* if the transparent source alpha stage is enabled then a source alpha of zero forces the */ -/* source to be transparent for that pixel regardless of the blend equation being used. */ -typedef struct _PVR2D_ALPHABLT -{ - PVR2D_BLEND_OP eAlpha1; - PVR2D_BOOL bAlpha1Invert; - PVR2D_BLEND_OP eAlpha2; - PVR2D_BOOL bAlpha2Invert; - PVR2D_BLEND_OP eAlpha3; - PVR2D_BOOL bAlpha3Invert; - PVR2D_BLEND_OP eAlpha4; - PVR2D_BOOL bAlpha4Invert; - PVR2D_BOOL bPremulAlpha; /* enable pre-multiplication stage */ - PVR2D_BOOL bTransAlpha; /* enable transparent source alpha stage */ - PVR2D_BOOL bUpdateAlphaLookup; /* enable and update the 1555-Lookup alpha table */ - unsigned char uAlphaLookup0; /* 8 bit alpha when A=0 in a 1555-Lookup surface */ - unsigned char uAlphaLookup1; /* 8 bit alpha when A=1 in a 1555-Lookup surface */ - unsigned char uGlobalRGB; /* Global Alpha Value for RGB, 0=transparent 255=opaque */ - unsigned char uGlobalA; /* Global Alpha Value for Alpha */ - -} PVR2D_ALPHABLT, *PPVR2D_ALPHABLT; - - -/* surface memory info structure */ -typedef struct _PVR2DMEMINFO -{ - void *pBase; - unsigned long ui32MemSize; - unsigned long ui32DevAddr; - unsigned long ulFlags; - void *hPrivateData; - void *hPrivateMapData; - -}PVR2DMEMINFO, *PPVR2DMEMINFO; - - -#define PVR2D_MAX_DEVICE_NAME 20 - -typedef struct _PVR2DDEVICEINFO -{ - unsigned long ulDevID; - char szDeviceName[PVR2D_MAX_DEVICE_NAME]; -}PVR2DDEVICEINFO; - - -typedef struct _PVR2DISPLAYINFO -{ - unsigned long ulMaxFlipChains; - unsigned long ulMaxBuffersInChain; - PVR2DFORMAT eFormat; - unsigned long ulWidth; - unsigned long ulHeight; - long lStride; - unsigned long ulMinFlipInterval; - unsigned long ulMaxFlipInterval; - -}PVR2DDISPLAYINFO; - - -typedef struct _PVR2DBLTINFO -{ - unsigned long CopyCode; /* rop code */ - unsigned long Colour; /* fill colour */ - unsigned long ColourKey; /* colour key */ - unsigned char GlobalAlphaValue; /* global alpha blending */ - unsigned char AlphaBlendingFunc; /* per-pixel alpha-blending function */ - - PVR2DBLITFLAGS BlitFlags; /* additional blit control information */ - - PVR2DMEMINFO *pDstMemInfo; /* destination memory */ - unsigned long DstOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */ - long DstStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ - long DstX, DstY; /* pixel offset from start of dest surface to start of blt rectangle */ - long DSizeX,DSizeY; /* blt size */ - PVR2DFORMAT DstFormat; /* dest format */ - unsigned long DstSurfWidth; /* size of dest surface in pixels */ - unsigned long DstSurfHeight; /* size of dest surface in pixels */ - - PVR2DMEMINFO *pSrcMemInfo; /* source mem, (source fields are also used for patterns) */ - unsigned long SrcOffset; /* byte offset from start of allocation to src/pat surface pixel 0,0 */ - long SrcStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ - long SrcX, SrcY; /* pixel offset from start of surface to start of source rectangle */ - /* for patterns this is the start offset within the pattern */ - long SizeX,SizeY; /* source rectangle size or pattern size in pixels */ - PVR2DFORMAT SrcFormat; /* source/pattern format */ - PVR2DMEMINFO *pPalMemInfo; /* source/pattern palette memory containing argb8888 colour table */ - unsigned long PalOffset; /* byte offset from start of allocation to start of palette */ - unsigned long SrcSurfWidth; /* size of source surface in pixels */ - unsigned long SrcSurfHeight; /* size of source surface in pixels */ - - PVR2DMEMINFO *pMaskMemInfo; /* mask memory, 1bpp format implied */ - unsigned long MaskOffset; /* byte offset from start of allocation to mask surface pixel 0,0 */ - long MaskStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ - long MaskX, MaskY; /* mask rect top left (mask size = blt size) */ - unsigned long MaskSurfWidth; /* size of mask surface in pixels */ - unsigned long MaskSurfHeight; /* size of mask surface in pixels */ - - PPVR2D_ALPHABLT pAlpha; /* fully specified alpha blend */ - -}PVR2DBLTINFO, *PPVR2DBLTINFO; - -typedef struct _PVR2DRECT -{ - long left, top; - long right, bottom; -} PVR2DRECT; - -typedef struct -{ - PVR2DMEMINFO *pSurfMemInfo; /* surface memory */ - unsigned long SurfOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */ - long Stride; /* signed stride */ - PVR2DFORMAT Format; - unsigned long SurfWidth; /* surface size in pixels */ - unsigned long SurfHeight; - -} PVR2D_SURFACE, *PPVR2D_SURFACE; - -typedef struct -{ - unsigned long *pUseCode; /* USSE code */ - unsigned long UseCodeSize; /* usse code size in bytes */ - -} PVR2D_USECODE, *PPVR2D_USECODE; - -typedef struct -{ - PVR2D_SURFACE sDst; /* destination surface */ - PVR2D_SURFACE sSrc; /* source surface */ - PVR2DRECT rcDest; /* destination rectangle */ - PVR2DRECT rcSource; /* source rectangle */ - PVR2D_HANDLE hUseCode; /* custom USE code (NULL implies source copy) */ - unsigned long UseParams[2]; /* per-blt params for use code */ - -} PVR2D_3DBLT, *PPVR2D_3DBLT; - - -#define MAKE_COPY_BLIT(src,soff,dest,doff,sx,sy,dx,dy,sz) - -typedef void* PVR2DCONTEXTHANDLE; -typedef void* PVR2DFLIPCHAINHANDLE; - - -// CopyCode field of PVR2DBLTINFO structure: -// the CopyCode field of the PVR2DBLTINFO structure should contain a rop3 or rop4 code. -// a rop3 is an 8 bit code that describes a blt with three inputs : source dest and pattern -// rop4 is a 16 bit code that describes a blt with four inputs : source dest pattern and mask -// common rop3 codes are defined below -// a colour fill blt is processed in the pattern channel as a constant colour with a rop code of 0xF0 -// PVR2D_BLIT_PAT_SURFACE_ENABLE defines whether the pattern channel is a surface or a fill colour. -// a rop4 is defined by two rop3 codes, and the 1 bit-per-pixel mask surface defines which is used. -// a common rop4 is 0xAAF0 which is the mask copy blt used for text glyphs. -// CopyCode is taken to be a rop4 when pMaskMemInfo is non zero, otherwise it is assumed to be a rop3 -// use the PVR2DMASKROP4 macro below to construct a rop4 from two rop3's -// rop3a is the rop used when mask pixel = 1, and rop3b when mask = 0 -#define PVR2DROP4(rop3b, rop3a) ((rop3b<<8)|rop3a) - -/* common rop codes */ -#define PVR2DROPclear 0x00 /* 0 (whiteness) */ -#define PVR2DROPset 0xFF /* 1 (blackness) */ -#define PVR2DROPnoop 0xAA /* dst (used for masked blts) */ - -/* source and dest rop codes */ -#define PVR2DROPand 0x88 /* src AND dst */ -#define PVR2DROPandReverse 0x44 /* src AND NOT dst */ -#define PVR2DROPcopy 0xCC /* src (used for source copy and alpha blts) */ -#define PVR2DROPandInverted 0x22 /* NOT src AND dst */ -#define PVR2DROPxor 0x66 /* src XOR dst */ -#define PVR2DROPor 0xEE /* src OR dst */ -#define PVR2DROPnor 0x11 /* NOT src AND NOT dst */ -#define PVR2DROPequiv 0x99 /* NOT src XOR dst */ -#define PVR2DROPinvert 0x55 /* NOT dst */ -#define PVR2DROPorReverse 0xDD /* src OR NOT dst */ -#define PVR2DROPcopyInverted 0x33 /* NOT src */ -#define PVR2DROPorInverted 0xBB /* NOT src OR dst */ -#define PVR2DROPnand 0x77 /* NOT src OR NOT dst */ - -/* pattern rop codes */ -#define PVR2DPATROPand 0xA0 /* pat AND dst */ -#define PVR2DPATROPandReverse 0x50 /* pat AND NOT dst */ -#define PVR2DPATROPcopy 0xF0 /* pat (used for solid color fills and pattern blts) */ -#define PVR2DPATROPandInverted 0x0A /* NOT pat AND dst */ -#define PVR2DPATROPxor 0x5A /* pat XOR dst */ -#define PVR2DPATROPor 0xFA /* pat OR dst */ -#define PVR2DPATROPnor 0x05 /* NOT pat AND NOT dst */ -#define PVR2DPATROPequiv 0xA5 /* NOT pat XOR dst */ -#define PVR2DPATROPinvert 0x55 /* NOT dst */ -#define PVR2DPATROPorReverse 0xF5 /* pat OR NOT dst */ -#define PVR2DPATROPcopyInverted 0x0F /* NOT pat */ -#define PVR2DPATROPorInverted 0xAF /* NOT pat OR dst */ -#define PVR2DPATROPnand 0x5F /* NOT pat OR NOT dst */ - -/* common rop4 codes */ -#define PVR2DROP4MaskedCopy PVR2DROP4(PVR2DROPnoop,PVR2DROPcopy) /* masked source copy blt (used for rounded window corners etc) */ -#define PVR2DROP4MaskedFill PVR2DROP4(PVR2DROPnoop,PVR2DPATROPcopy) /* masked colour fill blt (used for text) */ - -/* Legacy support */ -#define PVR2DROP3_PATMASK PVR2DPATROPcopy -#define PVR2DROP3_SRCMASK PVR2DROPcopy - -/* pixmap memory alignment */ -#define PVR2D_ALIGNMENT_4 4 /* DWORD alignment */ -#define PVR2D_ALIGNMENT_ANY 0 /* no alignment */ -#define PVR2D_ALIGNMENT_PALETTE 16 /* 16 byte alignment is required for palettes */ - -/* Heap number for PVR2DGetFrameBuffer */ -#define PVR2D_FB_PRIMARY_SURFACE 0 - -#define PVR2D_PRESENT_PROPERTY_SRCSTRIDE (1 << 0) -#define PVR2D_PRESENT_PROPERTY_DSTSIZE (1 << 1) -#define PVR2D_PRESENT_PROPERTY_DSTPOS (1 << 2) -#define PVR2D_PRESENT_PROPERTY_CLIPRECTS (1 << 3) -#define PVR2D_PRESENT_PROPERTY_INTERVAL (1 << 4) - - -#define PVR2D_CREATE_FLIPCHAIN_SHARED (1 << 0) -#define PVR2D_CREATE_FLIPCHAIN_QUERY (1 << 1) - -/* Functions that the library exports */ - -PVR2D_IMPORT -int PVR2DEnumerateDevices(PVR2DDEVICEINFO *pDevInfo); - -PVR2D_IMPORT -PVR2DERROR PVR2DCreateDeviceContext(unsigned long ulDevID, - PVR2DCONTEXTHANDLE* phContext, - unsigned long ulFlags); - -PVR2D_IMPORT -PVR2DERROR PVR2DDestroyDeviceContext(PVR2DCONTEXTHANDLE hContext); - -PVR2D_IMPORT -PVR2DERROR PVR2DGetDeviceInfo(PVR2DCONTEXTHANDLE hContext, - PVR2DDISPLAYINFO *pDisplayInfo); - -PVR2D_IMPORT -PVR2DERROR PVR2DGetScreenMode(PVR2DCONTEXTHANDLE hContext, - PVR2DFORMAT *pFormat, - long *plWidth, - long *plHeight, - long *plStride, - int *piRefreshRate); - -PVR2D_IMPORT -PVR2DERROR PVR2DGetFrameBuffer(PVR2DCONTEXTHANDLE hContext, - int nHeap, - PVR2DMEMINFO **ppsMemInfo); - -PVR2D_IMPORT -PVR2DERROR PVR2DMemAlloc(PVR2DCONTEXTHANDLE hContext, - unsigned long ulBytes, - unsigned long ulAlign, - unsigned long ulFlags, - PVR2DMEMINFO **ppsMemInfo); - -PVR2D_IMPORT -PVR2DERROR PVR2DMemWrap(PVR2DCONTEXTHANDLE hContext, - void *pMem, - unsigned long ulFlags, - unsigned long ulBytes, - unsigned long alPageAddress[], - PVR2DMEMINFO **ppsMemInfo); - -PVR2D_IMPORT -PVR2DERROR PVR2DMemMap(PVR2DCONTEXTHANDLE hContext, - unsigned long ulFlags, - void *hPrivateMapData, - PVR2DMEMINFO **ppsDstMem); - -PVR2D_IMPORT -PVR2DERROR PVR2DMemFree(PVR2DCONTEXTHANDLE hContext, - PVR2DMEMINFO *psMemInfo); - -PVR2D_IMPORT -PVR2DERROR PVR2DBlt(PVR2DCONTEXTHANDLE hContext, - PVR2DBLTINFO *pBltInfo); - -PVR2D_IMPORT -PVR2DERROR PVR2DBltClipped(PVR2DCONTEXTHANDLE hContext, - PVR2DBLTINFO *pBltInfo, - unsigned long ulNumClipRects, - PVR2DRECT *pClipRects); - -PVR2D_IMPORT -PVR2DERROR PVR2DQueryBlitsComplete(PVR2DCONTEXTHANDLE hContext, - PVR2DMEMINFO *pMemInfo, - unsigned int uiWaitForComplete); - -PVR2D_IMPORT -PVR2DERROR PVR2DSetPresentBltProperties(PVR2DCONTEXTHANDLE hContext, - unsigned long ulPropertyMask, - long lSrcStride, - unsigned long ulDstWidth, - unsigned long ulDstHeight, - long lDstXPos, - long lDstYPos, - unsigned long ulNumClipRects, - PVR2DRECT *pClipRects, - unsigned long ulSwapInterval); - -PVR2D_IMPORT -PVR2DERROR PVR2DPresentBlt(PVR2DCONTEXTHANDLE hContext, - PVR2DMEMINFO *pMemInfo, - long lRenderID); - -PVR2D_IMPORT -PVR2DERROR PVR2DCreateFlipChain(PVR2DCONTEXTHANDLE hContext, - unsigned long ulFlags, - unsigned long ulNumBuffers, - unsigned long ulWidth, - unsigned long ulHeight, - PVR2DFORMAT eFormat, - long *plStride, - unsigned long *pulFlipChainID, - PVR2DFLIPCHAINHANDLE *phFlipChain); - -PVR2D_IMPORT -PVR2DERROR PVR2DDestroyFlipChain(PVR2DCONTEXTHANDLE hContext, - PVR2DFLIPCHAINHANDLE hFlipChain); - -PVR2D_IMPORT -PVR2DERROR PVR2DGetFlipChainBuffers(PVR2DCONTEXTHANDLE hContext, - PVR2DFLIPCHAINHANDLE hFlipChain, - unsigned long *pulNumBuffers, - PVR2DMEMINFO *psMemInfo[]); - -PVR2D_IMPORT -PVR2DERROR PVR2DSetPresentFlipProperties(PVR2DCONTEXTHANDLE hContext, - PVR2DFLIPCHAINHANDLE hFlipChain, - unsigned long ulPropertyMask, - long lDstXPos, - long lDstYPos, - unsigned long ulNumClipRects, - PVR2DRECT *pClipRects, - unsigned long ulSwapInterval); - -PVR2D_IMPORT -PVR2DERROR PVR2DPresentFlip(PVR2DCONTEXTHANDLE hContext, - PVR2DFLIPCHAINHANDLE hFlipChain, - PVR2DMEMINFO *psMemInfo, - long lRenderID); - -PVR2D_IMPORT -PVR2DERROR PVR2DGetAPIRev(long *lRevMajor, long *lRevMinor); - -PVR2D_IMPORT -PVR2DERROR PVR2DLoadUseCode (const PVR2DCONTEXTHANDLE hContext, const unsigned char *pUseCode, - const unsigned long UseCodeSize, PVR2D_HANDLE *pUseCodeHandle); -PVR2D_IMPORT -PVR2DERROR PVR2DFreeUseCode (const PVR2DCONTEXTHANDLE hContext, const PVR2D_HANDLE hUseCodeHandle); - -PVR2D_IMPORT -PVR2DERROR PVR2DBlt3D (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT pBlt3D); - -#ifdef __cplusplus -} -#endif - -#endif /* _PVR2D_H_ */ - -/****************************************************************************** - End of file (pvr2d.h) -******************************************************************************/ +/*!**************************************************************************** +@File pvr2d.h +@Title PVR2D external header file +@Author Imagination Technologies +@Copyright Copyright (c) by Imagination Technologies Limited. + This specification is protected by copyright laws and contains + material proprietary to Imagination Technologies Limited. + You may use and distribute this specification free of charge for implementing + the functionality therein, without altering or removing any trademark, copyright, + or other notice from the specification. +@Platform Generic +@Description PVR2D definitions for PVR2D clients +******************************************************************************/ + + +/****************************************************************************** +Modifications :- +$Log: pvr2d.h $ +******************************************************************************/ + +#ifndef _PVR2D_H_ +#define _PVR2D_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* PVR2D Platform-specific definitions */ +#define PVR2D_EXPORT +#define PVR2D_IMPORT + + +#define PVR2D_REV_MAJOR 2 +#define PVR2D_REV_MINOR 1 + +typedef enum +{ + PVR2D_FALSE = 0, + PVR2D_TRUE +} PVR2D_BOOL; + + +/* error codes */ +typedef enum +{ + PVR2D_OK = 0, + PVR2DERROR_INVALID_PARAMETER = -1, + PVR2DERROR_DEVICE_UNAVAILABLE = -2, + PVR2DERROR_INVALID_CONTEXT = -3, + PVR2DERROR_MEMORY_UNAVAILABLE = -4, + PVR2DERROR_DEVICE_NOT_PRESENT = -5, + PVR2DERROR_IOCTL_ERROR = -6, + PVR2DERROR_GENERIC_ERROR = -7, + PVR2DERROR_BLT_NOTCOMPLETE = -8, + PVR2DERROR_HW_FEATURE_NOT_SUPPORTED = -9, + PVR2DERROR_NOT_YET_IMPLEMENTED = -10, + PVR2DERROR_MAPPING_FAILED = -11 +}PVR2DERROR; + + +/* pixel formats */ +typedef enum +{ + PVR2D_1BPP = 0, + PVR2D_RGB565, + PVR2D_ARGB4444, + PVR2D_RGB888, + PVR2D_ARGB8888, + PVR2D_ARGB1555, + PVR2D_ALPHA8, + PVR2D_ALPHA4, + PVR2D_PAL2, + PVR2D_PAL4, + PVR2D_PAL8, + PVR2D_VGAEMU + +}PVR2DFORMAT; + + +/* wrap surface type */ +typedef enum +{ + PVR2D_WRAPFLAG_NONCONTIGUOUS = 0, + PVR2D_WRAPFLAG_CONTIGUOUS = 1, + +}PVR2DWRAPFLAGS; + +/* flags for control information of additional blits */ +typedef enum +{ + PVR2D_BLIT_DISABLE_ALL = 0x0000, /* disable all additional controls */ + PVR2D_BLIT_CK_ENABLE = 0x0001, /* enable colour key */ + PVR2D_BLIT_GLOBAL_ALPHA_ENABLE = 0x0002, /* enable standard global alpha */ + PVR2D_BLIT_PERPIXEL_ALPHABLEND_ENABLE = 0x0004, /* enable per-pixel alpha bleding */ + PVR2D_BLIT_PAT_SURFACE_ENABLE = 0x0008, /* enable pattern surf (disable fill) */ + PVR2D_BLIT_FULLY_SPECIFIED_ALPHA_ENABLE = 0x0010, /* enable fully specified alpha */ + PVR2D_BLIT_ROT_90 = 0x0020, /* apply 90 degree rotation to the blt */ + PVR2D_BLIT_ROT_180 = 0x0040, /* apply 180 degree rotation to the blt */ + PVR2D_BLIT_ROT_270 = 0x0080, /* apply 270 degree rotation to the blt */ + PVR2D_BLIT_COPYORDER_TL2BR = 0x0100, /* copy order overrides */ + PVR2D_BLIT_COPYORDER_BR2TL = 0x0200, + PVR2D_BLIT_COPYORDER_TR2BL = 0x0400, + PVR2D_BLIT_COPYORDER_BL2TR = 0x0800, + PVR2D_BLIT_COLKEY_SOURCE = 0x1000, /* Key colour is on the source surface */ + PVR2D_BLIT_COLKEY_DEST = 0x2000 /* Key colour is on the destination surface */ + +} PVR2DBLITFLAGS; + +/* standard alpha-blending functions, AlphaBlendingFunc field of PVR2DBLTINFO */ +typedef enum +{ + PVR2D_ALPHA_OP_SRC_DSTINV = 1, /* source alpha : Cdst = Csrc*Asrc + Cdst*(1-Asrc) */ + PVR2D_ALPHA_OP_SRCP_DSTINV = 2 /* premultiplied source alpha : Cdst = Csrc + Cdst*(1-Asrc) */ +} PVR2D_ALPHABLENDFUNC; + +/* blend ops for fully specified alpha */ +typedef enum +{ + PVR2D_BLEND_OP_ZERO = 0, + PVR2D_BLEND_OP_ONE = 1, + PVR2D_BLEND_OP_SRC = 2, + PVR2D_BLEND_OP_DST = 3, + PVR2D_BLEND_OP_GLOBAL = 4, + PVR2D_BLEND_OP_SRC_PLUS_GLOBAL = 5, + PVR2D_BLEND_OP_DST_PLUS_GLOBAL = 6 +}PVR2D_BLEND_OP; + + +typedef void* PVR2D_HANDLE; + + +/* Fully specified alpha blend : pAlpha field of PVR2DBLTINFO structure */ +/* a fully specified Alpha Blend operation is defined as */ +/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (ALPHA_3 * DST (ALPHA)) */ +/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (ALPHA_4 * DST (RGB)) */ +/* if the pre-multiplication stage is enabled then the equations become the following: */ +/* PRE_MUL = ((SRC(A)) * (Global Alpha Value)) */ +/* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (PRE_MUL * DST (ALPHA)) */ +/* DST (RGB) = (ALPHA_2 * SRC (RGB)) + (PRE_MUL * DST (RGB)) */ +/* if the transparent source alpha stage is enabled then a source alpha of zero forces the */ +/* source to be transparent for that pixel regardless of the blend equation being used. */ +typedef struct _PVR2D_ALPHABLT +{ + PVR2D_BLEND_OP eAlpha1; + PVR2D_BOOL bAlpha1Invert; + PVR2D_BLEND_OP eAlpha2; + PVR2D_BOOL bAlpha2Invert; + PVR2D_BLEND_OP eAlpha3; + PVR2D_BOOL bAlpha3Invert; + PVR2D_BLEND_OP eAlpha4; + PVR2D_BOOL bAlpha4Invert; + PVR2D_BOOL bPremulAlpha; /* enable pre-multiplication stage */ + PVR2D_BOOL bTransAlpha; /* enable transparent source alpha stage */ + PVR2D_BOOL bUpdateAlphaLookup; /* enable and update the 1555-Lookup alpha table */ + unsigned char uAlphaLookup0; /* 8 bit alpha when A=0 in a 1555-Lookup surface */ + unsigned char uAlphaLookup1; /* 8 bit alpha when A=1 in a 1555-Lookup surface */ + unsigned char uGlobalRGB; /* Global Alpha Value for RGB, 0=transparent 255=opaque */ + unsigned char uGlobalA; /* Global Alpha Value for Alpha */ + +} PVR2D_ALPHABLT, *PPVR2D_ALPHABLT; + + +/* surface memory info structure */ +typedef struct _PVR2DMEMINFO +{ + void *pBase; + unsigned long ui32MemSize; + unsigned long ui32DevAddr; + unsigned long ulFlags; + void *hPrivateData; + void *hPrivateMapData; + +}PVR2DMEMINFO, *PPVR2DMEMINFO; + + +#define PVR2D_MAX_DEVICE_NAME 20 + +typedef struct _PVR2DDEVICEINFO +{ + unsigned long ulDevID; + char szDeviceName[PVR2D_MAX_DEVICE_NAME]; +}PVR2DDEVICEINFO; + + +typedef struct _PVR2DISPLAYINFO +{ + unsigned long ulMaxFlipChains; + unsigned long ulMaxBuffersInChain; + PVR2DFORMAT eFormat; + unsigned long ulWidth; + unsigned long ulHeight; + long lStride; + unsigned long ulMinFlipInterval; + unsigned long ulMaxFlipInterval; + +}PVR2DDISPLAYINFO; + + +typedef struct _PVR2DBLTINFO +{ + unsigned long CopyCode; /* rop code */ + unsigned long Colour; /* fill colour */ + unsigned long ColourKey; /* colour key */ + unsigned char GlobalAlphaValue; /* global alpha blending */ + unsigned char AlphaBlendingFunc; /* per-pixel alpha-blending function */ + + PVR2DBLITFLAGS BlitFlags; /* additional blit control information */ + + PVR2DMEMINFO *pDstMemInfo; /* destination memory */ + unsigned long DstOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */ + long DstStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ + long DstX, DstY; /* pixel offset from start of dest surface to start of blt rectangle */ + long DSizeX,DSizeY; /* blt size */ + PVR2DFORMAT DstFormat; /* dest format */ + unsigned long DstSurfWidth; /* size of dest surface in pixels */ + unsigned long DstSurfHeight; /* size of dest surface in pixels */ + + PVR2DMEMINFO *pSrcMemInfo; /* source mem, (source fields are also used for patterns) */ + unsigned long SrcOffset; /* byte offset from start of allocation to src/pat surface pixel 0,0 */ + long SrcStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ + long SrcX, SrcY; /* pixel offset from start of surface to start of source rectangle */ + /* for patterns this is the start offset within the pattern */ + long SizeX,SizeY; /* source rectangle size or pattern size in pixels */ + PVR2DFORMAT SrcFormat; /* source/pattern format */ + PVR2DMEMINFO *pPalMemInfo; /* source/pattern palette memory containing argb8888 colour table */ + unsigned long PalOffset; /* byte offset from start of allocation to start of palette */ + unsigned long SrcSurfWidth; /* size of source surface in pixels */ + unsigned long SrcSurfHeight; /* size of source surface in pixels */ + + PVR2DMEMINFO *pMaskMemInfo; /* mask memory, 1bpp format implied */ + unsigned long MaskOffset; /* byte offset from start of allocation to mask surface pixel 0,0 */ + long MaskStride; /* signed stride, the number of bytes from pixel 0,0 to 0,1 */ + long MaskX, MaskY; /* mask rect top left (mask size = blt size) */ + unsigned long MaskSurfWidth; /* size of mask surface in pixels */ + unsigned long MaskSurfHeight; /* size of mask surface in pixels */ + + PPVR2D_ALPHABLT pAlpha; /* fully specified alpha blend */ + +}PVR2DBLTINFO, *PPVR2DBLTINFO; + +typedef struct _PVR2DRECT +{ + long left, top; + long right, bottom; +} PVR2DRECT; + +typedef struct +{ + PVR2DMEMINFO *pSurfMemInfo; /* surface memory */ + unsigned long SurfOffset; /* byte offset from start of allocation to destination surface pixel 0,0 */ + long Stride; /* signed stride */ + PVR2DFORMAT Format; + unsigned long SurfWidth; /* surface size in pixels */ + unsigned long SurfHeight; + +} PVR2D_SURFACE, *PPVR2D_SURFACE; + +typedef struct +{ + unsigned long *pUseCode; /* USSE code */ + unsigned long UseCodeSize; /* usse code size in bytes */ + +} PVR2D_USECODE, *PPVR2D_USECODE; + +typedef struct +{ + PVR2D_SURFACE sDst; /* destination surface */ + PVR2D_SURFACE sSrc; /* source surface */ + PVR2DRECT rcDest; /* destination rectangle */ + PVR2DRECT rcSource; /* source rectangle */ + PVR2D_HANDLE hUseCode; /* custom USE code (NULL implies source copy) */ + unsigned long UseParams[2]; /* per-blt params for use code */ + +} PVR2D_3DBLT, *PPVR2D_3DBLT; + + +#define MAKE_COPY_BLIT(src,soff,dest,doff,sx,sy,dx,dy,sz) + +typedef void* PVR2DCONTEXTHANDLE; +typedef void* PVR2DFLIPCHAINHANDLE; + + +// CopyCode field of PVR2DBLTINFO structure: +// the CopyCode field of the PVR2DBLTINFO structure should contain a rop3 or rop4 code. +// a rop3 is an 8 bit code that describes a blt with three inputs : source dest and pattern +// rop4 is a 16 bit code that describes a blt with four inputs : source dest pattern and mask +// common rop3 codes are defined below +// a colour fill blt is processed in the pattern channel as a constant colour with a rop code of 0xF0 +// PVR2D_BLIT_PAT_SURFACE_ENABLE defines whether the pattern channel is a surface or a fill colour. +// a rop4 is defined by two rop3 codes, and the 1 bit-per-pixel mask surface defines which is used. +// a common rop4 is 0xAAF0 which is the mask copy blt used for text glyphs. +// CopyCode is taken to be a rop4 when pMaskMemInfo is non zero, otherwise it is assumed to be a rop3 +// use the PVR2DMASKROP4 macro below to construct a rop4 from two rop3's +// rop3a is the rop used when mask pixel = 1, and rop3b when mask = 0 +#define PVR2DROP4(rop3b, rop3a) ((rop3b<<8)|rop3a) + +/* common rop codes */ +#define PVR2DROPclear 0x00 /* 0 (whiteness) */ +#define PVR2DROPset 0xFF /* 1 (blackness) */ +#define PVR2DROPnoop 0xAA /* dst (used for masked blts) */ + +/* source and dest rop codes */ +#define PVR2DROPand 0x88 /* src AND dst */ +#define PVR2DROPandReverse 0x44 /* src AND NOT dst */ +#define PVR2DROPcopy 0xCC /* src (used for source copy and alpha blts) */ +#define PVR2DROPandInverted 0x22 /* NOT src AND dst */ +#define PVR2DROPxor 0x66 /* src XOR dst */ +#define PVR2DROPor 0xEE /* src OR dst */ +#define PVR2DROPnor 0x11 /* NOT src AND NOT dst */ +#define PVR2DROPequiv 0x99 /* NOT src XOR dst */ +#define PVR2DROPinvert 0x55 /* NOT dst */ +#define PVR2DROPorReverse 0xDD /* src OR NOT dst */ +#define PVR2DROPcopyInverted 0x33 /* NOT src */ +#define PVR2DROPorInverted 0xBB /* NOT src OR dst */ +#define PVR2DROPnand 0x77 /* NOT src OR NOT dst */ + +/* pattern rop codes */ +#define PVR2DPATROPand 0xA0 /* pat AND dst */ +#define PVR2DPATROPandReverse 0x50 /* pat AND NOT dst */ +#define PVR2DPATROPcopy 0xF0 /* pat (used for solid color fills and pattern blts) */ +#define PVR2DPATROPandInverted 0x0A /* NOT pat AND dst */ +#define PVR2DPATROPxor 0x5A /* pat XOR dst */ +#define PVR2DPATROPor 0xFA /* pat OR dst */ +#define PVR2DPATROPnor 0x05 /* NOT pat AND NOT dst */ +#define PVR2DPATROPequiv 0xA5 /* NOT pat XOR dst */ +#define PVR2DPATROPinvert 0x55 /* NOT dst */ +#define PVR2DPATROPorReverse 0xF5 /* pat OR NOT dst */ +#define PVR2DPATROPcopyInverted 0x0F /* NOT pat */ +#define PVR2DPATROPorInverted 0xAF /* NOT pat OR dst */ +#define PVR2DPATROPnand 0x5F /* NOT pat OR NOT dst */ + +/* common rop4 codes */ +#define PVR2DROP4MaskedCopy PVR2DROP4(PVR2DROPnoop,PVR2DROPcopy) /* masked source copy blt (used for rounded window corners etc) */ +#define PVR2DROP4MaskedFill PVR2DROP4(PVR2DROPnoop,PVR2DPATROPcopy) /* masked colour fill blt (used for text) */ + +/* Legacy support */ +#define PVR2DROP3_PATMASK PVR2DPATROPcopy +#define PVR2DROP3_SRCMASK PVR2DROPcopy + +/* pixmap memory alignment */ +#define PVR2D_ALIGNMENT_4 4 /* DWORD alignment */ +#define PVR2D_ALIGNMENT_ANY 0 /* no alignment */ +#define PVR2D_ALIGNMENT_PALETTE 16 /* 16 byte alignment is required for palettes */ + +/* Heap number for PVR2DGetFrameBuffer */ +#define PVR2D_FB_PRIMARY_SURFACE 0 + +#define PVR2D_PRESENT_PROPERTY_SRCSTRIDE (1 << 0) +#define PVR2D_PRESENT_PROPERTY_DSTSIZE (1 << 1) +#define PVR2D_PRESENT_PROPERTY_DSTPOS (1 << 2) +#define PVR2D_PRESENT_PROPERTY_CLIPRECTS (1 << 3) +#define PVR2D_PRESENT_PROPERTY_INTERVAL (1 << 4) + + +#define PVR2D_CREATE_FLIPCHAIN_SHARED (1 << 0) +#define PVR2D_CREATE_FLIPCHAIN_QUERY (1 << 1) + +/* Functions that the library exports */ + +PVR2D_IMPORT +int PVR2DEnumerateDevices(PVR2DDEVICEINFO *pDevInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DCreateDeviceContext(unsigned long ulDevID, + PVR2DCONTEXTHANDLE* phContext, + unsigned long ulFlags); + +PVR2D_IMPORT +PVR2DERROR PVR2DDestroyDeviceContext(PVR2DCONTEXTHANDLE hContext); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetDeviceInfo(PVR2DCONTEXTHANDLE hContext, + PVR2DDISPLAYINFO *pDisplayInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetScreenMode(PVR2DCONTEXTHANDLE hContext, + PVR2DFORMAT *pFormat, + long *plWidth, + long *plHeight, + long *plStride, + int *piRefreshRate); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetFrameBuffer(PVR2DCONTEXTHANDLE hContext, + int nHeap, + PVR2DMEMINFO **ppsMemInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DMemAlloc(PVR2DCONTEXTHANDLE hContext, + unsigned long ulBytes, + unsigned long ulAlign, + unsigned long ulFlags, + PVR2DMEMINFO **ppsMemInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DMemWrap(PVR2DCONTEXTHANDLE hContext, + void *pMem, + unsigned long ulFlags, + unsigned long ulBytes, + unsigned long alPageAddress[], + PVR2DMEMINFO **ppsMemInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DMemMap(PVR2DCONTEXTHANDLE hContext, + unsigned long ulFlags, + void *hPrivateMapData, + PVR2DMEMINFO **ppsDstMem); + +PVR2D_IMPORT +PVR2DERROR PVR2DMemFree(PVR2DCONTEXTHANDLE hContext, + PVR2DMEMINFO *psMemInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DBlt(PVR2DCONTEXTHANDLE hContext, + PVR2DBLTINFO *pBltInfo); + +PVR2D_IMPORT +PVR2DERROR PVR2DBltClipped(PVR2DCONTEXTHANDLE hContext, + PVR2DBLTINFO *pBltInfo, + unsigned long ulNumClipRects, + PVR2DRECT *pClipRects); + +PVR2D_IMPORT +PVR2DERROR PVR2DQueryBlitsComplete(PVR2DCONTEXTHANDLE hContext, + PVR2DMEMINFO *pMemInfo, + unsigned int uiWaitForComplete); + +PVR2D_IMPORT +PVR2DERROR PVR2DSetPresentBltProperties(PVR2DCONTEXTHANDLE hContext, + unsigned long ulPropertyMask, + long lSrcStride, + unsigned long ulDstWidth, + unsigned long ulDstHeight, + long lDstXPos, + long lDstYPos, + unsigned long ulNumClipRects, + PVR2DRECT *pClipRects, + unsigned long ulSwapInterval); + +PVR2D_IMPORT +PVR2DERROR PVR2DPresentBlt(PVR2DCONTEXTHANDLE hContext, + PVR2DMEMINFO *pMemInfo, + long lRenderID); + +PVR2D_IMPORT +PVR2DERROR PVR2DCreateFlipChain(PVR2DCONTEXTHANDLE hContext, + unsigned long ulFlags, + unsigned long ulNumBuffers, + unsigned long ulWidth, + unsigned long ulHeight, + PVR2DFORMAT eFormat, + long *plStride, + unsigned long *pulFlipChainID, + PVR2DFLIPCHAINHANDLE *phFlipChain); + +PVR2D_IMPORT +PVR2DERROR PVR2DDestroyFlipChain(PVR2DCONTEXTHANDLE hContext, + PVR2DFLIPCHAINHANDLE hFlipChain); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetFlipChainBuffers(PVR2DCONTEXTHANDLE hContext, + PVR2DFLIPCHAINHANDLE hFlipChain, + unsigned long *pulNumBuffers, + PVR2DMEMINFO *psMemInfo[]); + +PVR2D_IMPORT +PVR2DERROR PVR2DSetPresentFlipProperties(PVR2DCONTEXTHANDLE hContext, + PVR2DFLIPCHAINHANDLE hFlipChain, + unsigned long ulPropertyMask, + long lDstXPos, + long lDstYPos, + unsigned long ulNumClipRects, + PVR2DRECT *pClipRects, + unsigned long ulSwapInterval); + +PVR2D_IMPORT +PVR2DERROR PVR2DPresentFlip(PVR2DCONTEXTHANDLE hContext, + PVR2DFLIPCHAINHANDLE hFlipChain, + PVR2DMEMINFO *psMemInfo, + long lRenderID); + +PVR2D_IMPORT +PVR2DERROR PVR2DGetAPIRev(long *lRevMajor, long *lRevMinor); + +PVR2D_IMPORT +PVR2DERROR PVR2DLoadUseCode (const PVR2DCONTEXTHANDLE hContext, const unsigned char *pUseCode, + const unsigned long UseCodeSize, PVR2D_HANDLE *pUseCodeHandle); +PVR2D_IMPORT +PVR2DERROR PVR2DFreeUseCode (const PVR2DCONTEXTHANDLE hContext, const PVR2D_HANDLE hUseCodeHandle); + +PVR2D_IMPORT +PVR2DERROR PVR2DBlt3D (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT pBlt3D); + +#ifdef __cplusplus +} +#endif + +#endif /* _PVR2D_H_ */ + +/****************************************************************************** + End of file (pvr2d.h) +******************************************************************************/ diff --git a/src/3rdparty/powervr/wsegl.h b/src/3rdparty/powervr/wsegl.h index e82c968..0490607 100644 --- a/src/3rdparty/powervr/wsegl.h +++ b/src/3rdparty/powervr/wsegl.h @@ -1,240 +1,240 @@ -/****************************************************************************** - Name : wsegl.h - Copyright : Copyright (c) Imagination Technologies Limited. - This specification is protected by copyright laws and contains - material proprietary to Imagination Technologies Limited. - You may use and distribute this specification free of charge for implementing - the functionality therein, without altering or removing any trademark, copyright, - or other notice from the specification. - Platform : ANSI -*****************************************************************************/ - - -#if !defined(__WSEGL_H__) -#define __WSEGL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -// WSEGL Platform-specific definitions -*/ -#define WSEGL_EXPORT -#define WSEGL_IMPORT - -/* -// WSEGL API Version Number -*/ - -#define WSEGL_VERSION 1 -#define WSEGL_DEFAULT_DISPLAY 0 -#define WSEGL_DEFAULT_NATIVE_ENGINE 0 - -#define WSEGL_FALSE 0 -#define WSEGL_TRUE 1 -#define WSEGL_NULL 0 - -#define WSEGL_UNREFERENCED_PARAMETER(param) (param) = (param) - -/* -// WSEGL handles -*/ -typedef void *WSEGLDisplayHandle; -typedef void *WSEGLDrawableHandle; - -/* -// Display capability type -*/ -typedef enum WSEGLCapsType_TAG -{ - WSEGL_NO_CAPS = 0, - WSEGL_CAP_MIN_SWAP_INTERVAL = 1, /* System default value = 1 */ - WSEGL_CAP_MAX_SWAP_INTERVAL = 2, /* System default value = 1 */ - WSEGL_CAP_WINDOWS_USE_HW_SYNC = 3, /* System default value = 0 (FALSE) */ - WSEGL_CAP_PIXMAPS_USE_HW_SYNC = 4, /* System default value = 0 (FALSE) */ - -} WSEGLCapsType; - -/* -// Display capability -*/ -typedef struct WSEGLCaps_TAG -{ - WSEGLCapsType eCapsType; - unsigned long ui32CapsValue; - -} WSEGLCaps; - -/* -// Drawable type -*/ -#define WSEGL_NO_DRAWABLE 0x0 -#define WSEGL_DRAWABLE_WINDOW 0x1 -#define WSEGL_DRAWABLE_PIXMAP 0x2 - - -/* -// Pixel format of display/drawable -*/ -typedef enum WSEGLPixelFormat_TAG -{ - WSEGL_PIXELFORMAT_565 = 0, - WSEGL_PIXELFORMAT_4444 = 1, - WSEGL_PIXELFORMAT_8888 = 2, - WSEGL_PIXELFORMAT_1555 = 3 - -} WSEGLPixelFormat; - -/* -// Transparent of display/drawable -*/ -typedef enum WSEGLTransparentType_TAG -{ - WSEGL_OPAQUE = 0, - WSEGL_COLOR_KEY = 1, - -} WSEGLTransparentType; - -/* -// Display/drawable configuration -*/ -typedef struct WSEGLConfig_TAG -{ - /* - // Type of drawables this configuration applies to - - // OR'd values of drawable types. - */ - unsigned long ui32DrawableType; - - /* Pixel format */ - WSEGLPixelFormat ePixelFormat; - - /* Native Renderable - set to WSEGL_TRUE if native renderable */ - unsigned long ulNativeRenderable; - - /* FrameBuffer Level Parameter */ - unsigned long ulFrameBufferLevel; - - /* Native Visual ID */ - unsigned long ulNativeVisualID; - - /* Native Visual */ - void *hNativeVisual; - - /* Transparent Type */ - WSEGLTransparentType eTransparentType; - - /* Transparent Color - only used if transparent type is COLOR_KEY */ - unsigned long ulTransparentColor; /* packed as 0x00RRGGBB */ - - -} WSEGLConfig; - -/* -// WSEGL errors -*/ -typedef enum WSEGLError_TAG -{ - WSEGL_SUCCESS = 0, - WSEGL_CANNOT_INITIALISE = 1, - WSEGL_BAD_NATIVE_DISPLAY = 2, - WSEGL_BAD_NATIVE_WINDOW = 3, - WSEGL_BAD_NATIVE_PIXMAP = 4, - WSEGL_BAD_NATIVE_ENGINE = 5, - WSEGL_BAD_DRAWABLE = 6, - WSEGL_BAD_CONFIG = 7, - WSEGL_OUT_OF_MEMORY = 8 - -} WSEGLError; - -/* -// Drawable orientation (in degrees anti-clockwise) -*/ -typedef enum WSEGLRotationAngle_TAG -{ - WSEGL_ROTATE_0 = 0, - WSEGL_ROTATE_90 = 1, - WSEGL_ROTATE_180 = 2, - WSEGL_ROTATE_270 = 3 - -} WSEGLRotationAngle; - -/* -// Drawable information required by OpenGL-ES driver -*/ -typedef struct WSEGLDrawableParams_TAG -{ - /* Width in pixels of the drawable */ - unsigned long ui32Width; - - /* Height in pixels of the drawable */ - unsigned long ui32Height; - - /* Stride in pixels of the drawable */ - unsigned long ui32Stride; - - /* Pixel format of the drawable */ - WSEGLPixelFormat ePixelFormat; - - /* User space cpu virtual address of the drawable */ - void *pvLinearAddress; - - /* HW address of the drawable */ - unsigned long ui32HWAddress; - - /* Private data for the drawable */ - void *hPrivateData; - -} WSEGLDrawableParams; - - -/* -// Table of function pointers that is returned by WSEGL_GetFunctionTablePointer() -// -// The first entry in the table is the version number of the wsegl.h header file that -// the module has been written against, and should therefore be set to WSEGL_VERSION -*/ -typedef struct WSEGL_FunctionTable_TAG -{ - unsigned long ui32WSEGLVersion; - - WSEGLError (*pfnWSEGL_IsDisplayValid)(NativeDisplayType); - - WSEGLError (*pfnWSEGL_InitialiseDisplay)(NativeDisplayType, WSEGLDisplayHandle *, const WSEGLCaps **, WSEGLConfig **); - - WSEGLError (*pfnWSEGL_CloseDisplay)(WSEGLDisplayHandle); - - WSEGLError (*pfnWSEGL_CreateWindowDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativeWindowType, WSEGLRotationAngle *); - - WSEGLError (*pfnWSEGL_CreatePixmapDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativePixmapType, WSEGLRotationAngle *); - - WSEGLError (*pfnWSEGL_DeleteDrawable)(WSEGLDrawableHandle); - - WSEGLError (*pfnWSEGL_SwapDrawable)(WSEGLDrawableHandle, unsigned long); - - WSEGLError (*pfnWSEGL_SwapControlInterval)(WSEGLDrawableHandle, unsigned long); - - WSEGLError (*pfnWSEGL_WaitNative)(WSEGLDrawableHandle, unsigned long); - - WSEGLError (*pfnWSEGL_CopyFromDrawable)(WSEGLDrawableHandle, NativePixmapType); - - WSEGLError (*pfnWSEGL_CopyFromPBuffer)(void *, unsigned long, unsigned long, unsigned long, WSEGLPixelFormat, NativePixmapType); - - WSEGLError (*pfnWSEGL_GetDrawableParameters)(WSEGLDrawableHandle, WSEGLDrawableParams *, WSEGLDrawableParams *); - - -} WSEGL_FunctionTable; - - -WSEGL_IMPORT const WSEGL_FunctionTable *WSEGL_GetFunctionTablePointer(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __WSEGL_H__ */ - -/****************************************************************************** - End of file (wsegl.h) -******************************************************************************/ +/****************************************************************************** + Name : wsegl.h + Copyright : Copyright (c) Imagination Technologies Limited. + This specification is protected by copyright laws and contains + material proprietary to Imagination Technologies Limited. + You may use and distribute this specification free of charge for implementing + the functionality therein, without altering or removing any trademark, copyright, + or other notice from the specification. + Platform : ANSI +*****************************************************************************/ + + +#if !defined(__WSEGL_H__) +#define __WSEGL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +// WSEGL Platform-specific definitions +*/ +#define WSEGL_EXPORT +#define WSEGL_IMPORT + +/* +// WSEGL API Version Number +*/ + +#define WSEGL_VERSION 1 +#define WSEGL_DEFAULT_DISPLAY 0 +#define WSEGL_DEFAULT_NATIVE_ENGINE 0 + +#define WSEGL_FALSE 0 +#define WSEGL_TRUE 1 +#define WSEGL_NULL 0 + +#define WSEGL_UNREFERENCED_PARAMETER(param) (param) = (param) + +/* +// WSEGL handles +*/ +typedef void *WSEGLDisplayHandle; +typedef void *WSEGLDrawableHandle; + +/* +// Display capability type +*/ +typedef enum WSEGLCapsType_TAG +{ + WSEGL_NO_CAPS = 0, + WSEGL_CAP_MIN_SWAP_INTERVAL = 1, /* System default value = 1 */ + WSEGL_CAP_MAX_SWAP_INTERVAL = 2, /* System default value = 1 */ + WSEGL_CAP_WINDOWS_USE_HW_SYNC = 3, /* System default value = 0 (FALSE) */ + WSEGL_CAP_PIXMAPS_USE_HW_SYNC = 4, /* System default value = 0 (FALSE) */ + +} WSEGLCapsType; + +/* +// Display capability +*/ +typedef struct WSEGLCaps_TAG +{ + WSEGLCapsType eCapsType; + unsigned long ui32CapsValue; + +} WSEGLCaps; + +/* +// Drawable type +*/ +#define WSEGL_NO_DRAWABLE 0x0 +#define WSEGL_DRAWABLE_WINDOW 0x1 +#define WSEGL_DRAWABLE_PIXMAP 0x2 + + +/* +// Pixel format of display/drawable +*/ +typedef enum WSEGLPixelFormat_TAG +{ + WSEGL_PIXELFORMAT_565 = 0, + WSEGL_PIXELFORMAT_4444 = 1, + WSEGL_PIXELFORMAT_8888 = 2, + WSEGL_PIXELFORMAT_1555 = 3 + +} WSEGLPixelFormat; + +/* +// Transparent of display/drawable +*/ +typedef enum WSEGLTransparentType_TAG +{ + WSEGL_OPAQUE = 0, + WSEGL_COLOR_KEY = 1, + +} WSEGLTransparentType; + +/* +// Display/drawable configuration +*/ +typedef struct WSEGLConfig_TAG +{ + /* + // Type of drawables this configuration applies to - + // OR'd values of drawable types. + */ + unsigned long ui32DrawableType; + + /* Pixel format */ + WSEGLPixelFormat ePixelFormat; + + /* Native Renderable - set to WSEGL_TRUE if native renderable */ + unsigned long ulNativeRenderable; + + /* FrameBuffer Level Parameter */ + unsigned long ulFrameBufferLevel; + + /* Native Visual ID */ + unsigned long ulNativeVisualID; + + /* Native Visual */ + void *hNativeVisual; + + /* Transparent Type */ + WSEGLTransparentType eTransparentType; + + /* Transparent Color - only used if transparent type is COLOR_KEY */ + unsigned long ulTransparentColor; /* packed as 0x00RRGGBB */ + + +} WSEGLConfig; + +/* +// WSEGL errors +*/ +typedef enum WSEGLError_TAG +{ + WSEGL_SUCCESS = 0, + WSEGL_CANNOT_INITIALISE = 1, + WSEGL_BAD_NATIVE_DISPLAY = 2, + WSEGL_BAD_NATIVE_WINDOW = 3, + WSEGL_BAD_NATIVE_PIXMAP = 4, + WSEGL_BAD_NATIVE_ENGINE = 5, + WSEGL_BAD_DRAWABLE = 6, + WSEGL_BAD_CONFIG = 7, + WSEGL_OUT_OF_MEMORY = 8 + +} WSEGLError; + +/* +// Drawable orientation (in degrees anti-clockwise) +*/ +typedef enum WSEGLRotationAngle_TAG +{ + WSEGL_ROTATE_0 = 0, + WSEGL_ROTATE_90 = 1, + WSEGL_ROTATE_180 = 2, + WSEGL_ROTATE_270 = 3 + +} WSEGLRotationAngle; + +/* +// Drawable information required by OpenGL-ES driver +*/ +typedef struct WSEGLDrawableParams_TAG +{ + /* Width in pixels of the drawable */ + unsigned long ui32Width; + + /* Height in pixels of the drawable */ + unsigned long ui32Height; + + /* Stride in pixels of the drawable */ + unsigned long ui32Stride; + + /* Pixel format of the drawable */ + WSEGLPixelFormat ePixelFormat; + + /* User space cpu virtual address of the drawable */ + void *pvLinearAddress; + + /* HW address of the drawable */ + unsigned long ui32HWAddress; + + /* Private data for the drawable */ + void *hPrivateData; + +} WSEGLDrawableParams; + + +/* +// Table of function pointers that is returned by WSEGL_GetFunctionTablePointer() +// +// The first entry in the table is the version number of the wsegl.h header file that +// the module has been written against, and should therefore be set to WSEGL_VERSION +*/ +typedef struct WSEGL_FunctionTable_TAG +{ + unsigned long ui32WSEGLVersion; + + WSEGLError (*pfnWSEGL_IsDisplayValid)(NativeDisplayType); + + WSEGLError (*pfnWSEGL_InitialiseDisplay)(NativeDisplayType, WSEGLDisplayHandle *, const WSEGLCaps **, WSEGLConfig **); + + WSEGLError (*pfnWSEGL_CloseDisplay)(WSEGLDisplayHandle); + + WSEGLError (*pfnWSEGL_CreateWindowDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativeWindowType, WSEGLRotationAngle *); + + WSEGLError (*pfnWSEGL_CreatePixmapDrawable)(WSEGLDisplayHandle, WSEGLConfig *, WSEGLDrawableHandle *, NativePixmapType, WSEGLRotationAngle *); + + WSEGLError (*pfnWSEGL_DeleteDrawable)(WSEGLDrawableHandle); + + WSEGLError (*pfnWSEGL_SwapDrawable)(WSEGLDrawableHandle, unsigned long); + + WSEGLError (*pfnWSEGL_SwapControlInterval)(WSEGLDrawableHandle, unsigned long); + + WSEGLError (*pfnWSEGL_WaitNative)(WSEGLDrawableHandle, unsigned long); + + WSEGLError (*pfnWSEGL_CopyFromDrawable)(WSEGLDrawableHandle, NativePixmapType); + + WSEGLError (*pfnWSEGL_CopyFromPBuffer)(void *, unsigned long, unsigned long, unsigned long, WSEGLPixelFormat, NativePixmapType); + + WSEGLError (*pfnWSEGL_GetDrawableParameters)(WSEGLDrawableHandle, WSEGLDrawableParams *, WSEGLDrawableParams *); + + +} WSEGL_FunctionTable; + + +WSEGL_IMPORT const WSEGL_FunctionTable *WSEGL_GetFunctionTablePointer(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __WSEGL_H__ */ + +/****************************************************************************** + End of file (wsegl.h) +******************************************************************************/ -- cgit v0.12 From 083f41c81d735afa30cb6aa355862c3d2e67f55d Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 5 May 2009 10:16:25 -0700 Subject: DirectFB can't handle "mirrored" scales Fall back to raster engine when using a transform with m11 < 0 || m22 < 0. Task-number: 252921 Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 92f717e..c77632c 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -80,7 +80,7 @@ template inline const T *ptr(const T &t) { return &t; } template <> inline const bool* ptr(const bool &) { return 0; } template static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, - bool matrixScale, bool matrixRotShear, bool simplePen, + QDirectFBPaintEnginePrivate::Scale scale, bool matrixRotShear, bool simplePen, bool dfbHandledClip, bool forceRasterPrimitives, const char *nameOne, const T1 &one, const char *nameTwo, const T2 &two, @@ -95,7 +95,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * dbg << dev << "of type" << dev->devType(); } - dbg << "matrixScale" << matrixScale + dbg << "scale" << scale << "matrixRotShear" << matrixRotShear << "simplePen" << simplePen << "dfbHandledClip" << dfbHandledClip @@ -123,7 +123,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ rasterFallbackWarn("Disabled raster engine operation", \ __FUNCTION__, state()->painter->device(), \ - d_func()->matrixScale, d_func()->matrixRotShear, \ + d_func()->scale, d_func()->matrixRotShear, \ d_func()->simplePen, d_func()->dfbCanHandleClip(), \ d_func()->forceRasterPrimitives, \ #one, one, #two, two, #three, three); \ @@ -138,7 +138,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ rasterFallbackWarn("Falling back to raster engine for", \ __FUNCTION__, state()->painter->device(), \ - d_func()->matrixScale, d_func()->matrixRotShear, \ + d_func()->scale, d_func()->matrixRotShear, \ d_func()->simplePen, d_func()->dfbCanHandleClip(), \ d_func()->forceRasterPrimitives, \ #one, one, #two, two, #three, three); @@ -277,7 +277,7 @@ public: bool simplePen; bool matrixRotShear; - bool matrixScale; + enum Scale { NoScale, Scaled, NegativeScale } scale; void setTransform(const QTransform &m); void setPen(const QPen &pen); @@ -342,7 +342,7 @@ private: QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), forceRasterPrimitives(false), simplePen(false), - matrixRotShear(false), matrixScale(false), lastLockedHeight(-1), + matrixRotShear(false), scale(NoScale), lastLockedHeight(-1), fbWidth(-1), fbHeight(-1), opacity(255), drawFlagsFromCompositionMode(0), blitFlagsFromCompositionMode(0), porterDuffRule(DSPD_SRC_OVER), dirtyClip(true), dfbHandledClip(false), dfbDevice(0), q(p) @@ -408,7 +408,13 @@ void QDirectFBPaintEnginePrivate::setTransform(const QTransform &m) { transform = m; matrixRotShear = (transform.m12() != 0 || transform.m21() != 0); - matrixScale = (transform.m11() != 1 || transform.m22() != 1); + if (qMin(transform.m11(), transform.m22()) < 0) { + scale = NegativeScale; + } else if (transform.m11() != 1 || transform.m22() != 1) { + scale = Scaled; + } else { + scale = NoScale; + } } void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) @@ -458,7 +464,7 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &p) (pen.style() == Qt::SolidLine && !antialiased && (pen.brush().style() == Qt::SolidPattern) - && (pen.widthF() <= 1 && !matrixScale)); + && (pen.widthF() <= 1 && scale != NoScale)); } void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode) @@ -668,9 +674,9 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QRect dr = transform.mapRect(dest).toRect(); DFBResult result = DFB_OK; - if (!matrixScale && dr == QRect(0, 0, fbWidth, fbHeight)) { + if (scale == NoScale && dr == QRect(0, 0, fbWidth, fbHeight)) { result = surface->TileBlit(surface, s, 0, 0, 0); - } else if (!matrixScale) { + } else if (scale == NoScale) { const int dx = pixmap.width(); const int dy = pixmap.height(); const DFBRectangle rect = { 0, 0, dx, dy }; @@ -868,9 +874,9 @@ void QDirectFBPaintEngine::renderHintsChanged() void QDirectFBPaintEngine::transformChanged() { Q_D(QDirectFBPaintEngine); - const bool old = d->matrixScale; + const QDirectFBPaintEnginePrivate::Scale old = d->scale; d->setTransform(state()->transform()); - if (d->matrixScale != old) { + if (d->scale != old) { d->setPen(state()->pen); } QRasterPaintEngine::transformChanged(); @@ -1008,6 +1014,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, #ifndef QT_NO_DIRECTFB_PREALLOCATED d->updateClip(); if (!d->dfbCanHandleClip(r) || d->matrixRotShear + || d->scale == QDirectFBPaintEnginePrivate::NegativeScale || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN) #endif { @@ -1038,7 +1045,8 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); - } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear) { + } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear + || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); d->lock(); @@ -1064,7 +1072,8 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp); - } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()) { + } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull() + || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); d->lock(); -- cgit v0.12 From 183602a565147299a309fc4df3165b702f0d78f4 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 5 May 2009 11:25:28 -0700 Subject: Don't call prepare more than necessary Store the memory address of our last QRasterBuffer::prepare() call to make sure we reprepare if someone has unlocked and locked the device behind our back. Also optimize QDirectFBDevice::memory() since it might get called a fair bit. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 36 ++++++++++++---------- .../gfxdrivers/directfb/qdirectfbpaintdevice.h | 7 +++-- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 16 +++++++--- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 9796280..72e0ce5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -58,18 +58,18 @@ IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const void QDirectFBPaintDevice::lockDirectFB(uint flags) { - if (lockedImage) { - if (lockFlags & flags) - return; - unlockDirectFB(); - } - if (uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl)) { - const QSize s = size(); - lockedImage = new QImage(mem, s.width(), s.height(), bpl, - QDirectFBScreen::getImageFormat(dfbSurface)); - lockFlags = flags; - } else { - lockFlags = 0; + if (!(lock & flags)) { + if (lock) + unlockDirectFB(); + if ((mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl))) { + const QSize s = size(); + lockedImage = new QImage(mem, s.width(), s.height(), bpl, + QDirectFBScreen::getImageFormat(dfbSurface)); + lock = flags; + Q_ASSERT(mem); + } else { + lock = 0; + } } } @@ -82,15 +82,19 @@ void QDirectFBPaintDevice::unlockDirectFB() dfbSurface->Unlock(dfbSurface); delete lockedImage; lockedImage = 0; + mem = 0; + lock = 0; } void *QDirectFBPaintDevice::memory() const { - QDirectFBPaintDevice* that = const_cast(this); - that->lockDirectFB(DSLF_READ|DSLF_WRITE); - Q_ASSERT(that->lockedImage); - return that->lockedImage->bits(); + if (lock != (DSLF_READ|DSLF_WRITE)) { + QDirectFBPaintDevice *that = const_cast(this); + that->lockDirectFB(DSLF_READ|DSLF_WRITE); + Q_ASSERT(that->lockedImage); + } + return mem; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 1709d69..13f0a8f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -69,6 +69,7 @@ public: int bytesPerLine() const; QSize size() const; int metric(QPaintDevice::PaintDeviceMetric metric) const; + uint lockFlags() const { return lock; } protected: // Shouldn't create QDirectFBPaintDevice by itself but only sub-class it: QDirectFBPaintDevice(QDirectFBScreen *scr = QDirectFBScreen::instance()) @@ -77,7 +78,8 @@ protected: lockedImage(0), screen(scr), forceRaster(false), - lockFlags(0) + lock(0), + mem(0) {} inline int dotsPerMeterX() const @@ -94,7 +96,8 @@ protected: QDirectFBScreen *screen; int bpl; bool forceRaster; - uint lockFlags; + uint lock; + uchar *mem; private: Q_DISABLE_COPY(QDirectFBPaintDevice) }; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index c77632c..c9752e9 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -336,6 +336,7 @@ private: bool dfbHandledClip; bool ignoreSystemClip; QDirectFBPaintDevice *dfbDevice; + void *lockedMemory; QDirectFBPaintEngine *q; }; @@ -345,7 +346,7 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p matrixRotShear(false), scale(NoScale), lastLockedHeight(-1), fbWidth(-1), fbHeight(-1), opacity(255), drawFlagsFromCompositionMode(0), blitFlagsFromCompositionMode(0), porterDuffRule(DSPD_SRC_OVER), dirtyClip(true), - dfbHandledClip(false), dfbDevice(0), q(p) + dfbHandledClip(false), dfbDevice(0), lockedMemory(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; @@ -392,16 +393,21 @@ void QDirectFBPaintEnginePrivate::lock() // We will potentially get a new pointer to the buffer after a // lock so we need to call the base implementation of prepare so // it updates its rasterBuffer to point to the new buffer address. - lastLockedHeight = dfbDevice->height(); - Q_ASSERT(dfbDevice); - prepare(dfbDevice); + if (dfbDevice->lockFlags() != (DSLF_WRITE|DSLF_READ) + || dfbDevice->height() != lastLockedHeight + || dfbDevice->memory() != lockedMemory) { + prepare(dfbDevice); + lastLockedHeight = dfbDevice->height(); + lockedMemory = dfbDevice->memory(); + } } void QDirectFBPaintEnginePrivate::unlock() { Q_ASSERT(dfbDevice); dfbDevice->unlockDirectFB(); + lockedMemory = 0; } void QDirectFBPaintEnginePrivate::setTransform(const QTransform &m) @@ -436,6 +442,7 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x", device->devType()); } + lockedMemory = 0; forceRasterPrimitives = dfbDevice->forceRasterPrimitives(); surface->GetSize(surface, &fbWidth, &fbHeight); @@ -451,6 +458,7 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) void QDirectFBPaintEnginePrivate::end() { + lockedMemory = 0; dfbDevice = 0; surface->ReleaseSource(surface); surface->SetClip(surface, NULL); -- cgit v0.12 From 0208f6419556af968bb0bbe1d1cdedede1819e67 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 5 May 2009 14:46:31 -0700 Subject: Cleaned up code a little Made SurfaceCache entirely inline for better readability. Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 69 +++++++++------------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index c9752e9..57b2418 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -156,22 +156,42 @@ static inline uint ALPHA_MUL(uint x, uint a) class SurfaceCache { public: - SurfaceCache(); - ~SurfaceCache(); + SurfaceCache() : surface(0), buffer(0), bufsize(0) {} + ~SurfaceCache() { clear(); } - inline IDirectFBSurface *getSurface(const uint *buffer, int size); - inline void clear(); + IDirectFBSurface *getSurface(const uint *buf, int size) + { + if (buffer == buf && bufsize == size) + return surface; + + clear(); + + const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size); + surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface); + if (!surface) + qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface"); + + buffer = const_cast(buf); + bufsize = size; + + return surface; + } + + void clear() + { + if (surface && QDirectFBScreen::instance()) + QDirectFBScreen::instance()->releaseDFBSurface(surface); + surface = 0; + buffer = 0; + bufsize = 0; + } private: IDirectFBSurface *surface; uint *buffer; int bufsize; }; -SurfaceCache::SurfaceCache() - : surface(0), buffer(0), bufsize(0) -{ -} class CachedImage { @@ -228,39 +248,6 @@ CachedImage::~CachedImage() } static QCache imageCache(4*1024*1024); // 4 MB - -IDirectFBSurface* SurfaceCache::getSurface(const uint *buf, int size) -{ - if (buffer == buf && bufsize == size) - return surface; - - clear(); - - const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size); - surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface); - if (!surface) - qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface"); - - buffer = const_cast(buf); - bufsize = size; - - return surface; -} - -void SurfaceCache::clear() -{ - if (surface) - QDirectFBScreen::instance()->releaseDFBSurface(surface); - surface = 0; - buffer = 0; - bufsize = 0; -} - -SurfaceCache::~SurfaceCache() -{ - clear(); -} - class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate { public: -- cgit v0.12 From f06d186c3b9b053132d8107f843317067238083f Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 25 Mar 2009 11:17:57 -0700 Subject: Make sure image caching works with Qt3Support Store whether qt was built with qt3support enabled in .qmake.cache. We need this info to decide if QT3_SUPPORT should be defined when we include qimage_p.h. Otherwise we get data corruption issues since the size of struct in Qt is larger than the one we include in libqdirectfb. Reviewed-by: Donald --- configure | 3 +++ src/plugins/gfxdrivers/directfb/directfb.pro | 1 + 2 files changed, 4 insertions(+) diff --git a/configure b/configure index 24e755e..20bf457 100755 --- a/configure +++ b/configure @@ -5160,6 +5160,9 @@ if [ "$PLATFORM_QWS" = "yes" ]; then QMakeVar set QT_CFLAGS_DIRECTFB "$QT_CFLAGS_DIRECTFB" QMakeVar set QT_LIBS_DIRECTFB "$QT_LIBS_DIRECTFB" fi + if [ "$CFG_QT3SUPPORT" = "yes" ]; then + QMakeVar set QT_DEFINES_DIRECTFB "QT3_SUPPORT" + fi if ! "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qws/directfb "DirectFB" $L_FLAGS $I_FLAGS $l_FLAGS $QT_CFLAGS_DIRECTFB $QT_LIBS_DIRECTFB; then echo "The DirectFB screen driver functionality test failed!" diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index abdb78f..b128514 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -40,4 +40,5 @@ SOURCES = qdirectfbscreen.cpp \ QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB LIBS += $$QT_LIBS_DIRECTFB +DEFINES += $$QT_DEFINES_DIRECTFB -- cgit v0.12 From 8ee920d09ad139aedb14eaacc3f9c198d43e4351 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 5 May 2009 14:37:53 -0700 Subject: Refactored image caching Make image caching a lot cleaner and more sensible. By default we do not cache images since creating a preallocated surface is quick and we don't really want to waste memory. In the case where the driver does not support preallocated surfaces you can enable image caching to speed up drawImage. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/directfb.pro | 2 +- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 245 ++++++++++----------- .../gfxdrivers/directfb/qdirectfbpaintengine.h | 1 + .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 12 +- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 1 + .../gfxdrivers/directfb/qdirectfbscreen.cpp | 13 +- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 14 +- 7 files changed, 147 insertions(+), 141 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index b128514..5c60b2f 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -6,6 +6,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers # These defines might be necessary if your DirectFB driver doesn't # support all of the DirectFB API. # +#DEFINES += QT_DIRECTFB_IMAGECACHE #DEFINES += QT_NO_DIRECTFB_WM #DEFINES += QT_NO_DIRECTFB_LAYER #DEFINES += QT_NO_DIRECTFB_PALETTE @@ -41,4 +42,3 @@ SOURCES = qdirectfbscreen.cpp \ QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB LIBS += $$QT_LIBS_DIRECTFB DEFINES += $$QT_DEFINES_DIRECTFB - diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 57b2418..317f930 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -193,61 +193,21 @@ private: }; -class CachedImage +#ifdef QT_DIRECTFB_IMAGECACHE +#include +struct CachedImage { -public: - CachedImage(const QImage &image); - ~CachedImage(); - - IDirectFBSurface *surface() { return s; } - -private: - IDirectFBSurface *s; -}; - -CachedImage::CachedImage(const QImage &image) - : s(0) -{ - IDirectFBSurface *tmpSurface = 0; - DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(image); - QDirectFBScreen* screen = QDirectFBScreen::instance(); - - tmpSurface = screen->createDFBSurface(description, QDirectFBScreen::TrackSurface); - if (!tmpSurface) { - qWarning("CachedImage CreateSurface failed!"); - return; + IDirectFBSurface *surface; + ~CachedImage() + { + if (surface && QDirectFBScreen::instance()) { + QDirectFBScreen::instance()->releaseDFBSurface(surface); + } } - -#ifndef QT_NO_DIRECTFB_PALETTE - QDirectFBScreen::setSurfaceColorTable(tmpSurface, image); -#endif - - description.flags = DFBSurfaceDescriptionFlags(description.flags & ~DSDESC_PREALLOCATED); - - s = screen->createDFBSurface(description, QDirectFBScreen::TrackSurface); - if (!s) - qWarning("QDirectFBPaintEngine failed caching image"); - -#ifndef QT_NO_DIRECTFB_PALETTE - QDirectFBScreen::setSurfaceColorTable(s, image); +}; +static QCache imageCache(4*1024*1024); // 4 MB #endif - if (s) { - s->SetBlittingFlags(s, DSBLIT_NOFX); - s->Blit(s, tmpSurface, 0, 0, 0); - s->ReleaseSource(s); - } - if (tmpSurface) - screen->releaseDFBSurface(tmpSurface); -} - -CachedImage::~CachedImage() -{ - if (s && QDirectFBScreen::instance()) - QDirectFBScreen::instance()->releaseDFBSurface(s); -} - -static QCache imageCache(4*1024*1024); // 4 MB class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate { public: @@ -291,11 +251,8 @@ public: void fillRects(const QRectF *rects, int count); void drawRects(const QRectF *rects, int count); - - void drawPixmap(const QRectF &dest, - const QPixmap &pixmap, const QRectF &src); void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap); - void drawImage(const QRectF &dest, const QImage &image, const QRectF &src); + void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src); inline void updateClip(); inline void setClipDirty(); @@ -304,6 +261,12 @@ public: void begin(QPaintDevice *device); void end(); + static IDirectFBSurface *getSurface(const QImage &img, bool *release); + +#ifdef QT_DIRECTFB_IMAGECACHE + static inline int cacheCost(const QImage &img) { return img.width() * img.height() * img.depth() / 8; } +#endif + void prepareForBlit(bool alpha); SurfaceCache *surfaceCache; QTransform transform; @@ -338,9 +301,6 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p fb = QDirectFBScreen::instance()->dfb(); ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; surfaceCache = new SurfaceCache; - static int cacheLimit = qgetenv("QT_DIRECTFB_IMAGECACHE").toInt(); - if (cacheLimit > 0) - imageCache.setMaxCost(cacheLimit * 1024); } QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate() @@ -634,15 +594,43 @@ void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) } } -void QDirectFBPaintEnginePrivate::drawPixmap(const QRectF &dest, - const QPixmap &pixmap, - const QRectF &src) +IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release) +{ +#ifndef QT_DIRECTFB_IMAGECACHE + *release = true; + return QDirectFBScreen::instance()->createDFBSurface(img, QDirectFBScreen::DontTrackSurface); +#else + const qint64 key = img.cacheKey(); + *release = false; + if (imageCache.contains(key)) { + return imageCache[key]->surface; + } + + const int cost = cacheCost(img); + const bool cache = cost <= imageCache.maxCost(); + QDirectFBScreen *screen = QDirectFBScreen::instance(); + const QImage::Format format = (img.format() == screen->alphaPixmapFormat() || QDirectFBPixmapData::hasAlphaChannel(img) + ? screen->alphaPixmapFormat() : screen->pixelFormat()); + + IDirectFBSurface *surface = screen->copyToDFBSurface(img, format, + cache + ? QDirectFBScreen::TrackSurface + : QDirectFBScreen::DontTrackSurface); + if (cache) { + CachedImage *cachedImage = new CachedImage; + const_cast(img).data_ptr()->is_cached = true; + cachedImage->surface = surface; + imageCache.insert(key, cachedImage, cost); + } else { + *release = true; + } + return surface; +#endif +} + + +void QDirectFBPaintEnginePrivate::blit(const QRectF &dest, IDirectFBSurface *s, const QRectF &src) { - prepareForBlit(pixmap.hasAlphaChannel()); - QPixmapData *data = pixmap.pixmapData(); - Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); - QDirectFBPixmapData *dfbData = static_cast(data); - IDirectFBSurface *s = dfbData->directFBSurface(); const QRect sr = src.toRect(); const QRect dr = transform.mapRect(dest).toRect(); const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; @@ -709,64 +697,6 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, DirectFBError("QDirectFBPaintEngine::drawTiledPixmap()", result); } -void QDirectFBPaintEnginePrivate::drawImage(const QRectF &dest, - const QImage &image, - const QRectF &src) -{ - Q_ASSERT(QDirectFBScreen::getSurfacePixelFormat(image.format()) != DSPF_UNKNOWN); - CachedImage *img = imageCache[image.cacheKey()]; - IDirectFBSurface *imgSurface = 0; - bool doRelease = false; - - if (img) { - imgSurface = img->surface(); - } else { - const int cost = image.width() * image.height() * image.depth() / 8; - if (cost <= imageCache.maxCost()) { - img = new CachedImage(image); - imgSurface = img->surface(); - if (imgSurface) { - imageCache.insert(image.cacheKey(), img, cost); - } else { - delete img; - img = 0; - } - } - - if (!imgSurface) { - DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(image); - imgSurface = QDirectFBScreen::instance()->createDFBSurface(description, - QDirectFBScreen::DontTrackSurface); - if (!imgSurface) { - qWarning("QDirectFBPaintEnginePrivate::drawImage"); - return; - } - -#ifndef QT_NO_DIRECTFB_PALETTE - QDirectFBScreen::setSurfaceColorTable(surface, image); -#endif - doRelease = (imgSurface != 0); - } - } - - const QRect sr = src.toRect(); - const QRect dr = transform.mapRect(dest).toRect(); - const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; - - prepareForBlit(image.hasAlphaChannel()); - if (dr.size() == sr.size()) { - surface->Blit(surface, imgSurface, &sRect, dr.x(), dr.y()); - } else { - const DFBRectangle dRect = { dr.x(), dr.y(), - dr.width(), dr.height() }; - surface->StretchBlit(surface, imgSurface, &sRect, &dRect); - } - if (doRelease) { - surface->ReleaseSource(surface); - imgSurface->Release(imgSurface); - } -} - void QDirectFBPaintEnginePrivate::updateClip() { if (!dirtyClip) @@ -828,8 +758,6 @@ bool QDirectFBPaintEngine::end() return QRasterPaintEngine::end(); } - - void QDirectFBPaintEngine::clipEnabledChanged() { Q_D(QDirectFBPaintEngine); @@ -1004,13 +932,36 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, Qt::ImageConversionFlags flags) { Q_D(QDirectFBPaintEngine); - Q_UNUSED(flags); // XXX + Q_UNUSED(flags); + + /* This is hard to read. The way it works is like this: + + - If you do not have support for preallocated surfaces and do not use an + image cache we always fall back to raster engine. + + - If it's rotated/sheared/mirrored (negative scale) or we can't + clip it we fall back to raster engine. + + - If we don't cache the image, but we do have support for + preallocated surfaces we fall back to the raster engine if the + image is in a format DirectFB can't handle. + + - If we do cache the image but don't have support for preallocated + images and the cost of caching the image (bytes used) is higher + than the max image cache size we fall back to raster engine. + */ -#ifndef QT_NO_DIRECTFB_PREALLOCATED d->updateClip(); - if (!d->dfbCanHandleClip(r) || d->matrixRotShear +#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE + if (d->matrixRotShear || d->scale == QDirectFBPaintEnginePrivate::NegativeScale - || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN) + || !d->dfbCanHandleClip(r) +#ifndef QT_DIRECTFB_IMAGECACHE + || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN +#elif defined QT_NO_DIRECTFB_PREALLOCATED + || QDirectFBPaintEnginePrivate::cacheCost(image) > imageCache.maxCost() +#endif + ) #endif { RASTERFALLBACK(DRAW_IMAGE, r, image.size(), sr); @@ -1018,10 +969,16 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, QRasterPaintEngine::drawImage(r, image, sr, flags); return; } - -#ifndef QT_NO_DIRECTFB_PREALLOCATED +#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE d->unlock(); - d->drawImage(r, image, sr); + bool release; + IDirectFBSurface *imgSurface = d->getSurface(image, &release); + d->prepareForBlit(QDirectFBScreen::hasAlpha(imgSurface)); + d->blit(r, imgSurface, sr); + if (release) { + imgSurface->ReleaseSource(imgSurface); + imgSurface->Release(imgSurface); + } #endif } @@ -1048,7 +1005,12 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, QRasterPaintEngine::drawImage(r, *img, sr); } else { d->unlock(); - d->drawPixmap(r, pixmap, sr); + d->prepareForBlit(pixmap.hasAlphaChannel()); + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast(data); + IDirectFBSurface *s = dfbData->directFBSurface(); + d->blit(r, s, sr); } } @@ -1258,4 +1220,19 @@ void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize, d->surface->Blit(d->surface, src, &rect, x, y); } +#ifdef QT_DIRECTFB_IMAGECACHE +static void cachedImageCleanupHook(qint64 key) +{ + delete imageCache.take(key); +} +void QDirectFBPaintEngine::initImageCache(int size) +{ + Q_ASSERT(size >= 0); + imageCache.setMaxCost(size); + typedef void (*_qt_image_cleanup_hook_64)(qint64); + extern Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64; + qt_image_cleanup_hook_64 = ::cachedImageCleanupHook; +} + +#endif // QT_DIRECTFB_IMAGECACHE #endif // QT_NO_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h index e79ec61..d33255b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h @@ -106,6 +106,7 @@ public: virtual void clip(const QVectorPath &path, Qt::ClipOperation op); virtual void clip(const QRect &rect, Qt::ClipOperation op); + static void initImageCache(int size); }; QT_END_HEADER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index f7c428b..7297a99 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -157,6 +157,16 @@ static bool checkForAlphaPixels(const QImage &img) return false; } +bool QDirectFBPixmapData::hasAlphaChannel(const QImage &img) +{ +#ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION + return ::checkForAlphaPixels(img); +#else + return img.hasAlphaChannel(); +#endif +} + + void QDirectFBPixmapData::fromImage(const QImage &i, Qt::ImageConversionFlags flags) { @@ -166,7 +176,7 @@ void QDirectFBPixmapData::fromImage(const QImage &i, const QImage img = (i.depth() == 1 ? i.convertToFormat(screen->alphaPixmapFormat()) : i); if (img.hasAlphaChannel() #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION - && (flags & Qt::NoOpaqueDetection || ::checkForAlphaPixels(img)) + && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) #endif ) { alpha = true; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index 697e5ce..7cd60d6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -75,6 +75,7 @@ public: // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);} inline QImage::Format pixelFormat() const { return format; } + static bool hasAlphaChannel(const QImage &img); private: void invalidate(); QDirectFBPaintEngine *engine; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index ab60214..25e24fd 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -113,9 +113,9 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() delete keyboard; #endif - foreach (IDirectFBSurface *surf, allocatedSurfaces) - surf->Release(surf); - allocatedSurfaces.clear(); + for (QSet::const_iterator it = allocatedSurfaces.begin(); it != allocatedSurfaces.end(); ++it) { + (*it)->Release(*it); + } if (dfbSurface) dfbSurface->Release(dfbSurface); @@ -350,6 +350,7 @@ QDirectFBScreen::DirectFBFlags QDirectFBScreen::directFBFlags() const { return d_ptr->directFBFlags; } + IDirectFB *QDirectFBScreen::dfb() { return d_ptr->dfb; @@ -900,6 +901,12 @@ bool QDirectFBScreen::connect(const QString &displaySpec) d_ptr->directFBFlags |= BoundingRectFlip; } +#ifdef QT_DIRECTFB_IMAGECACHE + int imageCacheSize = 4 * 1024 * 1024; // 4 MB + ::setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize); + QDirectFBPaintEngine::initImageCache(imageCacheSize); +#endif + if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive)) d_ptr->directFBFlags |= IgnoreSystemClip; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index e91a06b..84199a2 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -105,8 +105,6 @@ public: TrackSurface = 1 }; Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption); - IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, - SurfaceCreationOptions options); IDirectFBSurface *createDFBSurface(const QImage &image, SurfaceCreationOptions options); IDirectFBSurface *createDFBSurface(const QSize &size, @@ -130,6 +128,7 @@ public: static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format); static inline bool isPremultiplied(QImage::Format format); static inline bool hasAlpha(DFBSurfacePixelFormat format); + static inline bool hasAlpha(IDirectFBSurface *surface); QImage::Format alphaPixmapFormat() const; #ifndef QT_NO_DIRECTFB_PALETTE @@ -140,11 +139,14 @@ public: static uchar *lockSurface(IDirectFBSurface *surface, uint flags, int *bpl = 0); private: + IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, + SurfaceCreationOptions options); void compose(const QRegion &r); void blit(IDirectFBSurface *src, const QPoint &topLeft, const QRegion ®ion); QDirectFBScreenPrivate *d_ptr; + friend class SurfaceCache; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions); @@ -186,6 +188,14 @@ inline bool QDirectFBScreen::hasAlpha(DFBSurfacePixelFormat format) } } +inline bool QDirectFBScreen::hasAlpha(IDirectFBSurface *surface) +{ + Q_ASSERT(surface); + DFBSurfacePixelFormat format; + surface->GetPixelFormat(surface, &format); + return QDirectFBScreen::hasAlpha(format); +} + QT_END_HEADER #endif // QDIRECTFBSCREEN_H -- cgit v0.12 From 508f241a6a56b0a31472ed99ad60eb3a22388c20 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 5 May 2009 15:18:17 -0700 Subject: Cleaned up code Move private functions to the bottom of the file to be more in line with how most qt cpp files are structured. Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 1434 ++++++++++---------- 1 file changed, 719 insertions(+), 715 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 317f930..bc8efdd 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -291,948 +291,952 @@ private: QDirectFBPaintEngine *q; }; -QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) - : surface(0), antialiased(false), forceRasterPrimitives(false), simplePen(false), - matrixRotShear(false), scale(NoScale), lastLockedHeight(-1), - fbWidth(-1), fbHeight(-1), opacity(255), drawFlagsFromCompositionMode(0), - blitFlagsFromCompositionMode(0), porterDuffRule(DSPD_SRC_OVER), dirtyClip(true), - dfbHandledClip(false), dfbDevice(0), lockedMemory(0), q(p) +QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device) + : QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device) { - fb = QDirectFBScreen::instance()->dfb(); - ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; - surfaceCache = new SurfaceCache; } -QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate() +QDirectFBPaintEngine::~QDirectFBPaintEngine() { - delete surfaceCache; } -bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRect &rect) const +bool QDirectFBPaintEngine::begin(QPaintDevice *device) { - // TODO: Check to see if DirectFB can handle the clip for the given rect - return dfbHandledClip; + Q_D(QDirectFBPaintEngine); + d->begin(device); + const bool status = QRasterPaintEngine::begin(device); + + // XXX: QRasterPaintEngine::begin() resets the capabilities + gccaps |= PorterDuff; + + return status; } -bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRectF &rect) const +bool QDirectFBPaintEngine::end() { - // TODO: Check to see if DirectFB can handle the clip for the given rect - return dfbHandledClip; + Q_D(QDirectFBPaintEngine); + d->end(); + return QRasterPaintEngine::end(); } -bool QDirectFBPaintEnginePrivate::dfbCanHandleClip() const +void QDirectFBPaintEngine::clipEnabledChanged() { - return dfbHandledClip; + Q_D(QDirectFBPaintEngine); + d->setClipDirty(); + QRasterPaintEngine::clipEnabledChanged(); } -bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const +void QDirectFBPaintEngine::penChanged() { - return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased); + Q_D(QDirectFBPaintEngine); + d->setPen(state()->pen); + + QRasterPaintEngine::penChanged(); } -void QDirectFBPaintEnginePrivate::setClipDirty() +void QDirectFBPaintEngine::opacityChanged() { - dirtyClip = true; + Q_D(QDirectFBPaintEngine); + d->setOpacity(quint8(state()->opacity * 255)); + QRasterPaintEngine::opacityChanged(); } -void QDirectFBPaintEnginePrivate::lock() +void QDirectFBPaintEngine::compositionModeChanged() { - // We will potentially get a new pointer to the buffer after a - // lock so we need to call the base implementation of prepare so - // it updates its rasterBuffer to point to the new buffer address. - Q_ASSERT(dfbDevice); - if (dfbDevice->lockFlags() != (DSLF_WRITE|DSLF_READ) - || dfbDevice->height() != lastLockedHeight - || dfbDevice->memory() != lockedMemory) { - prepare(dfbDevice); - lastLockedHeight = dfbDevice->height(); - lockedMemory = dfbDevice->memory(); - } + Q_D(QDirectFBPaintEngine); + d->setCompositionMode(state()->compositionMode()); + QRasterPaintEngine::compositionModeChanged(); } -void QDirectFBPaintEnginePrivate::unlock() +void QDirectFBPaintEngine::renderHintsChanged() { - Q_ASSERT(dfbDevice); - dfbDevice->unlockDirectFB(); - lockedMemory = 0; + Q_D(QDirectFBPaintEngine); + d->setRenderHints(state()->renderHints); + QRasterPaintEngine::renderHintsChanged(); } -void QDirectFBPaintEnginePrivate::setTransform(const QTransform &m) +void QDirectFBPaintEngine::transformChanged() { - transform = m; - matrixRotShear = (transform.m12() != 0 || transform.m21() != 0); - if (qMin(transform.m11(), transform.m22()) < 0) { - scale = NegativeScale; - } else if (transform.m11() != 1 || transform.m22() != 1) { - scale = Scaled; - } else { - scale = NoScale; + Q_D(QDirectFBPaintEngine); + const QDirectFBPaintEnginePrivate::Scale old = d->scale; + d->setTransform(state()->transform()); + if (d->scale != old) { + d->setPen(state()->pen); } + QRasterPaintEngine::transformChanged(); } -void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) +void QDirectFBPaintEngine::setState(QPainterState *s) { - lastLockedHeight = -1; - if (device->devType() == QInternal::CustomRaster) - dfbDevice = static_cast(device); - else if (device->devType() == QInternal::Pixmap) { - QPixmapData *data = static_cast(device)->pixmapData(); - Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); - QDirectFBPixmapData* dfbPixmapData = static_cast(data); - dfbDevice = static_cast(dfbPixmapData); - } - - if (dfbDevice) - surface = dfbDevice->directFBSurface(); - - if (!surface) { - qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x", - device->devType()); - } - lockedMemory = 0; - forceRasterPrimitives = dfbDevice->forceRasterPrimitives(); - - surface->GetSize(surface, &fbWidth, &fbHeight); - - setTransform(QTransform()); - antialiased = false; - opacity = 255; - setCompositionMode(q->state()->compositionMode()); - dirtyClip = true; - setPen(q->state()->pen); - setDFBColor(pen.color()); + Q_D(QDirectFBPaintEngine); + QRasterPaintEngine::setState(s); + d->setClipDirty(); + d->setPen(state()->pen); + d->setOpacity(quint8(state()->opacity * 255)); + d->setCompositionMode(state()->compositionMode()); + d->setTransform(state()->transform()); } -void QDirectFBPaintEnginePrivate::end() +void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { - lockedMemory = 0; - dfbDevice = 0; - surface->ReleaseSource(surface); - surface->SetClip(surface, NULL); - surface = 0; + Q_D(QDirectFBPaintEngine); + d->setClipDirty(); + const QPoint bottom = d->transform.map(QPoint(0, path.controlPointRect().y2)); + if (bottom.y() >= d->lastLockedHeight) + d->lock(); + QRasterPaintEngine::clip(path, op); } -void QDirectFBPaintEnginePrivate::setPen(const QPen &p) +void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) { - pen = p; - simplePen = (pen.style() == Qt::NoPen) || - (pen.style() == Qt::SolidLine - && !antialiased - && (pen.brush().style() == Qt::SolidPattern) - && (pen.widthF() <= 1 && scale != NoScale)); + Q_D(QDirectFBPaintEngine); + d->setClipDirty(); + if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { + const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); + if (bottom.y() >= d->lastLockedHeight) + d->lock(); + } + + QRasterPaintEngine::clip(rect, op); } -void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode) +void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) { - blitFlagsFromCompositionMode = DSBLIT_NOFX; - drawFlagsFromCompositionMode = DSDRAW_NOFX; - - bool blend = true; - switch (mode) { - case QPainter::CompositionMode_SourceOver: - porterDuffRule = DSPD_SRC_OVER; - break; - case QPainter::CompositionMode_DestinationOver: - porterDuffRule = DSPD_DST_OVER; - break; - case QPainter::CompositionMode_Clear: - porterDuffRule = DSPD_CLEAR; - blend = false; - break; - case QPainter::CompositionMode_Source: - porterDuffRule = DSPD_SRC; - blend = false; - break; - case QPainter::CompositionMode_Destination: - porterDuffRule = DSPD_NONE; // ### need to double check this - blend = false; - return; - case QPainter::CompositionMode_SourceIn: - porterDuffRule = DSPD_SRC_IN; - break; - case QPainter::CompositionMode_DestinationIn: - porterDuffRule = DSPD_DST_IN; - break; - case QPainter::CompositionMode_SourceOut: - porterDuffRule = DSPD_SRC_OUT; - break; - case QPainter::CompositionMode_DestinationOut: - porterDuffRule = DSPD_DST_OUT; - break; - case QPainter::CompositionMode_Xor: - porterDuffRule = DSPD_XOR; - blitFlagsFromCompositionMode |= DSBLIT_XOR; - drawFlagsFromCompositionMode |= DSDRAW_XOR; - break; -// case QPainter::CompositionMode_Plus: // ??? -// porterDuffRule = DSPD_ADD; -// break; - default: - qWarning("QDirectFBPaintEnginePrivate::setCompositionMode(): " - "mode %d not implemented", mode); + Q_D(QDirectFBPaintEngine); + d->updateClip(); + const QBrush &brush = state()->brush; + if (!d->dfbCanHandleClip() || d->matrixRotShear + || !d->simplePen || d->forceRasterPrimitives + || !d->isSimpleBrush(brush)) { + RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); + d->lock(); + QRasterPaintEngine::drawRects(rects, rectCount); return; } - // intentially not comparing with current porterDuffRule. surface might have changed. - if (blend) { - blitFlagsFromCompositionMode |= DSBLIT_BLEND_ALPHACHANNEL; - drawFlagsFromCompositionMode |= DSDRAW_BLEND; + + d->unlock(); + + if (brush != Qt::NoBrush) { + d->setDFBColor(brush.color()); + d->fillRects(rects, rectCount); } - if (opacity != 255) { - setOpacity(opacity); + if (d->pen != Qt::NoPen) { + d->setDFBColor(d->pen.color()); + d->drawRects(rects, rectCount); } } -void QDirectFBPaintEnginePrivate::setOpacity(quint8 op) +void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) { - opacity = op; - if (opacity == 255) { - blitFlagsFromCompositionMode &= ~DSBLIT_BLEND_COLORALPHA; - } else { - blitFlagsFromCompositionMode |= DSBLIT_BLEND_COLORALPHA; + Q_D(QDirectFBPaintEngine); + d->updateClip(); + const QBrush &brush = state()->brush; + if (!d->dfbCanHandleClip() || d->matrixRotShear + || !d->simplePen || d->forceRasterPrimitives + || !d->isSimpleBrush(brush)) { + RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); + d->lock(); + QRasterPaintEngine::drawRects(rects, rectCount); + return; } -} -void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) -{ - const bool old = antialiased; - antialiased = bool(hints & QPainter::Antialiasing); - if (old != antialiased) { - setPen(q->state()->pen); + d->unlock(); + + if (brush != Qt::NoBrush) { + d->setDFBColor(brush.color()); + d->fillRects(rects, rectCount); + } + if (d->pen != Qt::NoPen) { + d->setDFBColor(d->pen.color()); + d->drawRects(rects, rectCount); } } -void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) +void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) { - quint32 blittingFlags = blitFlagsFromCompositionMode; - if (alpha) { - surface->SetPorterDuff(surface, - (blittingFlags & DSBLIT_BLEND_COLORALPHA) - ? DSPD_NONE - : porterDuffRule); - } else { - blittingFlags &= ~DSBLIT_BLEND_ALPHACHANNEL; - surface->SetPorterDuff(surface, DSPD_NONE); + Q_D(QDirectFBPaintEngine); + d->updateClip(); + if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { + RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); + d->lock(); + QRasterPaintEngine::drawLines(lines, lineCount); + return; } - surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); - surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blittingFlags)); -} -void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) -{ - Q_ASSERT(surface); - const quint8 alpha = (opacity == 255 ? - color.alpha() : ALPHA_MUL(color.alpha(), opacity)); - surface->SetColor(surface, - color.red(), color.green(), color.blue(), alpha); - quint32 drawingFlags = drawFlagsFromCompositionMode; - if (alpha == 255) { - drawingFlags &= ~DSDRAW_BLEND; + if (d->pen != Qt::NoPen) { + d->unlock(); + d->setDFBColor(d->pen.color()); + d->drawLines(lines, lineCount); } - surface->SetPorterDuff(surface, DSPD_NONE); - // PorterDuff messes up alpha values for primitives - surface->SetDrawingFlags(surface, DFBSurfaceDrawingFlags(drawingFlags)); } -void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) +void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) { - for (int i = 0; i < n; ++i) { - const QLine l = transform.map(lines[i]); - surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); + Q_D(QDirectFBPaintEngine); + d->updateClip(); + if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { + RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); + d->lock(); + QRasterPaintEngine::drawLines(lines, lineCount); + return; } -} -void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) -{ - for (int i = 0; i < n; ++i) { - const QLine l = transform.map(lines[i]).toLine(); - surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); + if (d->pen != Qt::NoPen) { + d->unlock(); + d->setDFBColor(d->pen.color()); + d->drawLines(lines, lineCount); } } -void QDirectFBPaintEnginePrivate::fillRegion(const QRegion ®ion) +void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, + const QRectF &sr, + Qt::ImageConversionFlags flags) { - Q_ASSERT(isSimpleBrush(q->state()->brush)); - setDFBColor(q->state()->brush.color()); - const QVector rects = region.rects(); - const int n = rects.size(); - fillRects(rects.constData(), n); -} + Q_D(QDirectFBPaintEngine); + Q_UNUSED(flags); -void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) -{ - for (int i = 0; i < n; ++i) { - const QRect r = transform.mapRect(rects[i]); - surface->FillRectangle(surface, r.x(), r.y(), - r.width(), r.height()); + /* This is hard to read. The way it works is like this: + + - If you do not have support for preallocated surfaces and do not use an + image cache we always fall back to raster engine. + + - If it's rotated/sheared/mirrored (negative scale) or we can't + clip it we fall back to raster engine. + + - If we don't cache the image, but we do have support for + preallocated surfaces we fall back to the raster engine if the + image is in a format DirectFB can't handle. + + - If we do cache the image but don't have support for preallocated + images and the cost of caching the image (bytes used) is higher + than the max image cache size we fall back to raster engine. + */ + + d->updateClip(); +#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE + if (d->matrixRotShear + || d->scale == QDirectFBPaintEnginePrivate::NegativeScale + || !d->dfbCanHandleClip(r) +#ifndef QT_DIRECTFB_IMAGECACHE + || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN +#elif defined QT_NO_DIRECTFB_PREALLOCATED + || QDirectFBPaintEnginePrivate::cacheCost(image) > imageCache.maxCost() +#endif + ) +#endif + { + RASTERFALLBACK(DRAW_IMAGE, r, image.size(), sr); + d->lock(); + QRasterPaintEngine::drawImage(r, image, sr, flags); + return; + } +#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE + d->unlock(); + bool release; + IDirectFBSurface *imgSurface = d->getSurface(image, &release); + d->prepareForBlit(QDirectFBScreen::hasAlpha(imgSurface)); + d->blit(r, imgSurface, sr); + if (release) { + imgSurface->ReleaseSource(imgSurface); + imgSurface->Release(imgSurface); } +#endif } -void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) +void QDirectFBPaintEngine::drawImage(const QPointF &p, const QImage &img) { - for (int i = 0; i < n; ++i) { - const QRect r = transform.mapRect(rects[i]).toRect(); - surface->FillRectangle(surface, r.x(), r.y(), - r.width(), r.height()); - } + drawImage(QRectF(p, img.size()), img, img.rect()); } -void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) +void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, + const QRectF &sr) { - for (int i = 0; i < n; ++i) { - const QRect r = transform.mapRect(rects[i]); - surface->DrawRectangle(surface, r.x(), r.y(), - r.width() + 1, r.height() + 1); + Q_D(QDirectFBPaintEngine); + d->updateClip(); + + if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); + d->lock(); + QRasterPaintEngine::drawPixmap(r, pixmap, sr); + } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear + || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); + const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); + d->lock(); + QRasterPaintEngine::drawImage(r, *img, sr); + } else { + d->unlock(); + d->prepareForBlit(pixmap.hasAlphaChannel()); + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast(data); + IDirectFBSurface *s = dfbData->directFBSurface(); + d->blit(r, s, sr); } } -void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) +void QDirectFBPaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) { - for (int i = 0; i < n; ++i) { - const QRect r = transform.mapRect(rects[i]).toRect(); - surface->DrawRectangle(surface, r.x(), r.y(), - r.width() + 1, r.height() + 1); - } + drawPixmap(QRectF(p, pm.size()), pm, pm.rect()); } -IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release) +void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, + const QPixmap &pixmap, + const QPointF &sp) { -#ifndef QT_DIRECTFB_IMAGECACHE - *release = true; - return QDirectFBScreen::instance()->createDFBSurface(img, QDirectFBScreen::DontTrackSurface); -#else - const qint64 key = img.cacheKey(); - *release = false; - if (imageCache.contains(key)) { - return imageCache[key]->surface; - } - - const int cost = cacheCost(img); - const bool cache = cost <= imageCache.maxCost(); - QDirectFBScreen *screen = QDirectFBScreen::instance(); - const QImage::Format format = (img.format() == screen->alphaPixmapFormat() || QDirectFBPixmapData::hasAlphaChannel(img) - ? screen->alphaPixmapFormat() : screen->pixelFormat()); - - IDirectFBSurface *surface = screen->copyToDFBSurface(img, format, - cache - ? QDirectFBScreen::TrackSurface - : QDirectFBScreen::DontTrackSurface); - if (cache) { - CachedImage *cachedImage = new CachedImage; - const_cast(img).data_ptr()->is_cached = true; - cachedImage->surface = surface; - imageCache.insert(key, cachedImage, cost); + Q_D(QDirectFBPaintEngine); + d->updateClip(); + if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { + RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); + d->lock(); + QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp); + } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull() + || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { + RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); + const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); + d->lock(); + QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); + data->fromImage(*img, Qt::AutoColor); + const QPixmap pix(data); + QRasterPaintEngine::drawTiledPixmap(r, pix, sp); } else { - *release = true; + d->unlock(); + d->drawTiledPixmap(r, pixmap); } - return surface; -#endif } -void QDirectFBPaintEnginePrivate::blit(const QRectF &dest, IDirectFBSurface *s, const QRectF &src) +void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen) { - const QRect sr = src.toRect(); - const QRect dr = transform.mapRect(dest).toRect(); - const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; - DFBResult result; + RASTERFALLBACK(STROKE_PATH, path, VOID_ARG(), VOID_ARG()); + Q_D(QDirectFBPaintEngine); + d->lock(); + QRasterPaintEngine::stroke(path, pen); +} - if (dr.size() == sr.size()) { - result = surface->Blit(surface, s, &sRect, dr.x(), dr.y()); - } else { - const DFBRectangle dRect = { dr.x(), dr.y(), dr.width(), dr.height() }; - result = surface->StretchBlit(surface, s, &sRect, &dRect); - } - if (result != DFB_OK) - DirectFBError("QDirectFBPaintEngine::drawPixmap()", result); +void QDirectFBPaintEngine::drawPath(const QPainterPath &path) +{ + RASTERFALLBACK(DRAW_PATH, path, VOID_ARG(), VOID_ARG()); + Q_D(QDirectFBPaintEngine); + d->lock(); + QRasterPaintEngine::drawPath(path); } -void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, - const QPixmap &pixmap) -{ - prepareForBlit(pixmap.hasAlphaChannel()); - QPixmapData *data = pixmap.pixmapData(); - Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); - QDirectFBPixmapData *dfbData = static_cast(data); - IDirectFBSurface *s = dfbData->directFBSurface(); - const QRect dr = transform.mapRect(dest).toRect(); - DFBResult result = DFB_OK; - - if (scale == NoScale && dr == QRect(0, 0, fbWidth, fbHeight)) { - result = surface->TileBlit(surface, s, 0, 0, 0); - } else if (scale == NoScale) { - const int dx = pixmap.width(); - const int dy = pixmap.height(); - const DFBRectangle rect = { 0, 0, dx, dy }; - QVarLengthArray rects; - QVarLengthArray points; - - for (int y = dr.y(); y <= dr.bottom(); y += dy) { - for (int x = dr.x(); x <= dr.right(); x += dx) { - rects.append(rect); - const DFBPoint point = { x, y }; - points.append(point); - } - } - result = surface->BatchBlit(surface, s, rects.constData(), - points.constData(), points.size()); - } else { - const QRect sr = transform.mapRect(QRect(0, 0, pixmap.width(), pixmap.height())); - const int dx = sr.width(); - const int dy = sr.height(); - const DFBRectangle sRect = { 0, 0, dx, dy }; - - for (int y = dr.y(); y <= dr.bottom(); y += dy) { - for (int x = dr.x(); x <= dr.right(); x += dx) { - const DFBRectangle dRect = { x, y, dx, dy }; - result = surface->StretchBlit(surface, s, &sRect, &dRect); - if (result != DFB_OK) { - y = dr.bottom() + 1; - break; - } - } - } - } - - if (result != DFB_OK) - DirectFBError("QDirectFBPaintEngine::drawTiledPixmap()", result); -} - -void QDirectFBPaintEnginePrivate::updateClip() -{ - if (!dirtyClip) - return; - - const QClipData *clipData = clip(); - if (!clipData || !clipData->enabled) { - surface->SetClip(surface, NULL); - dfbHandledClip = true; - } else if (clipData->hasRectClip) { - const DFBRegion r = { - clipData->clipRect.x(), - clipData->clipRect.y(), - clipData->clipRect.x() + clipData->clipRect.width(), - clipData->clipRect.y() + clipData->clipRect.height() - }; - surface->SetClip(surface, &r); - dfbHandledClip = true; - } else if (clipData->hasRegionClip && ignoreSystemClip && clipData->clipRegion == systemClip) { - dfbHandledClip = true; - } else { - dfbHandledClip = false; - } - - dirtyClip = false; -} - -void QDirectFBPaintEnginePrivate::systemStateChanged() -{ - setClipDirty(); - QRasterPaintEnginePrivate::systemStateChanged(); -} - -QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device) - : QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device) -{ -} - -QDirectFBPaintEngine::~QDirectFBPaintEngine() -{ -} - -bool QDirectFBPaintEngine::begin(QPaintDevice *device) +void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) { + RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); - d->begin(device); - const bool status = QRasterPaintEngine::begin(device); - - // XXX: QRasterPaintEngine::begin() resets the capabilities - gccaps |= PorterDuff; - - return status; + d->lock(); + QRasterPaintEngine::drawPoints(points, pointCount); } -bool QDirectFBPaintEngine::end() +void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) { + RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); - d->end(); - return QRasterPaintEngine::end(); + d->lock(); + QRasterPaintEngine::drawPoints(points, pointCount); } -void QDirectFBPaintEngine::clipEnabledChanged() +void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) { + RASTERFALLBACK(DRAW_ELLIPSE, rect, VOID_ARG(), VOID_ARG()); Q_D(QDirectFBPaintEngine); - d->setClipDirty(); - QRasterPaintEngine::clipEnabledChanged(); + d->lock(); + QRasterPaintEngine::drawEllipse(rect); } -void QDirectFBPaintEngine::penChanged() +void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, + PolygonDrawMode mode) { + RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); Q_D(QDirectFBPaintEngine); - d->setPen(state()->pen); - - QRasterPaintEngine::penChanged(); + d->lock(); + QRasterPaintEngine::drawPolygon(points, pointCount, mode); } -void QDirectFBPaintEngine::opacityChanged() +void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, + PolygonDrawMode mode) { + RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); Q_D(QDirectFBPaintEngine); - d->setOpacity(quint8(state()->opacity * 255)); - QRasterPaintEngine::opacityChanged(); + d->lock(); + QRasterPaintEngine::drawPolygon(points, pointCount, mode); } -void QDirectFBPaintEngine::compositionModeChanged() +void QDirectFBPaintEngine::drawTextItem(const QPointF &p, + const QTextItem &textItem) { + RASTERFALLBACK(DRAW_TEXT, p, textItem.text(), VOID_ARG()); Q_D(QDirectFBPaintEngine); - d->setCompositionMode(state()->compositionMode()); - QRasterPaintEngine::compositionModeChanged(); + d->lock(); + QRasterPaintEngine::drawTextItem(p, textItem); } -void QDirectFBPaintEngine::renderHintsChanged() +void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush) { + RASTERFALLBACK(FILL_PATH, path, brush, VOID_ARG()); Q_D(QDirectFBPaintEngine); - d->setRenderHints(state()->renderHints); - QRasterPaintEngine::renderHintsChanged(); + d->lock(); + QRasterPaintEngine::fill(path, brush); } -void QDirectFBPaintEngine::transformChanged() + +void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) { Q_D(QDirectFBPaintEngine); - const QDirectFBPaintEnginePrivate::Scale old = d->scale; - d->setTransform(state()->transform()); - if (d->scale != old) { - d->setPen(state()->pen); + d->updateClip(); + if (d->dfbCanHandleClip(rect) && !d->matrixRotShear) { + switch (brush.style()) { + case Qt::SolidPattern: { + if (d->forceRasterPrimitives) + break; + d->unlock(); + d->setDFBColor(brush.color()); + const QRect r = d->transform.mapRect(rect).toRect(); + d->surface->FillRectangle(d->surface, r.x(), r.y(), + r.width(), r.height()); + return; } + case Qt::TexturePattern: + if (state()->brushOrigin == QPointF() && brush.transform().isIdentity()) { + //could handle certain types of brush.transform() E.g. scale + d->unlock(); + d->drawTiledPixmap(rect, brush.texture()); + return; + } + break; + default: + break; + } } - QRasterPaintEngine::transformChanged(); + RASTERFALLBACK(FILL_RECT, rect, brush, VOID_ARG()); + d->lock(); + QRasterPaintEngine::fillRect(rect, brush); } -void QDirectFBPaintEngine::setState(QPainterState *s) +void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) { Q_D(QDirectFBPaintEngine); - QRasterPaintEngine::setState(s); - d->setClipDirty(); - d->setPen(state()->pen); - d->setOpacity(quint8(state()->opacity * 255)); - d->setCompositionMode(state()->compositionMode()); - d->setTransform(state()->transform()); + d->updateClip(); + if (!d->dfbCanHandleClip() || d->matrixRotShear || d->forceRasterPrimitives) { + RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); + d->lock(); + QRasterPaintEngine::fillRect(rect, color); + } else { + d->unlock(); + d->setDFBColor(color); + const QRect r = d->transform.mapRect(rect).toRect(); + d->surface->FillRectangle(d->surface, r.x(), r.y(), + r.width(), r.height()); + } } -void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) +void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count, + uint color) { Q_D(QDirectFBPaintEngine); - d->setClipDirty(); - const QPoint bottom = d->transform.map(QPoint(0, path.controlPointRect().y2)); - if (bottom.y() >= d->lastLockedHeight) + if (d->forceRasterPrimitives) { + RASTERFALLBACK(DRAW_COLORSPANS, count, color, VOID_ARG()); d->lock(); - QRasterPaintEngine::clip(path, op); -} + QRasterPaintEngine::drawColorSpans(spans, count, color); + } else { + color = INV_PREMUL(color); -void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) -{ - Q_D(QDirectFBPaintEngine); - d->setClipDirty(); - if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { - const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); - if (bottom.y() >= d->lastLockedHeight) - d->lock(); + QVarLengthArray lines(count); + int j = 0; + for (int i = 0; i < count; ++i) { + if (spans[i].coverage == 255) { + lines[j].x1 = spans[i].x; + lines[j].y1 = spans[i].y; + lines[j].x2 = spans[i].x + spans[i].len - 1; + lines[j].y2 = spans[i].y; + ++j; + } else { + DFBSpan span = { spans[i].x, spans[i].len }; + uint c = BYTE_MUL(color, spans[i].coverage); + // ### how does this play with setDFBColor + d->surface->SetColor(d->surface, + qRed(c), qGreen(c), qBlue(c), qAlpha(c)); + d->surface->FillSpans(d->surface, spans[i].y, &span, 1); + } + } + if (j > 0) { + d->surface->SetColor(d->surface, + qRed(color), qGreen(color), qBlue(color), + qAlpha(color)); + d->surface->DrawLines(d->surface, lines.data(), j); + } } - - QRasterPaintEngine::clip(rect, op); } -void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) +void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize, + int x, int y, int length, + uint const_alpha) { Q_D(QDirectFBPaintEngine); - d->updateClip(); - const QBrush &brush = state()->brush; - if (!d->dfbCanHandleClip() || d->matrixRotShear - || !d->simplePen || d->forceRasterPrimitives - || !d->isSimpleBrush(brush)) { - RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); - d->lock(); - QRasterPaintEngine::drawRects(rects, rectCount); - return; - } + IDirectFBSurface *src = d->surfaceCache->getSurface(buffer, bufsize); + // ### how does this play with setDFBColor + src->SetColor(src, 0, 0, 0, const_alpha); + const DFBRectangle rect = { 0, 0, length, 1 }; + d->surface->Blit(d->surface, src, &rect, x, y); +} - d->unlock(); +#ifdef QT_DIRECTFB_IMAGECACHE +static void cachedImageCleanupHook(qint64 key) +{ + delete imageCache.take(key); +} +void QDirectFBPaintEngine::initImageCache(int size) +{ + Q_ASSERT(size >= 0); + imageCache.setMaxCost(size); + typedef void (*_qt_image_cleanup_hook_64)(qint64); + extern Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64; + qt_image_cleanup_hook_64 = ::cachedImageCleanupHook; +} - if (brush != Qt::NoBrush) { - d->setDFBColor(brush.color()); - d->fillRects(rects, rectCount); - } - if (d->pen != Qt::NoPen) { - d->setDFBColor(d->pen.color()); - d->drawRects(rects, rectCount); - } +#endif // QT_DIRECTFB_IMAGECACHE + +// ---- QDirectFBPaintEnginePrivate ---- + + +QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) + : surface(0), antialiased(false), forceRasterPrimitives(false), simplePen(false), + matrixRotShear(false), scale(NoScale), lastLockedHeight(-1), + fbWidth(-1), fbHeight(-1), opacity(255), drawFlagsFromCompositionMode(0), + blitFlagsFromCompositionMode(0), porterDuffRule(DSPD_SRC_OVER), dirtyClip(true), + dfbHandledClip(false), dfbDevice(0), lockedMemory(0), q(p) +{ + fb = QDirectFBScreen::instance()->dfb(); + ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; + surfaceCache = new SurfaceCache; } -void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) +QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate() { - Q_D(QDirectFBPaintEngine); - d->updateClip(); - const QBrush &brush = state()->brush; - if (!d->dfbCanHandleClip() || d->matrixRotShear - || !d->simplePen || d->forceRasterPrimitives - || !d->isSimpleBrush(brush)) { - RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); - d->lock(); - QRasterPaintEngine::drawRects(rects, rectCount); - return; - } + delete surfaceCache; +} - d->unlock(); +bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRect &rect) const +{ + // TODO: Check to see if DirectFB can handle the clip for the given rect + return dfbHandledClip; +} - if (brush != Qt::NoBrush) { - d->setDFBColor(brush.color()); - d->fillRects(rects, rectCount); - } - if (d->pen != Qt::NoPen) { - d->setDFBColor(d->pen.color()); - d->drawRects(rects, rectCount); - } +bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRectF &rect) const +{ + // TODO: Check to see if DirectFB can handle the clip for the given rect + return dfbHandledClip; } -void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) +bool QDirectFBPaintEnginePrivate::dfbCanHandleClip() const { - Q_D(QDirectFBPaintEngine); - d->updateClip(); - if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { - RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); - d->lock(); - QRasterPaintEngine::drawLines(lines, lineCount); - return; - } + return dfbHandledClip; +} - if (d->pen != Qt::NoPen) { - d->unlock(); - d->setDFBColor(d->pen.color()); - d->drawLines(lines, lineCount); - } +bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const +{ + return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased); } -void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) +void QDirectFBPaintEnginePrivate::setClipDirty() { - Q_D(QDirectFBPaintEngine); - d->updateClip(); - if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { - RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); - d->lock(); - QRasterPaintEngine::drawLines(lines, lineCount); - return; - } + dirtyClip = true; +} - if (d->pen != Qt::NoPen) { - d->unlock(); - d->setDFBColor(d->pen.color()); - d->drawLines(lines, lineCount); +void QDirectFBPaintEnginePrivate::lock() +{ + // We will potentially get a new pointer to the buffer after a + // lock so we need to call the base implementation of prepare so + // it updates its rasterBuffer to point to the new buffer address. + Q_ASSERT(dfbDevice); + if (dfbDevice->lockFlags() != (DSLF_WRITE|DSLF_READ) + || dfbDevice->height() != lastLockedHeight + || dfbDevice->memory() != lockedMemory) { + prepare(dfbDevice); + lastLockedHeight = dfbDevice->height(); + lockedMemory = dfbDevice->memory(); } } -void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, - const QRectF &sr, - Qt::ImageConversionFlags flags) +void QDirectFBPaintEnginePrivate::unlock() { - Q_D(QDirectFBPaintEngine); - Q_UNUSED(flags); + Q_ASSERT(dfbDevice); + dfbDevice->unlockDirectFB(); + lockedMemory = 0; +} - /* This is hard to read. The way it works is like this: +void QDirectFBPaintEnginePrivate::setTransform(const QTransform &m) +{ + transform = m; + matrixRotShear = (transform.m12() != 0 || transform.m21() != 0); + if (qMin(transform.m11(), transform.m22()) < 0) { + scale = NegativeScale; + } else if (transform.m11() != 1 || transform.m22() != 1) { + scale = Scaled; + } else { + scale = NoScale; + } +} - - If you do not have support for preallocated surfaces and do not use an - image cache we always fall back to raster engine. +void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) +{ + lastLockedHeight = -1; + if (device->devType() == QInternal::CustomRaster) + dfbDevice = static_cast(device); + else if (device->devType() == QInternal::Pixmap) { + QPixmapData *data = static_cast(device)->pixmapData(); + Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData* dfbPixmapData = static_cast(data); + dfbDevice = static_cast(dfbPixmapData); + } - - If it's rotated/sheared/mirrored (negative scale) or we can't - clip it we fall back to raster engine. + if (dfbDevice) + surface = dfbDevice->directFBSurface(); - - If we don't cache the image, but we do have support for - preallocated surfaces we fall back to the raster engine if the - image is in a format DirectFB can't handle. + if (!surface) { + qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x", + device->devType()); + } + lockedMemory = 0; + forceRasterPrimitives = dfbDevice->forceRasterPrimitives(); - - If we do cache the image but don't have support for preallocated - images and the cost of caching the image (bytes used) is higher - than the max image cache size we fall back to raster engine. - */ + surface->GetSize(surface, &fbWidth, &fbHeight); - d->updateClip(); -#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE - if (d->matrixRotShear - || d->scale == QDirectFBPaintEnginePrivate::NegativeScale - || !d->dfbCanHandleClip(r) -#ifndef QT_DIRECTFB_IMAGECACHE - || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN -#elif defined QT_NO_DIRECTFB_PREALLOCATED - || QDirectFBPaintEnginePrivate::cacheCost(image) > imageCache.maxCost() -#endif - ) -#endif - { - RASTERFALLBACK(DRAW_IMAGE, r, image.size(), sr); - d->lock(); - QRasterPaintEngine::drawImage(r, image, sr, flags); - return; - } -#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE - d->unlock(); - bool release; - IDirectFBSurface *imgSurface = d->getSurface(image, &release); - d->prepareForBlit(QDirectFBScreen::hasAlpha(imgSurface)); - d->blit(r, imgSurface, sr); - if (release) { - imgSurface->ReleaseSource(imgSurface); - imgSurface->Release(imgSurface); - } -#endif + setTransform(QTransform()); + antialiased = false; + opacity = 255; + setCompositionMode(q->state()->compositionMode()); + dirtyClip = true; + setPen(q->state()->pen); + setDFBColor(pen.color()); } -void QDirectFBPaintEngine::drawImage(const QPointF &p, const QImage &img) +void QDirectFBPaintEnginePrivate::end() { - drawImage(QRectF(p, img.size()), img, img.rect()); + lockedMemory = 0; + dfbDevice = 0; + surface->ReleaseSource(surface); + surface->SetClip(surface, NULL); + surface = 0; } -void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, - const QRectF &sr) +void QDirectFBPaintEnginePrivate::setPen(const QPen &p) { - Q_D(QDirectFBPaintEngine); - d->updateClip(); + pen = p; + simplePen = (pen.style() == Qt::NoPen) || + (pen.style() == Qt::SolidLine + && !antialiased + && (pen.brush().style() == Qt::SolidPattern) + && (pen.widthF() <= 1 && scale != NoScale)); +} - if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { - RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); - d->lock(); - QRasterPaintEngine::drawPixmap(r, pixmap, sr); - } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear - || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { - RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); - const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); - d->lock(); - QRasterPaintEngine::drawImage(r, *img, sr); +void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode) +{ + blitFlagsFromCompositionMode = DSBLIT_NOFX; + drawFlagsFromCompositionMode = DSDRAW_NOFX; + + bool blend = true; + switch (mode) { + case QPainter::CompositionMode_SourceOver: + porterDuffRule = DSPD_SRC_OVER; + break; + case QPainter::CompositionMode_DestinationOver: + porterDuffRule = DSPD_DST_OVER; + break; + case QPainter::CompositionMode_Clear: + porterDuffRule = DSPD_CLEAR; + blend = false; + break; + case QPainter::CompositionMode_Source: + porterDuffRule = DSPD_SRC; + blend = false; + break; + case QPainter::CompositionMode_Destination: + porterDuffRule = DSPD_NONE; // ### need to double check this + blend = false; + return; + case QPainter::CompositionMode_SourceIn: + porterDuffRule = DSPD_SRC_IN; + break; + case QPainter::CompositionMode_DestinationIn: + porterDuffRule = DSPD_DST_IN; + break; + case QPainter::CompositionMode_SourceOut: + porterDuffRule = DSPD_SRC_OUT; + break; + case QPainter::CompositionMode_DestinationOut: + porterDuffRule = DSPD_DST_OUT; + break; + case QPainter::CompositionMode_Xor: + porterDuffRule = DSPD_XOR; + blitFlagsFromCompositionMode |= DSBLIT_XOR; + drawFlagsFromCompositionMode |= DSDRAW_XOR; + break; +// case QPainter::CompositionMode_Plus: // ??? +// porterDuffRule = DSPD_ADD; +// break; + default: + qWarning("QDirectFBPaintEnginePrivate::setCompositionMode(): " + "mode %d not implemented", mode); + return; + } + // intentially not comparing with current porterDuffRule. surface might have changed. + if (blend) { + blitFlagsFromCompositionMode |= DSBLIT_BLEND_ALPHACHANNEL; + drawFlagsFromCompositionMode |= DSDRAW_BLEND; + } + if (opacity != 255) { + setOpacity(opacity); + } +} + +void QDirectFBPaintEnginePrivate::setOpacity(quint8 op) +{ + opacity = op; + if (opacity == 255) { + blitFlagsFromCompositionMode &= ~DSBLIT_BLEND_COLORALPHA; } else { - d->unlock(); - d->prepareForBlit(pixmap.hasAlphaChannel()); - QPixmapData *data = pixmap.pixmapData(); - Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); - QDirectFBPixmapData *dfbData = static_cast(data); - IDirectFBSurface *s = dfbData->directFBSurface(); - d->blit(r, s, sr); + blitFlagsFromCompositionMode |= DSBLIT_BLEND_COLORALPHA; } } -void QDirectFBPaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) +void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) { - drawPixmap(QRectF(p, pm.size()), pm, pm.rect()); + const bool old = antialiased; + antialiased = bool(hints & QPainter::Antialiasing); + if (old != antialiased) { + setPen(q->state()->pen); + } } -void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, - const QPixmap &pixmap, - const QPointF &sp) +void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) { - Q_D(QDirectFBPaintEngine); - d->updateClip(); - if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { - RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); - d->lock(); - QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp); - } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull() - || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { - RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); - const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); - d->lock(); - QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); - data->fromImage(*img, Qt::AutoColor); - const QPixmap pix(data); - QRasterPaintEngine::drawTiledPixmap(r, pix, sp); + quint32 blittingFlags = blitFlagsFromCompositionMode; + if (alpha) { + surface->SetPorterDuff(surface, + (blittingFlags & DSBLIT_BLEND_COLORALPHA) + ? DSPD_NONE + : porterDuffRule); } else { - d->unlock(); - d->drawTiledPixmap(r, pixmap); + blittingFlags &= ~DSBLIT_BLEND_ALPHACHANNEL; + surface->SetPorterDuff(surface, DSPD_NONE); } + surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); + surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blittingFlags)); } - -void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen) +void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) { - RASTERFALLBACK(STROKE_PATH, path, VOID_ARG(), VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::stroke(path, pen); + Q_ASSERT(surface); + const quint8 alpha = (opacity == 255 ? + color.alpha() : ALPHA_MUL(color.alpha(), opacity)); + surface->SetColor(surface, + color.red(), color.green(), color.blue(), alpha); + quint32 drawingFlags = drawFlagsFromCompositionMode; + if (alpha == 255) { + drawingFlags &= ~DSDRAW_BLEND; + } + surface->SetPorterDuff(surface, DSPD_NONE); + // PorterDuff messes up alpha values for primitives + surface->SetDrawingFlags(surface, DFBSurfaceDrawingFlags(drawingFlags)); } -void QDirectFBPaintEngine::drawPath(const QPainterPath &path) +void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) { - RASTERFALLBACK(DRAW_PATH, path, VOID_ARG(), VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::drawPath(path); + for (int i = 0; i < n; ++i) { + const QLine l = transform.map(lines[i]); + surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); + } } -void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) +void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) { - RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::drawPoints(points, pointCount); + for (int i = 0; i < n; ++i) { + const QLine l = transform.map(lines[i]).toLine(); + surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); + } } -void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) +void QDirectFBPaintEnginePrivate::fillRegion(const QRegion ®ion) { - RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::drawPoints(points, pointCount); + Q_ASSERT(isSimpleBrush(q->state()->brush)); + setDFBColor(q->state()->brush.color()); + const QVector rects = region.rects(); + const int n = rects.size(); + fillRects(rects.constData(), n); } -void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) +void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) { - RASTERFALLBACK(DRAW_ELLIPSE, rect, VOID_ARG(), VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::drawEllipse(rect); + for (int i = 0; i < n; ++i) { + const QRect r = transform.mapRect(rects[i]); + surface->FillRectangle(surface, r.x(), r.y(), + r.width(), r.height()); + } } -void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, - PolygonDrawMode mode) +void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) { - RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::drawPolygon(points, pointCount, mode); + for (int i = 0; i < n; ++i) { + const QRect r = transform.mapRect(rects[i]).toRect(); + surface->FillRectangle(surface, r.x(), r.y(), + r.width(), r.height()); + } } -void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, - PolygonDrawMode mode) +void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) { - RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::drawPolygon(points, pointCount, mode); + for (int i = 0; i < n; ++i) { + const QRect r = transform.mapRect(rects[i]); + surface->DrawRectangle(surface, r.x(), r.y(), + r.width() + 1, r.height() + 1); + } } -void QDirectFBPaintEngine::drawTextItem(const QPointF &p, - const QTextItem &textItem) +void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) { - RASTERFALLBACK(DRAW_TEXT, p, textItem.text(), VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::drawTextItem(p, textItem); + for (int i = 0; i < n; ++i) { + const QRect r = transform.mapRect(rects[i]).toRect(); + surface->DrawRectangle(surface, r.x(), r.y(), + r.width() + 1, r.height() + 1); + } } -void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush) +IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release) { - RASTERFALLBACK(FILL_PATH, path, brush, VOID_ARG()); - Q_D(QDirectFBPaintEngine); - d->lock(); - QRasterPaintEngine::fill(path, brush); -} +#ifndef QT_DIRECTFB_IMAGECACHE + *release = true; + return QDirectFBScreen::instance()->createDFBSurface(img, QDirectFBScreen::DontTrackSurface); +#else + const qint64 key = img.cacheKey(); + *release = false; + if (imageCache.contains(key)) { + return imageCache[key]->surface; + } + const int cost = cacheCost(img); + const bool cache = cost <= imageCache.maxCost(); + QDirectFBScreen *screen = QDirectFBScreen::instance(); + const QImage::Format format = (img.format() == screen->alphaPixmapFormat() || QDirectFBPixmapData::hasAlphaChannel(img) + ? screen->alphaPixmapFormat() : screen->pixelFormat()); -void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) -{ - Q_D(QDirectFBPaintEngine); - d->updateClip(); - if (d->dfbCanHandleClip(rect) && !d->matrixRotShear) { - switch (brush.style()) { - case Qt::SolidPattern: { - if (d->forceRasterPrimitives) - break; - d->unlock(); - d->setDFBColor(brush.color()); - const QRect r = d->transform.mapRect(rect).toRect(); - d->surface->FillRectangle(d->surface, r.x(), r.y(), - r.width(), r.height()); - return; } - case Qt::TexturePattern: - if (state()->brushOrigin == QPointF() && brush.transform().isIdentity()) { - //could handle certain types of brush.transform() E.g. scale - d->unlock(); - d->drawTiledPixmap(rect, brush.texture()); - return; - } - break; - default: - break; - } + IDirectFBSurface *surface = screen->copyToDFBSurface(img, format, + cache + ? QDirectFBScreen::TrackSurface + : QDirectFBScreen::DontTrackSurface); + if (cache) { + CachedImage *cachedImage = new CachedImage; + const_cast(img).data_ptr()->is_cached = true; + cachedImage->surface = surface; + imageCache.insert(key, cachedImage, cost); + } else { + *release = true; } - RASTERFALLBACK(FILL_RECT, rect, brush, VOID_ARG()); - d->lock(); - QRasterPaintEngine::fillRect(rect, brush); + return surface; +#endif } -void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) + +void QDirectFBPaintEnginePrivate::blit(const QRectF &dest, IDirectFBSurface *s, const QRectF &src) { - Q_D(QDirectFBPaintEngine); - d->updateClip(); - if (!d->dfbCanHandleClip() || d->matrixRotShear || d->forceRasterPrimitives) { - RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); - d->lock(); - QRasterPaintEngine::fillRect(rect, color); + const QRect sr = src.toRect(); + const QRect dr = transform.mapRect(dest).toRect(); + const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; + DFBResult result; + + if (dr.size() == sr.size()) { + result = surface->Blit(surface, s, &sRect, dr.x(), dr.y()); } else { - d->unlock(); - d->setDFBColor(color); - const QRect r = d->transform.mapRect(rect).toRect(); - d->surface->FillRectangle(d->surface, r.x(), r.y(), - r.width(), r.height()); + const DFBRectangle dRect = { dr.x(), dr.y(), dr.width(), dr.height() }; + result = surface->StretchBlit(surface, s, &sRect, &dRect); } + if (result != DFB_OK) + DirectFBError("QDirectFBPaintEngine::drawPixmap()", result); } -void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count, - uint color) +void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, + const QPixmap &pixmap) { - Q_D(QDirectFBPaintEngine); - if (d->forceRasterPrimitives) { - RASTERFALLBACK(DRAW_COLORSPANS, count, color, VOID_ARG()); - d->lock(); - QRasterPaintEngine::drawColorSpans(spans, count, color); - } else { - color = INV_PREMUL(color); + prepareForBlit(pixmap.hasAlphaChannel()); + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast(data); + IDirectFBSurface *s = dfbData->directFBSurface(); + const QRect dr = transform.mapRect(dest).toRect(); + DFBResult result = DFB_OK; - QVarLengthArray lines(count); - int j = 0; - for (int i = 0; i < count; ++i) { - if (spans[i].coverage == 255) { - lines[j].x1 = spans[i].x; - lines[j].y1 = spans[i].y; - lines[j].x2 = spans[i].x + spans[i].len - 1; - lines[j].y2 = spans[i].y; - ++j; - } else { - DFBSpan span = { spans[i].x, spans[i].len }; - uint c = BYTE_MUL(color, spans[i].coverage); - // ### how does this play with setDFBColor - d->surface->SetColor(d->surface, - qRed(c), qGreen(c), qBlue(c), qAlpha(c)); - d->surface->FillSpans(d->surface, spans[i].y, &span, 1); + if (scale == NoScale && dr == QRect(0, 0, fbWidth, fbHeight)) { + result = surface->TileBlit(surface, s, 0, 0, 0); + } else if (scale == NoScale) { + const int dx = pixmap.width(); + const int dy = pixmap.height(); + const DFBRectangle rect = { 0, 0, dx, dy }; + QVarLengthArray rects; + QVarLengthArray points; + + for (int y = dr.y(); y <= dr.bottom(); y += dy) { + for (int x = dr.x(); x <= dr.right(); x += dx) { + rects.append(rect); + const DFBPoint point = { x, y }; + points.append(point); } } - if (j > 0) { - d->surface->SetColor(d->surface, - qRed(color), qGreen(color), qBlue(color), - qAlpha(color)); - d->surface->DrawLines(d->surface, lines.data(), j); + result = surface->BatchBlit(surface, s, rects.constData(), + points.constData(), points.size()); + } else { + const QRect sr = transform.mapRect(QRect(0, 0, pixmap.width(), pixmap.height())); + const int dx = sr.width(); + const int dy = sr.height(); + const DFBRectangle sRect = { 0, 0, dx, dy }; + + for (int y = dr.y(); y <= dr.bottom(); y += dy) { + for (int x = dr.x(); x <= dr.right(); x += dx) { + const DFBRectangle dRect = { x, y, dx, dy }; + result = surface->StretchBlit(surface, s, &sRect, &dRect); + if (result != DFB_OK) { + y = dr.bottom() + 1; + break; + } + } } } -} -void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize, - int x, int y, int length, - uint const_alpha) -{ - Q_D(QDirectFBPaintEngine); - IDirectFBSurface *src = d->surfaceCache->getSurface(buffer, bufsize); - // ### how does this play with setDFBColor - src->SetColor(src, 0, 0, 0, const_alpha); - const DFBRectangle rect = { 0, 0, length, 1 }; - d->surface->Blit(d->surface, src, &rect, x, y); + if (result != DFB_OK) + DirectFBError("QDirectFBPaintEngine::drawTiledPixmap()", result); } -#ifdef QT_DIRECTFB_IMAGECACHE -static void cachedImageCleanupHook(qint64 key) +void QDirectFBPaintEnginePrivate::updateClip() { - delete imageCache.take(key); + if (!dirtyClip) + return; + + const QClipData *clipData = clip(); + if (!clipData || !clipData->enabled) { + surface->SetClip(surface, NULL); + dfbHandledClip = true; + } else if (clipData->hasRectClip) { + const DFBRegion r = { + clipData->clipRect.x(), + clipData->clipRect.y(), + clipData->clipRect.x() + clipData->clipRect.width(), + clipData->clipRect.y() + clipData->clipRect.height() + }; + surface->SetClip(surface, &r); + dfbHandledClip = true; + } else if (clipData->hasRegionClip && ignoreSystemClip && clipData->clipRegion == systemClip) { + dfbHandledClip = true; + } else { + dfbHandledClip = false; + } + + dirtyClip = false; } -void QDirectFBPaintEngine::initImageCache(int size) + +void QDirectFBPaintEnginePrivate::systemStateChanged() { - Q_ASSERT(size >= 0); - imageCache.setMaxCost(size); - typedef void (*_qt_image_cleanup_hook_64)(qint64); - extern Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64; - qt_image_cleanup_hook_64 = ::cachedImageCleanupHook; + setClipDirty(); + QRasterPaintEnginePrivate::systemStateChanged(); } -#endif // QT_DIRECTFB_IMAGECACHE #endif // QT_NO_DIRECTFB -- cgit v0.12 From 8ad9a7f781f1f092a2120773dccce4e8f50e675a Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 5 May 2009 15:22:08 -0700 Subject: Cleaned up code Put all variables in the same area for QDirectFBPaintEnginePrivate. Make QDirectFBPaintEngine a friend. Also, do away with setClipDirty and replace it with d->clipDirty = true; Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 44 ++++++++++------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index bc8efdd..6d8f617 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -214,18 +214,6 @@ public: QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p); ~QDirectFBPaintEnginePrivate(); - IDirectFBSurface *surface; - - QPen pen; - - bool antialiased; - bool forceRasterPrimitives; - - bool simplePen; - - bool matrixRotShear; - enum Scale { NoScale, Scaled, NegativeScale } scale; - void setTransform(const QTransform &m); void setPen(const QPen &pen); void setCompositionMode(QPainter::CompositionMode mode); @@ -255,7 +243,6 @@ public: void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src); inline void updateClip(); - inline void setClipDirty(); void systemStateChanged(); void begin(QPaintDevice *device); @@ -268,10 +255,23 @@ public: #endif void prepareForBlit(bool alpha); +private: + IDirectFBSurface *surface; + + QPen pen; + + bool antialiased; + bool forceRasterPrimitives; + + bool simplePen; + + bool matrixRotShear; + enum Scale { NoScale, Scaled, NegativeScale } scale; + SurfaceCache *surfaceCache; QTransform transform; int lastLockedHeight; -private: + IDirectFB *fb; DFBSurfaceDescription fbDescription; int fbWidth; @@ -289,6 +289,7 @@ private: void *lockedMemory; QDirectFBPaintEngine *q; + friend class QDirectFBPaintEngine; }; QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device) @@ -322,7 +323,7 @@ bool QDirectFBPaintEngine::end() void QDirectFBPaintEngine::clipEnabledChanged() { Q_D(QDirectFBPaintEngine); - d->setClipDirty(); + d->dirtyClip = true; QRasterPaintEngine::clipEnabledChanged(); } @@ -370,7 +371,7 @@ void QDirectFBPaintEngine::setState(QPainterState *s) { Q_D(QDirectFBPaintEngine); QRasterPaintEngine::setState(s); - d->setClipDirty(); + d->dirtyClip = true; d->setPen(state()->pen); d->setOpacity(quint8(state()->opacity * 255)); d->setCompositionMode(state()->compositionMode()); @@ -380,7 +381,7 @@ void QDirectFBPaintEngine::setState(QPainterState *s) void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); - d->setClipDirty(); + d->dirtyClip = true; const QPoint bottom = d->transform.map(QPoint(0, path.controlPointRect().y2)); if (bottom.y() >= d->lastLockedHeight) d->lock(); @@ -390,7 +391,7 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); - d->setClipDirty(); + d->dirtyClip = true; if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); if (bottom.y() >= d->lastLockedHeight) @@ -839,11 +840,6 @@ bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased); } -void QDirectFBPaintEnginePrivate::setClipDirty() -{ - dirtyClip = true; -} - void QDirectFBPaintEnginePrivate::lock() { // We will potentially get a new pointer to the buffer after a @@ -1235,7 +1231,7 @@ void QDirectFBPaintEnginePrivate::updateClip() void QDirectFBPaintEnginePrivate::systemStateChanged() { - setClipDirty(); + dirtyClip = true; QRasterPaintEnginePrivate::systemStateChanged(); } -- cgit v0.12 From a1d2c3c589a03cc427dcc22d109003576add9500 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 6 May 2009 08:50:36 +1000 Subject: Fixes crash when mysql_init() returns 0 Task-number: 250632 --- src/sql/drivers/mysql/qsql_mysql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index a84e840..1f54db7 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -224,7 +224,7 @@ static QTextCodec* codec(MYSQL* mysql) static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type, const QMYSQLDriverPrivate* p) { - const char *cerr = mysql_error(p->mysql); + const char *cerr = p->mysql ? mysql_error(p->mysql) : 0; return QSqlError(QLatin1String("QMYSQL: ") + err, p->tc ? toUnicode(p->tc, cerr) : QString::fromLatin1(cerr), type, mysql_errno(p->mysql)); -- cgit v0.12