From 4da9590140c063551f261b883fb275cafe986b60 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 30 Mar 2010 07:19:47 +0200 Subject: Fix use of bitmap fonts on some Linux systems In 30bd59a1dec78 we added a fallback from font config to XLFD in the case where font config could not supply us with the correct pixel size for a given font. Primarily, this was for when you would try to print a bitmap font on a high resolution printer. This caused a problem for applications that set a point size on a bitmap font, since the calculated pixel size would not be available. For UIs you will usually prefer to select the font with the correct family but nearest pixel size here, which is what font config does. We would however choose the fallback and if XLFD failed to load the font in question, you would get a substitution. Since getting the correct font family seems more important than getting the correct pixel size, we disable the fallback in the case where XLFD does not find the correct font. This will fix the bug where UI fonts were frequently created with the wrong family on e.g. Fedora, and it might cause some trouble with printing bitmap fonts, however, it was deemed that bitmap fonts are not ideal fonts to use for printing. In cases where XLFD can load the bitmap fonts, the fallback will still be used. Task-number: QTBUG-4428 Reviewed-by: Trond --- src/gui/text/qfontdatabase_x11.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index b1ab478..3b2e4e9 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1939,8 +1939,13 @@ void QFontDatabase::load(const QFontPrivate *d, int script) fe = loadFc(d, script, req); if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize) { - delete fe; - fe = loadXlfd(d->screen, script, req); + QFontEngine *xlfdFontEngine = loadXlfd(d->screen, script, req); + if (xlfdFontEngine->fontDef.family == fe->fontDef.family) { + delete fe; + fe = xlfdFontEngine; + } else { + delete xlfdFontEngine; + } } -- cgit v0.12 From e56af88f159ceee5f9613ab57b2358601e79c081 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 6 Apr 2010 16:48:59 +0200 Subject: QTreeView: fix PageUp/PageDown with disabled items. The problem was seen in Qt Creator (in the 'Sources' tab of the debugger). Same logic as in above() and bellow() Reviewed-by: Gabriel --- src/gui/itemviews/qtreeview.cpp | 4 ++++ tests/auto/qtreeview/tst_qtreeview.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index d934683..c3ff2bd 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -3194,12 +3194,16 @@ void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninit int QTreeViewPrivate::pageUp(int i) const { int index = itemAtCoordinate(coordinateForItem(i) - viewport->height()); + while (isItemHiddenOrDisabled(index)) + index--; return index == -1 ? 0 : index; } int QTreeViewPrivate::pageDown(int i) const { int index = itemAtCoordinate(coordinateForItem(i) + viewport->height()); + while (isItemHiddenOrDisabled(index)) + index++; return index == -1 ? viewItems.count() - 1 : index; } diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 2de189d..75a4c62 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -215,6 +215,7 @@ private slots: void addRowsWhileSectionsAreHidden(); void filterProxyModelCrash(); void styleOptionViewItem(); + void keyboardNavigationWithDisabled(); // task-specific tests: void task174627_moveLeftToRoot(); @@ -3753,5 +3754,36 @@ void tst_QTreeView::taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint() QTRY_VERIFY(view.painted > 0); } +void tst_QTreeView::keyboardNavigationWithDisabled() +{ + QTreeView view; + QStandardItemModel model(90, 0); + for (int i = 0; i < 90; i ++) { + model.setItem(i, new QStandardItem(QString::number(i))); + model.item(i)->setEnabled(i%6 == 0); + } + view.setModel(&model); + + view.resize(200, view.visualRect(model.index(0,0)).height()*10); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(view.isActiveWindow()); + + view.setCurrentIndex(model.index(1, 0)); + QTest::keyClick(view.viewport(), Qt::Key_Up); + QCOMPARE(view.currentIndex(), model.index(0, 0)); + QTest::keyClick(view.viewport(), Qt::Key_Down); + QCOMPARE(view.currentIndex(), model.index(6, 0)); + QTest::keyClick(view.viewport(), Qt::Key_PageDown); + QCOMPARE(view.currentIndex(), model.index(18, 0)); + QTest::keyClick(view.viewport(), Qt::Key_Down); + QCOMPARE(view.currentIndex(), model.index(24, 0)); + QTest::keyClick(view.viewport(), Qt::Key_PageUp); + QCOMPARE(view.currentIndex(), model.index(12, 0)); + QTest::keyClick(view.viewport(), Qt::Key_Up); + QCOMPARE(view.currentIndex(), model.index(6, 0)); +} + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" -- cgit v0.12 From 6253ced81bcd60c04803f1a52bc59a239022b9c4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 7 Apr 2010 13:48:13 +0200 Subject: Revert "Update Phonon ds9 backend to 4.4.0." This reverts commit 19a3fc3bd817628070e5637caf158b0be79eee82. The phonon backend in 4.4.0 is outdated. Qt has the most recent one. Conflicts: src/3rdparty/phonon/ds9/iodevicereader.cpp --- src/3rdparty/phonon/ds9/abstractvideorenderer.cpp | 4 +- src/3rdparty/phonon/ds9/backend.cpp | 14 +- src/3rdparty/phonon/ds9/backend.h | 4 + src/3rdparty/phonon/ds9/backendnode.cpp | 19 ++ src/3rdparty/phonon/ds9/ds9.desktop | 17 +- src/3rdparty/phonon/ds9/effect.cpp | 4 +- src/3rdparty/phonon/ds9/fakesource.cpp | 34 +--- src/3rdparty/phonon/ds9/iodevicereader.cpp | 94 +++------- src/3rdparty/phonon/ds9/iodevicereader.h | 1 - src/3rdparty/phonon/ds9/mediagraph.cpp | 38 ++-- src/3rdparty/phonon/ds9/mediaobject.cpp | 201 +++++++++----------- src/3rdparty/phonon/ds9/mediaobject.h | 8 +- src/3rdparty/phonon/ds9/qasyncreader.cpp | 72 +++----- src/3rdparty/phonon/ds9/qasyncreader.h | 6 +- src/3rdparty/phonon/ds9/qaudiocdreader.cpp | 54 ++---- src/3rdparty/phonon/ds9/qaudiocdreader.h | 2 +- src/3rdparty/phonon/ds9/qbasefilter.cpp | 33 ++-- src/3rdparty/phonon/ds9/qbasefilter.h | 4 +- src/3rdparty/phonon/ds9/qevr9.h | 143 ++++++++++++++ src/3rdparty/phonon/ds9/qmeminputpin.cpp | 113 ++++-------- src/3rdparty/phonon/ds9/qmeminputpin.h | 9 +- src/3rdparty/phonon/ds9/qpin.cpp | 73 +++----- src/3rdparty/phonon/ds9/qpin.h | 7 +- src/3rdparty/phonon/ds9/videorenderer_default.cpp | 153 +++++++++++++++ src/3rdparty/phonon/ds9/videorenderer_default.h | 55 ++++++ src/3rdparty/phonon/ds9/videorenderer_evr.cpp | 215 ++++++++++++++++++++++ src/3rdparty/phonon/ds9/videorenderer_evr.h | 56 ++++++ src/3rdparty/phonon/ds9/videorenderer_soft.cpp | 15 +- src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp | 113 +----------- src/3rdparty/phonon/ds9/videorenderer_vmr9.h | 1 - src/3rdparty/phonon/ds9/videowidget.cpp | 50 ++++- src/3rdparty/phonon/ds9/volumeeffect.cpp | 5 +- src/3rdparty/phonon/ds9/volumeeffect.h | 2 +- src/plugins/phonon/ds9/ds9.pro | 2 + 34 files changed, 1001 insertions(+), 620 deletions(-) create mode 100644 src/3rdparty/phonon/ds9/qevr9.h create mode 100644 src/3rdparty/phonon/ds9/videorenderer_default.cpp create mode 100644 src/3rdparty/phonon/ds9/videorenderer_default.h create mode 100644 src/3rdparty/phonon/ds9/videorenderer_evr.cpp create mode 100644 src/3rdparty/phonon/ds9/videorenderer_evr.h diff --git a/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp b/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp index e932e70..a9d0694 100644 --- a/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp +++ b/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp @@ -99,8 +99,8 @@ namespace Phonon m_dstX = m_dstY = 0; if (ratio > 0) { - if (realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView - || realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop) { + if ((realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView) + || (realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop)) { //the height is correct, let's change the width m_dstWidth = qRound(realHeight * ratio); m_dstX = qRound((realWidth - realHeight * ratio) / 2.); diff --git a/src/3rdparty/phonon/ds9/backend.cpp b/src/3rdparty/phonon/ds9/backend.cpp index 2c56af7..fbc4bdc 100644 --- a/src/3rdparty/phonon/ds9/backend.cpp +++ b/src/3rdparty/phonon/ds9/backend.cpp @@ -41,6 +41,8 @@ namespace Phonon { namespace DS9 { + QMutex *Backend::directShowMutex = 0; + bool Backend::AudioMoniker::operator==(const AudioMoniker &other) { return other->IsEqual(*this) == S_OK; @@ -50,6 +52,8 @@ namespace Phonon Backend::Backend(QObject *parent, const QVariantList &) : QObject(parent) { + directShowMutex = &m_directShowMutex; + ::CoInitialize(0); //registering meta types @@ -62,6 +66,8 @@ namespace Phonon m_audioOutputs.clear(); m_audioEffects.clear(); ::CoUninitialize(); + + directShowMutex = 0; } QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList &args) @@ -131,6 +137,7 @@ namespace Phonon QList Backend::objectDescriptionIndexes(Phonon::ObjectDescriptionType type) const { + QMutexLocker locker(&m_directShowMutex); QList ret; switch(type) @@ -157,7 +164,7 @@ namespace Phonon while (S_OK == enumMon->Next(1, mon.pparam(), 0)) { LPOLESTR str = 0; mon->GetDisplayName(0,0,&str); - const QString name = QString::fromUtf16((unsigned short*)str); + const QString name = QString::fromWCharArray(str); ComPointer alloc; ::CoGetMalloc(1, alloc.pparam()); alloc->Free(str); @@ -204,6 +211,7 @@ namespace Phonon QHash Backend::objectDescriptionProperties(Phonon::ObjectDescriptionType type, int index) const { + QMutexLocker locker(&m_directShowMutex); QHash ret; switch (type) { @@ -216,7 +224,7 @@ namespace Phonon LPOLESTR str = 0; HRESULT hr = mon->GetDisplayName(0,0, &str); if (SUCCEEDED(hr)) { - QString name = QString::fromUtf16((unsigned short*)str); + QString name = QString::fromWCharArray(str); ComPointer alloc; ::CoGetMalloc(1, alloc.pparam()); alloc->Free(str); @@ -231,7 +239,7 @@ namespace Phonon WCHAR name[80]; // 80 is clearly stated in the MSDN doc HRESULT hr = ::DMOGetName(m_audioEffects[index], name); if (SUCCEEDED(hr)) { - ret["name"] = QString::fromUtf16((unsigned short*)name); + ret["name"] = QString::fromWCharArray(name); } } break; diff --git a/src/3rdparty/phonon/ds9/backend.h b/src/3rdparty/phonon/ds9/backend.h index ad638f2..7c3c109 100644 --- a/src/3rdparty/phonon/ds9/backend.h +++ b/src/3rdparty/phonon/ds9/backend.h @@ -23,6 +23,7 @@ along with this library. If not, see . #include #include +#include #include "compointer.h" #include "backendnode.h" @@ -63,6 +64,8 @@ namespace Phonon Filter getAudioOutputFilter(int index) const; + static QMutex *directShowMutex; + Q_SIGNALS: void objectDescriptionChanged(ObjectDescriptionType); @@ -74,6 +77,7 @@ namespace Phonon }; mutable QVector m_audioOutputs; mutable QVector m_audioEffects; + mutable QMutex m_directShowMutex; }; } } diff --git a/src/3rdparty/phonon/ds9/backendnode.cpp b/src/3rdparty/phonon/ds9/backendnode.cpp index 7e0b3cd..737ab7b 100644 --- a/src/3rdparty/phonon/ds9/backendnode.cpp +++ b/src/3rdparty/phonon/ds9/backendnode.cpp @@ -57,6 +57,25 @@ namespace Phonon BackendNode::~BackendNode() { + //this will remove the filter from the graph + FILTER_INFO info; + for(int i = 0; i < FILTER_COUNT; ++i) { + const Filter &filter = m_filters[i]; + if (!filter) + continue; + filter->QueryFilterInfo(&info); + if (info.pGraph) { + HRESULT hr = info.pGraph->RemoveFilter(filter); + + if (FAILED(hr) && m_mediaObject) { + m_mediaObject->ensureStopped(); + + hr = info.pGraph->RemoveFilter(filter); + } + Q_ASSERT(SUCCEEDED(hr)); + info.pGraph->Release(); + } + } } void BackendNode::setMediaObject(MediaObject *mo) diff --git a/src/3rdparty/phonon/ds9/ds9.desktop b/src/3rdparty/phonon/ds9/ds9.desktop index 1bc3451..764390e 100644 --- a/src/3rdparty/phonon/ds9/ds9.desktop +++ b/src/3rdparty/phonon/ds9/ds9.desktop @@ -5,13 +5,12 @@ MimeType=application/x-annodex;video/quicktime;video/x-quicktime;audio/x-m4a;app X-KDE-Library=phonon_ds9 X-KDE-PhononBackendInfo-InterfaceVersion=1 X-KDE-PhononBackendInfo-Version=0.1 -X-KDE-PhononBackendInfo-Website=http://www.trolltech.com/ +X-KDE-PhononBackendInfo-Website=http://qt.nokia.com/ InitialPreference=15 Name=DirectShow9 Name[bg]=DirectShow9 Name[ca]=DirectShow9 -Name[ca@valencia]=DirectShow9 Name[cs]=DirectShow9 Name[da]=DirectShow9 Name[de]=DirectShow9 @@ -20,14 +19,11 @@ Name[en_GB]=DirectShow9 Name[es]=DirectShow9 Name[et]=DirectShow9 Name[eu]=DirectShow9 -Name[fi]=DirectShow9 Name[fr]=DirectShow9 Name[ga]=DirectShow9 Name[gl]=DirectShow9 -Name[hr]=DirectShow9 Name[hsb]=DirectShow9 Name[hu]=DirectShow9 -Name[id]=DirectShow9 Name[is]=DirectShow9 Name[it]=DirectShow9 Name[ja]=DirectShow9 @@ -35,7 +31,6 @@ Name[ko]=DirectShow9 Name[ku]=DirectShow9 Name[lt]=DirectShow9 Name[lv]=DirectShow9 -Name[nb]=DirectShow9 Name[nds]=DirectShow9 Name[nl]=DirectShow9 Name[nn]=DirectShow9 @@ -43,13 +38,10 @@ Name[pa]=ਡਾਇਰੈਕਸ਼ੋ9 Name[pl]=DirectShow9 Name[pt]=DirectShow9 Name[pt_BR]=DirectShow9 -Name[ru]=DirectShow9 Name[se]=DirectShow9 Name[sk]=DirectShow 9 Name[sl]=DirectShow 9 Name[sr]=Директшоу‑9 -Name[sr@ijekavian]=Директшоу‑9 -Name[sr@ijekavianlatin]=DirectShow‑9 Name[sr@latin]=DirectShow‑9 Name[sv]=Directshow 9 Name[tr]=DirectShow9 @@ -61,7 +53,6 @@ Name[zh_TW]=DirectShow9 Comment=Phonon DirectShow9 backend Comment[bg]=Phonon DirectShow9 Comment[ca]=Dorsal DirectShow9 del Phonon -Comment[ca@valencia]=Dorsal DirectShow9 del Phonon Comment[cs]=Phonon DirectShow9 backend Comment[da]=DirectShow9-backend til Phonon Comment[de]=Phonon-Treiber für DirectShow9 @@ -70,13 +61,11 @@ Comment[en_GB]=Phonon DirectShow9 backend Comment[es]=Motor DirectShow9 para Phonon Comment[et]=Phononi DirectShow9 taustaprogramm Comment[eu]=Phonon DirectShow9 backend -Comment[fi]=Phonon DirectShow9-taustaohjelma Comment[fr]=Système de gestion DirectShow9 pour Phonon Comment[ga]=Inneall DirectShow9 le haghaidh Phonon Comment[gl]=Infraestrutura de DirectShow9 para Phonon Comment[hsb]=Phonon DirectShow9 backend Comment[hu]=Phonon DirectShow9 modul -Comment[id]=Phonon DirectShow9 backend Comment[is]=Phonon DirectShow9 bakendi Comment[it]=Motore DirectShow9 di Phonon Comment[ja]=Phonon DirectShow9 バックエンド @@ -84,7 +73,6 @@ Comment[ko]=Phonon DirectShow9 백엔드 Comment[ku]=Binesaza Phonon DirectShow9 Comment[lt]=Phonon DirectShow9 galinė sąsaja Comment[lv]=Phonon DirectShow9 aizmugure -Comment[nb]=Phonon-motor for DirectShow9 Comment[nds]=Phonon-Hülpprogrmm DirectShow9 Comment[nl]=DirectShow9-backend (Phonon) Comment[nn]=Phonon-motor for DirectShow9 @@ -92,13 +80,10 @@ Comment[pa]=ਫੋਨੋਨ ਡਾਇਰੈਕਟਸ਼ੋ9 ਬੈਕਐਂਡ Comment[pl]=Obsługa DirectShow9 przez Phonon Comment[pt]=Infra-estrutura do DirectShow9 para o Phonon Comment[pt_BR]=Infraestrutura Phonon DirectShow9 -Comment[ru]=Механизм DirectShow9 для Phonon Comment[se]=Phonon DirectShow9 duogášmohtor Comment[sk]=Phonon DirectShow 9 podsystém Comment[sl]=Phononova Hrbtenica DirectShow 9 Comment[sr]=Директшоу‑9 као позадина Фонона -Comment[sr@ijekavian]=Директшоу‑9 као позадина Фонона -Comment[sr@ijekavianlatin]=DirectShow‑9 kao pozadina Phonona Comment[sr@latin]=DirectShow‑9 kao pozadina Phonona Comment[sv]=Phonon Directshow 9-gränssnitt Comment[tr]=Phonon DirectShow9 arka ucu diff --git a/src/3rdparty/phonon/ds9/effect.cpp b/src/3rdparty/phonon/ds9/effect.cpp index 104a3c1..ebe976b 100644 --- a/src/3rdparty/phonon/ds9/effect.cpp +++ b/src/3rdparty/phonon/ds9/effect.cpp @@ -82,7 +82,7 @@ namespace Phonon current += wcslen(current) + 1; //skip the name current += wcslen(current) + 1; //skip the unit for(; *current; current += wcslen(current) + 1) { - values.append( QString::fromUtf16((unsigned short*)current) ); + values.append( QString::fromWCharArray(current) ); } } //FALLTHROUGH @@ -107,7 +107,7 @@ namespace Phonon Phonon::EffectParameter::Hints hint = info.mopCaps == MP_CAPS_CURVE_INVSQUARE ? Phonon::EffectParameter::LogarithmicHint : Phonon::EffectParameter::Hints(0); - const QString n = QString::fromUtf16((unsigned short*)name); + const QString n = QString::fromWCharArray(name); ret.append(Phonon::EffectParameter(i, n, hint, def, min, max, values)); ::CoTaskMemFree(name); //let's free the memory } diff --git a/src/3rdparty/phonon/ds9/fakesource.cpp b/src/3rdparty/phonon/ds9/fakesource.cpp index 9a61a2e..4dce138 100644 --- a/src/3rdparty/phonon/ds9/fakesource.cpp +++ b/src/3rdparty/phonon/ds9/fakesource.cpp @@ -29,8 +29,10 @@ namespace Phonon namespace DS9 { static WAVEFORMATEX g_defaultWaveFormat = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; - static BITMAPINFOHEADER g_defautBitmapHeader = { sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}; - static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, {0}, 0, {sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0} }; + + static const AM_MEDIA_TYPE g_fakeAudioType = {MEDIATYPE_Audio, MEDIASUBTYPE_PCM, 0, 0, 2, FORMAT_WaveFormatEx, 0, sizeof(WAVEFORMATEX), reinterpret_cast(&g_defaultWaveFormat)}; + static const AM_MEDIA_TYPE g_fakeVideoType = {MEDIATYPE_Video, MEDIASUBTYPE_RGB32, TRUE, FALSE, 0, FORMAT_VideoInfo2, 0, sizeof(VIDEOINFOHEADER2), reinterpret_cast(&g_defaultVideoInfo)}; class FakePin : public QPin { @@ -128,36 +130,12 @@ namespace Phonon void FakeSource::createFakeAudioPin() { - AM_MEDIA_TYPE mt; - qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); - mt.majortype = MEDIATYPE_Audio; - mt.subtype = MEDIASUBTYPE_PCM; - mt.formattype = FORMAT_WaveFormatEx; - mt.lSampleSize = 2; - - //fake the format (stereo 44.1 khz stereo 16 bits) - mt.cbFormat = sizeof(WAVEFORMATEX); - mt.pbFormat = reinterpret_cast(&g_defaultWaveFormat); - - new FakePin(this, mt); + new FakePin(this, g_fakeAudioType); } void FakeSource::createFakeVideoPin() { - AM_MEDIA_TYPE mt; - qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); - mt.majortype = MEDIATYPE_Video; - mt.subtype = MEDIASUBTYPE_RGB32; - mt.formattype = FORMAT_VideoInfo2; - mt.bFixedSizeSamples = 1; - - g_defaultVideoInfo.bmiHeader = g_defautBitmapHeader; - - //fake the format - mt.cbFormat = sizeof(VIDEOINFOHEADER2); - mt.pbFormat = reinterpret_cast(&g_defaultVideoInfo); - - new FakePin(this, mt); + new FakePin(this, g_fakeVideoType); } } diff --git a/src/3rdparty/phonon/ds9/iodevicereader.cpp b/src/3rdparty/phonon/ds9/iodevicereader.cpp index 9152712..ba4ae5c 100644 --- a/src/3rdparty/phonon/ds9/iodevicereader.cpp +++ b/src/3rdparty/phonon/ds9/iodevicereader.cpp @@ -36,18 +36,20 @@ namespace Phonon //these mediatypes define a stream, its type will be autodetected by DirectShow static QVector getMediaTypes() { - AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; + //the order here is important because otherwise, + //directshow might not be able to detect the stream type correctly + + AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_Avi, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; QVector ret; - //normal auto-detect stream - mt.subtype = MEDIASUBTYPE_NULL; - ret << mt; //AVI stream - mt.subtype = MEDIASUBTYPE_Avi; ret << mt; //WAVE stream mt.subtype = MEDIASUBTYPE_WAVE; ret << mt; + //normal auto-detect stream (must be at the end!) + mt.subtype = MEDIASUBTYPE_NULL; + ret << mt; return ret; } @@ -64,7 +66,6 @@ namespace Phonon //for Phonon::StreamInterface void writeData(const QByteArray &data) { - QWriteLocker locker(&m_lock); m_pos += data.size(); m_buffer += data; } @@ -75,54 +76,22 @@ namespace Phonon void setStreamSize(qint64 newSize) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_size = newSize; } - qint64 streamSize() const - { - QReadLocker locker(&m_lock); - return m_size; - } - void setStreamSeekable(bool s) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_seekable = s; } - bool streamSeekable() const - { - QReadLocker locker(&m_lock); - return m_seekable; - } - - void setCurrentPos(qint64 pos) - { - QWriteLocker locker(&m_lock); - m_pos = pos; - seekStream(pos); - m_buffer.clear(); - } - - qint64 currentPos() const - { - QReadLocker locker(&m_lock); - return m_pos; - } - - int currentBufferSize() const - { - QReadLocker locker(&m_lock); - return m_buffer.size(); - } - //virtual pure members //implementation from IAsyncReader STDMETHODIMP Length(LONGLONG *total, LONGLONG *available) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (total) { *total = m_size; } @@ -137,37 +106,39 @@ namespace Phonon HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) { - QMutexLocker locker(&m_mutexRead); + Q_ASSERT(!m_mutex.tryLock()); + if (m_mediaGraph->isStopping()) { + return VFW_E_WRONG_STATE; + } - if(streamSize() != 1 && pos + length > streamSize()) { + if(m_size != 1 && pos + length > m_size) { //it tries to read outside of the boundaries return E_FAIL; } - if (currentPos() - currentBufferSize() != pos) { - if (!streamSeekable()) { + if (m_pos - m_buffer.size() != pos) { + if (!m_seekable) { return S_FALSE; } - setCurrentPos(pos); + m_pos = pos; + seekStream(pos); + m_buffer.clear(); } - int oldSize = currentBufferSize(); - while (currentBufferSize() < int(length)) { + int oldSize = m_buffer.size(); + while (m_buffer.size() < int(length)) { needData(); - if (oldSize == currentBufferSize()) { + if (oldSize == m_buffer.size()) { break; //we didn't get any data } - oldSize = currentBufferSize(); + oldSize = m_buffer.size(); } - DWORD bytesRead = qMin(currentBufferSize(), int(length)); - { - QWriteLocker locker(&m_lock); - qMemCopy(buffer, m_buffer.data(), bytesRead); - //truncate the buffer - m_buffer = m_buffer.mid(bytesRead); - } + int bytesRead = qMin(m_buffer.size(), int(length)); + qMemCopy(buffer, m_buffer.data(), bytesRead); + //truncate the buffer + m_buffer = m_buffer.mid(bytesRead); if (actual) { *actual = bytesRead; //initialization @@ -183,7 +154,6 @@ namespace Phonon qint64 m_pos; qint64 m_size; - QMutex m_mutexRead; const MediaGraph *m_mediaGraph; }; @@ -197,14 +167,6 @@ namespace Phonon IODeviceReader::~IODeviceReader() { } - - STDMETHODIMP IODeviceReader::Stop() - { - HRESULT hr = QBaseFilter::Stop(); - m_streamReader->enoughData(); //this asks to cancel any blocked call to needData - return hr; - } - } } diff --git a/src/3rdparty/phonon/ds9/iodevicereader.h b/src/3rdparty/phonon/ds9/iodevicereader.h index af4b271..c8b91c3 100644 --- a/src/3rdparty/phonon/ds9/iodevicereader.h +++ b/src/3rdparty/phonon/ds9/iodevicereader.h @@ -41,7 +41,6 @@ namespace Phonon public: IODeviceReader(const MediaSource &source, const MediaGraph *); ~IODeviceReader(); - STDMETHODIMP Stop(); private: StreamReader *m_streamReader; diff --git a/src/3rdparty/phonon/ds9/mediagraph.cpp b/src/3rdparty/phonon/ds9/mediagraph.cpp index db0ec84..3e7a68b 100644 --- a/src/3rdparty/phonon/ds9/mediagraph.cpp +++ b/src/3rdparty/phonon/ds9/mediagraph.cpp @@ -68,6 +68,8 @@ namespace Phonon return ret; } + +/* static HRESULT saveToFile(Graph graph, const QString &filepath) { const WCHAR wszStreamName[] = L"ActiveMovieGraph"; @@ -103,7 +105,7 @@ namespace Phonon return hr; } - +*/ MediaGraph::MediaGraph(MediaObject *mo, short index) : m_graph(CLSID_FilterGraph, IID_IGraphBuilder), @@ -377,11 +379,12 @@ namespace Phonon FILTER_INFO info; filter->QueryFilterInfo(&info); #ifdef GRAPH_DEBUG - qDebug() << "removeFilter" << QString::fromUtf16(info.achName); + qDebug() << "removeFilter" << QString((const QChar *)info.achName); #endif if (info.pGraph) { info.pGraph->Release(); - return m_graph->RemoveFilter(filter); + if (info.pGraph == m_graph) + return m_graph->RemoveFilter(filter); } //already removed @@ -537,11 +540,11 @@ namespace Phonon const QList outputs = BackendNode::pins(filter, PINDIR_OUTPUT); for(int i = 0; i < outputs.count(); ++i) { const OutputPin &pin = outputs.at(i); - if (VFW_E_NOT_CONNECTED == pin->ConnectedTo(inPin.pparam())) { + if (HRESULT(VFW_E_NOT_CONNECTED) == pin->ConnectedTo(inPin.pparam())) { return SUCCEEDED(pin->Connect(newIn, 0)); } } - //we should never go here + //we shoud never go here return false; } else { QAMMediaType type; @@ -679,7 +682,6 @@ namespace Phonon #ifndef QT_NO_PHONON_MEDIACONTROLLER } else if (source.discType() == Phonon::Cd) { m_realSource = Filter(new QAudioCDPlayer); - m_result = m_graph->AddFilter(m_realSource, 0); #endif //QT_NO_PHONON_MEDIACONTROLLER } else { @@ -809,7 +811,7 @@ namespace Phonon for (int i = 0; i < outputs.count(); ++i) { const OutputPin &out = outputs.at(i); InputPin pin; - if (out->ConnectedTo(pin.pparam()) == VFW_E_NOT_CONNECTED) { + if (out->ConnectedTo(pin.pparam()) == HRESULT(VFW_E_NOT_CONNECTED)) { m_decoderPins += out; //unconnected outputs can be decoded outputs } } @@ -820,7 +822,7 @@ namespace Phonon //let's reestablish the connections for (int i = 0; i < connections.count(); ++i) { const GraphConnection &connection = connections.at(i); - //check if we should transfer the sink node + //check if we shoud transfer the sink node grabFilter(connection.input); grabFilter(connection.output); @@ -873,7 +875,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); + qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -919,7 +921,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << "found a decoder filter" << QString::fromUtf16(info.achName); + qDebug() << "found a decoder filter" << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -935,7 +937,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); + qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -954,7 +956,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName); + qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -988,7 +990,7 @@ namespace Phonon { FILTER_INFO info; filter->QueryFilterInfo(&info); - qDebug() << "found a demuxer filter" << QString::fromUtf16(info.achName); + qDebug() << "found a demuxer filter" << QString((const QChar *)info.achName); if (info.pGraph) { info.pGraph->Release(); } @@ -1006,27 +1008,27 @@ namespace Phonon BSTR str; HRESULT hr = mediaContent->get_AuthorName(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("ARTIST"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("ARTIST"), QString::fromWCharArray(str)); SysFreeString(str); } hr = mediaContent->get_Title(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("TITLE"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("TITLE"), QString::fromWCharArray(str)); SysFreeString(str); } hr = mediaContent->get_Description(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("DESCRIPTION"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("DESCRIPTION"), QString::fromWCharArray(str)); SysFreeString(str); } hr = mediaContent->get_Copyright(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("COPYRIGHT"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("COPYRIGHT"), QString::fromWCharArray(str)); SysFreeString(str); } hr = mediaContent->get_MoreInfoText(&str); if (SUCCEEDED(hr)) { - ret.insert(QLatin1String("MOREINFO"), QString::fromUtf16((const unsigned short*)str)); + ret.insert(QLatin1String("MOREINFO"), QString::fromWCharArray(str)); SysFreeString(str); } } diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp index d1e15c0..34f92c2 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.cpp +++ b/src/3rdparty/phonon/ds9/mediaobject.cpp @@ -23,11 +23,10 @@ along with this library. If not, see . #ifndef Q_CC_MSVC #include -#endif //Q_CC_MSVC +#endif #include #include #include -#include #include #include "mediaobject.h" @@ -50,7 +49,7 @@ namespace Phonon //first the definition of the WorkerThread class WorkerThread::WorkerThread() - : QThread(), m_currentRenderId(0), m_finished(false), m_currentWorkId(1) + : QThread(), m_finished(false), m_currentWorkId(1) { } @@ -58,24 +57,6 @@ namespace Phonon { } - WorkerThread::Work WorkerThread::dequeueWork() - { - QMutexLocker locker(&m_mutex); - if (m_finished) { - return Work(); - } - Work ret = m_queue.dequeue(); - - //we ensure to have the wait condition in the right state - if (m_queue.isEmpty()) { - m_waitCondition.reset(); - } else { - m_waitCondition.set(); - } - - return ret; - } - void WorkerThread::run() { while (m_finished == false) { @@ -89,11 +70,6 @@ namespace Phonon } DWORD result = ::WaitForMultipleObjects(count, handles, FALSE, INFINITE); if (result == WAIT_OBJECT_0) { - if (m_finished) { - //that's the end of the thread execution - return; - } - handleTask(); } else { //this is the event management @@ -181,6 +157,7 @@ namespace Phonon //we create a new graph w.graph = Graph(CLSID_FilterGraph, IID_IGraphBuilder); w.filter = filter; + w.graph->AddFilter(filter, 0); w.id = m_currentWorkId++; m_queue.enqueue(w); m_waitCondition.set(); @@ -200,23 +177,29 @@ namespace Phonon void WorkerThread::handleTask() { - const Work w = dequeueWork(); + QMutexLocker locker(Backend::directShowMutex); + { + QMutexLocker locker(&m_mutex); + if (m_finished || m_queue.isEmpty()) { + return; + } - if (m_finished) { - return; + m_currentWork = m_queue.dequeue(); + + //we ensure to have the wait condition in the right state + if (m_queue.isEmpty()) { + m_waitCondition.reset(); + } else { + m_waitCondition.set(); + } } HRESULT hr = S_OK; - m_currentRender = w.graph; - m_currentRenderId = w.id; - if (w.task == ReplaceGraph) { - QMutexLocker locker(&m_mutex); - HANDLE h; - + if (m_currentWork.task == ReplaceGraph) { int index = -1; for(int i = 0; i < FILTER_COUNT; ++i) { - if (m_graphHandle[i].graph == w.oldGraph) { + if (m_graphHandle[i].graph == m_currentWork.oldGraph) { m_graphHandle[i].graph = Graph(); index = i; break; @@ -229,51 +212,40 @@ namespace Phonon Q_ASSERT(index != -1); //add the new graph - if (SUCCEEDED(ComPointer(w.graph, IID_IMediaEvent) + HANDLE h; + if (SUCCEEDED(ComPointer(m_currentWork.graph, IID_IMediaEvent) ->GetEventHandle(reinterpret_cast(&h)))) { - m_graphHandle[index].graph = w.graph; + m_graphHandle[index].graph = m_currentWork.graph; m_graphHandle[index].handle = h; } - } else if (w.task == Render) { - if (w.filter) { + } else if (m_currentWork.task == Render) { + if (m_currentWork.filter) { //let's render pins - w.graph->AddFilter(w.filter, 0); - const QList outputs = BackendNode::pins(w.filter, PINDIR_OUTPUT); - for (int i = 0; i < outputs.count(); ++i) { - //blocking call - hr = w.graph->Render(outputs.at(i)); - if (FAILED(hr)) { - break; - } + const QList outputs = BackendNode::pins(m_currentWork.filter, PINDIR_OUTPUT); + for (int i = 0; SUCCEEDED(hr) && i < outputs.count(); ++i) { + hr = m_currentWork.graph->Render(outputs.at(i)); } - } else if (!w.url.isEmpty()) { + } else if (!m_currentWork.url.isEmpty()) { //let's render a url (blocking call) - hr = w.graph->RenderFile(reinterpret_cast(w.url.utf16()), 0); + hr = m_currentWork.graph->RenderFile(reinterpret_cast(m_currentWork.url.utf16()), 0); } if (hr != E_ABORT) { - emit asyncRenderFinished(w.id, hr, w.graph); + emit asyncRenderFinished(m_currentWork.id, hr, m_currentWork.graph); } - } else if (w.task == Seek) { + } else if (m_currentWork.task == Seek) { //that's a seekrequest - ComPointer mediaSeeking(w.graph, IID_IMediaSeeking); - qint64 newtime = w.time * 10000; + ComPointer mediaSeeking(m_currentWork.graph, IID_IMediaSeeking); + qint64 newtime = m_currentWork.time * 10000; hr = mediaSeeking->SetPositions(&newtime, AM_SEEKING_AbsolutePositioning, 0, AM_SEEKING_NoPositioning); - qint64 currentTime = -1; - if (SUCCEEDED(hr)) { - hr = mediaSeeking->GetCurrentPosition(¤tTime); - if (SUCCEEDED(hr)) { - currentTime /= 10000; //convert to ms - } - } - emit asyncSeekingFinished(w.id, currentTime); + emit asyncSeekingFinished(m_currentWork.id, newtime / 10000); hr = E_ABORT; //to avoid emitting asyncRenderFinished - } else if (w.task == ChangeState) { + } else if (m_currentWork.task == ChangeState) { //remove useless decoders QList unused; - for (int i = 0; i < w.decoders.count(); ++i) { - const Filter &filter = w.decoders.at(i); + for (int i = 0; i < m_currentWork.decoders.count(); ++i) { + const Filter &filter = m_currentWork.decoders.at(i); bool used = false; const QList pins = BackendNode::pins(filter, PINDIR_OUTPUT); for( int i = 0; i < pins.count(); ++i) { @@ -290,15 +262,15 @@ namespace Phonon //we can get the state for (int i = 0; i < unused.count(); ++i) { //we should remove this filter from the graph - w.graph->RemoveFilter(unused.at(i)); + m_currentWork.graph->RemoveFilter(unused.at(i)); } //we can get the state - ComPointer mc(w.graph, IID_IMediaControl); + ComPointer mc(m_currentWork.graph, IID_IMediaControl); //we change the state here - switch(w.state) + switch(m_currentWork.state) { case State_Stopped: mc->Stop(); @@ -316,36 +288,38 @@ namespace Phonon if (SUCCEEDED(hr)) { if (s == State_Stopped) { - emit stateReady(w.graph, Phonon::StoppedState); + emit stateReady(m_currentWork.graph, Phonon::StoppedState); } else if (s == State_Paused) { - emit stateReady(w.graph, Phonon::PausedState); + emit stateReady(m_currentWork.graph, Phonon::PausedState); } else /*if (s == State_Running)*/ { - emit stateReady(w.graph, Phonon::PlayingState); + emit stateReady(m_currentWork.graph, Phonon::PlayingState); } } } - m_currentRender = Graph(); - m_currentRenderId = 0; - + { + QMutexLocker locker(&m_mutex); + m_currentWork = Work(); //reinitialize + } } - void WorkerThread::abortCurrentRender(qint16 renderId) - { + void WorkerThread::abortCurrentRender(qint16 renderId) + { QMutexLocker locker(&m_mutex); + if (m_currentWork.id == renderId) { + m_currentWork.graph->Abort(); + } bool found = false; - //we try to see if there is already an attempt to seek and we remove it for(int i = 0; !found && i < m_queue.size(); ++i) { const Work &w = m_queue.at(i); if (w.id == renderId) { found = true; m_queue.removeAt(i); + if (m_queue.isEmpty()) { + m_waitCondition.reset(); + } } } - - if (m_currentRender && m_currentRenderId == renderId) { - m_currentRender->Abort(); - } } //tells the thread to stop processing @@ -353,9 +327,9 @@ namespace Phonon { QMutexLocker locker(&m_mutex); m_queue.clear(); - if (m_currentRender) { + if (m_currentWork.graph) { //in case we're currently rendering something - m_currentRender->Abort(); + m_currentWork.graph->Abort(); } @@ -387,17 +361,17 @@ namespace Phonon m_graphs[i] = new MediaGraph(this, i); } - connect(&m_thread, SIGNAL(stateReady(Graph, Phonon::State)), - SLOT(slotStateReady(Graph, Phonon::State))); + connect(&m_thread, SIGNAL(stateReady(Graph,Phonon::State)), + SLOT(slotStateReady(Graph,Phonon::State))); - connect(&m_thread, SIGNAL(eventReady(Graph, long, long)), - SLOT(handleEvents(Graph, long, long))); + connect(&m_thread, SIGNAL(eventReady(Graph,long,long)), + SLOT(handleEvents(Graph,long,long))); - connect(&m_thread, SIGNAL(asyncRenderFinished(quint16, HRESULT, Graph)), - SLOT(finishLoading(quint16, HRESULT, Graph))); + connect(&m_thread, SIGNAL(asyncRenderFinished(quint16,HRESULT,Graph)), + SLOT(finishLoading(quint16,HRESULT,Graph))); - connect(&m_thread, SIGNAL(asyncSeekingFinished(quint16, qint64)), - SLOT(finishSeeking(quint16, qint64))); + connect(&m_thread, SIGNAL(asyncSeekingFinished(quint16,qint64)), + SLOT(finishSeeking(quint16,qint64))); //really special case m_mediaObject = this; m_thread.start(); @@ -520,6 +494,18 @@ namespace Phonon qSwap(m_graphs[0], m_graphs[1]); //swap the graphs + if (m_transitionTime >= 0) + m_graphs[1]->stop(); //make sure we stop the previous graph + + if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid && + catchComError(currentGraph()->renderResult())) { + setState(Phonon::ErrorState); + return; + } + + //we need to play the next media + play(); + //we tell the video widgets to switch now to the new source #ifndef QT_NO_PHONON_VIDEO for (int i = 0; i < m_videoWidgets.count(); ++i) { @@ -528,15 +514,6 @@ namespace Phonon #endif //QT_NO_PHONON_VIDEO emit currentSourceChanged(currentGraph()->mediaSource()); - - if (currentGraph()->isLoading()) { - //will simply tell that when loading is finished - //it should start the playback - play(); - } - - - emit metaDataChanged(currentGraph()->metadata()); if (nextGraph()->hasVideo() != currentGraph()->hasVideo()) { @@ -549,15 +526,6 @@ namespace Phonon #ifndef QT_NO_PHONON_MEDIACONTROLLER setTitles(currentGraph()->titles()); #endif //QT_NO_PHONON_MEDIACONTROLLER - - //this manages only gapless transitions - if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid) { - if (catchComError(currentGraph()->renderResult())) { - setState(Phonon::ErrorState); - } else { - play(); - } - } } Phonon::State MediaObject::state() const @@ -792,15 +760,16 @@ namespace Phonon case Phonon::PausedState: pause(); break; - case Phonon::StoppedState: - stop(); - break; case Phonon::PlayingState: play(); break; case Phonon::ErrorState: setState(Phonon::ErrorState); break; + case Phonon::StoppedState: + default: + stop(); + break; } } } @@ -848,11 +817,11 @@ namespace Phonon #endif LPAMGETERRORTEXT getErrorText = (LPAMGETERRORTEXT)QLibrary::resolve(QLatin1String("quartz"), "AMGetErrorTextW"); - ushort buffer[MAX_ERROR_TEXT_LEN]; - if (getErrorText && getErrorText(hr, (WCHAR*)buffer, MAX_ERROR_TEXT_LEN)) { - m_errorString = QString::fromUtf16(buffer); + WCHAR buffer[MAX_ERROR_TEXT_LEN]; + if (getErrorText && getErrorText(hr, buffer, MAX_ERROR_TEXT_LEN)) { + m_errorString = QString::fromWCharArray(buffer); } else { - m_errorString = QString::fromUtf16((ushort*)_com_error(hr).ErrorMessage()); + m_errorString = QString::fromLatin1("Unknown error"); } const QString comError = QString::number(uint(hr), 16); if (!m_errorString.toLower().contains(comError.toLower())) { diff --git a/src/3rdparty/phonon/ds9/mediaobject.h b/src/3rdparty/phonon/ds9/mediaobject.h index 2c34ffc..34aa666 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.h +++ b/src/3rdparty/phonon/ds9/mediaobject.h @@ -114,6 +114,7 @@ namespace Phonon enum Task { + None, Render, Seek, ChangeState, @@ -122,6 +123,7 @@ namespace Phonon struct Work { + Work() : task(None), id(0), time(0) { } Task task; quint16 id; Graph graph; @@ -135,16 +137,14 @@ namespace Phonon }; QList decoders; //for the state change requests }; - Work dequeueWork(); void handleTask(); - Graph m_currentRender; - qint16 m_currentRenderId; + Work m_currentWork; QQueue m_queue; bool m_finished; quint16 m_currentWorkId; QWinWaitCondition m_waitCondition; - QMutex m_mutex; + QMutex m_mutex; // mutex for the m_queue, m_finished and m_currentWorkId //this is for WaitForMultipleObjects struct diff --git a/src/3rdparty/phonon/ds9/qasyncreader.cpp b/src/3rdparty/phonon/ds9/qasyncreader.cpp index 68ec1f8..a3f9cda 100644 --- a/src/3rdparty/phonon/ds9/qasyncreader.cpp +++ b/src/3rdparty/phonon/ds9/qasyncreader.cpp @@ -15,8 +15,6 @@ You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ -#include - #include "qasyncreader.h" #include "qbasefilter.h" @@ -80,8 +78,7 @@ namespace Phonon STDMETHODIMP QAsyncReader::Request(IMediaSample *sample,DWORD_PTR user) { - QMutexLocker mutexLocker(&m_mutexWait); - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (m_flushing) { return VFW_E_WRONG_STATE; } @@ -93,33 +90,28 @@ namespace Phonon STDMETHODIMP QAsyncReader::WaitForNext(DWORD timeout, IMediaSample **sample, DWORD_PTR *user) { - QMutexLocker locker(&m_mutexWait); + QMutexLocker locker(&m_mutex); if (!sample ||!user) { return E_POINTER; } + //msdn says to return immediately if we're flushing but that doesn't seem to be true + //since it triggers a dead-lock somewhere inside directshow (see task 258830) + *sample = 0; *user = 0; - AsyncRequest r = getNextRequest(); - - if (r.sample == 0) { - //there is no request in the queue - if (isFlushing()) { + if (m_requestQueue.isEmpty()) { + if (m_requestWait.wait(&m_mutex, timeout) == false) { + return VFW_E_TIMEOUT; + } + if (m_requestQueue.isEmpty()) { return VFW_E_WRONG_STATE; - } else { - //First we need to lock the mutex - if (m_requestWait.wait(&m_mutexWait, timeout) == false) { - return VFW_E_TIMEOUT; - } - if (isFlushing()) { - return VFW_E_WRONG_STATE; - } - - r = getNextRequest(); } } + AsyncRequest r = m_requestQueue.dequeue(); + //at this point we're sure to have a request to proceed if (r.sample == 0) { return E_FAIL; @@ -127,14 +119,12 @@ namespace Phonon *sample = r.sample; *user = r.user; - - return SyncReadAligned(r.sample); + return syncReadAlignedUnlocked(r.sample); } STDMETHODIMP QAsyncReader::BeginFlush() { - QMutexLocker mutexLocker(&m_mutexWait); - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_flushing = true; m_requestWait.wakeOne(); return S_OK; @@ -142,13 +132,28 @@ namespace Phonon STDMETHODIMP QAsyncReader::EndFlush() { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_flushing = false; return S_OK; } STDMETHODIMP QAsyncReader::SyncReadAligned(IMediaSample *sample) { + QMutexLocker locker(&m_mutex); + return syncReadAlignedUnlocked(sample); + } + + STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer) + { + QMutexLocker locker(&m_mutex); + return read(pos, length, buffer, 0); + } + + + STDMETHODIMP QAsyncReader::syncReadAlignedUnlocked(IMediaSample *sample) + { + Q_ASSERT(!m_mutex.tryLock()); + if (!sample) { return E_POINTER; } @@ -175,23 +180,6 @@ namespace Phonon return sample->SetActualDataLength(actual); } - STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer) - { - return read(pos, length, buffer, 0); - } - - - //addition - QAsyncReader::AsyncRequest QAsyncReader::getNextRequest() - { - QWriteLocker locker(&m_lock); - AsyncRequest ret; - if (!m_requestQueue.isEmpty()) { - ret = m_requestQueue.dequeue(); - } - - return ret; - } } } diff --git a/src/3rdparty/phonon/ds9/qasyncreader.h b/src/3rdparty/phonon/ds9/qasyncreader.h index cb789ee..95872f9 100644 --- a/src/3rdparty/phonon/ds9/qasyncreader.h +++ b/src/3rdparty/phonon/ds9/qasyncreader.h @@ -48,11 +48,12 @@ namespace Phonon STDMETHODIMP WaitForNext(DWORD,IMediaSample **,DWORD_PTR *); STDMETHODIMP SyncReadAligned(IMediaSample *); STDMETHODIMP SyncRead(LONGLONG,LONG,BYTE *); - virtual STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0; + STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0; STDMETHODIMP BeginFlush(); STDMETHODIMP EndFlush(); protected: + STDMETHODIMP syncReadAlignedUnlocked(IMediaSample *); virtual HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) = 0; private: @@ -62,9 +63,6 @@ namespace Phonon IMediaSample *sample; DWORD_PTR user; }; - AsyncRequest getNextRequest(); - - QMutex m_mutexWait; QQueue m_requestQueue; QWaitCondition m_requestWait; diff --git a/src/3rdparty/phonon/ds9/qaudiocdreader.cpp b/src/3rdparty/phonon/ds9/qaudiocdreader.cpp index b9f9fd6..6d0f335 100644 --- a/src/3rdparty/phonon/ds9/qaudiocdreader.cpp +++ b/src/3rdparty/phonon/ds9/qaudiocdreader.cpp @@ -103,8 +103,8 @@ namespace Phonon private: HANDLE m_cddrive; - CDROM_TOC *m_toc; - WaveStructure *m_waveHeader; + CDROM_TOC m_toc; + WaveStructure m_waveHeader; qint64 m_trackAddress; }; @@ -112,19 +112,8 @@ namespace Phonon #define SECTOR_SIZE 2352 #define NB_SECTORS_READ 20 - static AM_MEDIA_TYPE getAudioCDMediaType() - { - AM_MEDIA_TYPE mt; - qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); - mt.majortype = MEDIATYPE_Stream; - mt.subtype = MEDIASUBTYPE_WAVE; - mt.bFixedSizeSamples = TRUE; - mt.bTemporalCompression = FALSE; - mt.lSampleSize = 1; - mt.formattype = GUID_NULL; - return mt; - } - + static const AM_MEDIA_TYPE audioCDMediaType = { MEDIATYPE_Stream, MEDIASUBTYPE_WAVE, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; + int addressToSectors(UCHAR address[4]) { return ((address[0] * 60 + address[1]) * 60 + address[2]) * 75 + address[3] - 150; @@ -141,11 +130,8 @@ namespace Phonon } - QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector() << getAudioCDMediaType()) + QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector() << audioCDMediaType) { - m_toc = new CDROM_TOC; - m_waveHeader = new WaveStructure; - //now open the cd-drive QString path; if (drive.isNull()) { @@ -154,36 +140,30 @@ namespace Phonon path = QString::fromLatin1("\\\\.\\%1:").arg(drive); } - m_cddrive = QT_WA_INLINE ( - ::CreateFile( (TCHAR*)path.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ), - ::CreateFileA( path.toLocal8Bit().constData(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ) - ); + m_cddrive = ::CreateFile((const wchar_t *)path.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - qMemSet(m_toc, 0, sizeof(CDROM_TOC)); + qMemSet(&m_toc, 0, sizeof(CDROM_TOC)); //read the TOC DWORD bytesRead = 0; - bool tocRead = ::DeviceIoControl(m_cddrive, IOCTL_CDROM_READ_TOC, 0, 0, m_toc, sizeof(CDROM_TOC), &bytesRead, 0); + bool tocRead = ::DeviceIoControl(m_cddrive, IOCTL_CDROM_READ_TOC, 0, 0, &m_toc, sizeof(CDROM_TOC), &bytesRead, 0); if (!tocRead) { qWarning("unable to load the TOC from the CD"); return; } - m_trackAddress = addressToSectors(m_toc->TrackData[0].Address); - const qint32 nbSectorsToRead = (addressToSectors(m_toc->TrackData[m_toc->LastTrack + 1 - m_toc->FirstTrack].Address) + m_trackAddress = addressToSectors(m_toc.TrackData[0].Address); + const qint32 nbSectorsToRead = (addressToSectors(m_toc.TrackData[m_toc.LastTrack + 1 - m_toc.FirstTrack].Address) - m_trackAddress); const qint32 dataLength = nbSectorsToRead * SECTOR_SIZE; - m_waveHeader->chunksize = 4 + (8 + m_waveHeader->chunksize2) + (8 + dataLength); - m_waveHeader->dataLength = dataLength; + m_waveHeader.chunksize = 4 + (8 + m_waveHeader.chunksize2) + (8 + dataLength); + m_waveHeader.dataLength = dataLength; } QAudioCDReader::~QAudioCDReader() { ::CloseHandle(m_cddrive); - delete m_toc; - delete m_waveHeader; - } STDMETHODIMP_(ULONG) QAudioCDReader::AddRef() @@ -199,7 +179,7 @@ namespace Phonon STDMETHODIMP QAudioCDReader::Length(LONGLONG *total,LONGLONG *available) { - const LONGLONG length = sizeof(WaveStructure) + m_waveHeader->dataLength; + const LONGLONG length = sizeof(WaveStructure) + m_waveHeader.dataLength; if (total) { *total = length; } @@ -238,11 +218,11 @@ namespace Phonon if (pos < sizeof(WaveStructure)) { //we first copy the content of the structure nbRead = qMin(LONG(sizeof(WaveStructure) - pos), length); - qMemCopy(buffer, reinterpret_cast(m_waveHeader) + pos, nbRead); + qMemCopy(buffer, reinterpret_cast(&m_waveHeader) + pos, nbRead); } const LONGLONG posInTrack = pos - sizeof(WaveStructure) + nbRead; - const int bytesLeft = qMin(m_waveHeader->dataLength - posInTrack, LONGLONG(length - nbRead)); + const int bytesLeft = qMin(m_waveHeader.dataLength - posInTrack, LONGLONG(length - nbRead)); if (bytesLeft > 0) { @@ -297,8 +277,8 @@ namespace Phonon { QList ret; ret << 0; - for(int i = m_toc->FirstTrack; i <= m_toc->LastTrack ; ++i) { - const uchar *address = m_toc->TrackData[i].Address; + for(int i = m_toc.FirstTrack; i <= m_toc.LastTrack ; ++i) { + const uchar *address = m_toc.TrackData[i].Address; ret << ((address[0] * 60 + address[1]) * 60 + address[2]) * 1000 + address[3]*1000/75 - 2000; } diff --git a/src/3rdparty/phonon/ds9/qaudiocdreader.h b/src/3rdparty/phonon/ds9/qaudiocdreader.h index 9049b66..eff845d 100644 --- a/src/3rdparty/phonon/ds9/qaudiocdreader.h +++ b/src/3rdparty/phonon/ds9/qaudiocdreader.h @@ -31,7 +31,7 @@ namespace Phonon { struct CDROM_TOC; struct WaveStructure; - extern const IID IID_ITitleInterface; + EXTERN_C const IID IID_ITitleInterface; //interface for the Titles struct ITitleInterface : public IUnknown diff --git a/src/3rdparty/phonon/ds9/qbasefilter.cpp b/src/3rdparty/phonon/ds9/qbasefilter.cpp index 95cab92..78b8b8f 100644 --- a/src/3rdparty/phonon/ds9/qbasefilter.cpp +++ b/src/3rdparty/phonon/ds9/qbasefilter.cpp @@ -92,8 +92,8 @@ namespace Phonon return E_POINTER; } - int nbfetched = 0; - while (nbfetched < int(count) && m_index < m_pins.count()) { + uint nbfetched = 0; + while (nbfetched < count && m_index < m_pins.count()) { IPin *current = m_pins[m_index]; current->AddRef(); ret[nbfetched] = current; @@ -166,19 +166,19 @@ namespace Phonon const QList QBaseFilter::pins() const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); return m_pins; } void QBaseFilter::addPin(QPin *pin) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_pins.append(pin); } void QBaseFilter::removePin(QPin *pin) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_pins.removeAll(pin); } @@ -211,7 +211,8 @@ namespace Phonon } else if (iid == IID_IMediaPosition || iid == IID_IMediaSeeking) { if (inputPins().isEmpty()) { - if (*out = getUpStreamInterface(iid)) { + *out = getUpStreamInterface(iid); + if (*out) { return S_OK; //we return here to avoid adding a reference } else { hr = E_NOINTERFACE; @@ -250,35 +251,35 @@ namespace Phonon STDMETHODIMP QBaseFilter::GetClassID(CLSID *clsid) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); *clsid = m_clsid; return S_OK; } STDMETHODIMP QBaseFilter::Stop() { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_state = State_Stopped; return S_OK; } STDMETHODIMP QBaseFilter::Pause() { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_state = State_Paused; return S_OK; } STDMETHODIMP QBaseFilter::Run(REFERENCE_TIME) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_state = State_Running; return S_OK; } STDMETHODIMP QBaseFilter::GetState(DWORD, FILTER_STATE *state) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!state) { return E_POINTER; } @@ -289,7 +290,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::SetSyncSource(IReferenceClock *clock) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (clock) { clock->AddRef(); } @@ -302,7 +303,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::GetSyncSource(IReferenceClock **clock) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!clock) { return E_POINTER; } @@ -341,7 +342,7 @@ namespace Phonon STDMETHODIMP QBaseFilter::QueryFilterInfo(FILTER_INFO *info ) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!info) { return E_POINTER; } @@ -355,9 +356,9 @@ namespace Phonon STDMETHODIMP QBaseFilter::JoinFilterGraph(IFilterGraph *graph, LPCWSTR name) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_graph = graph; - m_name = QString::fromUtf16((const unsigned short*)name); + m_name = QString::fromWCharArray(name); return S_OK; } diff --git a/src/3rdparty/phonon/ds9/qbasefilter.h b/src/3rdparty/phonon/ds9/qbasefilter.h index 85f1431..a72d6fe 100644 --- a/src/3rdparty/phonon/ds9/qbasefilter.h +++ b/src/3rdparty/phonon/ds9/qbasefilter.h @@ -22,7 +22,7 @@ along with this library. If not, see . #include #include -#include +#include #include @@ -127,7 +127,7 @@ namespace Phonon IFilterGraph *m_graph; FILTER_STATE m_state; QList m_pins; - mutable QReadWriteLock m_lock; + mutable QMutex m_mutex; }; } } diff --git a/src/3rdparty/phonon/ds9/qevr9.h b/src/3rdparty/phonon/ds9/qevr9.h new file mode 100644 index 0000000..8599fce --- /dev/null +++ b/src/3rdparty/phonon/ds9/qevr9.h @@ -0,0 +1,143 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . +*/ + +#include + +#define DXVA2_ProcAmp_Brightness 1 +#define DXVA2_ProcAmp_Contrast 2 +#define DXVA2_ProcAmp_Hue 4 +#define DXVA2_ProcAmp_Saturation 8 + +typedef enum { + MFVideoARMode_None = 0x00000000, + MFVideoARMode_PreservePicture = 0x00000001, + MFVideoARMode_PreservePixel = 0x00000002, + MFVideoARMode_NonLinearStretch = 0x00000004, + MFVideoARMode_Mask = 0x00000007 +} MFVideoAspectRatioMode; + +typedef struct { + float left; + float top; + float right; + float bottom; +} MFVideoNormalizedRect; + +typedef struct { + UINT DeviceCaps; + D3DPOOL InputPool; + UINT NumForwardRefSamples; + UINT NumBackwardRefSamples; + UINT Reserved; + UINT DeinterlaceTechnology; + UINT ProcAmpControlCaps; + UINT VideoProcessorOperations; + UINT NoiseFilterTechnology; + UINT DetailFilterTechnology; +} DXVA2_VideoProcessorCaps; + +typedef struct { + union { + struct { + USHORT Fraction; + SHORT Value; + }; + LONG ll; + }; +} DXVA2_Fixed32; + +typedef struct { + DXVA2_Fixed32 MinValue; + DXVA2_Fixed32 MaxValue; + DXVA2_Fixed32 DefaultValue; + DXVA2_Fixed32 StepSize; +} DXVA2_ValueRange; + +typedef struct { + DXVA2_Fixed32 Brightness; + DXVA2_Fixed32 Contrast; + DXVA2_Fixed32 Hue; + DXVA2_Fixed32 Saturation; +} DXVA2_ProcAmpValues; + +DXVA2_Fixed32 DXVA2FloatToFixed(const float _float_) +{ + DXVA2_Fixed32 _fixed_; + _fixed_.Fraction = LOWORD(_float_ * 0x10000); + _fixed_.Value = HIWORD(_float_ * 0x10000); + return _fixed_; +} + +float DXVA2FixedToFloat(const DXVA2_Fixed32 _fixed_) +{ + return (FLOAT)_fixed_.Value + (FLOAT)_fixed_.Fraction / 0x10000; +} + +#undef INTERFACE +#define INTERFACE IMFVideoDisplayControl +DECLARE_INTERFACE_(IMFVideoDisplayControl, IUnknown) +{ + STDMETHOD(GetNativeVideoSize)(THIS_ SIZE* pszVideo, SIZE* pszARVideo) PURE; + STDMETHOD(GetIdealVideoSize)(THIS_ SIZE* pszMin, SIZE* pszMax) PURE; + STDMETHOD(SetVideoPosition)(THIS_ const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest) PURE; + STDMETHOD(GetVideoPosition)(THIS_ MFVideoNormalizedRect* pnrcSource, LPRECT prcDest) PURE; + STDMETHOD(SetAspectRatioMode)(THIS_ DWORD dwAspectRatioMode) PURE; + STDMETHOD(GetAspectRatioMode)(THIS_ DWORD* pdwAspectRatioMode) PURE; + STDMETHOD(SetVideoWindow)(THIS_ HWND hwndVideo) PURE; + STDMETHOD(GetVideoWindow)(THIS_ HWND* phwndVideo) PURE; + STDMETHOD(RepaintVideo)(THIS_) PURE; + STDMETHOD(GetCurrentImage)(THIS_ BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp) PURE; + STDMETHOD(SetBorderColor)(THIS_ COLORREF Clr) PURE; + STDMETHOD(GetBorderColor)(THIS_ COLORREF* pClr) PURE; + STDMETHOD(SetRenderingPrefs)(THIS_ DWORD dwRenderFlags) PURE; + STDMETHOD(GetRenderingPrefs)(THIS_ DWORD* pdwRenderFlags) PURE; + STDMETHOD(SetFullScreen)(THIS_ BOOL fFullscreen) PURE; + STDMETHOD(GetFullScreen)(THIS_ BOOL* pfFullscreen) PURE; +}; +#undef INTERFACE +#define INTERFACE IMFVideoMixerControl +DECLARE_INTERFACE_(IMFVideoMixerControl, IUnknown) +{ + STDMETHOD(SetStreamZOrder)(THIS_ DWORD dwStreamID, DWORD dwZ) PURE; + STDMETHOD(GetStreamZOrder)(THIS_ DWORD dwStreamID, DWORD* pdwZ) PURE; + STDMETHOD(SetStreamOutputRect)(THIS_ DWORD dwStreamID, const MFVideoNormalizedRect* pnrcOutput) PURE; + STDMETHOD(GetStreamOutputRect)(THIS_ DWORD dwStreamID, MFVideoNormalizedRect* pnrcOutput) PURE; +}; +#undef INTERFACE +#define INTERFACE IMFVideoProcessor +DECLARE_INTERFACE_(IMFVideoProcessor, IUnknown) +{ + STDMETHOD(GetAvailableVideoProcessorModes)(THIS_ UINT* lpdwNumProcessingModes, GUID** ppVideoProcessingModes) PURE; + STDMETHOD(GetVideoProcessorCaps)(THIS_ LPGUID lpVideoProcessorMode, DXVA2_VideoProcessorCaps* lpVideoProcessorCaps) PURE; + STDMETHOD(GetVideoProcessorMode)(THIS_ LPGUID lpMode) PURE; + STDMETHOD(SetVideoProcessorMode)(THIS_ LPGUID lpMode) PURE; + STDMETHOD(GetProcAmpRange)(THIS_ DWORD dwProperty, DXVA2_ValueRange* pPropRange) PURE; + STDMETHOD(GetProcAmpValues)(THIS_ DWORD dwFlags, DXVA2_ProcAmpValues* Values) PURE; + STDMETHOD(SetProcAmpValues)(THIS_ DWORD dwFlags, DXVA2_ProcAmpValues* pValues) PURE; + STDMETHOD(GetFilteringRange)(THIS_ DWORD dwProperty, DXVA2_ValueRange* pPropRange) PURE; + STDMETHOD(GetFilteringValue)(THIS_ DWORD dwProperty, DXVA2_Fixed32* pValue) PURE; + STDMETHOD(SetFilteringValue)(THIS_ DWORD dwProperty, DXVA2_Fixed32* pValue) PURE; + STDMETHOD(GetBackgroundColor)(THIS_ COLORREF* lpClrBkg) PURE; + STDMETHOD(SetBackgroundColor)(THIS_ COLORREF ClrBkg) PURE; +}; +#undef INTERFACE +#define INTERFACE IMFGetService +DECLARE_INTERFACE_(IMFGetService, IUnknown) +{ + STDMETHOD(GetService)(THIS_ REFGUID guidService, REFIID riid, LPVOID* ppvObject) PURE; +}; +#undef INTERFACE diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.cpp b/src/3rdparty/phonon/ds9/qmeminputpin.cpp index dca99db..a21fbe7 100644 --- a/src/3rdparty/phonon/ds9/qmeminputpin.cpp +++ b/src/3rdparty/phonon/ds9/qmeminputpin.cpp @@ -28,8 +28,8 @@ namespace Phonon namespace DS9 { - QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector &mt, bool transform) : - QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform) + QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector &mt, bool transform, QPin *output) : + QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform), m_output(output) { } @@ -66,11 +66,9 @@ namespace Phonon { //this allows to serialize with Receive calls QMutexLocker locker(&m_mutexReceive); - for(int i = 0; i < m_outputs.count(); ++i) { - IPin *conn = m_outputs.at(i)->connected(); - if (conn) { - conn->EndOfStream(); - } + IPin *conn = m_output ? m_output->connected() : 0; + if (conn) { + conn->EndOfStream(); } return S_OK; } @@ -78,13 +76,11 @@ namespace Phonon STDMETHODIMP QMemInputPin::BeginFlush() { //pass downstream - for(int i = 0; i < m_outputs.count(); ++i) { - IPin *conn = m_outputs.at(i)->connected(); - if (conn) { - conn->BeginFlush(); - } + IPin *conn = m_output ? m_output->connected() : 0; + if (conn) { + conn->BeginFlush(); } - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_flushing = true; return S_OK; } @@ -92,22 +88,19 @@ namespace Phonon STDMETHODIMP QMemInputPin::EndFlush() { //pass downstream - for(int i = 0; i < m_outputs.count(); ++i) { - IPin *conn = m_outputs.at(i)->connected(); - if (conn) { - conn->EndFlush(); - } + IPin *conn = m_output ? m_output->connected() : 0; + if (conn) { + conn->EndFlush(); } - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_flushing = false; return S_OK; } STDMETHODIMP QMemInputPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate) { - for(int i = 0; i < m_outputs.count(); ++i) { - m_outputs.at(i)->NewSegment(start, stop, rate); - } + if (m_output) + m_output->NewSegment(start, stop, rate); return S_OK; } @@ -119,14 +112,9 @@ namespace Phonon if (hr == S_OK && mt->majortype != MEDIATYPE_NULL && mt->subtype != MEDIASUBTYPE_NULL && - mt->formattype != GUID_NULL) { - //we tell the output pins that they should connect with this type - for(int i = 0; i < m_outputs.count(); ++i) { - hr = m_outputs.at(i)->setAcceptedMediaType(connectedType()); - if (FAILED(hr)) { - break; - } - } + mt->formattype != GUID_NULL && m_output) { + //we tell the output pin that it should connect with this type + hr = m_output->setAcceptedMediaType(connectedType()); } return hr; } @@ -137,7 +125,8 @@ namespace Phonon return E_POINTER; } - if (*alloc = memoryAllocator(true)) { + *alloc = memoryAllocator(true); + if (*alloc) { return S_OK; } @@ -151,18 +140,15 @@ namespace Phonon } { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); m_shouldDuplicateSamples = m_transform && readonly; } setMemoryAllocator(alloc); - for(int i = 0; i < m_outputs.count(); ++i) { - IPin *pin = m_outputs.at(i)->connected(); - if (pin) { - ComPointer input(pin, IID_IMemInputPin); - input->NotifyAllocator(alloc, m_shouldDuplicateSamples); - } + if (m_output) { + ComPointer input(m_output, IID_IMemInputPin); + input->NotifyAllocator(alloc, m_shouldDuplicateSamples); } return S_OK; @@ -201,22 +187,18 @@ namespace Phonon } } - for (int i = 0; i < m_outputs.count(); ++i) { - QPin *current = m_outputs.at(i); + if (m_output) { IMediaSample *outSample = m_shouldDuplicateSamples ? - duplicateSampleForOutput(sample, current->memoryAllocator()) + duplicateSampleForOutput(sample, m_output->memoryAllocator()) : sample; if (m_shouldDuplicateSamples) { m_parent->processSample(outSample); } - IPin *pin = current->connected(); - if (pin) { - ComPointer input(pin, IID_IMemInputPin); - if (input) { - input->Receive(outSample); - } + ComPointer input(m_output->connected(), IID_IMemInputPin); + if (input) { + input->Receive(outSample); } if (m_shouldDuplicateSamples) { @@ -247,39 +229,16 @@ namespace Phonon STDMETHODIMP QMemInputPin::ReceiveCanBlock() { - //we test the output to see if they can block - for(int i = 0; i < m_outputs.count(); ++i) { - IPin *input = m_outputs.at(i)->connected(); - if (input) { - ComPointer meminput(input, IID_IMemInputPin); - if (meminput && meminput->ReceiveCanBlock() != S_FALSE) { - return S_OK; - } + //we test the output to see if it can block + if (m_output) { + ComPointer meminput(m_output->connected(), IID_IMemInputPin); + if (meminput && meminput->ReceiveCanBlock() != S_FALSE) { + return S_OK; } } return S_FALSE; } - //addition - //this should be used by the filter to tell its input pins to which output they should route the samples - - void QMemInputPin::addOutput(QPin *output) - { - QWriteLocker locker(&m_lock); - m_outputs += output; - } - - void QMemInputPin::removeOutput(QPin *output) - { - QWriteLocker locker(&m_lock); - m_outputs.removeOne(output); - } - - QList QMemInputPin::outputs() const - { - QReadLocker locker(&m_lock); - return m_outputs; - } ALLOCATOR_PROPERTIES QMemInputPin::getDefaultAllocatorProperties() const { @@ -294,7 +253,7 @@ namespace Phonon LONG length = sample->GetActualDataLength(); HRESULT hr = alloc->Commit(); - if (hr == VFW_E_SIZENOTSET) { + if (hr == HRESULT(VFW_E_SIZENOTSET)) { ALLOCATOR_PROPERTIES prop = getDefaultAllocatorProperties(); prop.cbBuffer = qMax(prop.cbBuffer, length); ALLOCATOR_PROPERTIES actual; @@ -324,7 +283,7 @@ namespace Phonon { LONGLONG start, end; hr = sample->GetMediaTime(&start, &end); - if (hr != VFW_E_MEDIA_TIME_NOT_SET) { + if (hr != HRESULT(VFW_E_MEDIA_TIME_NOT_SET)) { hr = out->SetMediaTime(&start, &end); Q_ASSERT(SUCCEEDED(hr)); } diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.h b/src/3rdparty/phonon/ds9/qmeminputpin.h index c449721..d74c451 100644 --- a/src/3rdparty/phonon/ds9/qmeminputpin.h +++ b/src/3rdparty/phonon/ds9/qmeminputpin.h @@ -37,7 +37,7 @@ namespace Phonon class QMemInputPin : public QPin, public IMemInputPin { public: - QMemInputPin(QBaseFilter *, const QVector &, bool transform); + QMemInputPin(QBaseFilter *, const QVector &, bool transform, QPin *output); ~QMemInputPin(); //reimplementation from IUnknown @@ -60,18 +60,13 @@ namespace Phonon STDMETHODIMP ReceiveMultiple(IMediaSample **,long,long *); STDMETHODIMP ReceiveCanBlock(); - //addition - void addOutput(QPin *output); - void removeOutput(QPin *output); - QList outputs() const; - private: IMediaSample *duplicateSampleForOutput(IMediaSample *, IMemAllocator *); ALLOCATOR_PROPERTIES getDefaultAllocatorProperties() const; bool m_shouldDuplicateSamples; const bool m_transform; //defines if the pin is transforming the samples - QList m_outputs; + QPin* const m_output; QMutex m_mutexReceive; }; } diff --git a/src/3rdparty/phonon/ds9/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp index 37fe48d..b4afd10 100644 --- a/src/3rdparty/phonon/ds9/qpin.cpp +++ b/src/3rdparty/phonon/ds9/qpin.cpp @@ -28,20 +28,7 @@ namespace Phonon namespace DS9 { - static const AM_MEDIA_TYPE defaultMediaType() - { - AM_MEDIA_TYPE ret; - ret.majortype = MEDIATYPE_NULL; - ret.subtype = MEDIASUBTYPE_NULL; - ret.bFixedSizeSamples = TRUE; - ret.bTemporalCompression = FALSE; - ret.lSampleSize = 1; - ret.formattype = GUID_NULL; - ret.pUnk = 0; - ret.cbFormat = 0; - ret.pbFormat = 0; - return ret; - } + static const AM_MEDIA_TYPE defaultMediaType = { MEDIATYPE_NULL, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; class QEnumMediaTypes : public IEnumMediaTypes { @@ -104,8 +91,8 @@ namespace Phonon return E_INVALIDARG; } - int nbFetched = 0; - while (nbFetched < int(count) && m_index < m_pin->mediaTypes().count()) { + uint nbFetched = 0; + while (nbFetched < count && m_index < m_pin->mediaTypes().count()) { //the caller will deallocate the memory *out = static_cast(::CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))); const AM_MEDIA_TYPE original = m_pin->mediaTypes().at(m_index); @@ -158,9 +145,9 @@ namespace Phonon QPin::QPin(QBaseFilter *parent, PIN_DIRECTION dir, const QVector &mt) : - m_memAlloc(0), m_parent(parent), m_refCount(1), m_connected(0), - m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType()), - m_flushing(false) + m_parent(parent), m_flushing(false), m_refCount(1), m_connected(0), + m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType), + m_memAlloc(0) { Q_ASSERT(m_parent); m_parent->addPin(this); @@ -273,7 +260,7 @@ namespace Phonon if (FAILED(hr)) { setConnected(0); - setConnectedType(defaultMediaType()); + setConnectedType(defaultMediaType); } else { ComPointer input(pin, IID_IMemInputPin); if (input) { @@ -315,10 +302,8 @@ namespace Phonon } setConnected(0); - setConnectedType(defaultMediaType()); - if (m_direction == PINDIR_INPUT) { - setMemoryAllocator(0); - } + setConnectedType(defaultMediaType); + setMemoryAllocator(0); return S_OK; } @@ -338,7 +323,7 @@ namespace Phonon STDMETHODIMP QPin::ConnectionMediaType(AM_MEDIA_TYPE *type) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!type) { return E_POINTER; } @@ -353,7 +338,6 @@ namespace Phonon STDMETHODIMP QPin::QueryPinInfo(PIN_INFO *info) { - QReadLocker locker(&m_lock); if (!info) { return E_POINTER; } @@ -361,14 +345,12 @@ namespace Phonon info->dir = m_direction; info->pFilter = m_parent; m_parent->AddRef(); - qMemCopy(info->achName, m_name.utf16(), qMin(MAX_FILTER_NAME, m_name.length()+1) *2); - + info->achName[0] = 0; return S_OK; } STDMETHODIMP QPin::QueryDirection(PIN_DIRECTION *dir) { - QReadLocker locker(&m_lock); if (!dir) { return E_POINTER; } @@ -379,20 +361,18 @@ namespace Phonon STDMETHODIMP QPin::QueryId(LPWSTR *id) { - QReadLocker locker(&m_lock); if (!id) { return E_POINTER; } - int nbBytes = (m_name.length()+1)*2; - *id = static_cast(::CoTaskMemAlloc(nbBytes)); - qMemCopy(*id, m_name.utf16(), nbBytes); + *id = static_cast(::CoTaskMemAlloc(2)); + *id[0] = 0; return S_OK; } STDMETHODIMP QPin::QueryAccept(const AM_MEDIA_TYPE *type) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (!type) { return E_POINTER; } @@ -439,7 +419,7 @@ namespace Phonon STDMETHODIMP QPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate) { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (m_direction == PINDIR_OUTPUT && m_connected) { //we deliver this downstream m_connected->NewSegment(start, stop, rate); @@ -456,8 +436,8 @@ namespace Phonon HRESULT QPin::checkOutputMediaTypesConnection(IPin *pin) { - IEnumMediaTypes *emt = 0; - HRESULT hr = pin->EnumMediaTypes(&emt); + ComPointer emt; + HRESULT hr = pin->EnumMediaTypes(emt.pparam()); if (hr != S_OK) { return hr; } @@ -470,7 +450,7 @@ namespace Phonon freeMediaType(type); return S_OK; } else { - setConnectedType(defaultMediaType()); + setConnectedType(defaultMediaType); freeMediaType(type); } } @@ -520,7 +500,7 @@ namespace Phonon void QPin::setConnectedType(const AM_MEDIA_TYPE &type) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); //1st we free memory freeMediaType(m_connectedType); @@ -530,13 +510,13 @@ namespace Phonon const AM_MEDIA_TYPE &QPin::connectedType() const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); return m_connectedType; } void QPin::setConnected(IPin *pin) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (pin) { pin->AddRef(); } @@ -548,7 +528,7 @@ namespace Phonon IPin *QPin::connected(bool addref) const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (addref && m_connected) { m_connected->AddRef(); } @@ -557,13 +537,12 @@ namespace Phonon bool QPin::isFlushing() const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); return m_flushing; } FILTER_STATE QPin::filterState() const { - QReadLocker locker(&m_lock); FILTER_STATE fstate = State_Stopped; m_parent->GetState(0, &fstate); return fstate; @@ -571,7 +550,7 @@ namespace Phonon QVector QPin::mediaTypes() const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); return m_mediaTypes; } @@ -607,7 +586,7 @@ namespace Phonon void QPin::setMemoryAllocator(IMemAllocator *alloc) { - QWriteLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (alloc) { alloc->AddRef(); } @@ -619,7 +598,7 @@ namespace Phonon IMemAllocator *QPin::memoryAllocator(bool addref) const { - QReadLocker locker(&m_lock); + QMutexLocker locker(&m_mutex); if (addref && m_memAlloc) { m_memAlloc->AddRef(); } diff --git a/src/3rdparty/phonon/ds9/qpin.h b/src/3rdparty/phonon/ds9/qpin.h index a3287c4..280ad61 100644 --- a/src/3rdparty/phonon/ds9/qpin.h +++ b/src/3rdparty/phonon/ds9/qpin.h @@ -22,7 +22,7 @@ along with this library. If not, see . #include #include -#include +#include #include @@ -85,8 +85,8 @@ namespace Phonon protected: //this can be used by sub-classes - mutable QReadWriteLock m_lock; - QBaseFilter *m_parent; + mutable QMutex m_mutex; + QBaseFilter * const m_parent; bool m_flushing; private: @@ -98,7 +98,6 @@ namespace Phonon const PIN_DIRECTION m_direction; QVector m_mediaTypes; //accepted media types AM_MEDIA_TYPE m_connectedType; - QString m_name; IMemAllocator *m_memAlloc; }; diff --git a/src/3rdparty/phonon/ds9/videorenderer_default.cpp b/src/3rdparty/phonon/ds9/videorenderer_default.cpp new file mode 100644 index 0000000..0045a49 --- /dev/null +++ b/src/3rdparty/phonon/ds9/videorenderer_default.cpp @@ -0,0 +1,153 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . +*/ + + +#include "videorenderer_default.h" + +#ifndef QT_NO_PHONON_VIDEO + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + + +namespace Phonon +{ + namespace DS9 + { + VideoRendererDefault::~VideoRendererDefault() + { + } + + bool VideoRendererDefault::isNative() const + { + return true; + } + + + VideoRendererDefault::VideoRendererDefault(QWidget *target) : m_target(target) + { + m_target->setAttribute(Qt::WA_PaintOnScreen, true); + m_filter = Filter(CLSID_VideoRenderer, IID_IBaseFilter); + } + + QSize VideoRendererDefault::videoSize() const + { + LONG w = 0, + h = 0; + ComPointer basic(m_filter, IID_IBasicVideo); + if (basic) { + basic->GetVideoSize( &w, &h); + } + return QSize(w, h); + } + + void VideoRendererDefault::repaintCurrentFrame(QWidget * /*target*/, const QRect & /*rect*/) + { + //nothing to do here: the renderer paints everything + } + + void VideoRendererDefault::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, + Phonon::VideoWidget::ScaleMode scaleMode) + { + if (!isActive()) { + ComPointer basic(m_filter, IID_IBasicVideo); + if (basic) { + basic->SetDestinationPosition(0, 0, 0, 0); + } + return; + } + + ComPointer video(m_filter, IID_IVideoWindow); + + OAHWND owner; + HRESULT hr = video->get_Owner(&owner); + if (FAILED(hr)) { + return; + } + + const OAHWND newOwner = reinterpret_cast(m_target->winId()); + if (owner != newOwner) { + video->put_Owner(newOwner); + video->put_MessageDrain(newOwner); + video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + } + + //make sure the widget takes the whole size of the parent + video->SetWindowPosition(0, 0, size.width(), size.height()); + + const QSize vsize = videoSize(); + internalNotifyResize(size, vsize, aspectRatio, scaleMode); + + ComPointer basic(m_filter, IID_IBasicVideo); + if (basic) { + basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight); + } + } + + void VideoRendererDefault::applyMixerSettings(qreal /*brightness*/, qreal /*contrast*/, qreal /*m_hue*/, qreal /*saturation*/) + { + //this can't be supported for the default renderer + } + + QImage VideoRendererDefault::snapshot() const + { + ComPointer basic(m_filter, IID_IBasicVideo); + if (basic) { + LONG bufferSize = 0; + //1st we get the buffer size + basic->GetCurrentImage(&bufferSize, 0); + + QByteArray buffer; + buffer.resize(bufferSize); + HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast(buffer.data())); + + if (SUCCEEDED(hr)) { + + const BITMAPINFOHEADER *bmi = reinterpret_cast(buffer.constData()); + + const int w = qAbs(bmi->biWidth), + h = qAbs(bmi->biHeight); + + // Create image and copy data into image. + QImage ret(w, h, QImage::Format_RGB32); + + if (!ret.isNull()) { + const char *data = buffer.constData() + bmi->biSize; + const int bytes_per_line = w * sizeof(QRgb); + for (int y = h - 1; y >= 0; --y) { + qMemCopy(ret.scanLine(y), //destination + data, //source + bytes_per_line); + data += bytes_per_line; + } + } + return ret; + } + } + return QImage(); + } + + } +} + +QT_END_NAMESPACE + +#endif //QT_NO_PHONON_VIDEO diff --git a/src/3rdparty/phonon/ds9/videorenderer_default.h b/src/3rdparty/phonon/ds9/videorenderer_default.h new file mode 100644 index 0000000..43768d9 --- /dev/null +++ b/src/3rdparty/phonon/ds9/videorenderer_default.h @@ -0,0 +1,55 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . +*/ + +#ifndef PHONON_VIDEORENDERER_DEFAULT_H +#define PHONON_VIDEORENDERER_DEFAULT_H + +#include "abstractvideorenderer.h" + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_PHONON_VIDEO + +namespace Phonon +{ + namespace DS9 + { + class VideoRendererDefault : public AbstractVideoRenderer + { + public: + VideoRendererDefault(QWidget *target); + ~VideoRendererDefault(); + + //Implementation from AbstractVideoRenderer + void repaintCurrentFrame(QWidget *target, const QRect &rect); + void notifyResize(const QSize&, Phonon::VideoWidget::AspectRatio, Phonon::VideoWidget::ScaleMode); + QSize videoSize() const; + QImage snapshot() const; + void applyMixerSettings(qreal brightness, qreal contrast, qreal m_hue, qreal saturation); + bool isNative() const; + private: + QWidget *m_target; + }; + } +} + +#endif //QT_NO_PHONON_VIDEO + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/ds9/videorenderer_evr.cpp b/src/3rdparty/phonon/ds9/videorenderer_evr.cpp new file mode 100644 index 0000000..d23d9ce --- /dev/null +++ b/src/3rdparty/phonon/ds9/videorenderer_evr.cpp @@ -0,0 +1,215 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . +*/ + + +#include "videorenderer_evr.h" +#include "qevr9.h" + +#ifndef QT_NO_PHONON_VIDEO + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ + namespace DS9 + { + //we have to define them here because not all compilers/sdk have them + static const GUID MR_VIDEO_RENDER_SERVICE = {0x1092a86c, 0xab1a, 0x459a, {0xa3, 0x36, 0x83, 0x1f, 0xbc, 0x4d, 0x11, 0xff} }; + static const GUID MR_VIDEO_MIXER_SERVICE = { 0x73cd2fc, 0x6cf4, 0x40b7, {0x88, 0x59, 0xe8, 0x95, 0x52, 0xc8, 0x41, 0xf8} }; + static const IID IID_IMFVideoDisplayControl = {0xa490b1e4, 0xab84, 0x4d31, {0xa1, 0xb2, 0x18, 0x1e, 0x03, 0xb1, 0x07, 0x7a} }; + static const IID IID_IMFVideoMixerControl = {0xA5C6C53F, 0xC202, 0x4aa5, {0x96, 0x95, 0x17, 0x5B, 0xA8, 0xC5, 0x08, 0xA5} }; + static const IID IID_IMFVideoProcessor = {0x6AB0000C, 0xFECE, 0x4d1f, {0xA2, 0xAC, 0xA9, 0x57, 0x35, 0x30, 0x65, 0x6E} }; + static const IID IID_IMFGetService = {0xFA993888, 0x4383, 0x415A, {0xA9, 0x30, 0xDD, 0x47, 0x2A, 0x8C, 0xF6, 0xF7} }; + static const GUID CLSID_EnhancedVideoRenderer = {0xfa10746c, 0x9b63, 0x4b6c, {0xbc, 0x49, 0xfc, 0x30, 0xe, 0xa5, 0xf2, 0x56} }; + + template ComPointer getService(const Filter &filter, REFGUID guidService, REFIID riid) + { + //normally we should use IID_IMFGetService but this introduces another dependency + //so here we simply define our own IId with the same value + ComPointer getService(filter, IID_IMFGetService); + Q_ASSERT(getService); + T *ptr = 0; + HRESULT hr = getService->GetService(guidService, riid, reinterpret_cast(&ptr)); + if (!SUCCEEDED(hr) || ptr == 0) + Q_ASSERT(!SUCCEEDED(hr) && ptr != 0); + ComPointer service(ptr); + return service; + } + + VideoRendererEVR::~VideoRendererEVR() + { + } + + bool VideoRendererEVR::isNative() const + { + return true; + } + + VideoRendererEVR::VideoRendererEVR(QWidget *target) : m_target(target) + { + m_filter = Filter(CLSID_EnhancedVideoRenderer, IID_IBaseFilter); + if (!m_filter) { + return; + } + + ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); + + filterControl->SetVideoWindow(reinterpret_cast(target->winId())); + filterControl->SetAspectRatioMode(MFVideoARMode_None); // We're in control of the size + } + + QImage VideoRendererEVR::snapshot() const + { + // This will always capture black areas where no video is drawn, if any are present. + // Due to the hack in notifyResize() + ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); + if (filterControl) { + BITMAPINFOHEADER bmi; + BYTE *buffer = 0; + DWORD bufferSize; + LONGLONG timeStamp; + + bmi.biSize = sizeof(BITMAPINFOHEADER); + + HRESULT hr = filterControl->GetCurrentImage(&bmi, &buffer, &bufferSize, &timeStamp); + if (SUCCEEDED(hr)) { + + const int w = qAbs(bmi.biWidth), + h = qAbs(bmi.biHeight); + + // Create image and copy data into image. + QImage ret(w, h, QImage::Format_RGB32); + + if (!ret.isNull()) { + uchar *data = buffer; + const int bytes_per_line = w * sizeof(QRgb); + for (int y = h - 1; y >= 0; --y) { + qMemCopy(ret.scanLine(y), //destination + data, //source + bytes_per_line); + data += bytes_per_line; + } + } + ::CoTaskMemFree(buffer); + return ret; + } + } + return QImage(); + } + + QSize VideoRendererEVR::videoSize() const + { + SIZE nativeSize; + SIZE aspectRatioSize; + + ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); + + filterControl->GetNativeVideoSize(&nativeSize, &aspectRatioSize); + + return QSize(nativeSize.cx, nativeSize.cy); + } + + void VideoRendererEVR::repaintCurrentFrame(QWidget *target, const QRect &rect) + { + // repaint the video + ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); + // All failed results can be safely ignored + filterControl->RepaintVideo(); + } + + void VideoRendererEVR::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, + Phonon::VideoWidget::ScaleMode scaleMode) + { + if (!isActive()) { + RECT dummyRect = { 0, 0, 0, 0}; + ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); + filterControl->SetVideoPosition(0, &dummyRect); + return; + } + + const QSize vsize = videoSize(); + internalNotifyResize(size, vsize, aspectRatio, scaleMode); + + RECT dstRectWin = { 0, 0, size.width(), size.height()}; + + // Resize the Stream output rect instead of the destination rect. + // Hacky workaround for flicker in the areas outside of the destination rect + // This way these areas don't exist + MFVideoNormalizedRect streamOutputRect = { float(m_dstX) / float(size.width()), float(m_dstY) / float(size.height()), + float(m_dstWidth + m_dstX) / float(size.width()), float(m_dstHeight + m_dstY) / float(size.height())}; + + ComPointer filterMixer = getService(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerControl); + ComPointer filterControl = getService(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); + + filterMixer->SetStreamOutputRect(0, &streamOutputRect); + filterControl->SetVideoPosition(0, &dstRectWin); + } + + void VideoRendererEVR::applyMixerSettings(qreal brightness, qreal contrast, qreal hue, qreal saturation) + { + InputPin sink = BackendNode::pins(m_filter, PINDIR_INPUT).first(); + OutputPin source; + if (FAILED(sink->ConnectedTo(source.pparam()))) { + return; //it must be connected to work + } + + // Get the "Video Processor" (used for brightness/contrast/saturation/hue) + ComPointer processor = getService(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoProcessor); + Q_ASSERT(processor); + + DXVA2_ValueRange contrastRange; + DXVA2_ValueRange brightnessRange; + DXVA2_ValueRange saturationRange; + DXVA2_ValueRange hueRange; + + if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Contrast, &contrastRange))) + return; + if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Brightness, &brightnessRange))) + return; + if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Saturation, &saturationRange))) + return; + if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Hue, &hueRange))) + return; + + DXVA2_ProcAmpValues values; + + values.Contrast = DXVA2FloatToFixed(((contrast < 0 + ? DXVA2FixedToFloat(contrastRange.MinValue) : DXVA2FixedToFloat(contrastRange.MaxValue)) + - DXVA2FixedToFloat(contrastRange.DefaultValue)) * qAbs(contrast) + DXVA2FixedToFloat(contrastRange.DefaultValue)); + values.Brightness = DXVA2FloatToFixed(((brightness < 0 + ? DXVA2FixedToFloat(brightnessRange.MinValue) : DXVA2FixedToFloat(brightnessRange.MaxValue)) + - DXVA2FixedToFloat(brightnessRange.DefaultValue)) * qAbs(brightness) + DXVA2FixedToFloat(brightnessRange.DefaultValue)); + values.Saturation = DXVA2FloatToFixed(((saturation < 0 + ? DXVA2FixedToFloat(saturationRange.MinValue) : DXVA2FixedToFloat(saturationRange.MaxValue)) + - DXVA2FixedToFloat(saturationRange.DefaultValue)) * qAbs(saturation) + DXVA2FixedToFloat(saturationRange.DefaultValue)); + values.Hue = DXVA2FloatToFixed(((hue < 0 + ? DXVA2FixedToFloat(hueRange.MinValue) : DXVA2FixedToFloat(hueRange.MaxValue)) + - DXVA2FixedToFloat(hueRange.DefaultValue)) * qAbs(hue) + DXVA2FixedToFloat(hueRange.DefaultValue)); + + //finally set the settings + processor->SetProcAmpValues(DXVA2_ProcAmp_Contrast | DXVA2_ProcAmp_Brightness | DXVA2_ProcAmp_Saturation | DXVA2_ProcAmp_Hue, &values); + + } + } +} + +QT_END_NAMESPACE + +#endif //QT_NO_PHONON_VIDEO diff --git a/src/3rdparty/phonon/ds9/videorenderer_evr.h b/src/3rdparty/phonon/ds9/videorenderer_evr.h new file mode 100644 index 0000000..229c36d --- /dev/null +++ b/src/3rdparty/phonon/ds9/videorenderer_evr.h @@ -0,0 +1,56 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . +*/ + +#ifndef PHONON_VIDEORENDERER_EVR_H +#define PHONON_VIDEORENDERER_EVR_H + +#include "abstractvideorenderer.h" +#include "compointer.h" + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_PHONON_VIDEO + +namespace Phonon +{ + namespace DS9 + { + class VideoRendererEVR : public AbstractVideoRenderer + { + public: + VideoRendererEVR(QWidget *target); + ~VideoRendererEVR(); + + //Implementation from AbstractVideoRenderer + void repaintCurrentFrame(QWidget *target, const QRect &rect); + void notifyResize(const QSize&, Phonon::VideoWidget::AspectRatio, Phonon::VideoWidget::ScaleMode); + QSize videoSize() const; + QImage snapshot() const; + void applyMixerSettings(qreal brightness, qreal contrast, qreal m_hue, qreal saturation); + bool isNative() const; + private: + QWidget *m_target; + }; + } +} + +#endif //QT_NO_PHONON_VIDEO + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp index 491d1bd..9c7993c 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp +++ b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp @@ -194,8 +194,8 @@ namespace Phonon m_sampleBuffer = ComPointer(); #ifndef QT_NO_OPENGL freeGLResources(); -#endif // QT_NO_OPENGL m_textureUploaded = false; +#endif // QT_NO_OPENGL } void endOfStream() @@ -314,7 +314,6 @@ namespace Phonon REFERENCE_TIME m_start; HANDLE m_renderEvent, m_receiveCanWait; // Signals sample to render QSize m_size; - bool m_textureUploaded; //mixer settings qreal m_brightness, @@ -356,6 +355,7 @@ namespace Phonon bool m_checkedPrograms; bool m_usingOpenGL; + bool m_textureUploaded; GLuint m_program[2]; GLuint m_texture[3]; #endif @@ -365,7 +365,7 @@ namespace Phonon { public: VideoRendererSoftPin(VideoRendererSoftFilter *parent) : - QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/), + QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/, 0), m_renderer(parent) { } @@ -436,7 +436,7 @@ namespace Phonon QBaseFilter(CLSID_NULL), m_inputPin(new VideoRendererSoftPin(this)), m_renderer(renderer), m_start(0) #ifndef QT_NO_OPENGL - ,m_usingOpenGL(false), m_checkedPrograms(false), m_textureUploaded(false) + , m_checkedPrograms(false), m_usingOpenGL(false), m_textureUploaded(false) #endif { m_renderEvent = ::CreateEvent(0, 0, 0, 0); @@ -661,7 +661,10 @@ namespace Phonon #ifndef QT_NO_OPENGL - if (painter.paintEngine() && painter.paintEngine()->type() == QPaintEngine::OpenGL && checkGLPrograms()) { + if (painter.paintEngine() && + (painter.paintEngine()->type() == QPaintEngine::OpenGL || painter.paintEngine()->type() == QPaintEngine::OpenGL2) + && checkGLPrograms()) { + //for now we only support YUV (both YV12 and YUY2) updateTexture(); @@ -673,6 +676,7 @@ namespace Phonon } //let's draw the texture + painter.beginNativePainting(); //Let's pass the other arguments const Program prog = (m_inputPin->connectedType().subtype == MEDIASUBTYPE_YV12) ? YV12toRGB : YUY2toRGB; @@ -722,6 +726,7 @@ namespace Phonon glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_FRAGMENT_PROGRAM_ARB); + painter.endNativePainting(); return; } else #endif diff --git a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp index 298e9fa..545b31e 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp +++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp @@ -22,14 +22,9 @@ along with this library. If not, see . #include #include -#include -#ifndef Q_OS_WINCE #include #include -#else -#include -#endif QT_BEGIN_NAMESPACE @@ -48,116 +43,10 @@ namespace Phonon } -#ifdef Q_OS_WINCE - VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target) - { - m_target->setAttribute(Qt::WA_PaintOnScreen, true); - m_filter = Filter(CLSID_VideoRenderer, IID_IBaseFilter); - } - - QSize VideoRendererVMR9::videoSize() const - { - LONG w = 0, - h = 0; - ComPointer basic(m_filter, IID_IBasicVideo); - if (basic) { - basic->GetVideoSize( &w, &h); - } - return QSize(w, h); - } - - void VideoRendererVMR9::repaintCurrentFrame(QWidget * /*target*/, const QRect & /*rect*/) - { - //nothing to do here: the renderer paints everything - } - - void VideoRendererVMR9::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, - Phonon::VideoWidget::ScaleMode scaleMode) - { - if (!isActive()) { - ComPointer basic(m_filter, IID_IBasicVideo); - if (basic) { - basic->SetDestinationPosition(0, 0, 0, 0); - } - return; - } - - ComPointer video(m_filter, IID_IVideoWindow); - - OAHWND owner; - HRESULT hr = video->get_Owner(&owner); - if (FAILED(hr)) { - return; - } - - const OAHWND newOwner = reinterpret_cast(m_target->winId()); - if (owner != newOwner) { - video->put_Owner(newOwner); - video->put_MessageDrain(newOwner); - video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - } - - //make sure the widget takes the whole size of the parent - video->SetWindowPosition(0, 0, size.width(), size.height()); - - const QSize vsize = videoSize(); - internalNotifyResize(size, vsize, aspectRatio, scaleMode); - - ComPointer basic(m_filter, IID_IBasicVideo); - if (basic) { - basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight); - } - } - - void VideoRendererVMR9::applyMixerSettings(qreal /*brightness*/, qreal /*contrast*/, qreal /*m_hue*/, qreal /*saturation*/) - { - //this can't be supported for WinCE - } - - QImage VideoRendererVMR9::snapshot() const - { - ComPointer basic(m_filter, IID_IBasicVideo); - if (basic) { - LONG bufferSize = 0; - //1st we get the buffer size - basic->GetCurrentImage(&bufferSize, 0); - - QByteArray buffer; - buffer.resize(bufferSize); - HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast(buffer.data())); - - if (SUCCEEDED(hr)) { - - const BITMAPINFOHEADER *bmi = reinterpret_cast(buffer.constData()); - - const int w = qAbs(bmi->biWidth), - h = qAbs(bmi->biHeight); - - // Create image and copy data into image. - QImage ret(w, h, QImage::Format_RGB32); - - if (!ret.isNull()) { - const char *data = buffer.constData() + bmi->biSize; - const int bytes_per_line = w * sizeof(QRgb); - for (int y = h - 1; y >= 0; --y) { - qMemCopy(ret.scanLine(y), //destination - data, //source - bytes_per_line); - data += bytes_per_line; - } - } - return ret; - } - } - return QImage(); - } - -#else VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target) { m_filter = Filter(CLSID_VideoMixingRenderer9, IID_IBaseFilter); if (!m_filter) { - qWarning("the video widget could not be initialized correctly"); return; } @@ -169,6 +58,7 @@ namespace Phonon Q_ASSERT(SUCCEEDED(hr)); ComPointer windowlessControl(m_filter, IID_IVMRWindowlessControl9); windowlessControl->SetVideoClippingWindow(reinterpret_cast(target->winId())); + windowlessControl->SetAspectRatioMode(VMR9ARMode_None); //we're in control of the size } QImage VideoRendererVMR9::snapshot() const @@ -324,7 +214,6 @@ namespace Phonon //finally set the settings mixer->SetProcAmpControl(0, &ctrl); } -#endif } } diff --git a/src/3rdparty/phonon/ds9/videorenderer_vmr9.h b/src/3rdparty/phonon/ds9/videorenderer_vmr9.h index 4eb237e..516d79d 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.h +++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.h @@ -19,7 +19,6 @@ along with this library. If not, see . #define PHONON_VIDEORENDERER_VMR9_H #include "abstractvideorenderer.h" -#include "compointer.h" QT_BEGIN_NAMESPACE diff --git a/src/3rdparty/phonon/ds9/videowidget.cpp b/src/3rdparty/phonon/ds9/videowidget.cpp index de7ce5f..09d42a4 100644 --- a/src/3rdparty/phonon/ds9/videowidget.cpp +++ b/src/3rdparty/phonon/ds9/videowidget.cpp @@ -24,7 +24,12 @@ along with this library. If not, see . #include "mediaobject.h" +#ifndef Q_OS_WINCE +#include "videorenderer_evr.h" #include "videorenderer_vmr9.h" +#else +#include "videorenderer_default.h" +#endif #include "videorenderer_soft.h" QT_BEGIN_NAMESPACE @@ -84,7 +89,19 @@ namespace Phonon void setCurrentRenderer(AbstractVideoRenderer *renderer) { m_currentRenderer = renderer; - update(); + //we disallow repaint on that widget for just a fraction of second + //this allows better transition between videos + setUpdatesEnabled(false); + m_flickerFreeTimer.start(20, this); + } + + void timerEvent(QTimerEvent *e) + { + if (e->timerId() == m_flickerFreeTimer.timerId()) { + m_flickerFreeTimer.stop(); + setUpdatesEnabled(true); + } + QWidget::timerEvent(e); } QSize sizeHint() const @@ -106,6 +123,8 @@ namespace Phonon void paintEvent(QPaintEvent *e) { + if (!updatesEnabled()) + return; //this avoids repaint from native events checkCurrentRenderingMode(); m_currentRenderer->repaintCurrentFrame(this, e->rect()); } @@ -153,13 +172,14 @@ namespace Phonon } } else if (!isEmbedded()) { m_currentRenderer = m_node->switchRendering(m_currentRenderer); - setAttribute(Qt::WA_PaintOnScreen, true); + setAttribute(Qt::WA_PaintOnScreen, false); } } VideoWidget *m_node; AbstractVideoRenderer *m_currentRenderer; QVariant m_restoreScreenSaverActive; + QBasicTimer m_flickerFreeTimer; }; VideoWidget::VideoWidget(QWidget *parent) @@ -203,6 +223,9 @@ namespace Phonon if (toNative && m_noNativeRendererSupported) return current; //no switch here + if (!mediaObject()) + return current; + //firt we delete the renderer //initialization of the widgets for(int i = 0; i < FILTER_COUNT; ++i) { @@ -261,6 +284,7 @@ namespace Phonon { m_aspectRatio = aspectRatio; updateVideoSize(); + m_widget->update(); } Phonon::VideoWidget::ScaleMode VideoWidget::scaleMode() const @@ -279,6 +303,7 @@ namespace Phonon { m_scaleMode = scaleMode; updateVideoSize(); + m_widget->update(); } void VideoWidget::setBrightness(qreal b) @@ -332,14 +357,29 @@ namespace Phonon int index = graphIndex * 2 + type; if (m_renderers[index] == 0 && autoCreate) { AbstractVideoRenderer *renderer = 0; - if (type == Native) { - renderer = new VideoRendererVMR9(m_widget); + if (type == Native) { +#ifndef Q_OS_WINCE + renderer = new VideoRendererEVR(m_widget); + if (renderer->getFilter() == 0) { + delete renderer; + //EVR not present, let's try VMR + renderer = new VideoRendererVMR9(m_widget); + if (renderer->getFilter() == 0) { + //instanciating the renderer might fail + m_noNativeRendererSupported = true; + delete renderer; + renderer = 0; + } + } +#else + renderer = new VideoRendererDefault(m_widget); if (renderer->getFilter() == 0) { - //instanciating the renderer might fail with error VFW_E_DDRAW_CAPS_NOT_SUITABLE (0x80040273) + //instanciating the renderer might fail m_noNativeRendererSupported = true; delete renderer; renderer = 0; } +#endif } if (renderer == 0) { diff --git a/src/3rdparty/phonon/ds9/volumeeffect.cpp b/src/3rdparty/phonon/ds9/volumeeffect.cpp index b9a5fce..a93b074 100644 --- a/src/3rdparty/phonon/ds9/volumeeffect.cpp +++ b/src/3rdparty/phonon/ds9/volumeeffect.cpp @@ -76,7 +76,7 @@ namespace Phonon class VolumeMemInputPin : public QMemInputPin { public: - VolumeMemInputPin(QBaseFilter *parent, const QVector &mt) : QMemInputPin(parent, mt, true /*transform*/) + VolumeMemInputPin(QBaseFilter *parent, const QVector &mt, QPin *output) : QMemInputPin(parent, mt, true /*transform*/, output) { } @@ -139,8 +139,7 @@ namespace Phonon //then creating the input mt << audioMediaType(); - m_input = new VolumeMemInputPin(this, mt); - m_input->addOutput(m_output); //make the connection here + m_input = new VolumeMemInputPin(this, mt, m_output); } void VolumeEffectFilter::treatOneSamplePerChannel(BYTE **buffer, int sampleSize, int channelCount, int frequency) diff --git a/src/3rdparty/phonon/ds9/volumeeffect.h b/src/3rdparty/phonon/ds9/volumeeffect.h index 39b20d0..d1b0186 100644 --- a/src/3rdparty/phonon/ds9/volumeeffect.h +++ b/src/3rdparty/phonon/ds9/volumeeffect.h @@ -47,7 +47,7 @@ namespace Phonon private: float m_volume; - //parameters used to fade + //paramaters used to fade Phonon::VolumeFaderEffect::FadeCurve m_fadeCurve; bool m_fading; //determines if we should be fading. diff --git a/src/plugins/phonon/ds9/ds9.pro b/src/plugins/phonon/ds9/ds9.pro index f40c561..dab5116 100644 --- a/src/plugins/phonon/ds9/ds9.pro +++ b/src/plugins/phonon/ds9/ds9.pro @@ -23,6 +23,7 @@ HEADERS += \ $$PHONON_DS9_DIR/videowidget.h \ $$PHONON_DS9_DIR/videorenderer_soft.h \ $$PHONON_DS9_DIR/videorenderer_vmr9.h \ + $$PHONON_DS9_DIR/videorenderer_evr.h \ $$PHONON_DS9_DIR/volumeeffect.h \ $$PHONON_DS9_DIR/qbasefilter.h \ $$PHONON_DS9_DIR/qpin.h \ @@ -46,6 +47,7 @@ SOURCES += \ $$PHONON_DS9_DIR/videowidget.cpp \ $$PHONON_DS9_DIR/videorenderer_soft.cpp \ $$PHONON_DS9_DIR/videorenderer_vmr9.cpp \ + $$PHONON_DS9_DIR/videorenderer_evr.cpp \ $$PHONON_DS9_DIR/volumeeffect.cpp \ $$PHONON_DS9_DIR/qbasefilter.cpp \ $$PHONON_DS9_DIR/qpin.cpp \ -- cgit v0.12 From a7177ea6be1a7617f82edf062164083bbc2eb47a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 7 Apr 2010 13:56:39 +0200 Subject: Revert "Remove references to evr based renderer from .pro." This reverts commit 04d3b7ada83042c587a9ba199395b639c5f83623. Why would anyone want to remove evr renderer... --- src/plugins/phonon/ds9/ds9.pro | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/phonon/ds9/ds9.pro b/src/plugins/phonon/ds9/ds9.pro index dab5116..301808e 100644 --- a/src/plugins/phonon/ds9/ds9.pro +++ b/src/plugins/phonon/ds9/ds9.pro @@ -22,8 +22,6 @@ HEADERS += \ $$PHONON_DS9_DIR/mediaobject.h \ $$PHONON_DS9_DIR/videowidget.h \ $$PHONON_DS9_DIR/videorenderer_soft.h \ - $$PHONON_DS9_DIR/videorenderer_vmr9.h \ - $$PHONON_DS9_DIR/videorenderer_evr.h \ $$PHONON_DS9_DIR/volumeeffect.h \ $$PHONON_DS9_DIR/qbasefilter.h \ $$PHONON_DS9_DIR/qpin.h \ @@ -46,8 +44,6 @@ SOURCES += \ $$PHONON_DS9_DIR/mediaobject.cpp \ $$PHONON_DS9_DIR/videowidget.cpp \ $$PHONON_DS9_DIR/videorenderer_soft.cpp \ - $$PHONON_DS9_DIR/videorenderer_vmr9.cpp \ - $$PHONON_DS9_DIR/videorenderer_evr.cpp \ $$PHONON_DS9_DIR/volumeeffect.cpp \ $$PHONON_DS9_DIR/qbasefilter.cpp \ $$PHONON_DS9_DIR/qpin.cpp \ @@ -55,6 +51,15 @@ SOURCES += \ $$PHONON_DS9_DIR/qaudiocdreader.cpp \ $$PHONON_DS9_DIR/qmeminputpin.cpp +#the EVR renderer (only available on desktop) +!wince*:SOURCES += $$PHONON_DS9_DIR/videorenderer_evr.cpp \ + $$PHONON_DS9_DIR/videorenderer_vmr9.cpp +!wince*:HEADERS += $$PHONON_DS9_DIR/qevr9.h \ + $$PHONON_DS9_DIR/videorenderer_evr.h \ + $$PHONON_DS9_DIR/videorenderer_vmr9.h +wince*:SOURCES += $$PHONON_DS9_DIR/videorenderer_default.cpp +wince*:HEADERS += $$PHONON_DS9_DIR/videorenderer_default.h + target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend INSTALLS += target -- cgit v0.12 From 2df78bfc92bdf6da1de87ae684b4c59b70767f90 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 7 Apr 2010 16:38:37 +0200 Subject: Disable EGLImage usage It's broken. It will be fixed properly. --- src/opengl/qgl_x11egl.cpp | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index af0100b..456e111 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -435,30 +435,30 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // If the pixmap doesn't already have a valid surface, try binding it via EGLImage // first, as going through EGLImage should be faster and better supported: - if (!textureIsBound && haveEglImageTFP) { - Q_ASSERT(eglCreateImageKHR); - - EGLImageKHR eglImage; - - EGLint attribs[] = { - EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, - EGL_NONE - }; - eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs); - - QGLContext* ctx = q; - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage); - - GLint err = glGetError(); - if (err == GL_NO_ERROR) - textureIsBound = true; - - // Once the egl image is bound, the texture becomes a new sibling image and we can safely - // destroy the EGLImage we created for the pixmap: - if (eglImage != EGL_NO_IMAGE_KHR) - eglDestroyImageKHR(QEgl::display(), eglImage); - } +// if (!textureIsBound && haveEglImageTFP) { +// Q_ASSERT(eglCreateImageKHR); +// +// EGLImageKHR eglImage; +// +// EGLint attribs[] = { +// EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, +// EGL_NONE +// }; +// eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, +// (EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs); +// +// QGLContext* ctx = q; +// glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage); +// +// GLint err = glGetError(); +// if (err == GL_NO_ERROR) +// textureIsBound = true; +// +// // Once the egl image is bound, the texture becomes a new sibling image and we can safely +// // destroy the EGLImage we created for the pixmap: +// if (eglImage != EGL_NO_IMAGE_KHR) +// eglDestroyImageKHR(QEgl::display(), eglImage); +// } if (!textureIsBound && haveTFP) { // Check to see if the surface is still valid -- cgit v0.12 From 864ace14e12cedd8e8f78841249e5309eb0a0795 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 7 Apr 2010 16:44:59 +0200 Subject: Fixed the action geometry of menu bar in RTL It could happen (with MDI widgets) that the first actions would not be visible. Task-number: QTBUG-9560 Reviewed-by: gabi --- src/gui/widgets/qmenubar.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index e368d3d..a13a2fa 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -268,19 +268,15 @@ void QMenuBarPrivate::updateGeometries() QRect QMenuBarPrivate::actionRect(QAction *act) const { - Q_Q(const QMenuBar); const int index = actions.indexOf(act); - if (index == -1) - return QRect(); //makes sure the geometries are up-to-date const_cast(this)->updateGeometries(); - if (index >= actionRects.count()) + if (index < 0 || index >= actionRects.count()) return QRect(); // that can happen in case of native menubar - QRect ret = actionRects.at(index); - return QStyle::visualRect(q->layoutDirection(), q->rect(), ret); + return actionRects.at(index); } void QMenuBarPrivate::focusFirstAction() @@ -505,6 +501,9 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const //keep moving along.. x += rect.width() + itemSpacing; + + //make sure we follow the layout direction + rect = QStyle::visualRect(q->layoutDirection(), q->rect(), rect); } } -- cgit v0.12 From 99c17c0efb1331f5d11260b08614c9dff9bbf2e1 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 7 Apr 2010 17:18:04 +0200 Subject: Fix EGLImage & re-enable its use in QtOpenGL Make sure we set the EGL_KHR_image_base define when we define the reset of the extension defines. This also makes eglCreateImageKHR get defined when previously it wasn't. Reviewed-By: TrustMe --- src/gui/egl/qegl_p.h | 9 ++++++--- src/opengl/qgl_x11egl.cpp | 48 +++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index 540cd3d..f81add6 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -139,6 +139,12 @@ QT_BEGIN_NAMESPACE typedef void *EGLImageKHR; #define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) #define EGL_IMAGE_PRESERVED_KHR 0x30D2 +#define EGL_KHR_image_base +#endif + +#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_pixmap) +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 +#define EGL_KHR_image_pixmap #endif // It is possible that something has included eglext.h (like Symbian 10.1's broken egl.h), in @@ -154,9 +160,6 @@ extern Q_GUI_EXPORT _eglCreateImageKHR eglCreateImageKHR; extern Q_GUI_EXPORT _eglDestroyImageKHR eglDestroyImageKHR; #endif // (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) -#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_pixmap) -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 -#endif class QEglProperties; diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 456e111..af0100b 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -435,30 +435,30 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // If the pixmap doesn't already have a valid surface, try binding it via EGLImage // first, as going through EGLImage should be faster and better supported: -// if (!textureIsBound && haveEglImageTFP) { -// Q_ASSERT(eglCreateImageKHR); -// -// EGLImageKHR eglImage; -// -// EGLint attribs[] = { -// EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, -// EGL_NONE -// }; -// eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, -// (EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs); -// -// QGLContext* ctx = q; -// glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage); -// -// GLint err = glGetError(); -// if (err == GL_NO_ERROR) -// textureIsBound = true; -// -// // Once the egl image is bound, the texture becomes a new sibling image and we can safely -// // destroy the EGLImage we created for the pixmap: -// if (eglImage != EGL_NO_IMAGE_KHR) -// eglDestroyImageKHR(QEgl::display(), eglImage); -// } + if (!textureIsBound && haveEglImageTFP) { + Q_ASSERT(eglCreateImageKHR); + + EGLImageKHR eglImage; + + EGLint attribs[] = { + EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, + EGL_NONE + }; + eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs); + + QGLContext* ctx = q; + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage); + + GLint err = glGetError(); + if (err == GL_NO_ERROR) + textureIsBound = true; + + // Once the egl image is bound, the texture becomes a new sibling image and we can safely + // destroy the EGLImage we created for the pixmap: + if (eglImage != EGL_NO_IMAGE_KHR) + eglDestroyImageKHR(QEgl::display(), eglImage); + } if (!textureIsBound && haveTFP) { // Check to see if the surface is still valid -- cgit v0.12 From e1e728daad07600fca7bc1811c92fb05065884c6 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 7 Apr 2010 16:55:01 +0200 Subject: O(n^2) to O(n) optimization in QTreeWidget::selectedItems() As we need to ensure that there will be no duplicates in the list returned by QTreeWidget::selectedItems() (see commit ea75d434e40100a9abf56195b646a8efdf3c1288), we now use a QSet to ensure unicity while keeping the same order as before. Reviewed-by: Olivier Task-number: QTBUG-9485 --- src/gui/itemviews/qtreewidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 19ed10b..4c80325 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -3039,10 +3039,14 @@ QList QTreeWidget::selectedItems() const Q_D(const QTreeWidget); QModelIndexList indexes = selectionModel()->selectedIndexes(); QList items; + items.reserve(indexes.count()); + QSet seen; + seen.reserve(indexes.count()); for (int i = 0; i < indexes.count(); ++i) { QTreeWidgetItem *item = d->item(indexes.at(i)); - if (isItemHidden(item) || items.contains(item)) // ### slow, optimize later + if (isItemHidden(item) || seen.contains(item)) continue; + seen.insert(item); items.append(item); } return items; -- cgit v0.12 From 75b338aaa8e3c5138718019e95271d8eed5f0c39 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 18 Mar 2010 22:24:13 +0900 Subject: Fix compile error with QT_NO_ANIMATION Task-number: QTBUG-7414 Author: Tasuku Suzuki --- src/gui/animation/qguivariantanimation.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp index 52303f5..28cde3e 100644 --- a/src/gui/animation/qguivariantanimation.cpp +++ b/src/gui/animation/qguivariantanimation.cpp @@ -38,12 +38,11 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -#ifndef QT_NO_ANIMATION - #include #include +#ifndef QT_NO_ANIMATION + #include #include #include -- cgit v0.12 From bf195e57ff96c326fa26c6b3a4f64e26d18fd9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 8 Apr 2010 13:50:46 +0200 Subject: Fixed bug in QPainterPath::intersected(). When we compute the angle delta we can't use qFuzzyCompare as it will cause slightly negative deltas to be snapped to 0, causing the winged edge builder to put path edges in the wrong order. Task-number: QTBUG-3778 Reviewed-by: Trond --- src/gui/painting/qpathclipper.cpp | 7 +++---- tests/auto/qpathclipper/tst_qpathclipper.cpp | 29 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 949a820..00e74ba 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -935,10 +935,9 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const qreal result = b_angle - a_angle; - if (qFuzzyIsNull(result) || qFuzzyCompare(result, 128)) - return 0; - - if (result < 0) + if (result >= 128.) + return result - 128.; + else if (result < 0) return result + 128.; else return result; diff --git a/tests/auto/qpathclipper/tst_qpathclipper.cpp b/tests/auto/qpathclipper/tst_qpathclipper.cpp index 38d253a..db5a13e 100644 --- a/tests/auto/qpathclipper/tst_qpathclipper.cpp +++ b/tests/auto/qpathclipper/tst_qpathclipper.cpp @@ -95,6 +95,8 @@ private slots: void task209056(); void task251909(); + + void qtbug3778(); }; Q_DECLARE_METATYPE(QPainterPath) @@ -1346,6 +1348,33 @@ void tst_QPathClipper::task251909() QVERIFY(result.elementCount() <= 5); } +void tst_QPathClipper::qtbug3778() +{ + QPainterPath path1; + path1.moveTo(200, 3.22409e-5); + // e-5 and higher leads to a bug + // Using 3.22409e-4 starts to work correctly + path1.lineTo(0, 0); + path1.lineTo(1.07025e-13, 1450); + path1.lineTo(750, 950); + path1.lineTo(950, 750); + path1.lineTo(200, 3.22409e-13); + + QPainterPath path2; + path2.moveTo(0, 0); + path2.lineTo(200, 800); + path2.lineTo(600, 1500); + path2.lineTo(1500, 1400); + path2.lineTo(1900, 1200); + path2.lineTo(2000, 1000); + path2.lineTo(1400, 0); + path2.lineTo(0, 0); + + QPainterPath p12 = path1.intersected(path2); + + QVERIFY(p12.contains(QPointF(100, 100))); +} + QTEST_APPLESS_MAIN(tst_QPathClipper) -- cgit v0.12 From 4a557f79976d7b6cbb1fa35d728cba784dc32a09 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Thu, 8 Apr 2010 16:01:18 +0200 Subject: Use DIR_SEPARATOR when setting up variables for RCC and UIC in features. When using the configuration option "-config silent" building on MinGW fails due to the use of the backslash as path delimiter. Using DIR_SEPARATOR instead of the hardcoded delimiter (like done for MOC) fixes this. Reviewed-by: aavit Merge-request: 1697 Reviewed-by: aavit --- mkspecs/features/resources.prf | 4 ++-- mkspecs/features/uic.prf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index 8ccd576..eb33aab 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -1,6 +1,6 @@ isEmpty(QMAKE_RCC) { - win32:QMAKE_RCC = $$[QT_INSTALL_BINS]\rcc.exe - else:QMAKE_RCC = $$[QT_INSTALL_BINS]/rcc + win32:QMAKE_RCC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}rcc.exe + else:QMAKE_RCC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}rcc } isEmpty(RCC_DIR):RCC_DIR = . diff --git a/mkspecs/features/uic.prf b/mkspecs/features/uic.prf index eaf373a..8ebe0ea 100644 --- a/mkspecs/features/uic.prf +++ b/mkspecs/features/uic.prf @@ -1,11 +1,11 @@ isEmpty(QMAKE_UIC3) { - contains(QMAKE_HOST.os,Windows):QMAKE_UIC3 = $$[QT_INSTALL_BINS]\uic3.exe + contains(QMAKE_HOST.os,Windows):QMAKE_UIC3 = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic3.exe else:QMAKE_UIC3 = $$[QT_INSTALL_BINS]/uic3 } isEmpty(QMAKE_UIC) { - contains(QMAKE_HOST.os,Windows):QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe + contains(QMAKE_HOST.os,Windows):QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe else:QMAKE_UIC = $$[QT_INSTALL_BINS]/uic } -- cgit v0.12 From 3b68918cf1754a915b0c399d855f178cb934ad6c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 8 Apr 2010 15:52:26 +0200 Subject: Get stride from LinuxFB instead of calculating it ourselves. Fix comes from the bug report. Task-number: QTBUG-9532 Reviewed-by: Tom --- src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c index e6ac418..d05dd5d 100644 --- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c +++ b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c @@ -95,7 +95,7 @@ static int pvrQwsInitFbScreen(int screen) width = var.xres; height = var.yres; bytesPerPixel = var.bits_per_pixel / 8; - stride = var.xres * bytesPerPixel; + stride = fix.line_length; format = PVR2D_1BPP; if (var.bits_per_pixel == 16) { if (var.red.length == 5 && var.green.length == 6 && -- cgit v0.12 From 670e4fd179027eb13d4fc1558cac6eabade4a4d0 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Thu, 8 Apr 2010 16:20:43 +0200 Subject: Support 8-Track e-Ink devices This patch adds support for e-Ink devices based on the 8-Track chipset, such as the Sony PRS-505. The 8-Track driver is a Linux framebuffer driver with a few extensions and a few glitches in information reporting. Merge-request: 417 Reviewed-by: Tom Cooksey --- src/gui/embedded/qscreenlinuxfb_qws.cpp | 52 +++++++++++++++++++++++++++++---- src/gui/embedded/qscreenlinuxfb_qws.h | 1 + 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/gui/embedded/qscreenlinuxfb_qws.cpp b/src/gui/embedded/qscreenlinuxfb_qws.cpp index 8a21022..2cdd16f 100644 --- a/src/gui/embedded/qscreenlinuxfb_qws.cpp +++ b/src/gui/embedded/qscreenlinuxfb_qws.cpp @@ -91,6 +91,7 @@ public: int startuph; int startupd; bool blank; + bool is8Track; bool doGraphicsMode; #ifdef QT_QWS_DEPTH_GENERIC @@ -164,6 +165,19 @@ void QLinuxFbScreenPrivate::closeTty() ttyfd = -1; } +static void fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo) +{ + // 8Track e-ink devices (as found in Sony PRS-505) lie + // about their bit depth -- they claim they're 1 bit per + // pixel while the only supported mode is 8 bit per pixel + // grayscale. + // Caused by this, they also miscalculate their line length. + if(!strcmp(finfo.id, "8TRACKFB") && vinfo.bits_per_pixel == 1) { + vinfo.bits_per_pixel = 8; + finfo.line_length = vinfo.xres; + } +} + /*! \internal @@ -306,6 +320,8 @@ bool QLinuxFbScreen::connect(const QString &displaySpec) return false; } + d_ptr->is8Track = !strcmp(finfo.id, "8TRACKFB"); + if (finfo.type == FB_TYPE_VGA_PLANES) { qWarning("VGA16 video mode not supported"); return false; @@ -318,6 +334,8 @@ bool QLinuxFbScreen::connect(const QString &displaySpec) return false; } + fixupScreenInfo(finfo, vinfo); + grayscale = vinfo.grayscale; d = vinfo.bits_per_pixel; if (d == 24) { @@ -664,11 +682,6 @@ bool QLinuxFbScreen::initDevice() vinfo.transp.msb_right); #endif - d_ptr->startupw=vinfo.xres; - d_ptr->startuph=vinfo.yres; - d_ptr->startupd=vinfo.bits_per_pixel; - grayscale = vinfo.grayscale; - if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) { perror("QLinuxFbScreen::initDevice"); qCritical("Error reading fixed information in card init"); @@ -677,6 +690,13 @@ bool QLinuxFbScreen::initDevice() return true; } + fixupScreenInfo(finfo, vinfo); + + d_ptr->startupw=vinfo.xres; + d_ptr->startuph=vinfo.yres; + d_ptr->startupd=vinfo.bits_per_pixel; + grayscale = vinfo.grayscale; + #ifdef __i386__ // Now init mtrr if(!::getenv("QWS_NOMTRR")) { @@ -1122,6 +1142,7 @@ void QLinuxFbScreen::setMode(int nw,int nh,int nd) qFatal("Error reading fixed information"); } + fixupScreenInfo(finfo, vinfo); disconnect(); connect(d_ptr->displaySpec); exposeRegion(region(), 0); @@ -1200,6 +1221,23 @@ int QLinuxFbScreen::sharedRamSize(void * end) /*! \reimp */ +void QLinuxFbScreen::setDirty(const QRect &) +{ + if(d_ptr->is8Track) { + // e-Ink displays need a trigger to actually show what is + // in their framebuffer memory. The 8-Track driver does this + // by adding custom IOCTLs - FBIO_EINK_DISP_PIC (0x46a2) takes + // an argument specifying whether or not to update the Flash + // memory. + // There doesn't seem to be a way to tell it to just update + // a subset of the screen. + ioctl(d_ptr->fd, 0x46a2, 1); + } +} + +/*! + \reimp +*/ void QLinuxFbScreen::blank(bool on) { if (d_ptr->blank == on) @@ -1315,7 +1353,9 @@ void QLinuxFbScreen::setPixelFormat(struct fb_var_screeninfo info) bool QLinuxFbScreen::useOffscreen() { - if ((mapsize - size) < 16*1024) + // Not done for 8Track because on e-Ink displays, + // everything is offscreen anyway + if (d_ptr->is8Track || ((mapsize - size) < 16*1024)) return false; return true; diff --git a/src/gui/embedded/qscreenlinuxfb_qws.h b/src/gui/embedded/qscreenlinuxfb_qws.h index ac488b7..0854191 100644 --- a/src/gui/embedded/qscreenlinuxfb_qws.h +++ b/src/gui/embedded/qscreenlinuxfb_qws.h @@ -98,6 +98,7 @@ public: virtual uchar * cache(int); virtual void uncache(uchar *); virtual int sharedRamSize(void *); + virtual void setDirty(const QRect&); QLinuxFb_Shared * shared; -- cgit v0.12 From e1671f51dde620a403fdf9a6d71d9a89f8795b96 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Thu, 8 Apr 2010 16:20:44 +0200 Subject: Tweak the display update IOCTL calls It seems to be best practice to pass the "update flash" command only when the entire display needs to be updated, while the refresh call without updating flash is sufficient for updating smaller regions Merge-request: 417 Reviewed-by: Tom Cooksey --- src/gui/embedded/qscreenlinuxfb_qws.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/embedded/qscreenlinuxfb_qws.cpp b/src/gui/embedded/qscreenlinuxfb_qws.cpp index 2cdd16f..4c91416 100644 --- a/src/gui/embedded/qscreenlinuxfb_qws.cpp +++ b/src/gui/embedded/qscreenlinuxfb_qws.cpp @@ -1221,7 +1221,7 @@ int QLinuxFbScreen::sharedRamSize(void * end) /*! \reimp */ -void QLinuxFbScreen::setDirty(const QRect &) +void QLinuxFbScreen::setDirty(const QRect &r) { if(d_ptr->is8Track) { // e-Ink displays need a trigger to actually show what is @@ -1231,7 +1231,10 @@ void QLinuxFbScreen::setDirty(const QRect &) // memory. // There doesn't seem to be a way to tell it to just update // a subset of the screen. - ioctl(d_ptr->fd, 0x46a2, 1); + if(r.left() == 0 && r.top() == 0 && r.width() == dw && r.height() == dh) + ioctl(d_ptr->fd, 0x46a2, 1); + else + ioctl(d_ptr->fd, 0x46a2, 0); } } -- cgit v0.12 From f1c3756ff7fae9caea84b70dfda139757a0ef98d Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Thu, 8 Apr 2010 16:20:45 +0200 Subject: e-Ink support cleanup * make fixupScreenInfo a protected virtual function * Change is8Track bool to DriverType enum * Document new functions Merge-request: 417 Reviewed-by: Tom Cooksey --- src/gui/embedded/qscreenlinuxfb_qws.cpp | 31 ++++++++++++++++++++++++------- src/gui/embedded/qscreenlinuxfb_qws.h | 3 +++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/gui/embedded/qscreenlinuxfb_qws.cpp b/src/gui/embedded/qscreenlinuxfb_qws.cpp index 4c91416..16ea4dd 100644 --- a/src/gui/embedded/qscreenlinuxfb_qws.cpp +++ b/src/gui/embedded/qscreenlinuxfb_qws.cpp @@ -91,7 +91,7 @@ public: int startuph; int startupd; bool blank; - bool is8Track; + QLinuxFbScreen::DriverTypes driverType; bool doGraphicsMode; #ifdef QT_QWS_DEPTH_GENERIC @@ -165,7 +165,24 @@ void QLinuxFbScreenPrivate::closeTty() ttyfd = -1; } -static void fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo) +/*! + \enum QLinuxFbScreen::DriverTypes + + This enum describes the driver type. + + \value GenericDriver Generic Linux framebuffer driver + \value EInk8Track e-Ink framebuffer driver using the 8Track chipset + */ + +/*! + \fn QLinuxFbScreen::fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo) + + Adjust the values returned by the framebuffer driver, to work + around driver bugs or nonstandard behavior in certain drivers. + \a finfo and \a vinfo specify the fixed and variable screen info + returned by the driver. + */ +void QLinuxFbScreen::fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo) { // 8Track e-ink devices (as found in Sony PRS-505) lie // about their bit depth -- they claim they're 1 bit per @@ -320,7 +337,7 @@ bool QLinuxFbScreen::connect(const QString &displaySpec) return false; } - d_ptr->is8Track = !strcmp(finfo.id, "8TRACKFB"); + d_ptr->driverType = strcmp(finfo.id, "8TRACKFB") ? GenericDriver : EInk8Track; if (finfo.type == FB_TYPE_VGA_PLANES) { qWarning("VGA16 video mode not supported"); @@ -1223,12 +1240,12 @@ int QLinuxFbScreen::sharedRamSize(void * end) */ void QLinuxFbScreen::setDirty(const QRect &r) { - if(d_ptr->is8Track) { + if(d_ptr->driverType == EInk8Track) { // e-Ink displays need a trigger to actually show what is // in their framebuffer memory. The 8-Track driver does this // by adding custom IOCTLs - FBIO_EINK_DISP_PIC (0x46a2) takes - // an argument specifying whether or not to update the Flash - // memory. + // an argument specifying whether or not to flash the screen + // while updating. // There doesn't seem to be a way to tell it to just update // a subset of the screen. if(r.left() == 0 && r.top() == 0 && r.width() == dw && r.height() == dh) @@ -1358,7 +1375,7 @@ bool QLinuxFbScreen::useOffscreen() { // Not done for 8Track because on e-Ink displays, // everything is offscreen anyway - if (d_ptr->is8Track || ((mapsize - size) < 16*1024)) + if (d_ptr->driverType == EInk8Track || ((mapsize - size) < 16*1024)) return false; return true; diff --git a/src/gui/embedded/qscreenlinuxfb_qws.h b/src/gui/embedded/qscreenlinuxfb_qws.h index 0854191..6abadbf 100644 --- a/src/gui/embedded/qscreenlinuxfb_qws.h +++ b/src/gui/embedded/qscreenlinuxfb_qws.h @@ -88,6 +88,8 @@ public: virtual bool useOffscreen(); + enum DriverTypes { GenericDriver, EInk8Track }; + virtual void disconnect(); virtual void shutdownDevice(); virtual void setMode(int,int,int); @@ -110,6 +112,7 @@ protected: int dataoffset; int cacheStart; + virtual void fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo); static void clearCache(QScreen *instance, int); private: -- cgit v0.12 From 806f0c05ec590d2d8ad0b5e0a6b2b22c76c4d871 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Thu, 8 Apr 2010 16:20:46 +0200 Subject: Adjust indentation Adjust indentation to match the rest of the file Merge-request: 417 Reviewed-by: Tom Cooksey --- src/gui/embedded/qscreenlinuxfb_qws.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/embedded/qscreenlinuxfb_qws.cpp b/src/gui/embedded/qscreenlinuxfb_qws.cpp index 16ea4dd..1effcfa 100644 --- a/src/gui/embedded/qscreenlinuxfb_qws.cpp +++ b/src/gui/embedded/qscreenlinuxfb_qws.cpp @@ -1242,16 +1242,16 @@ void QLinuxFbScreen::setDirty(const QRect &r) { if(d_ptr->driverType == EInk8Track) { // e-Ink displays need a trigger to actually show what is - // in their framebuffer memory. The 8-Track driver does this - // by adding custom IOCTLs - FBIO_EINK_DISP_PIC (0x46a2) takes - // an argument specifying whether or not to flash the screen - // while updating. - // There doesn't seem to be a way to tell it to just update - // a subset of the screen. - if(r.left() == 0 && r.top() == 0 && r.width() == dw && r.height() == dh) - ioctl(d_ptr->fd, 0x46a2, 1); - else - ioctl(d_ptr->fd, 0x46a2, 0); + // in their framebuffer memory. The 8-Track driver does this + // by adding custom IOCTLs - FBIO_EINK_DISP_PIC (0x46a2) takes + // an argument specifying whether or not to flash the screen + // while updating. + // There doesn't seem to be a way to tell it to just update + // a subset of the screen. + if(r.left() == 0 && r.top() == 0 && r.width() == dw && r.height() == dh) + ioctl(d_ptr->fd, 0x46a2, 1); + else + ioctl(d_ptr->fd, 0x46a2, 0); } } -- cgit v0.12 From 9ff7a7252ded96084c40947f5ae386b7365c180d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 25 Mar 2010 17:23:45 +0100 Subject: Make configure.exe compatible with mingw 64 --- tools/configure/environment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index 74bebb2..60b8dcc 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -73,7 +73,7 @@ struct CompilerInfo{ } compiler_info[] = { // The compilers here are sorted in a reversed-preferred order {CC_BORLAND, "Borland C++", 0, "bcc32.exe"}, - {CC_MINGW, "MinGW (Minimalist GNU for Windows)", 0, "mingw32-gcc.exe"}, + {CC_MINGW, "MinGW (Minimalist GNU for Windows)", 0, "g++.exe"}, {CC_INTEL, "Intel(R) C++ Compiler for 32-bit applications", 0, "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe {CC_MSVC6, "Microsoft (R) 32-bit C/C++ Optimizing Compiler (6.x)", "Software\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++\\ProductDir", "cl.exe"}, // link.exe, lib.exe {CC_NET2002, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2002 (7.0)", "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir", "cl.exe"}, // link.exe, lib.exe -- cgit v0.12 From fa46493ef935ecfc915fa03c4c2372236c70bede Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 8 Apr 2010 17:12:42 +0200 Subject: Fix build with mingw (64 bit) --- src/corelib/tools/qsimd_p.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index c69dd09..cbe6146 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -66,6 +66,9 @@ QT_BEGIN_HEADER # include # undef posix_memalign #else +# ifdef Q_CC_MINGW +# include +# endif # include #endif -- cgit v0.12 From b69d5d35e0705a494aff6dfd021dde1ace1b3d7b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 9 Apr 2010 09:48:31 +0200 Subject: Build fix for mingw --- tools/assistant/lib/fulltextsearch/qclucene-config_p.h | 14 ++++++-------- tools/assistant/lib/fulltextsearch/qclucene_global_p.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/assistant/lib/fulltextsearch/qclucene-config_p.h b/tools/assistant/lib/fulltextsearch/qclucene-config_p.h index 0c70718..387d64d 100644 --- a/tools/assistant/lib/fulltextsearch/qclucene-config_p.h +++ b/tools/assistant/lib/fulltextsearch/qclucene-config_p.h @@ -314,14 +314,12 @@ configure. #define _CL_HAVE_SYS_TYPES_H 1 #endif -// Do not use the tchar.h that ships with mingw, this causes the qt build to -// fail (211547, 211401, etc...), reuse the replacement as with any other compiler -// #if defined(__MINGW32__) -// /* Define to 1 if you have the header file. */ -// # ifndef _CL_HAVE_TCHAR_H -// # define _CL_HAVE_TCHAR_H 1 -// # endif -// #endif +#if defined(__MINGW32__) + /* Define to 1 if you have the header file. */ + # ifndef _CL_HAVE_TCHAR_H + # define _CL_HAVE_TCHAR_H 1 + # endif +#endif #if defined(__MINGW32__) || defined(__SUNPRO_CC) || defined(__SUNPRO_C) /* Define to 1 if you have the `tell' function. */ diff --git a/tools/assistant/lib/fulltextsearch/qclucene_global_p.h b/tools/assistant/lib/fulltextsearch/qclucene_global_p.h index f4b744d..206725b 100644 --- a/tools/assistant/lib/fulltextsearch/qclucene_global_p.h +++ b/tools/assistant/lib/fulltextsearch/qclucene_global_p.h @@ -36,7 +36,7 @@ #include #include -#if !defined(_MSC_VER) && defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) +#if !defined(_MSC_VER) && !defined(__MINGW32__) && defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) # if !defined(TCHAR) # define TCHAR wchar_t # endif -- cgit v0.12 From 0d1be2406cb58a51ef5a7271fbf5e191fe50ab91 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 9 Apr 2010 10:50:20 +0200 Subject: Allow y-interted pixmaps for brushes in GL2 paint engine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This means texture-from-pixmap can now be used for brush pixmaps. Task-number: QTBUG-9707 Task-number: QT-3013 Reviewed-By: Samuel Rødal --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 9ed722f..2275c3d 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -217,7 +217,9 @@ void QGL2PaintEngineExPrivate::updateBrushTexture() const QPixmap& texPixmap = currentBrush.texture(); glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); - QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); + QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption | + QGLContext::CanFlipNativePixmapBindOption); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform); textureInvertedY = tex->options & QGLContext::InvertedYBindOption ? -1 : 1; } -- cgit v0.12 From 6a9e6f4780f5fc3aaf34f93c85de575f81c91e48 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 9 Apr 2010 11:24:43 +0200 Subject: Speedup fetchTransformedBilinear in the fast_matrix case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3% faster on a trace from the qml samegame. Reviewed-by: Samuel Rødal --- src/gui/painting/qdrawhelper.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 917b910..6561419 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -70,8 +70,10 @@ static uint gccBug(uint value) constants and structures */ -static const int fixed_scale = 1 << 16; -static const int half_point = 1 << 15; +enum { + fixed_scale = 1 << 16, + half_point = 1 << 15 +}; static const int buffer_size = 2048; struct LinearGradientValues @@ -695,11 +697,6 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * int y1 = (fy >> 16); int y2 = y1 + 1; - int distx = ((fx - (x1 << 16)) >> 8); - int disty = ((fy - (y1 << 16)) >> 8); - int idistx = 256 - distx; - int idisty = 256 - disty; - if (blendType == BlendTransformedBilinearTiled) { x1 %= image_width; x2 %= image_width; @@ -730,6 +727,11 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * uint bl = fetch(s2, x1, data->texture.colorTable); uint br = fetch(s2, x2, data->texture.colorTable); + int distx = (fx & 0x0000ffff) >> 8; + int disty = (fy & 0x0000ffff) >> 8; + int idistx = 256 - distx; + int idisty = 256 - disty; + uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); -- cgit v0.12 From ef3b0420bfa9ef810267d174922ff2477f983c8d Mon Sep 17 00:00:00 2001 From: miniak Date: Fri, 9 Apr 2010 14:04:43 +0200 Subject: Remove obsolete function set_winapp_name() Make sure that qWinAppInst(), qWinAppPrevInst(), qWinAppCmdShow() return correct values. Merge-request: 2263 Reviewed-by: Thierry Bastian --- src/corelib/kernel/qcoreapplication.cpp | 7 ---- src/corelib/kernel/qcoreapplication_win.cpp | 51 ++++++++--------------------- 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 8fc3fb8..f30f301 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -522,8 +522,6 @@ QCoreApplication::QCoreApplication(int &argc, char **argv) } -extern void set_winapp_name(); - // ### move to QCoreApplicationPrivate constructor? void QCoreApplication::init() { @@ -534,11 +532,6 @@ void QCoreApplication::init() qt_locale_initialized = true; #endif -#ifdef Q_WS_WIN - // Get the application name/instance if qWinMain() was not invoked - set_winapp_name(); -#endif - Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object"); QCoreApplication::self = this; diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index c1925e7..040b2cc 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -52,26 +52,26 @@ QT_BEGIN_NAMESPACE -char appFileName[MAX_PATH]; // application file name -char theAppName[MAX_PATH]; // application name -HINSTANCE appInst = 0; // handle to app instance -HINSTANCE appPrevInst = 0; // handle to prev app instance -int appCmdShow = 0; bool usingWinMain = false; // whether the qWinMain() is used or not Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle { - return appInst; + return GetModuleHandle(0); } Q_CORE_EXPORT HINSTANCE qWinAppPrevInst() // get Windows prev app handle { - return appPrevInst; + return 0; } Q_CORE_EXPORT int qWinAppCmdShow() // get main window show command { - return appCmdShow; + STARTUPINFO startupInfo; + GetStartupInfo(&startupInfo); + + return (startupInfo.dwFlags & STARTF_USESHOWWINDOW) + ? startupInfo.wShowWindow + : SW_SHOWDEFAULT; } Q_CORE_EXPORT QString qAppFileName() // get application file name @@ -115,25 +115,6 @@ Q_CORE_EXPORT QString qAppFileName() // get application file name return res; } -void set_winapp_name() -{ - static bool already_set = false; - if (!already_set) { - already_set = true; - - QString moduleName = qAppFileName(); - - QByteArray filePath = moduleName.toLocal8Bit(); - QByteArray fileName = QFileInfo(moduleName).baseName().toLocal8Bit(); - - memcpy(appFileName, filePath.constData(), filePath.length()); - memcpy(theAppName, fileName.constData(), fileName.length()); - - if (appInst == 0) - appInst = GetModuleHandle(0); - } -} - QString QCoreApplicationPrivate::appName() const { return QFileInfo(qAppFileName()).baseName(); @@ -198,20 +179,16 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, already_called = true; usingWinMain = true; - // Install default debug handler - + // Install default debug handler qInstallMsgHandler(qWinMsgHandler); - // Create command line - + // Create command line argv = qWinCmdLine(cmdParam, int(strlen(cmdParam)), argc); - // Get Windows parameters - - appInst = instance; - appPrevInst = prevInstance; - appCmdShow = cmdShow; - set_winapp_name(); + // Ignore Windows parameters + Q_UNUSED(instance); + Q_UNUSED(prevInstance); + Q_UNUSED(cmdShow); } /*! -- cgit v0.12 From e31beded6bbb75a50edb1c42690c9d6b5b9a4c6a Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 9 Apr 2010 14:26:03 +0200 Subject: Improve matching X11 VisualIDs to EGL configs Use the individual channel sizes to match rather than the combined per-pixel sizes. Task-number: QTBUG-9444 Reviewed-By: Trond --- src/gui/egl/qegl_x11.cpp | 77 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index 91423c8..5341ea1 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -147,9 +147,6 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) EGLint configAlphaSize = 0; eglGetConfigAttrib(display(), config, EGL_ALPHA_SIZE, &configAlphaSize); - eglGetConfigAttrib(display(), config, EGL_BUFFER_SIZE, &eglValue); - int configBitDepth = eglValue; - eglGetConfigAttrib(display(), config, EGL_CONFIG_ID, &eglValue); int configId = eglValue; @@ -166,28 +163,53 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) int matchingCount = 0; chosenVisualInfo = XGetVisualInfo(X11->display, VisualIDMask, &visualInfoTemplate, &matchingCount); if (chosenVisualInfo) { - if (configBitDepth == chosenVisualInfo->depth) { + int visualRedSize = countBits(chosenVisualInfo->red_mask); + int visualGreenSize = countBits(chosenVisualInfo->green_mask); + int visualBlueSize = countBits(chosenVisualInfo->blue_mask); + int visualAlphaSize = -1; // Need XRender to tell us the alpha channel size + #if !defined(QT_NO_XRENDER) + if (X11->use_xrender) { // If we have XRender, actually check the visual supplied by EGL is ARGB - if (configAlphaSize > 0) { - XRenderPictFormat *format; - format = XRenderFindVisualFormat(X11->display, chosenVisualInfo->visual); - if (!format || (format->type != PictTypeDirect) || (!format->direct.alphaMask)) { - qWarning("Warning: EGL suggested using X visual ID %d for config %d, but this is not ARGB", - (int)visualId, configId); - visualId = 0; - } - } + XRenderPictFormat *format; + format = XRenderFindVisualFormat(X11->display, chosenVisualInfo->visual); + if (format && (format->type == PictTypeDirect)) + visualAlphaSize = countBits(format->direct.alphaMask); + } #endif - } else { - qWarning("Warning: EGL suggested using X visual ID %d (%d bpp) for config %d (%d bpp), but the depths do not match!", - (int)visualId, chosenVisualInfo->depth, configId, configBitDepth); + + bool visualMatchesConfig = false; + if ( visualRedSize == configRedSize && + visualGreenSize == configGreenSize && + visualBlueSize == configBlueSize ) + { + // We need XRender to check the alpha channel size of the visual. If we don't have + // the alpha size, we don't check it against the EGL config's alpha size. + if (visualAlphaSize >= 0) + visualMatchesConfig = visualAlphaSize == configAlphaSize; + else + visualMatchesConfig = true; + } + + if (!visualMatchesConfig) { + if (visualAlphaSize >= 0) { + qWarning("Warning: EGL suggested using X Visual ID %d (ARGB%d%d%d%d) for EGL config %d (ARGB%d%d%d%d), but this is incompatable", + (int)visualId, visualAlphaSize, visualRedSize, visualGreenSize, visualBlueSize, + configId, configAlphaSize, configRedSize, configGreenSize, configBlueSize); + } else { + qWarning("Warning: EGL suggested using X Visual ID %d (RGB%d%d%d) for EGL config %d (RGB%d%d%d), but this is incompatable", + (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, + configId, configRedSize, configGreenSize, configBlueSize); + } visualId = 0; } + } else { + qWarning("Warning: EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID", + (int)visualId, configId); + visualId = 0; } XFree(chosenVisualInfo); } - if (visualId) { #ifdef QT_DEBUG_X11_VISUAL_SELECTION if (configAlphaSize > 0) @@ -201,17 +223,16 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) // If EGL didn't give us a valid visual ID, try XRender #if !defined(QT_NO_XRENDER) - if (!visualId) { + if (!visualId && X11->use_xrender) { XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - visualInfoTemplate.depth = configBitDepth; visualInfoTemplate.c_class = TrueColor; XVisualInfo *matchingVisuals; int matchingCount = 0; matchingVisuals = XGetVisualInfo(X11->display, - VisualDepthMask|VisualClassMask, + VisualClassMask, &visualInfoTemplate, &matchingCount); @@ -246,19 +267,27 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) // Finally, if XRender also failed to find a visual (or isn't present), try to - // use XGetVisualInfo and only use the bit depth to match on: + // use XGetVisualInfo and only use the bit depths to match on: if (!visualId) { XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - - visualInfoTemplate.depth = configBitDepth; - XVisualInfo *matchingVisuals; int matchingCount = 0; + + visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize; matchingVisuals = XGetVisualInfo(X11->display, VisualDepthMask, &visualInfoTemplate, &matchingCount); + if (!matchingVisuals) { + // Try again without taking the alpha channel into account: + visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize; + matchingVisuals = XGetVisualInfo(X11->display, + VisualDepthMask, + &visualInfoTemplate, + &matchingCount); + } + if (matchingVisuals) { visualId = matchingVisuals[0].visualid; XFree(matchingVisuals); -- cgit v0.12 From 82870f794fb61930d8a944d78c966b847c831d5c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 9 Apr 2010 15:13:17 +0200 Subject: QDrawHelper: Reduce code duplications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And apply same optimisation as in 6a9e6f4780f5fc3aaf34f93c85de575f81c91e48 for duplicated code Reviewed-by: Samuel Rødal --- src/gui/painting/qdrawhelper.cpp | 276 +++++++++------------------------------ 1 file changed, 61 insertions(+), 215 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 6561419..322882d 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5143,7 +5143,7 @@ static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData) } -template +template /* blendType must be either BlendTransformedBilinear or BlendTransformedBilinearTiled */ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -5156,10 +5156,12 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; uint buffer[buffer_size]; - int image_x1 = data->texture.x1; - int image_y1 = data->texture.y1; - int image_x2 = data->texture.x2; - int image_y2 = data->texture.y2; + const int image_x1 = data->texture.x1; + const int image_y1 = data->texture.y1; + const int image_x2 = data->texture.x2; + const int image_y2 = data->texture.y2; + const int image_width = data->texture.width; + const int image_height = data->texture.height; const int scanline_offset = data->texture.bytesPerLine / 4; if (data->fast_matrix) { @@ -5193,15 +5195,27 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const int y1 = (y >> 16); int y2 = y1 + 1; - int distx = ((x - (x1 << 16)) >> 8); - int disty = ((y - (y1 << 16)) >> 8); - int idistx = 256 - distx; - int idisty = 256 - disty; - - x1 = qBound(image_x1, x1, image_x2 - 1); - x2 = qBound(image_x1, x2, image_x2 - 1); - y1 = qBound(image_y1, y1, image_y2 - 1); - y2 = qBound(image_y1, y2, image_y2 - 1); + if (blendType == BlendTransformedBilinearTiled) { + x1 %= image_width; + x2 %= image_width; + y1 %= image_height; + y2 %= image_height; + + if (x1 < 0) x1 += image_width; + if (x2 < 0) x2 += image_width; + if (y1 < 0) y1 += image_height; + if (y2 < 0) y2 += image_height; + + Q_ASSERT(x1 >= 0 && x1 < image_width); + Q_ASSERT(x2 >= 0 && x2 < image_width); + Q_ASSERT(y1 >= 0 && y1 < image_height); + Q_ASSERT(y2 >= 0 && y2 < image_height); + } else { + x1 = qBound(image_x1, x1, image_x2 - 1); + x2 = qBound(image_x1, x2, image_x2 - 1); + y1 = qBound(image_y1, y1, image_y2 - 1); + y2 = qBound(image_y1, y2, image_y2 - 1); + } int y1_offset = y1 * scanline_offset; int y2_offset = y2 * scanline_offset; @@ -5218,6 +5232,11 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const uint br = image_bits[y2_offset + x2]; #endif + int distx = (x & 0x0000ffff) >> 8; + int disty = (y & 0x0000ffff) >> 8; + int idistx = 256 - distx; + int idisty = 256 - disty; + uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); @@ -5276,10 +5295,27 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const int idistx = 256 - distx; int idisty = 256 - disty; - x1 = qBound(image_x1, x1, image_x2 - 1); - x2 = qBound(image_x1, x2, image_x2 - 1); - y1 = qBound(image_y1, y1, image_y2 - 1); - y2 = qBound(image_y1, y2, image_y2 - 1); + if (blendType == BlendTransformedBilinearTiled) { + x1 %= image_width; + x2 %= image_width; + y1 %= image_height; + y2 %= image_height; + + if (x1 < 0) x1 += image_width; + if (x2 < 0) x2 += image_width; + if (y1 < 0) y1 += image_height; + if (y2 < 0) y2 += image_height; + + Q_ASSERT(x1 >= 0 && x1 < image_width); + Q_ASSERT(x2 >= 0 && x2 < image_width); + Q_ASSERT(y1 >= 0 && y1 < image_height); + Q_ASSERT(y2 >= 0 && y2 < image_height); + } else { + x1 = qBound(image_x1, x1, image_x2 - 1); + x2 = qBound(image_x1, x2, image_x2 - 1); + y1 = qBound(image_y1, y1, image_y2 - 1); + y2 = qBound(image_y1, y2, image_y2 - 1); + } int y1_offset = y1 * scanline_offset; int y2_offset = y2 * scanline_offset; @@ -5372,8 +5408,9 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan int y1 = (y >> 16); int y2 = y1 + 1; - const int distx = ((x - (x1 << 16)) >> 8); - const int disty = ((y - (y1 << 16)) >> 8); + const int distx = (x & 0x0000ffff) >> 8; + const int disty = (y & 0x0000ffff) >> 8; + x1 = qBound(src_minx, x1, src_maxx); x2 = qBound(src_minx, x2, src_maxx); y1 = qBound(src_miny, y1, src_maxy); @@ -5648,197 +5685,6 @@ static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, voi } template -Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_tiled_argb(int count, const QSpan *spans, void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - if (data->texture.format != QImage::Format_ARGB32_Premultiplied - && data->texture.format != QImage::Format_RGB32) { - blend_src_generic(count, spans, userData); - return; - } - - CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; - uint buffer[buffer_size]; - - int image_width = data->texture.width; - int image_height = data->texture.height; - const int scanline_offset = data->texture.bytesPerLine / 4; - - if (data->fast_matrix) { - // The increment pr x in the scanline - int fdx = (int)(data->m11 * fixed_scale); - int fdy = (int)(data->m12 * fixed_scale); - - while (count--) { - void *t = data->rasterBuffer->scanLine(spans->y); - - uint *target = ((uint *)t) + spans->x; - uint *image_bits = (uint *)data->texture.imageData; - - const qreal cx = spans->x + 0.5; - const qreal cy = spans->y + 0.5; - - int x = int((data->m21 * cy - + data->m11 * cx + data->dx) * fixed_scale) - half_point; - int y = int((data->m22 * cy - + data->m12 * cx + data->dy) * fixed_scale) - half_point; - - int length = spans->len; - const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; - while (length) { - int l = qMin(length, buffer_size); - const uint *end = buffer + l; - uint *b = buffer; - while (b < end) { - int x1 = (x >> 16); - int x2 = (x1 + 1); - int y1 = (y >> 16); - int y2 = (y1 + 1); - - int distx = ((x - (x1 << 16)) >> 8); - int disty = ((y - (y1 << 16)) >> 8); - int idistx = 256 - distx; - int idisty = 256 - disty; - - x1 %= image_width; - x2 %= image_width; - y1 %= image_height; - y2 %= image_height; - - if (x1 < 0) x1 += image_width; - if (x2 < 0) x2 += image_width; - if (y1 < 0) y1 += image_height; - if (y2 < 0) y2 += image_height; - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); - - int y1_offset = y1 * scanline_offset; - int y2_offset = y2 * scanline_offset; - -#if defined(Q_IRIX_GCC3_3_WORKAROUND) - uint tl = gccBug(image_bits[y1_offset + x1]); - uint tr = gccBug(image_bits[y1_offset + x2]); - uint bl = gccBug(image_bits[y2_offset + x1]); - uint br = gccBug(image_bits[y2_offset + x2]); -#else - uint tl = image_bits[y1_offset + x1]; - uint tr = image_bits[y1_offset + x2]; - uint bl = image_bits[y2_offset + x1]; - uint br = image_bits[y2_offset + x2]; -#endif - - uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); - uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); - *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); - ++b; - x += fdx; - y += fdy; - } - if (spanMethod == RegularSpans) - func(target, buffer, l, coverage); - else - drawBufferSpan(data, buffer, buffer_size, - spans->x + spans->len - length, - spans->y, l, coverage); - target += l; - length -= l; - } - ++spans; - } - } else { - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - while (count--) { - void *t = data->rasterBuffer->scanLine(spans->y); - - uint *target = ((uint *)t) + spans->x; - uint *image_bits = (uint *)data->texture.imageData; - - const qreal cx = spans->x + 0.5; - const qreal cy = spans->y + 0.5; - - qreal x = data->m21 * cy + data->m11 * cx + data->dx; - qreal y = data->m22 * cy + data->m12 * cx + data->dy; - qreal w = data->m23 * cy + data->m13 * cx + data->m33; - - int length = spans->len; - const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; - while (length) { - int l = qMin(length, buffer_size); - const uint *end = buffer + l; - uint *b = buffer; - while (b < end) { - const qreal iw = w == 0 ? 1 : 1 / w; - const qreal px = x * iw - 0.5; - const qreal py = y * iw - 0.5; - - int x1 = int(px) - (px < 0); - int x2 = x1 + 1; - int y1 = int(py) - (py < 0); - int y2 = y1 + 1; - - int distx = int((px - x1) * 256); - int disty = int((py - y1) * 256); - int idistx = 256 - distx; - int idisty = 256 - disty; - - x1 %= image_width; - x2 %= image_width; - y1 %= image_height; - y2 %= image_height; - - if (x1 < 0) x1 += image_width; - if (x2 < 0) x2 += image_width; - if (y1 < 0) y1 += image_height; - if (y2 < 0) y2 += image_height; - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); - - int y1_offset = y1 * scanline_offset; - int y2_offset = y2 * scanline_offset; - -#if defined(Q_IRIX_GCC3_3_WORKAROUND) - uint tl = gccBug(image_bits[y1_offset + x1]); - uint tr = gccBug(image_bits[y1_offset + x2]); - uint bl = gccBug(image_bits[y2_offset + x1]); - uint br = gccBug(image_bits[y2_offset + x2]); -#else - uint tl = image_bits[y1_offset + x1]; - uint tr = image_bits[y1_offset + x2]; - uint bl = image_bits[y2_offset + x1]; - uint br = image_bits[y2_offset + x2]; -#endif - - uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); - uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); - *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); - ++b; - x += fdx; - y += fdy; - w += fdw; - } - if (spanMethod == RegularSpans) - func(target, buffer, l, coverage); - else - drawBufferSpan(data, buffer, buffer_size, - spans->x + spans->len - length, - spans->y, l, coverage); - target += l; - length -= l; - } - ++spans; - } - } -} - -template Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_argb(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -6740,7 +6586,7 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 - SPANFUNC_POINTER(blend_transformed_bilinear_argb, RegularSpans), // ARGB32_Premultiplied + blend_transformed_bilinear_argb, // ARGB32_Premultiplied blend_transformed_bilinear_rgb565, blend_transformed_bilinear_argb8565, blend_transformed_bilinear_rgb666, @@ -6759,7 +6605,7 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8 SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32 SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32 - SPANFUNC_POINTER(blend_transformed_bilinear_tiled_argb, RegularSpans), // ARGB32_Premultiplied + blend_transformed_bilinear_argb, // ARGB32_Premultiplied SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB16 SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB8565_Premultiplied SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB666 @@ -6858,7 +6704,7 @@ static const ProcessSpans processTextureSpansCallback[NBlendTypes][QImage::NImag blend_src_generic, // Indexed8 blend_src_generic, // RGB32 blend_src_generic, // ARGB32 - blend_transformed_bilinear_argb, // ARGB32_Premultiplied + blend_transformed_bilinear_argb, // ARGB32_Premultiplied blend_src_generic, // RGB16 blend_src_generic, // ARGB8565_Premultiplied blend_src_generic, // RGB666 @@ -6877,7 +6723,7 @@ static const ProcessSpans processTextureSpansCallback[NBlendTypes][QImage::NImag blend_src_generic, // Indexed8 blend_src_generic, // RGB32 blend_src_generic, // ARGB32 - blend_transformed_bilinear_tiled_argb, // ARGB32_Premultiplied + blend_transformed_bilinear_argb, // ARGB32_Premultiplied blend_src_generic, // RGB16 blend_src_generic, // ARGB8565_Premultiplied blend_src_generic, // RGB666 -- cgit v0.12 From 254f093dff864f574e05540e771e1fa6d6c4f7c5 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 9 Apr 2010 16:09:12 +0200 Subject: Add runtime check for GLX >= 1.3 before using glXCreatePixmap Task-number: QTBUG-9084 Reviewed-By: TrustMe --- src/opengl/qgl_x11.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index e1a202f..d203646 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -1677,6 +1677,14 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons #if !defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX) return 0; #else + + // Check we have GLX 1.3, as it is needed for glXCreatePixmap & glXDestroyPixmap + int majorVersion = 0; + int minorVersion = 0; + glXQueryVersion(X11->display, &majorVersion, &minorVersion); + if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 3)) + return 0; + Q_Q(QGLContext); QX11PixmapData *pixmapData = static_cast(pixmap->data_ptr().data()); -- cgit v0.12 From 7558db24cea4912b8082275821ea390527d2a911 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 9 Apr 2010 16:20:26 +0200 Subject: Don't use texture-from-pixmap if the target isn't GL_TEXTURE_2D Task-number: QTBUG-8546 Reviewed-By: TrustMe --- src/opengl/qgl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index e56b149..5595e02 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2442,7 +2442,8 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, // Try to use texture_from_pixmap const QX11Info *xinfo = qt_x11Info(paintDevice); if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType - && xinfo && xinfo->screen() == pixmap.x11Info().screen()) + && xinfo && xinfo->screen() == pixmap.x11Info().screen() + && target == GL_TEXTURE_2D) { texture = bindTextureFromNativePixmap(const_cast(&pixmap), key, options); if (texture) { -- cgit v0.12 From f9d26f506b30dcdb1fc50c824f20455756d67cc4 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 9 Apr 2010 16:27:22 +0200 Subject: Fix the doc for QFrame::frameStyle The default is QFrame::Plain (and not QFrame::NoFrame) Task-number: QTBUG-9728 --- src/gui/widgets/qframe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qframe.cpp b/src/gui/widgets/qframe.cpp index c2e4b35..f51ddfd 100644 --- a/src/gui/widgets/qframe.cpp +++ b/src/gui/widgets/qframe.cpp @@ -244,7 +244,7 @@ QFrame::~QFrame() /*! Returns the frame style. - The default value is QFrame::NoFrame. + The default value is QFrame::Plain. \sa setFrameStyle(), frameShape(), frameShadow() */ -- cgit v0.12 From d22c8c60ffd986cc46d1f1cab878d60b03b5d4ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 9 Apr 2010 14:48:41 +0200 Subject: Implement heightForWidth support for QTabWidget and QStackedLayout. In order to add the support we also had to add hasHeightForWidth to QWidget that calls the new virtual hasHeightForWidth() in QWidgetPrivate Task-number: QTBUG-7792 Reviewed-by: Paul --- src/gui/kernel/qlayoutitem.cpp | 4 +-- src/gui/kernel/qstackedlayout.cpp | 26 +++++++++++++++++ src/gui/kernel/qstackedlayout.h | 2 ++ src/gui/kernel/qwidget.cpp | 17 +++++++++++ src/gui/kernel/qwidget.h | 1 + src/gui/kernel/qwidget_p.h | 1 + src/gui/widgets/qsizegrip.cpp | 17 +++-------- src/gui/widgets/qtabwidget.cpp | 49 ++++++++++++++++++++++++++++++++ src/gui/widgets/qtabwidget.h | 1 + tests/auto/qtabwidget/tst_qtabwidget.cpp | 47 ++++++++++++++++++++++++++++++ 10 files changed, 149 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qlayoutitem.cpp b/src/gui/kernel/qlayoutitem.cpp index 6a91d95..e615b2d 100644 --- a/src/gui/kernel/qlayoutitem.cpp +++ b/src/gui/kernel/qlayoutitem.cpp @@ -516,9 +516,7 @@ bool QWidgetItem::hasHeightForWidth() const { if (isEmpty()) return false; - if (wid->layout()) - return wid->layout()->hasHeightForWidth(); - return wid->sizePolicy().hasHeightForWidth(); + return wid->hasHeightForWidth(); } /*! diff --git a/src/gui/kernel/qstackedlayout.cpp b/src/gui/kernel/qstackedlayout.cpp index 7559066..4b49638 100644 --- a/src/gui/kernel/qstackedlayout.cpp +++ b/src/gui/kernel/qstackedlayout.cpp @@ -475,6 +475,32 @@ void QStackedLayout::setGeometry(const QRect &rect) } } +bool QStackedLayout::hasHeightForWidth() const +{ + const int n = count(); + + for (int i = 0; i < n; ++i) { + if (QLayoutItem *item = itemAt(i)) { + if (item->hasHeightForWidth()) + return true; + } + } + return false; +} + +int QStackedLayout::heightForWidth(int width) const +{ + const int n = count(); + + int hfw = 0; + for (int i = 0; i < n; ++i) { + if (QLayoutItem *item = itemAt(i)) { + hfw = qMax(hfw, item->heightForWidth(width)); + } + } + return hfw; +} + /*! \enum QStackedLayout::StackingMode \since 4.4 diff --git a/src/gui/kernel/qstackedlayout.h b/src/gui/kernel/qstackedlayout.h index c069149..842b62b 100644 --- a/src/gui/kernel/qstackedlayout.h +++ b/src/gui/kernel/qstackedlayout.h @@ -95,6 +95,8 @@ public: QLayoutItem *itemAt(int) const; QLayoutItem *takeAt(int); void setGeometry(const QRect &rect); + bool hasHeightForWidth() const; + int heightForWidth(int width) const; Q_SIGNALS: void widgetRemoved(int index); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e88026c..7a8b700 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -3816,6 +3816,11 @@ void QWidget::setMaximumSize(int maxw, int maxh) d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh); } +bool QWidgetPrivate::hasHeightForWidth() const +{ + return layout ? layout->hasHeightForWidth() : size_policy.hasHeightForWidth(); +} + /*! \overload @@ -7961,6 +7966,18 @@ QSize QWidget::minimumSizeHint() const return QSize(-1, -1); } +/*! + \internal + This is a bit hackish, but ideally this would have been a virtual + function so that subclasses could reimplement their own function. + Instead we add a virtual function to QWidgetPrivate. +*/ +bool QWidget::hasHeightForWidth() const +{ + Q_D(const QWidget); + return d->hasHeightForWidth(); +} + /*! \fn QWidget *QWidget::parentWidget() const diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index e12148b..6e5de7d 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -524,6 +524,7 @@ public: virtual QSize sizeHint() const; virtual QSize minimumSizeHint() const; + bool hasHeightForWidth() const; QSizePolicy sizePolicy() const; void setSizePolicy(QSizePolicy); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 89ea256..05a859c 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -493,6 +493,7 @@ public: bool setMinimumSize_helper(int &minw, int &minh); bool setMaximumSize_helper(int &maxw, int &maxh); + virtual bool hasHeightForWidth() const; void setConstraints_sys(); QWidget *childAt_helper(const QPoint &, bool) const; void updateGeometry_helper(bool forceUpdate); diff --git a/src/gui/widgets/qsizegrip.cpp b/src/gui/widgets/qsizegrip.cpp index c9d613a..40f3129 100644 --- a/src/gui/widgets/qsizegrip.cpp +++ b/src/gui/widgets/qsizegrip.cpp @@ -78,15 +78,6 @@ static QWidget *qt_sizegrip_topLevelWidget(QWidget* w) return w; } -static inline bool hasHeightForWidth(QWidget *widget) -{ - if (!widget) - return false; - if (QLayout *layout = widget->layout()) - return layout->hasHeightForWidth(); - return widget->sizePolicy().hasHeightForWidth(); -} - class QSizeGripPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QSizeGrip) @@ -318,7 +309,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) #ifdef Q_WS_X11 // Use a native X11 sizegrip for "real" top-level windows if supported. if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) - && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth()) { XEvent xev; xev.xclient.type = ClientMessage; xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE); @@ -340,7 +331,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) } #endif // Q_WS_X11 #ifdef Q_WS_WIN - if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth()) { uint orientation = 0; if (d->atBottom()) orientation = d->atLeft() ? SZ_SIZEBOTTOMLEFT : SZ_SIZEBOTTOMRIGHT; @@ -429,12 +420,12 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e) #ifdef Q_WS_X11 if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) - && tlw->isTopLevel() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) + && tlw->isTopLevel() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth()) return; #endif #ifdef Q_WS_WIN if (tlw->isWindow() && GetSystemMenu(tlw->winId(), FALSE) != 0 && internalWinId() - && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth()) { MSG msg; while(PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)); return; diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 047a905..fb7ca64 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -195,6 +195,7 @@ public: void _q_removeTab(int); void _q_tabMoved(int from, int to); void init(); + bool hasHeightForWidth() const; QTabBar *tabs; QStackedWidget *stack; @@ -871,6 +872,46 @@ QSize QTabWidget::minimumSizeHint() const .expandedTo(QApplication::globalStrut()); } +int QTabWidget::heightForWidth(int width) const +{ + Q_D(const QTabWidget); + QStyleOption opt(0); + opt.init(this); + opt.state = QStyle::State_None; + + QSize zero(0,0); + const QSize padding = style()->sizeFromContents(QStyle::CT_TabWidget, &opt, zero, this) + .expandedTo(QApplication::globalStrut()); + + QSize lc(0, 0), rc(0, 0); + if (d->leftCornerWidget) + lc = d->leftCornerWidget->sizeHint(); + if(d->rightCornerWidget) + rc = d->rightCornerWidget->sizeHint(); + if (!d->dirty) { + QTabWidget *that = (QTabWidget*)this; + that->setUpLayout(true); + } + QSize t(d->tabs->sizeHint()); + + if(usesScrollButtons()) + t = t.boundedTo(QSize(200,200)); + else + t = t.boundedTo(QApplication::desktop()->size()); + + const bool tabIsHorizontal = (d->pos == North || d->pos == South); + const int contentsWidth = width - padding.width(); + int stackWidth = contentsWidth; + if (!tabIsHorizontal) + stackWidth -= qMax(t.width(), qMax(lc.width(), rc.width())); + + int stackHeight = d->stack->heightForWidth(stackWidth); + QSize s(stackWidth, stackHeight); + + QSize contentSize = basicSize(tabIsHorizontal, lc, rc, s, t); + return (contentSize + padding).expandedTo(QApplication::globalStrut()).height(); +} + /*! \reimp */ @@ -903,6 +944,14 @@ void QTabWidgetPrivate::updateTabBarPosition() q->setUpLayout(); } +bool QTabWidgetPrivate::hasHeightForWidth() const +{ + bool has = size_policy.hasHeightForWidth(); + if (!has && stack) + has = stack->hasHeightForWidth(); + return has; +} + /*! \property QTabWidget::tabPosition \brief the position of the tabs in this tab widget diff --git a/src/gui/widgets/qtabwidget.h b/src/gui/widgets/qtabwidget.h index 68200c8..ee50655 100644 --- a/src/gui/widgets/qtabwidget.h +++ b/src/gui/widgets/qtabwidget.h @@ -129,6 +129,7 @@ public: QSize sizeHint() const; QSize minimumSizeHint() const; + int heightForWidth(int width) const; void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner); QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const; diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp index 4491fb3..204c27a 100644 --- a/tests/auto/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp @@ -45,6 +45,7 @@ #include #include #include +#include //TESTED_CLASS= //TESTED_FILES= @@ -120,6 +121,8 @@ class tst_QTabWidget:public QObject { void clear(); void keyboardNavigation(); void paintEventCount(); + void heightForWidth(); + void heightForWidth_data(); private: int addPage(); @@ -621,6 +624,50 @@ void tst_QTabWidget::paintEventCount() QCOMPARE(tab2->count, 1); } +void tst_QTabWidget::heightForWidth_data() +{ + QTest::addColumn("tabPosition"); + QTest::newRow("West") << int(QTabWidget::West); + QTest::newRow("North") << int(QTabWidget::North); + QTest::newRow("East") << int(QTabWidget::East); + QTest::newRow("South") << int(QTabWidget::South); +} + +void tst_QTabWidget::heightForWidth() +{ + QFETCH(int, tabPosition); + + QWidget *window = new QWidget; + QVBoxLayout *lay = new QVBoxLayout(window); + lay->setMargin(0); + lay->setSpacing(0); + QTabWidget *tabWid = new QTabWidget(window); + QWidget *w = new QWidget; + tabWid->addTab(w, QLatin1String("HFW page")); + tabWid->setTabPosition(QTabWidget::TabPosition(tabPosition)); + QVBoxLayout *lay2 = new QVBoxLayout(w); + QLabel *label = new QLabel("Label with wordwrap turned on makes it trade height for width." + " Make it a really long text so that it spans on several lines" + " when the label is on its narrowest." + " I don't like to repeat myself." + " I don't like to repeat myself." + " I don't like to repeat myself." + " I don't like to repeat myself." + ); + label->setWordWrap(true); + lay2->addWidget(label); + lay2->setMargin(0); + + lay->addWidget(tabWid); + int h = window->heightForWidth(160); + window->resize(160, h); + window->show(); + + QTest::qWaitForWindowShown(window); + QVERIFY(label->height() >= label->heightForWidth(label->width())); + + delete window; +} QTEST_MAIN(tst_QTabWidget) #include "tst_qtabwidget.moc" -- cgit v0.12 From d45c0d3930e295e9798f9172fa0f151044f7036b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 12 Apr 2010 09:18:10 +0200 Subject: Make sure the selectionChanged signal is not called too much It could happen that it was called with empty selectionrange Now we check to see if the selection ranges are empty Task-number: QTBUG-9507 Reviewed-by: gabi --- src/gui/itemviews/qitemselectionmodel.cpp | 21 +++++++++++++++++++++ src/gui/itemviews/qitemselectionmodel.h | 2 ++ src/gui/itemviews/qtableview.cpp | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index d6e68f6..f848321 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -292,6 +292,27 @@ static void indexesFromRange(const QItemSelectionRange &range, QModelIndexList & } /*! + Returns true if the selection range contains no selectable item + \since 4.7 +*/ + +bool QItemSelectionRange::isEmpty() const +{ + if (!isValid() || !model()) + return true; + + for (int column = left(); column <= right(); ++column) { + for (int row = top(); row <= bottom(); ++row) { + QModelIndex index = model()->index(row, column, parent()); + Qt::ItemFlags flags = model()->flags(index); + if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) + return false; + } + } + return true; +} + +/*! Returns the list of model index items stored in the selection. */ diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/gui/itemviews/qitemselectionmodel.h index 9980d0f..436514f 100644 --- a/src/gui/itemviews/qitemselectionmodel.h +++ b/src/gui/itemviews/qitemselectionmodel.h @@ -108,6 +108,8 @@ public: && top() <= bottom() && left() <= right()); } + bool isEmpty() const; + QModelIndexList indexes() const; private: diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 43445b4..f49f273 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -1847,7 +1847,9 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF selection.append(QItemSelectionRange(topLeft, bottomRight)); } } else { // nothing moved - selection.append(QItemSelectionRange(tl, br)); + QItemSelectionRange range(tl, br); + if (!range.isEmpty()) + selection.append(range); } d->selectionModel->select(selection, command); -- cgit v0.12 From d7d6bef4916c35bc98a84bba2527b678547d043a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 12 Apr 2010 10:24:56 +0200 Subject: Compile fix for WinCE --- src/corelib/kernel/qcoreapplication_win.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 040b2cc..320f801 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE bool usingWinMain = false; // whether the qWinMain() is used or not +int appCmdShow = 0; Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle { @@ -66,12 +67,16 @@ Q_CORE_EXPORT HINSTANCE qWinAppPrevInst() // get Windows prev app Q_CORE_EXPORT int qWinAppCmdShow() // get main window show command { +#if defined(Q_OS_WINCE) + return appCmdShow; +#else STARTUPINFO startupInfo; GetStartupInfo(&startupInfo); return (startupInfo.dwFlags & STARTF_USESHOWWINDOW) ? startupInfo.wShowWindow : SW_SHOWDEFAULT; +#endif } Q_CORE_EXPORT QString qAppFileName() // get application file name @@ -185,10 +190,11 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, // Create command line argv = qWinCmdLine(cmdParam, int(strlen(cmdParam)), argc); + appCmdShow = cmdShow; + // Ignore Windows parameters Q_UNUSED(instance); Q_UNUSED(prevInstance); - Q_UNUSED(cmdShow); } /*! -- cgit v0.12 From 2245641baa58125b57faf12496bc472491565498 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 12 Apr 2010 11:15:26 +0200 Subject: qdrawhelper: optimize the fetch transformed bilinear functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we know that x1 and y1 are between the bounds, and than x2 and y2 are bigger, we only need to check the upper bound for x2 and y2 This gives 5% speedup on a trace from the QML samegame demo. Reviewed-by: Samuel Rødal --- src/gui/painting/qdrawhelper.cpp | 92 ++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 322882d..b1e3281 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -693,32 +693,32 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * fy -= half_point; while (b < end) { int x1 = (fx >> 16); - int x2 = x1 + 1; + int x2; int y1 = (fy >> 16); - int y2 = y1 + 1; + int y2; if (blendType == BlendTransformedBilinearTiled) { x1 %= image_width; + if (x1 < 0) x1 += image_width; + x2 = x1 + 1; x2 %= image_width; - y1 %= image_height; - y2 %= image_height; - if (x1 < 0) x1 += image_width; - if (x2 < 0) x2 += image_width; + y1 %= image_height; if (y1 < 0) y1 += image_height; - if (y2 < 0) y2 += image_height; - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); + y2 = y1 + 1; + y2 %= image_height; } else { x1 = qBound(0, x1, image_width - 1); - x2 = qBound(0, x2, image_width - 1); + x2 = qMin(x1 + 1, image_width - 1); y1 = qBound(0, y1, image_height - 1); - y2 = qBound(0, y2, image_height - 1); + y2 = qMin(y1 + 1, image_height - 1); } + Q_ASSERT(x1 >= 0 && x1 < image_width); + Q_ASSERT(x2 >= 0 && x2 < image_width); + Q_ASSERT(y1 >= 0 && y1 < image_height); + Q_ASSERT(y2 >= 0 && y2 < image_height); + const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); @@ -755,9 +755,9 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * const qreal py = fy * iw - 0.5; int x1 = int(px) - (px < 0); - int x2 = x1 + 1; + int x2; int y1 = int(py) - (py < 0); - int y2 = y1 + 1; + int y2; int distx = int((px - x1) * 256); int disty = int((py - y1) * 256); @@ -766,26 +766,26 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * if (blendType == BlendTransformedBilinearTiled) { x1 %= image_width; + if (x1 < 0) x1 += image_width; + x2 = x1 + 1; x2 %= image_width; - y1 %= image_height; - y2 %= image_height; - if (x1 < 0) x1 += image_width; - if (x2 < 0) x2 += image_width; + y1 %= image_height; if (y1 < 0) y1 += image_height; - if (y2 < 0) y2 += image_height; - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); + y2 = y1 + 1; + y2 %= image_height; } else { x1 = qBound(0, x1, image_width - 1); - x2 = qBound(0, x2, image_width - 1); + x2 = qMin(x1 + 1, image_width - 1); y1 = qBound(0, y1, image_height - 1); - y2 = qBound(0, y2, image_height - 1); + y2 = qMin(y1 + 1, image_height - 1); } + Q_ASSERT(x1 >= 0 && x1 < image_width); + Q_ASSERT(x2 >= 0 && x2 < image_width); + Q_ASSERT(y1 >= 0 && y1 < image_height); + Q_ASSERT(y2 >= 0 && y2 < image_height); + const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); @@ -5191,20 +5191,20 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const uint *b = buffer; while (b < end) { int x1 = (x >> 16); - int x2 = x1 + 1; + int x2; int y1 = (y >> 16); - int y2 = y1 + 1; + int y2; if (blendType == BlendTransformedBilinearTiled) { x1 %= image_width; + if (x1 < 0) x1 += image_width; + x2 = x1 + 1; x2 %= image_width; - y1 %= image_height; - y2 %= image_height; - if (x1 < 0) x1 += image_width; - if (x2 < 0) x2 += image_width; + y1 %= image_height; if (y1 < 0) y1 += image_height; - if (y2 < 0) y2 += image_height; + y2 = y1 + 1; + y2 %= image_height; Q_ASSERT(x1 >= 0 && x1 < image_width); Q_ASSERT(x2 >= 0 && x2 < image_width); @@ -5212,9 +5212,9 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const Q_ASSERT(y2 >= 0 && y2 < image_height); } else { x1 = qBound(image_x1, x1, image_x2 - 1); - x2 = qBound(image_x1, x2, image_x2 - 1); + x2 = qMin(x1 + 1, image_x2 - 1); y1 = qBound(image_y1, y1, image_y2 - 1); - y2 = qBound(image_y1, y2, image_y2 - 1); + y2 = qMin(y1 + 1, image_y2 - 1); } int y1_offset = y1 * scanline_offset; @@ -5286,9 +5286,9 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const const qreal py = y * iw - 0.5; int x1 = int(px) - (px < 0); - int x2 = x1 + 1; + int x2; int y1 = int(py) - (py < 0); - int y2 = y1 + 1; + int y2; int distx = int((px - x1) * 256); int disty = int((py - y1) * 256); @@ -5297,14 +5297,14 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const if (blendType == BlendTransformedBilinearTiled) { x1 %= image_width; + if (x1 < 0) x1 += image_width; + x2 = x1 + 1; x2 %= image_width; - y1 %= image_height; - y2 %= image_height; - if (x1 < 0) x1 += image_width; - if (x2 < 0) x2 += image_width; + y1 %= image_height; if (y1 < 0) y1 += image_height; - if (y2 < 0) y2 += image_height; + y2 = y1 + 1; + y2 %= image_height; Q_ASSERT(x1 >= 0 && x1 < image_width); Q_ASSERT(x2 >= 0 && x2 < image_width); @@ -5312,9 +5312,9 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const Q_ASSERT(y2 >= 0 && y2 < image_height); } else { x1 = qBound(image_x1, x1, image_x2 - 1); - x2 = qBound(image_x1, x2, image_x2 - 1); + x2 = qMin(x1 + 1, image_x2 - 1); y1 = qBound(image_y1, y1, image_y2 - 1); - y2 = qBound(image_y1, y2, image_y2 - 1); + y2 = qMin(y1 + 1, image_y2 - 1); } int y1_offset = y1 * scanline_offset; -- cgit v0.12 From f1c74441b17dde565a91ab596cc1b9a920c2ab41 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 12 Apr 2010 11:45:48 +0200 Subject: fix cetest build properly Commit f5b19c173109c53bf3d8167573f7276cf39262d2 broke the build for cetest. Reverting my initial naive attempt to fix this bd5d323373dbaf9d827126b77895da253128c1e5. We're introducing a new define for building qmake without generators. QT_QMAKE_PARSER_ONLY is used for cetest and the qmake COM wrapper of the Visual Studio Add-in. Reviewed-by: ossi --- qmake/generators/metamakefile.cpp | 38 +++++++++++++++------------ qmake/project.cpp | 2 -- tools/qtestlib/wince/cetest/cetest.pro | 3 +-- tools/qtestlib/wince/cetest/qmake_include.pri | 2 ++ 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index e76e596..c42a837 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -58,6 +58,8 @@ MetaMakefileGenerator::~MetaMakefileGenerator() delete project; } +#ifndef QT_QMAKE_PARSER_ONLY + class BuildsMetaMakefileGenerator : public MetaMakefileGenerator { private: @@ -489,6 +491,25 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO) return mkfile; } +MetaMakefileGenerator * +MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &name, bool op, bool *success) +{ + MetaMakefileGenerator *ret = 0; + if ((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || + Option::qmake_mode == Option::QMAKE_GENERATE_PRL)) { + if (proj->first("TEMPLATE").endsWith("subdirs")) + ret = new SubdirsMetaMakefileGenerator(proj, name, op); + } + if (!ret) + ret = new BuildsMetaMakefileGenerator(proj, name, op); + bool res = ret->init(); + if (success) + *success = res; + return ret; +} + +#endif // QT_QMAKE_PARSER_ONLY + bool MetaMakefileGenerator::modesForGenerator(const QString &gen, Option::HOST_MODE *host_mode, Option::TARG_MODE *target_mode) @@ -523,21 +544,4 @@ MetaMakefileGenerator::modesForGenerator(const QString &gen, return true; } -MetaMakefileGenerator * -MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &name, bool op, bool *success) -{ - MetaMakefileGenerator *ret = 0; - if ((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || - Option::qmake_mode == Option::QMAKE_GENERATE_PRL)) { - if (proj->first("TEMPLATE").endsWith("subdirs")) - ret = new SubdirsMetaMakefileGenerator(proj, name, op); - } - if (!ret) - ret = new BuildsMetaMakefileGenerator(proj, name, op); - bool res = ret->init(); - if (success) - *success = res; - return ret; -} - QT_END_NAMESPACE diff --git a/qmake/project.cpp b/qmake/project.cpp index 56707cf..764264f 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1507,7 +1507,6 @@ QMakeProject::read(uchar cmd) void QMakeProject::validateModes() { -#if !defined(QT_BUILD_QMAKE_NO_GENERATORS) if (Option::host_mode == Option::HOST_UNKNOWN_MODE || Option::target_mode == Option::TARG_UNKNOWN_MODE) { Option::HOST_MODE host_mode; @@ -1544,7 +1543,6 @@ void QMakeProject::validateModes() } } } -#endif // !defined(QT_BUILD_QMAKE_NO_GENERATORS) } bool diff --git a/tools/qtestlib/wince/cetest/cetest.pro b/tools/qtestlib/wince/cetest/cetest.pro index 43ed18e..82747da 100644 --- a/tools/qtestlib/wince/cetest/cetest.pro +++ b/tools/qtestlib/wince/cetest/cetest.pro @@ -13,8 +13,7 @@ DEFINES += QT_BUILD_QMAKE QT_BOOTSTRAPPED QT_NO_CODECS QT_LITE_UNICODE QT QT_NO_STL QT_NO_COMPRESS QT_NO_DATASTREAM \ QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_NO_THREAD \ QT_NO_SYSTEMLOCALE QT_NO_GEOM_VARIANT \ - QT_NODLL QT_NO_QOBJECT \ - QT_BUILD_QMAKE_NO_GENERATORS + QT_NODLL QT_NO_QOBJECT INCLUDEPATH = \ $$QT_SOURCE_TREE/tools/qtestlib/ce/cetest \ diff --git a/tools/qtestlib/wince/cetest/qmake_include.pri b/tools/qtestlib/wince/cetest/qmake_include.pri index 8b415b0..35fbc64 100644 --- a/tools/qtestlib/wince/cetest/qmake_include.pri +++ b/tools/qtestlib/wince/cetest/qmake_include.pri @@ -5,7 +5,9 @@ SOURCES += \ $$QT_SOURCE_TREE/qmake/option.cpp \ $$QT_SOURCE_TREE/qmake/project.cpp \ $$QT_SOURCE_TREE/qmake/property.cpp \ + $$QT_SOURCE_TREE/qmake/generators/metamakefile.cpp \ $$QT_SOURCE_TREE/qmake/generators/symbian/initprojectdeploy_symbian.cpp \ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.cpp \ $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp +DEFINES += QT_QMAKE_PARSER_ONLY -- cgit v0.12 From aab30e9a3ec78c3a9b2998feeef275e973ef0ff2 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 12 Apr 2010 12:12:01 +0200 Subject: Safeguard ourselves against corrupt registry values for cleartype gamma Reviewed-by: Eskil Task: http://bugreports.qt.nokia.com/browse/QTBUG-7596 --- src/gui/painting/qdrawhelper.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index b1e3281..a0c9828 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6983,6 +6983,11 @@ void qt_build_pow_tables() { int winSmooth; if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0)) smoothing = winSmooth / 1000.0; + + // Safeguard ourselves against corrupt registry values... + if (smoothing > 5 || smoothing < 1) + smoothing = 1.4; + #endif #ifdef Q_WS_X11 -- cgit v0.12 From f5bde58801fb2f38404a1ecfd5b006d5d627ee96 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 12 Apr 2010 12:19:19 +0200 Subject: Build fix --- src/3rdparty/phonon/ds9/mediaobject.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp index b8ef93b..d640956 100644 --- a/src/3rdparty/phonon/ds9/mediaobject.cpp +++ b/src/3rdparty/phonon/ds9/mediaobject.cpp @@ -820,21 +820,11 @@ namespace Phonon #endif LPAMGETERRORTEXT getErrorText = (LPAMGETERRORTEXT)QLibrary::resolve(QLatin1String("quartz"), "AMGetErrorTextW"); -<<<<<<< HEAD:src/3rdparty/phonon/ds9/mediaobject.cpp WCHAR buffer[MAX_ERROR_TEXT_LEN]; if (getErrorText && getErrorText(hr, buffer, MAX_ERROR_TEXT_LEN)) { m_errorString = QString::fromWCharArray(buffer); } else { m_errorString = QString::fromLatin1("Unknown error"); -======= - ushort buffer[MAX_ERROR_TEXT_LEN]; - if (getErrorText && getErrorText(hr, (WCHAR*)buffer, MAX_ERROR_TEXT_LEN)) { - m_errorString = QString::fromUtf16(buffer); -#ifdef Q_CC_MSVC - } else { - m_errorString = QString::fromUtf16((ushort*)_com_error(hr).ErrorMessage()); -#endif ->>>>>>> internal-qt-repo/4.7:src/3rdparty/phonon/ds9/mediaobject.cpp } const QString comError = QString::number(uint(hr), 16); if (!m_errorString.toLower().contains(comError.toLower())) { -- cgit v0.12 From 082ca8b884e407cbee65b04e602c9c309fa66e35 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 12 Apr 2010 12:52:19 +0200 Subject: Fix QT_NO_FILESYSTEMMODEL Merge-request: 2358 Reviewed-by: Thierry Bastian --- src/gui/util/qcompleter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index c095b3b..8e7ec80 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -1689,8 +1689,10 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const QString t; if (isDirModel) t = sourceModel->data(idx, Qt::EditRole).toString(); +#ifndef QT_NO_FILESYSTEMMODEL else t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString(); +#endif list.prepend(t); QModelIndex parent = idx.parent(); idx = parent.sibling(parent.row(), index.column()); -- cgit v0.12 From ab4b6120d76a33c44fd1ce8468c926f7cfa03f92 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 12 Apr 2010 12:53:53 +0200 Subject: Fix QT_NO_FSCOMPLETER Merge-request: 2357 Reviewed-by: Thierry Bastian --- src/gui/dialogs/qfiledialog.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 3b5fb9f..cb74a3c 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -723,15 +723,19 @@ void QFileDialog::setVisible(bool visible) // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below // updates the state correctly, but skips showing the non-native version: setAttribute(Qt::WA_DontShowOnScreen); +#ifndef QT_NO_FSCOMPLETER //So the completer don't try to complete and therefore to show a popup d->completer->setModel(0); +#endif } else { d->nativeDialogInUse = false; setAttribute(Qt::WA_DontShowOnScreen, false); +#ifndef QT_NO_FSCOMPLETER if (d->proxyModel != 0) d->completer->setModel(d->proxyModel); else d->completer->setModel(d->model); +#endif } } -- cgit v0.12 From 787f713f87b365d8385af97073540c7ee565fde0 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 12 Apr 2010 13:19:20 +0200 Subject: Fix QT_NO_COMPLETER Merge-request: 2356 Reviewed-by: Thierry Bastian --- src/gui/dialogs/qprintdialog_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index 9b4d6e8..e3c62be 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -703,7 +703,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p) } #endif -#ifndef QT_NO_FILESYSTEMMODEL +#if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER) QFileSystemModel *fsm = new QFileSystemModel(widget.filename); fsm->setRootPath(QDir::homePath()); widget.filename->setCompleter(new QCompleter(fsm, widget.filename)); -- cgit v0.12 From c4c8f9cbad91222364f5262753c6d0dbb931a57a Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 12 Apr 2010 13:30:04 +0200 Subject: Fix compile error with QT_NO_ACTION in QtGui Merge-request: 2321 Reviewed-by: Thierry Bastian --- src/gui/widgets/qdialogbuttonbox.cpp | 15 ++++++++------- tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp | 12 ++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index cc74a53..732dbc9 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -258,6 +258,7 @@ static const int layouts[2][5][14] = } }; +#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) class QDialogButtonEnabledProxy : public QObject { public: @@ -281,7 +282,7 @@ private: QWidget *source; QAction *target; }; - +#endif class QDialogButtonBoxPrivate : public QWidgetPrivate { @@ -314,7 +315,7 @@ public: void addButtonsToLayout(const QList &buttonList, bool reverse); void retranslateStrings(); const char *standardButtonText(QDialogButtonBox::StandardButton sbutton) const; -#ifdef QT_SOFTKEYS_ENABLED +#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) QAction *createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role); #endif }; @@ -571,7 +572,7 @@ void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBo QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_handleButtonClicked())); QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed())); buttonLists[role].append(button); -#ifdef QT_SOFTKEYS_ENABLED +#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) QAction *action = createSoftKey(button, role); softKeyActions.insert(button, action); new QDialogButtonEnabledProxy(action, button, action); @@ -580,7 +581,7 @@ void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBo layoutButtons(); } -#ifdef QT_SOFTKEYS_ENABLED +#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role) { Q_Q(QDialogButtonBox); @@ -718,7 +719,7 @@ void QDialogButtonBoxPrivate::retranslateStrings() if (buttonText) { QPushButton *button = it.key(); button->setText(QDialogButtonBox::tr(buttonText)); -#ifdef QT_SOFTKEYS_ENABLED +#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) QAction *action = softKeyActions.value(button, 0); if (action) action->setText(button->text()); @@ -997,7 +998,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) } } } -#ifdef QT_SOFTKEYS_ENABLED +#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) QAction *action = d->softKeyActions.value(button, 0); if (action) { d->softKeyActions.remove(button); @@ -1243,7 +1244,7 @@ bool QDialogButtonBox::event(QEvent *event) }else if (event->type() == QEvent::LanguageChange) { d->retranslateStrings(); } -#ifdef QT_SOFTKEYS_ENABLED +#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION) else if (event->type() == QEvent::ParentChange) { QWidget *dialog = 0; QWidget *p = this; diff --git a/tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index bf4ea5f..195f8b6 100644 --- a/tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -721,11 +721,13 @@ void tst_QDialogButtonBox::testDefaultButton_data() static int softKeyCount(QWidget *widget) { int softkeyCount = 0; +#ifndef QT_NO_ACTION QList actions = widget->actions(); foreach (QAction *action, actions) { if (action->softKeyRole() != QAction::NoSoftKey) softkeyCount++; } +#endif return softkeyCount; } @@ -737,14 +739,18 @@ void tst_QDialogButtonBox::testS60SoftKeys() buttonBox.setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dialog.show(); +#ifndef QT_NO_ACTION QCOMPARE( softKeyCount(&dialog), 2); +#endif QDialog dialog2(0); QDialogButtonBox buttonBox2(&dialog2); buttonBox2.setStandardButtons(QDialogButtonBox::Cancel); dialog2.show(); +#ifndef QT_NO_ACTION QCOMPARE( softKeyCount(&dialog2), 1); +#endif #else QSKIP("S60-specific test", SkipAll ); @@ -759,21 +765,27 @@ void tst_QDialogButtonBox::testSoftKeyReparenting() buttonBox->addButton(QDialogButtonBox::Ok); buttonBox->addButton(QDialogButtonBox::Cancel); +#ifndef QT_NO_ACTION QCOMPARE(softKeyCount(&dialog), 0); QCOMPARE(softKeyCount(buttonBox), 2); +#endif // Were the softkeys re-parented correctly? dialog.setLayout(new QVBoxLayout); dialog.layout()->addWidget(buttonBox); +#ifndef QT_NO_ACTION QCOMPARE(softKeyCount(&dialog), 2); QCOMPARE(softKeyCount(buttonBox), 0); +#endif // Softkeys are only added to QDialog, not QWidget QWidget *nested = new QWidget; nested->setLayout(new QVBoxLayout); nested->layout()->addWidget(buttonBox); +#ifndef QT_NO_ACTION QCOMPARE(softKeyCount(nested), 0); QCOMPARE(softKeyCount(buttonBox), 2); +#endif } #endif -- cgit v0.12 From a6453627640151474c5348f09ff9e8b592648c70 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 12 Apr 2010 13:33:16 +0200 Subject: Fix QT_NO_MOVIE Merge-request: 2360 Reviewed-by: Thierry Bastian --- src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp | 4 ++++ src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h | 4 ++++ src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h | 4 ++++ src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp | 2 ++ 4 files changed, 14 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index f14f773..08ede7d 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -42,6 +42,8 @@ #include "private/qdeclarativeanimatedimage_p.h" #include "private/qdeclarativeanimatedimage_p_p.h" +#ifndef QT_NO_MOVIE + #include #include @@ -320,3 +322,5 @@ void QDeclarativeAnimatedImage::componentComplete() } QT_END_NAMESPACE + +#endif // QT_NO_MOVIE diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h index 6ab66b3..b148fa4 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h @@ -44,6 +44,8 @@ #include "private/qdeclarativeimage_p.h" +#ifndef QT_NO_MOVIE + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -103,4 +105,6 @@ QML_DECLARE_TYPE(QDeclarativeAnimatedImage) QT_END_HEADER +#endif // QT_NO_MOVIE + #endif diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h index 8ca9755..a02893d 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h @@ -55,6 +55,8 @@ #include "private/qdeclarativeimage_p_p.h" +#ifndef QT_NO_MOVIE + QT_BEGIN_NAMESPACE class QMovie; @@ -80,4 +82,6 @@ public: QT_END_NAMESPACE +#endif // QT_NO_MOVIE + #endif // QDECLARATIVEANIMATEDIMAGE_P_H diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 7989a27..2af14f6 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -82,7 +82,9 @@ void QDeclarativeItemModule::defineModule() { +#ifndef QT_NO_MOVIE qmlRegisterType("Qt",4,6,"AnimatedImage"); +#endif qmlRegisterType("Qt",4,6,"Blur"); qmlRegisterType("Qt",4,6,"BorderImage"); qmlRegisterType("Qt",4,6,"Colorize"); -- cgit v0.12 From c41dbbb5e6495e26cd3223d39c61decd951afeba Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 12 Apr 2010 13:33:26 +0200 Subject: Increased the precision used to flatten beziers Reviewed-by: Samuel --- src/gui/painting/qbezier.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index ea7fe4f..a08c79e 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -117,8 +117,8 @@ QBezier QBezier::mapBy(const QTransform &transform) const return QBezier::fromPoints(transform.map(pt1()), transform.map(pt2()), transform.map(pt3()), transform.map(pt4())); } -//0.5 is really low -static const qreal flatness = 0.5; +//0.05 is really low, but required for scaled-up beziers... +static const qreal flatness = 0.05; //based on "Fast, precise flattening of cubic Bezier path and offset curves" // by T. F. Hain, A. L. Ahmad, S. V. R. Racherla and D. D. Langan -- cgit v0.12 From 119d7dddc8da189ccd1cbc55ed3292f311c30e0c Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 12 Apr 2010 14:10:13 +0200 Subject: Fix flattening of largely scaled, thin, dashed beziers. Reviewed-by: Samuel Task: http://bugreports.qt.nokia.com/browse/QTBUG-9218 --- .../gl2paintengineex/qtriangulatingstroker.cpp | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index d952988..16340a1 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -111,7 +111,7 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, co // depending on if the pen is cosmetic or not. // // The curvyness value of PI/14 was based on, - // arcLength=2*PI*r/4=PI/2 and splitting length into somewhere + // arcLength = 2*PI*r/4 = PI*r/2 and splitting length into somewhere // between 3 and 8 where 5 seemed to be give pretty good results // hence: Q_PI/14. Lower divisors will give more detail at the // direct cost of performance. @@ -487,6 +487,8 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c const QPainterPath::ElementType *types = path.elements(); int count = path.elementCount(); + bool cosmetic = pen.isCosmetic(); + m_points.reset(); m_types.reset(); @@ -495,10 +497,26 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c width = 1; m_dash_stroker.setDashPattern(pen.dashPattern()); - m_dash_stroker.setStrokeWidth(pen.isCosmetic() ? width * m_inv_scale : width); + m_dash_stroker.setStrokeWidth(cosmetic ? width * m_inv_scale : width); m_dash_stroker.setMiterLimit(pen.miterLimit()); m_dash_stroker.setClipRect(clip); - qreal curvyness = sqrt(width) * m_inv_scale / 8; + + float curvynessAdd, curvynessMul, roundness = 0; + + // simplfy pens that are thin in device size (2px wide or less) + if (width < 2.5 && (cosmetic || m_inv_scale == 1)) { + curvynessAdd = 0.5; + curvynessMul = CURVE_FLATNESS / m_inv_scale; + roundness = 1; + } else if (cosmetic) { + curvynessAdd= width / 2; + curvynessMul= CURVE_FLATNESS; + roundness = qMax(4, width * CURVE_FLATNESS); + } else { + curvynessAdd = width * m_inv_scale; + curvynessMul = CURVE_FLATNESS / m_inv_scale; + roundness = qMax(4, width * curvynessMul); + } if (count < 2) return; @@ -533,9 +551,11 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c *(((const QPointF *) pts) + 1), *(((const QPointF *) pts) + 2)); QRectF bounds = b.bounds(); - int threshold = qMin(64, qMax(bounds.width(), bounds.height()) * curvyness); + float rad = qMax(bounds.width(), bounds.height()); + int threshold = qMin(64, (rad + curvynessAdd) * curvynessMul); if (threshold < 4) threshold = 4; + qreal threshold_minus_1 = threshold - 1; for (int i=0; i Date: Mon, 12 Apr 2010 14:03:30 +0200 Subject: Fix antialiasing with transformed text in OpenGL2 paint engine Since the paint engine now transforms the prerendered glyphs instead of rendering transformed glyphs as paths, we need to turn on texture filtering to avoid antialiasing artifacts. In order to do this, we also need to pad the glyphs in the glyph cache, otherwise you will get artifacts when sampling the area around the glyph's bounding rect (where there might be other glyphs.) This done by adding a glyphPadding() function to the cache which returns the number of pixels to pad between each glyph. Task-number: QTBUG-9706 Reviewed-by: Tom --- src/gui/painting/qtextureglyphcache.cpp | 7 ++++--- src/gui/painting/qtextureglyphcache_p.h | 1 + src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 +- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 5 +++++ src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 9eda0ef..631a9cf 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -79,6 +79,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const m_current_fontengine = fontEngine; const int margin = glyphMargin(); + const int paddingDoubled = glyphPadding() * 2; QHash listItemCoordinates; int rowHeight = 0; @@ -124,7 +125,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const if (listItemCoordinates.isEmpty()) return; - rowHeight += margin * 2; + rowHeight += margin * 2 + paddingDoubled; if (isNull()) createCache(QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH, qt_next_power_of_two(rowHeight)); @@ -138,7 +139,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const if (m_cx + c.w > m_w) { // no room on the current line, start new glyph strip m_cx = 0; - m_cy += m_currentRowHeight; + m_cy += m_currentRowHeight + paddingDoubled; m_currentRowHeight = 0; // New row } if (m_cy + c.h > m_h) { @@ -156,7 +157,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const fillTexture(c, iter.key()); coords.insert(iter.key(), c); - m_cx += c.w; + m_cx += c.w + paddingDoubled; ++iter; } diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index 8c2f5b4..390fe51 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -98,6 +98,7 @@ public: virtual void createTextureData(int width, int height) = 0; virtual void resizeTextureData(int width, int height) = 0; virtual int glyphMargin() const { return 0; } + virtual int glyphPadding() const { return 0; } virtual void fillTexture(const Coord &coord, glyph_t glyph) = 0; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 9ed722f..a163fa9 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1641,7 +1641,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp glBindTexture(GL_TEXTURE_2D, cache->texture()); lastMaskTextureUsed = cache->texture(); } - updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); + updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, s->matrix.type() > QTransform::TxTranslate); shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); #if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 6cb76ee..994c1c9 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -246,4 +246,9 @@ int QGLTextureGlyphCache::glyphMargin() const #endif } +int QGLTextureGlyphCache::glyphPadding() const +{ + return 1; +} + QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index 2a8a782..04731b1 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -73,6 +73,7 @@ public: virtual void resizeTextureData(int width, int height); virtual void fillTexture(const Coord &c, glyph_t glyph); virtual int glyphMargin() const; + virtual int glyphPadding() const; inline GLuint texture() const { return m_texture; } -- cgit v0.12 From 9e43ab153dbbe83e1e7e2fb1e9d6815424c4b5f2 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 12 Apr 2010 16:26:19 +0200 Subject: accelerate QWindowsPipeWriter for bigger chunks of data Don't put pipes into message mode. This makes it possible to not split data into 2k chunks. Reviewed-by: ossi --- src/corelib/io/qwindowspipewriter.cpp | 6 ++---- src/network/socket/qlocalserver_win.cpp | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index 417439f..2fe4424 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -128,11 +128,9 @@ void QWindowsPipeWriter::run() overl.OffsetHigh = 0; while ((!quitNow) && totalWritten < maxlen) { DWORD written = 0; - // Write 2k at a time to prevent flooding the pipe. If you - // write too much (4k-8k), the pipe can close - // unexpectedly. if (!WriteFile(writePipe, ptrData + totalWritten, - qMin(2048, maxlen - totalWritten), &written, &overl)) { + maxlen - totalWritten, &written, &overl)) { + if (GetLastError() == 0xE8/*NT_STATUS_INVALID_USER_BUFFER*/) { // give the os a rest msleep(100); diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp index e820f73..5d2be72 100644 --- a/src/network/socket/qlocalserver_win.cpp +++ b/src/network/socket/qlocalserver_win.cpp @@ -65,8 +65,8 @@ bool QLocalServerPrivate::addListener() listener.handle = CreateNamedPipe( (const wchar_t *)fullServerName.utf16(), // pipe name PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, // read/write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode + PIPE_TYPE_BYTE | // byte type pipe + PIPE_READMODE_BYTE | // byte-read mode PIPE_WAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances BUFSIZE, // output buffer size -- cgit v0.12 From 8576aa104528f9a2863fd097abc8bac5c956fdb8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 12 Apr 2010 17:04:03 +0200 Subject: QSlider and StyleSheet: fix one pixel error while drawing the SliderAddPage Task-number: QTBUG-9674 Reviewed-by: jbache --- src/gui/styles/qstylesheetstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index cc0ce08..a1a98ba 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -3169,8 +3169,8 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC if (subRule1.hasDrawable()) { QRect r(gr.topLeft(), slider->orientation == Qt::Horizontal - ? QPoint(hr.x()+hr.width()/2, gr.y()+gr.height()) - : QPoint(gr.x()+gr.width(), hr.y()+hr.height()/2)); + ? QPoint(hr.x()+hr.width()/2, gr.y()+gr.height() - 1) + : QPoint(gr.x()+gr.width() - 1, hr.y()+hr.height()/2)); subRule1.drawRule(p, r); } -- cgit v0.12 From 53dc05de72d2176346a52f2b26b22fa1e5f83eb9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 13 Apr 2010 09:45:29 +0200 Subject: qdrawhelper: fix optim in 2245641ba MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The commit 2245641baa58125b57faf12496bc472491565498 was not correct as the x2 (and y2) were not correct on the first line (the value was 1 instead of 0) Fixes tst_QImage::smoothScale3 Reviewed-by: Samuel Rødal --- src/gui/painting/qdrawhelper.cpp | 117 +++++++++++++++++++++++++++++---------- 1 file changed, 88 insertions(+), 29 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a0c9828..b440fce 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -708,10 +708,20 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * y2 = y1 + 1; y2 %= image_height; } else { - x1 = qBound(0, x1, image_width - 1); - x2 = qMin(x1 + 1, image_width - 1); - y1 = qBound(0, y1, image_height - 1); - y2 = qMin(y1 + 1, image_height - 1); + if (x1 < 0) { + x2 = x1 = 0; + } else if (x1 >= image_width - 1) { + x2 = x1 = image_width - 1; + } else { + x2 = x1 + 1; + } + if (y1 < 0) { + y2 = y1 = 0; + } else if (y1 >= image_height - 1) { + y2 = y1 = image_height - 1; + } else { + y2 = y1 + 1; + } } Q_ASSERT(x1 >= 0 && x1 < image_width); @@ -775,10 +785,20 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * y2 = y1 + 1; y2 %= image_height; } else { - x1 = qBound(0, x1, image_width - 1); - x2 = qMin(x1 + 1, image_width - 1); - y1 = qBound(0, y1, image_height - 1); - y2 = qMin(y1 + 1, image_height - 1); + if (x1 < 0) { + x2 = x1 = 0; + } else if (x1 >= image_width - 1) { + x2 = x1 = image_width - 1; + } else { + x2 = x1 + 1; + } + if (y1 < 0) { + y2 = y1 = 0; + } else if (y1 >= image_height - 1) { + y2 = y1 = image_height - 1; + } else { + y2 = y1 + 1; + } } Q_ASSERT(x1 >= 0 && x1 < image_width); @@ -5211,10 +5231,20 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const Q_ASSERT(y1 >= 0 && y1 < image_height); Q_ASSERT(y2 >= 0 && y2 < image_height); } else { - x1 = qBound(image_x1, x1, image_x2 - 1); - x2 = qMin(x1 + 1, image_x2 - 1); - y1 = qBound(image_y1, y1, image_y2 - 1); - y2 = qMin(y1 + 1, image_y2 - 1); + if (x1 < image_x1) { + x2 = x1 = image_x1; + } else if (x1 >= image_x2 - 1) { + x2 = x1 = image_x2 - 1; + } else { + x2 = x1 + 1; + } + if (y1 < image_y1) { + y2 = y1 = image_y1; + } else if (y1 >= image_y2 - 1) { + y2 = y1 = image_y2 - 1; + } else { + y2 = y1 + 1; + } } int y1_offset = y1 * scanline_offset; @@ -5311,10 +5341,20 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const Q_ASSERT(y1 >= 0 && y1 < image_height); Q_ASSERT(y2 >= 0 && y2 < image_height); } else { - x1 = qBound(image_x1, x1, image_x2 - 1); - x2 = qMin(x1 + 1, image_x2 - 1); - y1 = qBound(image_y1, y1, image_y2 - 1); - y2 = qMin(y1 + 1, image_y2 - 1); + if (x1 < image_x1) { + x2 = x1 = image_x1; + } else if (x1 >= image_x2 - 1) { + x2 = x1 = image_x2 - 1; + } else { + x2 = x1 + 1; + } + if (y1 < image_y1) { + y2 = y1 = image_y1; + } else if (y1 >= image_y2 - 1) { + y2 = y1 = image_y2 - 1; + } else { + y2 = y1 + 1; + } } int y1_offset = y1 * scanline_offset; @@ -5404,18 +5444,27 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan SRC *b = buffer; while (b < end) { int x1 = (x >> 16); - int x2 = x1 + 1; + int x2; int y1 = (y >> 16); - int y2 = y1 + 1; + int y2; const int distx = (x & 0x0000ffff) >> 8; const int disty = (y & 0x0000ffff) >> 8; - x1 = qBound(src_minx, x1, src_maxx); - x2 = qBound(src_minx, x2, src_maxx); - y1 = qBound(src_miny, y1, src_maxy); - y2 = qBound(src_miny, y2, src_maxy); - + if (x1 < src_minx) { + x2 = x1 = src_minx; + } else if (x1 >= src_maxx) { + x2 = x1 = src_maxx; + } else { + x2 = x1 + 1; + } + if (y1 < src_miny) { + y2 = y1 = src_miny; + } else if (y1 >= src_maxy) { + y2 = y1 = src_maxy; + } else { + y2 = y1 + 1; + } #if 0 if (x1 == x2) { if (y1 == y2) { @@ -5506,17 +5555,27 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan const qreal py = y * iw - qreal(0.5); int x1 = int(px) - (px < 0); - int x2 = x1 + 1; + int x2; int y1 = int(py) - (py < 0); - int y2 = y1 + 1; + int y2; const int distx = int((px - x1) * 256); const int disty = int((py - y1) * 256); - x1 = qBound(src_minx, x1, src_maxx); - x2 = qBound(src_minx, x2, src_maxx); - y1 = qBound(src_miny, y1, src_maxy); - y2 = qBound(src_miny, y2, src_maxy); + if (x1 < src_minx) { + x2 = x1 = src_minx; + } else if (x1 >= src_maxx) { + x2 = x1 = src_maxx; + } else { + x2 = x1 + 1; + } + if (y1 < src_miny) { + y2 = y1 = src_miny; + } else if (y1 >= src_maxy) { + y2 = y1 = src_maxy; + } else { + y2 = y1 + 1; + } const SRC *src1 = (SRC*)data->texture.scanLine(y1); const SRC *src2 = (SRC*)data->texture.scanLine(y2); -- cgit v0.12 From be16b3def01783e693883c0990f73c815042b1e7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 13 Apr 2010 11:39:23 +0200 Subject: Remove useless assert It would make qconfig crash. --- src/gui/dialogs/qfiledialog_win.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index afeed8e..258707c 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -218,7 +218,6 @@ static OPENFILENAME* qt_win_make_OFN(QWidget *parent, memset(ofn, 0, sizeof(OPENFILENAME)); ofn->lStructSize = sizeof(OPENFILENAME); - Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created)); ofn->hwndOwner = parent ? parent->winId() : 0; ofn->lpstrFilter = (wchar_t*)tFilters.utf16(); ofn->lpstrFile = tInitSel; -- cgit v0.12 From 6433302cf96b64460cbcd770d8cb703f29a001ad Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 13 Apr 2010 11:41:21 +0200 Subject: Improve handling of QAction in soft key manager It also reduces QActionPrivate by 16 bytes. --- src/gui/kernel/qaction.cpp | 1 + src/gui/kernel/qaction_p.h | 17 ++++++++++++++--- src/gui/kernel/qsoftkeymanager.cpp | 12 ++++-------- src/gui/kernel/qsoftkeymanager_p.h | 3 --- src/gui/kernel/qsoftkeymanager_s60.cpp | 5 +++-- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index 8ddd051..a6d2594 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -81,6 +81,7 @@ static QString qt_strippedText(QString s) QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), + forceEnabledInSoftkeys(false), menuActionSoftkeys(false), menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey), priority(QAction::NormalPriority), iconVisibleInMenu(-1) { diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h index b57e5d2..899b01b 100644 --- a/src/gui/kernel/qaction_p.h +++ b/src/gui/kernel/qaction_p.h @@ -75,6 +75,11 @@ public: QActionPrivate(); ~QActionPrivate(); + static QActionPrivate *get(QAction *q) + { + return q->d_func(); + } + bool showStatusText(QWidget *w, const QString &str); QPointer group; @@ -103,10 +108,16 @@ public: uint checked : 1; uint separator : 1; uint fontSet : 1; - QAction::MenuRole menuRole; - QAction::SoftKeyRole softKeyRole; - QAction::Priority priority; + + //for soft keys management + uint forceEnabledInSoftkeys : 1; + uint menuActionSoftkeys : 1; + + QAction::MenuRole menuRole : 3; + QAction::SoftKeyRole softKeyRole : 2; + QAction::Priority priority : 14; int iconVisibleInMenu : 3; // Only has values -1, 0, and 1 + QList widgets; #ifndef QT_NO_GRAPHICSVIEW QList graphicsWidgets; diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 23f1481..04e4685 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -43,7 +43,7 @@ #include "qevent.h" #include "qbitmap.h" #include "private/qsoftkeymanager_p.h" -#include "private/qobject_p.h" +#include "private/qaction_p.h" #include "private/qsoftkeymanager_common_p.h" #ifdef Q_WS_S60 @@ -104,7 +104,7 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey; switch (standardKey) { case MenuSoftKey: // FALL-THROUGH - action->setProperty(MENU_ACTION_PROPERTY, QVariant(true)); // TODO: can be refactored away to use _q_action_menubar + QActionPrivate::get(action)->menuActionSoftkeys = true; case OkSoftKey: case SelectSoftKey: case DoneSoftKey: @@ -255,16 +255,12 @@ bool QSoftKeyManager::handleUpdateSoftKeys() void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action) { - action->setProperty(FORCE_ENABLED_PROPERTY, QVariant(true)); + QActionPrivate::get(action)->forceEnabledInSoftkeys = true; } bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action) { - bool ret = false; - QVariant property = action->property(FORCE_ENABLED_PROPERTY); - if (property.isValid() && property.toBool()) - ret = true; - return ret; + return QActionPrivate::get(action)->forceEnabledInSoftkeys; } bool QSoftKeyManager::event(QEvent *e) diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h index a5b258b..6eedfa8 100644 --- a/src/gui/kernel/qsoftkeymanager_p.h +++ b/src/gui/kernel/qsoftkeymanager_p.h @@ -63,9 +63,6 @@ QT_BEGIN_NAMESPACE class QSoftKeyManagerPrivate; -const char MENU_ACTION_PROPERTY[] = "_q_menuAction"; -const char FORCE_ENABLED_PROPERTY[] = "_q_forceEnabledInSoftkeys"; - class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject { Q_OBJECT diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index c0761f0..fbe5888 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -46,6 +46,7 @@ #include "qmenubar.h" #include "private/qt_s60_p.h" #include "private/qmenu_p.h" +#include "private/qaction_p.h" #include "private/qsoftkeymanager_p.h" #include "private/qsoftkeymanager_s60_p.h" #include "private/qobject_p.h" @@ -382,8 +383,8 @@ bool QSoftKeyManagerPrivateS60::handleCommand(int command) { QAction *action = realSoftKeyActions.value(command); if (action) { - QVariant property = action->property(MENU_ACTION_PROPERTY); - if (property.isValid() && property.toBool()) { + bool property = QActionPrivate(action)->menuActionSoftkeys; + if (property) { QT_TRAP_THROWING(tryDisplayMenuBarL()); } else if (action->menu()) { // TODO: This is hack, in order to use exising QMenuBar implementation for Symbian -- cgit v0.12 From 3c3d5521a94254bf3ce5591e8a326005fcb4d3b1 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 13 Apr 2010 12:07:16 +0200 Subject: build fix for S60 --- src/gui/kernel/qsoftkeymanager_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index fbe5888..e4990b1 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -383,7 +383,7 @@ bool QSoftKeyManagerPrivateS60::handleCommand(int command) { QAction *action = realSoftKeyActions.value(command); if (action) { - bool property = QActionPrivate(action)->menuActionSoftkeys; + bool property = QActionPrivate::get(action)->menuActionSoftkeys; if (property) { QT_TRAP_THROWING(tryDisplayMenuBarL()); } else if (action->menu()) { -- cgit v0.12