diff options
29 files changed, 780 insertions, 220 deletions
diff --git a/demos/declarative/minehunt/MinehuntCore/qmldir b/demos/declarative/minehunt/MinehuntCore/qmldir index 2beccf9..81980e0 100644 --- a/demos/declarative/minehunt/MinehuntCore/qmldir +++ b/demos/declarative/minehunt/MinehuntCore/qmldir @@ -1,3 +1,2 @@ -plugin qmlminehuntplugin Explosion 1.0 Explosion.qml Tile 1.0 Tile.qml diff --git a/demos/declarative/minehunt/README b/demos/declarative/minehunt/README index b9f1d2a..3849ca5 100644 --- a/demos/declarative/minehunt/README +++ b/demos/declarative/minehunt/README @@ -1,3 +1,6 @@ -To compile the C++ part, do 'qmake && make'. Minehunt will not run properly if the C++ plugin is not compiled. +Minehunt has to be compiled to run. + +To compile the C++ part, do 'qmake && make'. +To run, simply run the executable. +To deploy on a device, do 'make sis'. -To run, simply load the minehunt.qml file with the qml runtime. diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp new file mode 100644 index 0000000..fc223dd --- /dev/null +++ b/demos/declarative/minehunt/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QApplication> +#include <QtDeclarative/QDeclarativeView> +#include <QtDeclarative/QDeclarativeContext> +#include <QtDeclarative/QDeclarativeEngine> + +#include "minehunt.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QDeclarativeView canvas; + + qmlRegisterType<TileData>(); + MinehuntGame* game = new MinehuntGame(); + +#ifdef Q_OS_SYMBIAN + canvas.setResizeMode(QDeclarativeView::SizeRootObjectToView); +#endif + canvas.engine()->rootContext()->setContextObject(game); + canvas.setSource(QString("minehunt.qml")); + +#ifdef Q_OS_SYMBIAN + canvas.showFullScreen(); +#else + canvas.setGeometry(QRect(100, 100, 450, 450)); + canvas.show(); +#endif + return app.exec(); +} diff --git a/demos/declarative/minehunt/minehunt.cpp b/demos/declarative/minehunt/minehunt.cpp index 2a4ed10..9c82f30 100644 --- a/demos/declarative/minehunt/minehunt.cpp +++ b/demos/declarative/minehunt/minehunt.cpp @@ -40,99 +40,10 @@ ****************************************************************************/ #include <stdlib.h> -#include <qdeclarativeextensionplugin.h> -#include <qdeclarativecontext.h> -#include <qdeclarativeengine.h> -#include <qdeclarative.h> - #include <QTime> #include <QTimer> -class TileData : public QObject -{ - Q_OBJECT -public: - TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} - - Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) - bool hasFlag() const { return _hasFlag; } - - Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) - bool hasMine() const { return _hasMine; } - - Q_PROPERTY(int hint READ hint NOTIFY hintChanged) - int hint() const { return _hint; } - - Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) - bool flipped() const { return _flipped; } - - void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} - void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} - void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } - void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } - void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } - -signals: - void flippedChanged(); - void hasFlagChanged(); - void hintChanged(); - void hasMineChanged(); - -private: - bool _hasFlag; - bool _hasMine; - int _hint; - bool _flipped; -}; - -class MinehuntGame : public QObject -{ - Q_OBJECT -public: - MinehuntGame(); - - Q_PROPERTY(QDeclarativeListProperty<TileData> tiles READ tiles CONSTANT) - QDeclarativeListProperty<TileData> tiles(); - - Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) - bool isPlaying() {return playing;} - - Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) - bool hasWon() {return won;} - - Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) - int numMines() const{return nMines;} - - Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) - int numFlags() const{return nFlags;} - -public slots: - Q_INVOKABLE bool flip(int row, int col); - Q_INVOKABLE bool flag(int row, int col); - void setBoard(); - void reset(); - -signals: - void isPlayingChanged(); - void hasWonChanged(); - void numMinesChanged(); - void numFlagsChanged(); - -private: - bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } - TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } - int getHint(int row, int col); - void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} - - QList<TileData *> _tiles; - int numCols; - int numRows; - bool playing; - bool won; - int remaining; - int nMines; - int nFlags; -}; +#include "minehunt.h" void tilesPropAppend(QDeclarativeListProperty<TileData>* prop, TileData* value) { @@ -306,29 +217,3 @@ bool MinehuntGame::flag(int row, int col) emit numFlagsChanged(); return true; } - -class MinehuntExtensionPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT - - public: - void registerTypes(const char *uri) { - Q_UNUSED(uri); - qmlRegisterType<TileData>(); - } - - void initializeEngine(QDeclarativeEngine *engine, const char *uri) { - Q_UNUSED(uri); - - srand(QTime(0,0,0).secsTo(QTime::currentTime())); - - MinehuntGame* game = new MinehuntGame(); - - engine->rootContext()->setContextObject(game); - } -}; - -#include "minehunt.moc" - -Q_EXPORT_PLUGIN(MinehuntExtensionPlugin); - diff --git a/demos/declarative/minehunt/minehunt.h b/demos/declarative/minehunt/minehunt.h new file mode 100644 index 0000000..962cf3d --- /dev/null +++ b/demos/declarative/minehunt/minehunt.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <qdeclarative.h> + +class TileData : public QObject +{ + Q_OBJECT +public: + TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} + + Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) + bool hasFlag() const { return _hasFlag; } + + Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) + bool hasMine() const { return _hasMine; } + + Q_PROPERTY(int hint READ hint NOTIFY hintChanged) + int hint() const { return _hint; } + + Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) + bool flipped() const { return _flipped; } + + void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} + void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} + void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } + void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } + void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } + +signals: + void flippedChanged(); + void hasFlagChanged(); + void hintChanged(); + void hasMineChanged(); + +private: + bool _hasFlag; + bool _hasMine; + int _hint; + bool _flipped; +}; + +class MinehuntGame : public QObject +{ + Q_OBJECT +public: + MinehuntGame(); + + Q_PROPERTY(QDeclarativeListProperty<TileData> tiles READ tiles CONSTANT) + QDeclarativeListProperty<TileData> tiles(); + + Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) + bool isPlaying() {return playing;} + + Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) + bool hasWon() {return won;} + + Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) + int numMines() const{return nMines;} + + Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) + int numFlags() const{return nFlags;} + +public slots: + Q_INVOKABLE bool flip(int row, int col); + Q_INVOKABLE bool flag(int row, int col); + void setBoard(); + void reset(); + +signals: + void isPlayingChanged(); + void hasWonChanged(); + void numMinesChanged(); + void numFlagsChanged(); + +private: + bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } + TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } + int getHint(int row, int col); + void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} + + QList<TileData *> _tiles; + int numCols; + int numRows; + bool playing; + bool won; + int remaining; + int nMines; + int nFlags; +}; diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index f85afeb..1d56013 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -1,38 +1,22 @@ -TEMPLATE = lib -TARGET = qmlminehuntplugin +TEMPLATE = app +TARGET = minehunt QT += declarative CONFIG += qt plugin -TARGET = $$qtLibraryTarget($$TARGET) -DESTDIR = MinehuntCore - # Input -SOURCES += minehunt.cpp +HEADERS += minehunt.h +SOURCES += main.cpp minehunt.cpp -sources.files = minehunt.qml minehunt.pro +sources.files = minehunt.qml minehunt.pro MinehuntCore sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt +target.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt -target.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt/MinehuntCore - -MinehuntCore_sources.files = \ - MinehuntCore/Explosion.qml \ - MinehuntCore/Tile.qml \ - MinehuntCore/pics \ - MinehuntCore/qmldir -MinehuntCore_sources.path = $$[QT_INSTALL_DEMOS]/declarative/minehunt/MinehuntCore - -INSTALLS = sources MinehuntCore_sources target +INSTALLS = sources target symbian:{ TARGET.EPOCALLOWDLLDATA = 1 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) - TARGET.CAPABILITY = NetworkServices ReadUserData - importFiles.sources = MinehuntCore/qmlminehuntplugin.dll \ - MinehuntCore/Explosion.qml \ - MinehuntCore/pics \ - MinehuntCore/qmldir - importFiles.path = MinehuntCore - DEPLOYMENT = importFiles + qmlminehuntfiles.sources = MinehuntCore minehunt.qml + DEPLOYMENT = qmlminehuntfiles } - -INSTALLS = sources MinehuntCore_sources target +
\ No newline at end of file diff --git a/demos/qtdemo/mainwindow.h b/demos/qtdemo/mainwindow.h index e613268..b8cfda6 100644 --- a/demos/qtdemo/mainwindow.h +++ b/demos/qtdemo/mainwindow.h @@ -43,7 +43,6 @@ #define MAIN_WINDOW_H #include <QtGui> -#include <QtDeclarative> #include <QPixmap> class DemoTextItem; diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index 5b851b4..4ae9ca1 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -356,6 +356,7 @@ void MenuManager::launchExample(const QString &name) void MenuManager::launchQmlExample(const QString &name) { +#ifndef QT_NO_DECLARATIVE if(!qmlRoot){ exampleError(QProcess::UnknownError); return; @@ -382,6 +383,17 @@ void MenuManager::launchQmlExample(const QString &name) qmlRoot->setProperty("qmlFile", QVariant(""));//unload component qmlRoot->setProperty("show", QVariant(true)); qmlRoot->setProperty("qmlFile", QUrl::fromLocalFile(file.fileName())); +#else + QMessageBox::critical(0, tr("Failed to launch the example"), + tr("This application was built without the QtDeclarative module, and therefore declarative examples have been disabled."), + QMessageBox::Cancel); +#endif +} + +void MenuManager::quitQML() +{ + if(qmlRoot) + qmlRoot->setProperty("show", QVariant(false)); } void MenuManager::exampleFinished() @@ -427,21 +439,28 @@ void MenuManager::init(MainWindow *window) level2MenuNode = level2MenuNode.nextSibling(); } + qmlRoot = 0; +#ifndef QT_NO_DECLARATIVE // Create QML Loader declarativeEngine = new QDeclarativeEngine(this); + connect(declarativeEngine, SIGNAL(quit()), + this, SLOT(quitQML())); QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this); - qmlRoot = 0; - if(component.isReady()) - qmlRoot = qobject_cast<QDeclarativeItem*>(component.create()); - else + QDeclarativeItem* qmlRootItem = 0; + if(component.isReady()){ + qmlRoot = component.create(); + qmlRootItem = qobject_cast<QDeclarativeItem*>(qmlRoot); + }else{ qDebug() << component.status() << component.errorString(); - if(qmlRoot){ - qmlRoot->setHeight(this->window->scene->sceneRect().height()); - qmlRoot->setWidth(this->window->scene->sceneRect().width()); - qmlRoot->setZValue(101);//Above other items - qmlRoot->setCursor(Qt::ArrowCursor); - window->scene->addItem(qmlRoot); + } + + if(qmlRootItem){ + qmlRootItem->setHeight(this->window->scene->sceneRect().height()); + qmlRootItem->setWidth(this->window->scene->sceneRect().width()); + qmlRootItem->setZValue(101);//Above other items + qmlRootItem->setCursor(Qt::ArrowCursor); + window->scene->addItem(qmlRootItem); //Note that QML adds key handling to the app. window->viewport()->setFocusPolicy(Qt::NoFocus);//Correct keyboard focus handling @@ -451,6 +470,7 @@ void MenuManager::init(MainWindow *window) }else{ qDebug() << "Error initializing QML subsystem, Declarative examples will not work"; } +#endif } void MenuManager::readInfoAboutExample(const QDomElement &example) diff --git a/demos/qtdemo/menumanager.h b/demos/qtdemo/menumanager.h index 5e14204..93fb998 100644 --- a/demos/qtdemo/menumanager.h +++ b/demos/qtdemo/menumanager.h @@ -45,6 +45,9 @@ #include <QtGui> #include <QtXml> #include <QtHelp/QHelpEngineCore> +#ifndef QT_NO_DECLARATIVE +#include <QtDeclarative> +#endif #include "score.h" #include "textbutton.h" @@ -83,13 +86,17 @@ public: Score *score; int currentMenuCode; + QObject *qmlRoot; +#ifndef QT_NO_DECLARATIVE QDeclarativeEngine* declarativeEngine; - QDeclarativeItem *qmlRoot; +#endif private slots: void exampleFinished(); void exampleError(QProcess::ProcessError error); + void quitQML(); + private: // singleton pattern: MenuManager(); diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index b5fdf39..24c12ae 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -68,8 +68,6 @@ Item { loader.item.width = 640; if(loader.item.height > 480) loader.item.height = 480; - if(loader.item.inAnotherDemo != undefined) - loader.item.inAnotherDemo = true; }} } @@ -100,6 +98,30 @@ Item { } } + Rectangle{ id: closeButton + width: 24 + height: 24 + z: 11 + border.color: "#aaaaaaaa" + gradient: Gradient{ + GradientStop{ position: 0.0; color: "#34FFFFFF" } + GradientStop{ position: 1.0; color: "#7AFFFFFF" } + } + anchors.left: frame.right + anchors.bottom: frame.top + anchors.margins: -(2*width/3) + Text{ + text: 'X' + font.bold: true + color: "white" + font.pixelSize: 12 + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: main.show = false; + } + } Text{ id: errorTxt @@ -116,32 +138,6 @@ Item { onLinkActivated: Qt.openUrlExternally(link); } } - Rectangle{ - id: helpLabel - property bool timedOut: false - z: 9 - //Positioned in the top left corner - x: 8 - y: 8 - color: "white" - border.color: "black" - border.width: 1 - width: helpText.width + 16 - height: helpText.height + 8 - Text{ - id: helpText - color: "black" - anchors.centerIn: parent - text: "Click outside the example to exit it." - } - opacity: 0 - Behavior on opacity{ NumberAnimation{duration:500} } - Timer{ - id: helpTimer - interval: 5000 - onTriggered: {helpLabel.timedOut=true} - } - } Rectangle{ id: blackout //Maybe use a colorize effect instead? z: 8 anchors.fill: parent @@ -154,7 +150,6 @@ Item { hoverEnabled: main.show //To steal focus from the buttons acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton anchors.fill: parent - onClicked: main.show=false; } states: [ @@ -166,10 +161,6 @@ Item { opacity: 1 } PropertyChanges { - target: helpLabel - opacity: helpLabel.timedOut?0:1 - } - PropertyChanges { target: blackout opacity: 0.5 } @@ -178,8 +169,7 @@ Item { transitions: [//Should not be too long, because the component has already started running Transition { from: ''; to: "show"; reversible: true ParallelAnimation{ - ScriptAction{ script: {helpLabel.timedOut = false; helpTimer.restart();} } - NumberAnimation{ exclude: helpLabel; properties: "opacity"; easing.type: Easing.InQuad; duration: 500} + NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500} PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us } } diff --git a/demos/qtdemo/qtdemo.pro b/demos/qtdemo/qtdemo.pro index 61ea376..836178b 100644 --- a/demos/qtdemo/qtdemo.pro +++ b/demos/qtdemo/qtdemo.pro @@ -6,13 +6,17 @@ DESTDIR = $$DEMO_DESTDIR/bin INSTALLS += target sources -QT += xml network declarative +QT += xml network contains(QT_CONFIG, opengl) { DEFINES += QT_OPENGL_SUPPORT QT += opengl } +contains(QT_CONFIG, declarative) { + QT += declarative +} + build_all:!build_pass { CONFIG -= build_all CONFIG += release diff --git a/doc/src/examples/qml-minehunt.qdoc b/doc/src/examples/qml-minehunt.qdoc index be82302..e1ff22f 100644 --- a/doc/src/examples/qml-minehunt.qdoc +++ b/doc/src/examples/qml-minehunt.qdoc @@ -30,7 +30,7 @@ \example demos/declarative/minehunt This demo shows how to create a simple Minehunt game, using QML for the - UI and a C++ plugin for the game logic. + UI and C++ for the game logic. \image qml-minehunt-demo.png */ diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 6d96b01..04b81b0 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -70,7 +70,12 @@ QMAKE_LIBS_CORE = $$QMAKE_LIBS -lefsrv -lhal -lbafl QMAKE_LIBS_GUI = $$QMAKE_LIBS_CORE -lfbscli -lbitgdi -lgdi -lws32 -lapgrfx -lcone -leikcore -lmediaclientaudio -lapparc -lcentralrepository QMAKE_LIBS_NETWORK = QMAKE_LIBS_EGL = -llibEGL -QMAKE_LIBS_OPENGL = +QMAKE_LIBS_OPENGL = -llibglesv2 +QMAKE_LIBS_OPENGL_ES1 = -llibGLESv1_CM +QMAKE_LIBS_OPENGL_ES2 = -llibglesv2 +QMAKE_LIBS_OPENGL_QT = -llibglesv2 -lcone -lws32 +QMAKE_LIBS_OPENGL_ES1_QT = -llibGLESv1_CM -lcone -lws32 +QMAKE_LIBS_OPENGL_ES2_QT = -llibglesv2 -lcone -lws32 QMAKE_LIBS_OPENVG = -llibOpenVG -lfbscli -lbitgdi -lgdi QMAKE_LIBS_THREAD = -llibpthread QMAKE_LIBS_COMPAT = diff --git a/mkspecs/features/symbian/opengl.prf b/mkspecs/features/symbian/opengl.prf new file mode 100644 index 0000000..9a8ab18 --- /dev/null +++ b/mkspecs/features/symbian/opengl.prf @@ -0,0 +1,21 @@ +contains(QT_CONFIG, opengles1) { + INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES1 + !isEmpty(QMAKE_LIBDIR_OPENGL_ES1):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL_ES1 + target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_ES1_QT + else:LIBS += $$QMAKE_LIBS_OPENGL_ES1 +} else:contains(QT_CONFIG, opengles2) { + INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2 + !isEmpty(QMAKE_LIBDIR_OPENGL_ES2):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL_ES2 + target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_ES2_QT + else:LIBS += $$QMAKE_LIBS_OPENGL_ES2 +} else { + INCLUDEPATH += $$QMAKE_INCDIR_OPENGL + !isEmpty(QMAKE_LIBDIR_OPENGL):QMAKE_LIBDIR += $$QMAKE_LIBDIR_OPENGL + target_qt:LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL_QT + else:LIBS += $$QMAKE_LIBS_OPENGL +} + +contains(QT_CONFIG, egl) { + !isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL +} + diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index bc7468f..cedf9d5 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -551,7 +551,7 @@ QDeclarativeEngine::~QDeclarativeEngine() } /*! \fn void QDeclarativeEngine::quit() - This signal is emitted when the QDeclarativeEngine quits. + This signal is emitted when the QML loaded by the engine would like to quit. */ /*! \fn void QDeclarativeEngine::warnings(const QList<QDeclarativeError> &warnings) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 670bf34..7c5e790 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1107,17 +1107,19 @@ void QSymbianControl::Draw(const TRect& controlRect) const CFbsBitmap *bitmap = s60Surface->symbianBitmap(); CWindowGc &gc = SystemGc(); - switch(qwidget->d_func()->extraData()->nativePaintMode) { + QWExtra::NativePaintMode nativePaintMode = qwidget->d_func()->extraData()->nativePaintMode; + if(qwidget->d_func()->paintOnScreen()) + nativePaintMode = QWExtra::Disable; + + switch(nativePaintMode) { case QWExtra::Disable: // Do nothing break; - case QWExtra::Blit: if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect); break; - case QWExtra::ZeroFill: if (Window().DisplayMode() == EColor16MA || Window().DisplayMode() == Q_SYMBIAN_ECOLOR16MAP) { @@ -1130,7 +1132,6 @@ void QSymbianControl::Draw(const TRect& controlRect) const gc.Clear(controlRect); }; break; - default: Q_ASSERT(false); } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index dad4848..8b8641f 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1274,7 +1274,16 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) q->setAttribute(Qt::WA_WState_Hidden); //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later +#ifdef Q_OS_SYMBIAN + if(q->inherits("QGLWidget")) { + // Don't waste GPU mem for unnecessary large egl surface + data.crect = parentWidget ? QRect(0,0,2,2) : QRect(0,0,2,2); + } else { + data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640); + } +#else data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480); +#endif focus_next = focus_prev = q; @@ -9957,7 +9966,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) desktopWidget = parent; bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) if (newParent && parent && !desktopWidget) { if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) parent->d_func()->enforceNativeChildren(); @@ -10611,7 +10620,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } case Qt::WA_PaintOnScreen: d->updateIsOpaque(); -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) // Recreate the widget if it's already created as an alien widget and // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id. // So must their children. diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 7ab9fbc..7494f92 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -486,7 +486,7 @@ void QWidgetPrivate::show_sys() #ifdef Q_WS_S60 // Lazily initialize the S60 screen furniture when the first window is shown. - if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) + if (q->isWindow() && !QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) && !S60->buttonGroupContainer() && !S60->statusPane()) { if (!q->testAttribute(Qt::WA_DontShowOnScreen)) { diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index d3f6a29..18192e3 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -90,7 +90,10 @@ QT_BEGIN_NAMESPACE -//#define QT_GL_NO_SCISSOR_TEST +#if defined(Q_OS_SYMBIAN) +#define QT_GL_NO_SCISSOR_TEST +#endif + #if defined(Q_WS_WIN) extern Q_GUI_EXPORT bool qt_cleartype_enabled; #endif @@ -374,12 +377,12 @@ void QGL2PaintEngineExPrivate::updateMatrix() dx = ceilf(dx - 0.5f); dy = ceilf(dy - 0.5f); } - +#ifndef Q_OS_SYMBIAN if (addOffset) { dx += 0.49f; dy += 0.49f; } - +#endif pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13(); pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23(); pmvMatrix[2][0] = (wfactor * dx) - transform.m33(); @@ -686,7 +689,12 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); // ### Remove before release... - static bool do_vectorpath_cache = qgetenv("QT_OPENGL_NO_PATH_CACHE").isEmpty(); +#ifdef Q_OS_SYMBIAN + // ### There are some unresolved issues in Symbian vector path caching. + static bool do_vectorpath_cache = false; +#else + static bool do_vectorpath_cache = true; +#endif // Check to see if there's any hints if (path.shape() == QVectorPath::RectangleHint) { diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp index df7cbc2..f14b0a4 100644 --- a/src/opengl/gl2paintengineex/qtriangulator.cpp +++ b/src/opengl/gl2paintengineex/qtriangulator.cpp @@ -65,7 +65,11 @@ QT_BEGIN_NAMESPACE // Quick sort. template <class T, class LessThan> +#ifdef Q_CC_RVCT // RVCT 2.2 doesn't see recursive _static_ template function +void sort(T *array, int count, LessThan lessThan) +#else static void sort(T *array, int count, LessThan lessThan) +#endif { // If the number of elements fall below some threshold, use insertion sort. const int INSERTION_SORT_LIMIT = 7; // About 7 is fastest on my computer... @@ -122,7 +126,11 @@ sort_loop_end: // Quick sort. template <class T> +#ifdef Q_CC_RVCT +void sort(T *array, int count) // RVCT 2.2 doesn't see recursive _static_ template function +#else static void sort(T *array, int count) +#endif { // If the number of elements fall below some threshold, use insertion sort. const int INSERTION_SORT_LIMIT = 25; // About 25 is fastest on my computer... diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index d6011cf..0e82467 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -11,18 +11,18 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui include(../qbase.pri) -!win32:!embedded:!mac:CONFIG += x11 +!win32:!embedded:!mac:!symbian:CONFIG += x11 contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles1):CONFIG += opengles1 contains(QT_CONFIG, opengles2):CONFIG += opengles2 contains(QT_CONFIG, egl):CONFIG += egl HEADERS += qgl.h \ - qgl_p.h \ - qglcolormap.h \ - qglpixelbuffer.h \ + qgl_p.h \ + qglcolormap.h \ + qglpixelbuffer.h \ qglpixelbuffer_p.h \ - qglframebufferobject.h \ + qglframebufferobject.h \ qglframebufferobject_p.h \ qglextensions_p.h \ qglpaintdevice_p.h \ @@ -30,9 +30,9 @@ HEADERS += qgl.h \ SOURCES += qgl.cpp \ - qglcolormap.cpp \ - qglpixelbuffer.cpp \ - qglframebufferobject.cpp \ + qglcolormap.cpp \ + qglpixelbuffer.cpp \ + qglframebufferobject.cpp \ qglextensions.cpp \ qglpaintdevice.cpp \ qglbuffer.cpp \ @@ -119,7 +119,7 @@ mac { win32:!wince*: { DEFINES += QT_NO_EGL SOURCES += qgl_win.cpp \ - qglpixelbuffer_win.cpp + qglpixelbuffer_win.cpp } wince*: { SOURCES += qgl_wince.cpp \ @@ -147,4 +147,14 @@ embedded { } } +symbian { + SOURCES += qgl_symbian.cpp \ + qglpixelbuffer_egl.cpp \ + qgl_egl.cpp + + HEADERS += qgl_egl_p.h + + symbian:TARGET.UID3 = 0x2002131A +} + INCLUDEPATH += ../3rdparty/harfbuzz/src diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 74bde36..1802107 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -96,7 +96,7 @@ QT_BEGIN_NAMESPACE -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs; #endif @@ -2264,7 +2264,7 @@ static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum textu } } -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) QGLExtensionFuncs& QGLContextPrivate::extensionFuncs(const QGLContext *) { return qt_extensionFuncs; @@ -4197,6 +4197,34 @@ bool QGLWidget::event(QEvent *e) d->glcx->d_ptr->clearDrawable(); # endif } +#elif defined(Q_OS_SYMBIAN) + // prevents errors on some systems, where we get a flush to a + // hidden widget + if (e->type() == QEvent::Hide) { + makeCurrent(); + glFinish(); + doneCurrent(); + } else if (e->type() == QEvent::ParentChange) { + // if we've reparented a window that has the current context + // bound, we need to rebind that context to the new window id + if (d->glcx == QGLContext::currentContext()) + makeCurrent(); + + if (testAttribute(Qt::WA_TranslucentBackground)) + setContext(new QGLContext(d->glcx->requestedFormat(), this)); + } + + // A re-parent is likely to destroy the Symbian window and re-create it. It is important + // that we free the EGL surface _before_ the winID changes - otherwise we can leak. + if (e->type() == QEvent::ParentAboutToChange) + d->glcx->d_func()->destroyEglSurfaceForDevice(); + + if ((e->type() == QEvent::ParentChange) || (e->type() == QEvent::WindowStateChange)) { + // The window may have been re-created during re-parent or state change - if so, the EGL + // surface will need to be re-created. + d->recreateEglSurface(); + } + #endif return QWidget::event(e); diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index a154325..ebd1169 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -230,7 +230,7 @@ void QGLContext::swapBuffers() const void QGLContextPrivate::destroyEglSurfaceForDevice() { if (eglSurface != EGL_NO_SURFACE) { -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN) // Make sure we don't call eglDestroySurface on a surface which // was created for a different winId. This applies only to QGLWidget // paint device, so make sure this is the one we're operating on diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index ca0d3fa..387c8f7 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -167,6 +167,9 @@ public: #if defined(Q_WS_X11) && !defined(QT_NO_EGL) , eglSurfaceWindowId(0) #endif +#if defined(Q_OS_SYMBIAN) + , eglSurfaceWindowId(0) +#endif { isGLWidget = 1; } @@ -208,6 +211,10 @@ public: #elif defined(Q_WS_QWS) QWSGLWindowSurface *wsurf; #endif +#ifdef Q_OS_SYMBIAN + void recreateEglSurface(); + WId eglSurfaceWindowId; +#endif }; class QGLContextResource; @@ -417,7 +424,7 @@ public: static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); } #endif -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) static QGLExtensionFuncs qt_extensionFuncs; static Q_OPENGL_EXPORT QGLExtensionFuncs& extensionFuncs(const QGLContext *); #endif diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp new file mode 100644 index 0000000..73fe4c9 --- /dev/null +++ b/src/opengl/qgl_symbian.cpp @@ -0,0 +1,362 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qgl.h" +#include <coemain.h> +#include <coecntrl.h> +#include <w32std.h> +#include <private/qpixmap_s60_p.h> +#include <private/qimagepixmapcleanuphooks_p.h> +#include <private/qgl_p.h> +#include <private/qpaintengine_opengl_p.h> +#include <private/qwidget_p.h> // to access QWExtra +#include "qgl_egl_p.h" +#include "qcolormap.h" +#include <QDebug> + +QT_BEGIN_NAMESPACE + +// Turn off "direct to window" rendering if EGL cannot support it. +#if !defined(EGL_RENDER_BUFFER) || !defined(EGL_SINGLE_BUFFER) +#if defined(QGL_DIRECT_TO_WINDOW) +#undef QGL_DIRECT_TO_WINDOW +#endif +#endif + +// Determine if preserved window contents should be used. +#if !defined(EGL_SWAP_BEHAVIOR) || !defined(EGL_BUFFER_PRESERVED) +#if !defined(QGL_NO_PRESERVED_SWAP) +#define QGL_NO_PRESERVED_SWAP 1 +#endif +#endif + +/* + QGLTemporaryContext implementation +*/ + + +class QGLTemporaryContextPrivate +{ +public: + bool initialized; + RWindow *window; + EGLContext context; + EGLSurface surface; + EGLDisplay display; +}; + +QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) + : d(new QGLTemporaryContextPrivate) +{ + d->initialized = false; + d->window = 0; + d->context = 0; + d->surface = 0; + + d->display = d->display = QEgl::display(); + + EGLConfig config; + int numConfigs = 0; + EGLint attribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, +#ifdef QT_OPENGL_ES_2 + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, +#endif + EGL_NONE + }; + + eglChooseConfig(d->display, attribs, &config, 1, &numConfigs); + if (!numConfigs) { + qWarning("QGLTemporaryContext: No EGL configurations available."); + return; + } + + d->window = new RWindow(CCoeEnv::Static()->WsSession()); + d->window->Construct(CCoeEnv::Static()->RootWin(),(uint)this); + + d->surface = eglCreateWindowSurface(d->display, config, (EGLNativeWindowType) d->window, NULL); + + if (d->surface == EGL_NO_SURFACE) { + qWarning("QGLTemporaryContext: Error creating EGL surface."); + delete d->window; + d->window = 0; + return; + } + + EGLint contextAttribs[] = { +#ifdef QT_OPENGL_ES_2 + EGL_CONTEXT_CLIENT_VERSION, 2, +#endif + EGL_NONE + }; + d->context = eglCreateContext(d->display, config, 0, contextAttribs); + if (d->context != EGL_NO_CONTEXT + && eglMakeCurrent(d->display, d->surface, d->surface, d->context)) + { + d->initialized = true; + } else { + qWarning("QGLTemporaryContext: Error creating EGL context."); + d->window = 0; + return; + } +} + +QGLTemporaryContext::~QGLTemporaryContext() +{ + if (d->initialized) { + eglMakeCurrent(d->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroyContext(d->display, d->context); + eglDestroySurface(d->display, d->surface); + delete d->window; + } +} + +bool QGLFormat::hasOpenGLOverlays() +{ + return false; +} + +// Chooses the EGL config and creates the EGL context +bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as in qgl_x11egl.cpp +{ + Q_D(QGLContext); + + if (!device()) + return false; + + int devType = device()->devType(); + + if ((devType != QInternal::Widget) && (devType != QInternal::Pbuffer)) { + qWarning("WARNING: Creating a QGLContext not supported on device type %d", devType); + return false; + } + + // Get the display and initialize it. + if (d->eglContext == 0) { + d->eglContext = new QEglContext(); + d->ownsEglContext = true; + d->eglContext->setApi(QEgl::OpenGL); + + // If the device is a widget with WA_TranslucentBackground set, make sure the glFormat + // has the alpha channel option set: + if (devType == QInternal::Widget) { + QWidget* widget = static_cast<QWidget*>(device()); + if (widget->testAttribute(Qt::WA_TranslucentBackground)) + d->glFormat.setAlpha(true); + } + + // Construct the configuration we need for this surface. + QEglProperties configProps; + configProps.setDeviceType(devType); + configProps.setPaintDeviceFormat(device()); + configProps.setRenderableType(QEgl::OpenGL); + configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_SWAP_BEHAVIOR_PRESERVED_BIT); + + qt_eglproperties_set_glformat(configProps, d->glFormat); + + if (!d->eglContext->chooseConfig(configProps, QEgl::BestPixelFormat)) { + delete d->eglContext; + d->eglContext = 0; + return false; + } + + // Create a new context for the configuration. + QEglContext* eglSharedContext = shareContext ? shareContext->d_func()->eglContext : 0; + if (!d->eglContext->createContext(eglSharedContext)) { + delete d->eglContext; + d->eglContext = 0; + return false; + } + d->sharing = d->eglContext->isSharing(); + if (d->sharing && shareContext) + const_cast<QGLContext *>(shareContext)->d_func()->sharing = true; + } + + // Inform the higher layers about the actual format properties + qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config()); + + // Do don't create the EGLSurface for everything. + // QWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface + // QGLWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface + // QGLPixelBuffer - no, it creates the surface itself and stores it in QGLPixelBufferPrivate::pbuf + + if (devType == QInternal::Widget) { + if (d->eglSurface != EGL_NO_SURFACE) + eglDestroySurface(d->eglContext->display(), d->eglSurface); + + d->eglSurface = QEgl::createSurface(device(), d->eglContext->config()); + +#if !defined(QGL_NO_PRESERVED_SWAP) + eglGetError(); // Clear error state first. + eglSurfaceAttrib(QEgl::display(), d->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + if (eglGetError() != EGL_SUCCESS) { + qWarning("QGLContext: could not enable preserved swap"); + } +#endif + + setWindowCreated(true); + } + + return true; +} + +void QGLWidget::resizeEvent(QResizeEvent *) +{ + Q_D(QGLWidget); + if (!isValid()) + return; + + if (QGLContext::currentContext()) + doneCurrent(); + + // Symbian needs to recreate the surface on resize. + d->recreateEglSurface(); + + makeCurrent(); + if (!d->glcx->initialized()) + glInit(); + resizeGL(width(), height()); + //handle overlay +} + +const QGLContext* QGLWidget::overlayContext() const +{ + return 0; +} + +void QGLWidget::makeOverlayCurrent() +{ + //handle overlay +} + +void QGLWidget::updateOverlayGL() +{ + //handle overlay +} + +void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, bool deleteOldContext) +{ + Q_D(QGLWidget); + if (context == 0) { + qWarning("QGLWidget::setContext: Cannot set null context"); + return; + } + if (!context->deviceIsPixmap() && context->device() != this) { + qWarning("QGLWidget::setContext: Context must refer to this widget"); + return; + } + + if (d->glcx) + d->glcx->doneCurrent(); + QGLContext* oldcx = d->glcx; + d->glcx = context; + + bool createFailed = false; + if (!d->glcx->isValid()) { + // Create the QGLContext here, which in turn chooses the EGL config + // and creates the EGL context: + if (!d->glcx->create(shareContext ? shareContext : oldcx)) + createFailed = true; + } + if (createFailed) { + if (deleteOldContext) + delete oldcx; + return; + } + + d->eglSurfaceWindowId = winId(); // Remember the window id we created the surface for +} + +void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget* shareWidget) +{ + Q_Q(QGLWidget); + + initContext(context, shareWidget); + + if(q->isValid() && glcx->format().hasOverlay()) { + //no overlay + qWarning("QtOpenGL ES doesn't currently support overlays"); + } +} + +void QGLWidgetPrivate::cleanupColormaps() +{ +} + +const QGLColormap & QGLWidget::colormap() const +{ + return d_func()->cmap; +} + +void QGLWidget::setColormap(const QGLColormap &) +{ +} + +void QGLWidgetPrivate::recreateEglSurface() +{ + Q_Q(QGLWidget); + + WId currentId = q->winId(); + + if (glcx->d_func()->eglSurface != EGL_NO_SURFACE) { + eglDestroySurface(glcx->d_func()->eglContext->display(), + glcx->d_func()->eglSurface); + } + + glcx->d_func()->eglSurface = QEgl::createSurface(glcx->device(), + glcx->d_func()->eglContext->config()); + +#if !defined(QGL_NO_PRESERVED_SWAP) + eglGetError(); // Clear error state first. + eglSurfaceAttrib(QEgl::display(), glcx->d_func()->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + if (eglGetError() != EGL_SUCCESS) { + qWarning("QGLContext: could not enable preserved swap"); + } +#endif + + eglSurfaceWindowId = currentId; +} + +QT_END_NAMESPACE + diff --git a/src/plugins/graphicssystems/opengl/opengl.pro b/src/plugins/graphicssystems/opengl/opengl.pro index 7d6fe3f..47e15c5 100644 --- a/src/plugins/graphicssystems/opengl/opengl.pro +++ b/src/plugins/graphicssystems/opengl/opengl.pro @@ -9,3 +9,5 @@ SOURCES = main.cpp target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems INSTALLS += target + +symbian: TARGET.UID3 = 0x2002131B diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby index 935bdc5..b6cdce9 100644 --- a/src/s60installs/qt.iby +++ b/src/s60installs/qt.iby @@ -20,6 +20,7 @@ file=ABI_DIR\BUILD_DIR\phonon.dll SHARED_LIB_DIR\phonon.dll file=ABI_DIR\BUILD_DIR\QtMultimedia.dll SHARED_LIB_DIR\QtMultimedia.dll file=ABI_DIR\BUILD_DIR\QtXmlPatterns.dll SHARED_LIB_DIR\QtXmlPatterns.dll file=ABI_DIR\BUILD_DIR\QtDeclarative.dll SHARED_LIB_DIR\QtDeclarative.dll +file=ABI_DIR\BUILD_DIR\QtOpenGL.dll SHARED_LIB_DIR\QtOpenGL.dll // imageformats file=ABI_DIR\BUILD_DIR\qgif.dll SHARED_LIB_DIR\qgif.dll @@ -50,6 +51,7 @@ file=ABI_DIR\BUILD_DIR\qaudio.dll SHARED_LIB_DIR\qaudio.dll // graphicssystems file=ABI_DIR\BUILD_DIR\qvggraphicssystem.dll SHARED_LIB_DIR\qvggraphicssystem.dll +file=ABI_DIR\BUILD_DIR\qglgraphicssystem.dll SHARED_LIB_DIR\qglgraphicssystem.dll // S60 version compatibility plugins for 5.0 (3.1 and 3.2 devices are never likely to have this in ROM, // so don't bother including those plugins @@ -95,6 +97,7 @@ data=\epoc32\data\qt\qtlibspluginstubs\qaudio.qtplugin resource\qt\plugins\audio // graphicssystems data=\epoc32\data\z\resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin +data=\epoc32\data\z\resource\qt\plugins\graphicssystems\qglgraphicssystem.qtplugin resource\qt\plugins\graphicssystems\qglgraphicssystem.qtplugin // Stub sis file data=ZSYSTEM\install\qt_stub.sis System\Install\qt_stub.sis diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 8a8167b..9e1d582 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -189,6 +189,11 @@ symbian: { "[0x1028315F],0,0,0,{\"S60ProductID\"}" } + contains(QT_CONFIG, opengl) { + qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtOpenGL$${QT_LIBINFIX}.dll + graphicssystems_plugins.sources += $$QT_BUILD_TREE/plugins/graphicssystems/qglgraphicssystem$${QT_LIBINFIX}.dll + } + contains(QT_CONFIG, multimedia){ qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMultimedia$${QT_LIBINFIX}.dll } diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index bdff5ed..e411508 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -847,6 +847,7 @@ void tst_QGL::graphicsViewClipping() scene.addWidget(widget)->setPos(0, 0); QGraphicsView view(&scene); + view.setBackgroundBrush(Qt::white); #ifdef Q_WS_QWS view.setWindowFlags(Qt::FramelessWindowHint); #endif |