From efba403423db53ed480bd88be4dcd650f8ae831a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 31 May 2011 15:04:19 +0100 Subject: Revert "Revert "Fix QNetworkConfigurationManager usage outside main thread first"" This reverts commit daba0c0d588c55e3f1591ab8ce0ef0946d1447fd. --- src/network/bearer/qnetworkconfigmanager_p.cpp | 15 ++++++-- .../tst_qnetworkconfigurationmanager.cpp | 44 ++++++++++++++++++++++ .../tst_qnetworkproxyfactory.cpp | 31 ++++++++++++++- 3 files changed, 86 insertions(+), 4 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 7297b0e..2391a34 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -392,8 +392,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); - - QMetaObject::invokeMethod(engine, "initialize"); } } @@ -423,8 +421,19 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() startPolling(); } - if (firstUpdate) + if (firstUpdate) { firstUpdate = false; + QList enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex + Qt::ConnectionType connectionType; + if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) + connectionType = Qt::DirectConnection; + else + connectionType = Qt::BlockingQueuedConnection; + locker.unlock(); + foreach (QBearerEngine* engine, enginesToInitialize) { + QMetaObject::invokeMethod(engine, "initialize", connectionType); + } + } } void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 57bf583..d29ef77 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -62,6 +62,7 @@ public slots: void cleanup(); private slots: + void usedInThread(); // this test must be first, or it will falsely pass void allConfigurations(); void defaultConfiguration(); void configurationFromIdentifier(); @@ -329,6 +330,49 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier() QVERIFY(!invalid.isValid()); } +class QNCMTestThread : public QThread +{ +protected: + virtual void run() + { + QNetworkConfigurationManager manager; + preScanConfigs = manager.allConfigurations(); + QSignalSpy spy(&manager, SIGNAL(updateCompleted())); + manager.updateConfigurations(); //initiate scans + QTRY_VERIFY(spy.count() == 1); //wait for scan to complete + configs = manager.allConfigurations(); + } +public: + QList configs; + QList preScanConfigs; +}; + +// regression test for QTBUG-18795 +void tst_QNetworkConfigurationManager::usedInThread() +{ +#if defined Q_OS_MAC && !defined (QT_NO_COREWLAN) + QSKIP("QTBUG-19070 Mac CoreWlan plugin is broken", SkipAll); +#else + QNCMTestThread thread; + connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + thread.start(); + QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY could take ~90 seconds to time out in the thread + QVERIFY(!QTestEventLoop::instance().timeout()); + qDebug() << "prescan:" << thread.preScanConfigs.count(); + qDebug() << "postscan:" << thread.configs.count(); + + QNetworkConfigurationManager manager; + QList preScanConfigs = manager.allConfigurations(); + QSignalSpy spy(&manager, SIGNAL(updateCompleted())); + manager.updateConfigurations(); //initiate scans + QTRY_VERIFY(spy.count() == 1); //wait for scan to complete + QList configs = manager.allConfigurations(); + QCOMPARE(thread.configs, configs); + //Don't compare pre scan configs, because these may be cached and therefore give different results + //which makes the test unstable. The post scan results should have all configurations every time + //QCOMPARE(thread.preScanConfigs, preScanConfigs); +#endif +} QTEST_MAIN(tst_QNetworkConfigurationManager) #include "tst_qnetworkconfigurationmanager.moc" diff --git a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index 954b369..c56fedb 100644 --- a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -41,14 +41,17 @@ #include +#include #include #include #include +#include class tst_QNetworkProxyFactory : public QObject { Q_OBJECT private slots: + void systemProxyForQueryCalledFromThread(); void systemProxyForQuery() const; private: @@ -96,5 +99,31 @@ void tst_QNetworkProxyFactory::systemProxyForQuery() const QFAIL("One or more system proxy lookup failures occurred."); } +class QSPFQThread : public QThread +{ +protected: + virtual void run() + { + proxies = QNetworkProxyFactory::systemProxyForQuery(query); + } +public: + QNetworkProxyQuery query; + QList proxies; +}; + +//regression test for QTBUG-18799 +void tst_QNetworkProxyFactory::systemProxyForQueryCalledFromThread() +{ + QUrl url(QLatin1String("http://qt.nokia.com")); + QNetworkProxyQuery query(url); + QSPFQThread thread; + thread.query = query; + connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + thread.start(); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(thread.isFinished()); + QCOMPARE(thread.proxies, QNetworkProxyFactory::systemProxyForQuery(query)); +} + QTEST_MAIN(tst_QNetworkProxyFactory) #include "tst_qnetworkproxyfactory.moc" -- cgit v0.12 From 5f879c55e531165cc2569b03c3796d0f33d0a0b7 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 1 Jun 2011 16:35:43 +0100 Subject: bearer: run the bearer engines in their own worker thread The original architecture of the QtNetwork bearer support hosted the engines in the application's main thread, but this causes some problems. If the QNetworkConfigurationManager is constructed in a worker thread, then it is populated asynchronously without any notification when it is done (the app gets incomplete or missing results) Fixing that by restoring the earlier behaviour of using blocking queued connections to wait for the lists to be populated caused a regression, as some applications deadlock because the main thread is waiting on the worker thread at this time. By introducing a dedicated worker thread for the bearer engines, QNetworkConfigurationManager can be safely constructed in any thread while using blocking queued connections internally. Task-number: QTBUG-18795 Reviewed-by: mread --- src/network/bearer/qnetworkconfigmanager.cpp | 4 +-- src/network/bearer/qnetworkconfigmanager_p.cpp | 36 ++++++++++++++++---------- src/network/bearer/qnetworkconfigmanager_p.h | 3 +++ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 65a15d7..d2c7317 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC_INIT(TYPE, NAME); \ static void NAME##_cleanup() \ { \ - delete this_##NAME.pointer; \ + this_##NAME.pointer->cleanup(); \ this_##NAME.pointer = 0; \ } \ static TYPE *NAME() \ @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE delete x; \ else { \ qAddPostRoutine(NAME##_cleanup); \ - this_##NAME.pointer->updateConfigurations(); \ + this_##NAME.pointer->initialize(); \ } \ } \ return this_##NAME.pointer; \ diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 2391a34..17e47bd 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -66,11 +66,31 @@ QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() qRegisterMetaType("QNetworkConfigurationPrivatePointer"); } +void QNetworkConfigurationManagerPrivate::initialize() +{ + //Two stage construction, because we only want to do this heavyweight work for the winner of the Q_GLOBAL_STATIC race. + bearerThread = new QThread(); + bearerThread->moveToThread(QCoreApplicationPrivate::mainThread()); // because cleanup() is called in main thread context. + moveToThread(bearerThread); + bearerThread->start(); + updateConfigurations(); +} + QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() { QMutexLocker locker(&mutex); qDeleteAll(sessionEngines); + if (bearerThread) + bearerThread->quit(); +} + +void QNetworkConfigurationManagerPrivate::cleanup() +{ + QThread* thread = bearerThread; + deleteLater(); + if(thread->wait(5000)) + delete thread; } QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() @@ -356,13 +376,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() if (sender()) return; - if (thread() != QCoreApplicationPrivate::mainThread()) { - if (thread() != QThread::currentThread()) - return; - - moveToThread(QCoreApplicationPrivate::mainThread()); - } - updating = false; #ifndef QT_NO_LIBRARY @@ -382,7 +395,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() else sessionEngines.append(engine); - engine->moveToThread(QCoreApplicationPrivate::mainThread()); + engine->moveToThread(bearerThread); connect(engine, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations())); @@ -424,14 +437,9 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() if (firstUpdate) { firstUpdate = false; QList enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex - Qt::ConnectionType connectionType; - if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) - connectionType = Qt::DirectConnection; - else - connectionType = Qt::BlockingQueuedConnection; locker.unlock(); foreach (QBearerEngine* engine, enginesToInitialize) { - QMetaObject::invokeMethod(engine, "initialize", connectionType); + QMetaObject::invokeMethod(engine, "initialize", Qt::BlockingQueuedConnection); } } } diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 1679c3b..b3c83bc 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -91,6 +91,8 @@ public: void enablePolling(); void disablePolling(); + void initialize(); + void cleanup(); public slots: void updateConfigurations(); @@ -105,6 +107,7 @@ Q_SIGNALS: private: QTimer *pollTimer; + QThread *bearerThread; QMutex mutex; -- cgit v0.12 From 3359984cd1f8e568feb42969830b3fb6a13f5718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Niemel=C3=A4?= Date: Mon, 13 Jun 2011 15:49:35 +0300 Subject: Qmlshadersplugin API documentation enhancements. Added a link from qml element index, removed some unnecessary doc markings, added missing example image and some other minor fixes. Reviewed-by: Kim Gronholm --- doc/src/declarative/elements.qdoc | 13 +++ doc/src/declarative/pics/shaderexample.png | Bin 0 -> 3941 bytes src/imports/shaders/scenegraph/qsggeometry.cpp | 116 ------------------------- src/imports/shaders/shadereffectitem.cpp | 6 +- src/imports/shaders/shadereffectsource.cpp | 10 +-- 5 files changed, 21 insertions(+), 124 deletions(-) create mode 100644 doc/src/declarative/pics/shaderexample.png diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index a861a66..6b7a5fc 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -175,6 +175,8 @@ Elements that animate properties based on data types \o \l {ParticleMotionLinear} - Adds linear motion behavior to \l {Particles} \o \l {ParticleMotionGravity} - Adds gravitational motion to \l {Particles} \o \l {ParticleMotionWander} - Adds varied motions to \l {Particles} +\o \l {ShaderEffectItem} - Enables the use of OpenGL Shading Language together with QML +\o \l {ShaderEffectSource} - Encapsulates QML item tree as a source item for \l {ShaderEffectItem} \endlist \section1 Add-On Elements @@ -321,3 +323,14 @@ should first be obtained and installed. \generatelist{related} */ + +/*! + \group qml-shader-elements + \title QML Shader Elements + \ingroup qml-groups + + \brief Elements for using OpenGL shading language code together with the QML code. + + \generatelist{related} + +*/ diff --git a/doc/src/declarative/pics/shaderexample.png b/doc/src/declarative/pics/shaderexample.png new file mode 100644 index 0000000..dbc7291 Binary files /dev/null and b/doc/src/declarative/pics/shaderexample.png differ diff --git a/src/imports/shaders/scenegraph/qsggeometry.cpp b/src/imports/shaders/scenegraph/qsggeometry.cpp index 05c111a..08ac10e 100644 --- a/src/imports/shaders/scenegraph/qsggeometry.cpp +++ b/src/imports/shaders/scenegraph/qsggeometry.cpp @@ -44,11 +44,6 @@ QT_BEGIN_NAMESPACE -/*! - Convenience function which returns attributes to be used for 2D solid - color drawing. - */ - const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_Point2D() { static Attribute data[] = { @@ -58,9 +53,6 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_Point2D() return attrs; } -/*! - Convenience function which returns attributes to be used for textured 2D drawing. - */ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_TexturedPoint2D() { @@ -72,9 +64,6 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_TexturedPoint2D( return attrs; } -/*! - Convenience function which returns attributes to be used for per vertex colored 2D drawing. - */ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D() { @@ -87,29 +76,6 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D() } -/*! - \class QSGGeometry - \brief The QSGGeometry class provides low-level storage for graphics primitives - in the QML Scene Graph. - - The QSGGeometry class provides a few convenience attributes and attribute accessors - by default. The defaultAttributes_Point2D() function returns attributes to be used - in normal solid color rectangles, while the defaultAttributes_TexturedPoint2D function - returns attributes to be used for the common pixmap usecase. - */ - - -/*! - Constructs a geometry object based on \a attributes. - - The object allocate space for \a vertexCount vertices based on the accumulated - size in \a attributes and for \a indexCount. - - Geometry objects are constructed with GL_TRIANGLE_STRIP as default drawing mode. - - The attribute structure is assumed to be POD and the geometry object - assumes this will not go away. There is no memory management involved. - */ QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes, int vertexCount, @@ -138,41 +104,6 @@ QSGGeometry::~QSGGeometry() qFree(m_data); } -/*! - \fn int QSGGeometry::vertexCount() const - - Returns the number of vertices in this geometry object. - */ - -/*! - \fn int QSGGeometry::indexCount() const - - Returns the number of indices in this geometry object. - */ - - - -/*! - \fn void *QSGGeometry::vertexData() - - Returns a pointer to the raw vertex data of this geometry object. - - \sa vertexDataAsPoint2D(), vertexDataAsTexturedPoint2D - */ - -/*! - \fn const void *QSGGeometry::vertexData() const - - Returns a pointer to the raw vertex data of this geometry object. - - \sa vertexDataAsPoint2D(), vertexDataAsTexturedPoint2D - */ - -/*! - Returns a pointer to the raw index data of this geometry object. - - \sa indexDataAsUShort(), indexDataAsUInt() - */ void *QSGGeometry::indexData() { return m_index_data_offset < 0 @@ -180,11 +111,6 @@ void *QSGGeometry::indexData() : ((char *) m_data + m_index_data_offset); } -/*! - Returns a pointer to the raw index data of this geometry object. - - \sa indexDataAsUShort(), indexDataAsUInt() - */ const void *QSGGeometry::indexData() const { return m_index_data_offset < 0 @@ -192,38 +118,11 @@ const void *QSGGeometry::indexData() const : ((char *) m_data + m_index_data_offset); } -/*! - Sets the drawing mode to be used for this geometry. - - The default value is GL_TRIANGLE_STRIP. - */ void QSGGeometry::setDrawingMode(GLenum mode) { m_drawing_mode = mode; } -/*! - \fn int QSGGeometry::drawingMode() const - - Returns the drawing mode of this geometry. - - The default value is GL_TRIANGLE_STRIP. - */ - -/*! - \fn int QSGGeometry::indexType() const - - Returns the primitive type used for indices in this - geometry object. - */ - - -/*! - Resizes the vertex and index data of this geometry object to fit \a vertexCount - vertices and \a indexCount indices. - - Vertex and index data will be invalidated after this call and the caller must - */ void QSGGeometry::allocate(int vertexCount, int indexCount) { if (vertexCount == m_vertex_count && indexCount == m_index_count) @@ -252,12 +151,6 @@ void QSGGeometry::allocate(int vertexCount, int indexCount) } -/*! - Updates the geometry \a g with the coordinates in \a rect. - - The function assumes the geometry object contains a single triangle strip - of QSGGeometry::Point2D vertices - */ void QSGGeometry::updateRectGeometry(QSGGeometry *g, const QRectF &rect) { Point2D *v = g->vertexDataAsPoint2D(); @@ -274,15 +167,6 @@ void QSGGeometry::updateRectGeometry(QSGGeometry *g, const QRectF &rect) v[3].y = rect.bottom(); } -/*! - Updates the geometry \a g with the coordinates in \a rect and texture - coordinates from \a textureRect. - - \a textureRect should be in normalized coordinates. - - \a g is assumed to be a triangle strip of four vertices of type - QSGGeometry::TexturedPoint2D. - */ void QSGGeometry::updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &textureRect) { TexturedPoint2D *v = g->vertexDataAsTexturedPoint2D(); diff --git a/src/imports/shaders/shadereffectitem.cpp b/src/imports/shaders/shadereffectitem.cpp index 5bb906c..48c842a 100644 --- a/src/imports/shaders/shadereffectitem.cpp +++ b/src/imports/shaders/shadereffectitem.cpp @@ -72,7 +72,7 @@ static const char qt_emptyAttributeName[] = ""; /*! \qmlclass ShaderEffectItem ShaderEffectItem - \ingroup qmlshadersplugin + \ingroup qml-shader-elements \brief The ShaderEffectItem object alters the output of given item with OpenGL shaders. \inherits Item @@ -84,7 +84,7 @@ static const char qt_emptyAttributeName[] = ""; and may be heavily changed or removed in later versions. Requirement for the use of shaders is that the application is either using - Qt OpenGL graphicssystem or is forced to use OpenGL by setting QGLWidget as the viewport to QDeclarativeView (recommened way). + Qt OpenGL graphicssystem or is using OpenGL by setting QGLWidget as the viewport to QDeclarativeView (depending on which one is the recommened way in the targeted platform). ShaderEffectItem internal behaviour is such that during the paint event it first renders its ShaderEffectSource items into a OpenGL framebuffer object which can be used as a texture. If the ShaderEffectSource is defined to be an image, @@ -195,7 +195,7 @@ Rectangle { } } \endqml - \image Example1.png + \image shaderexample.png */ diff --git a/src/imports/shaders/shadereffectsource.cpp b/src/imports/shaders/shadereffectsource.cpp index dec3bb0..e6dbc73 100644 --- a/src/imports/shaders/shadereffectsource.cpp +++ b/src/imports/shaders/shadereffectsource.cpp @@ -48,7 +48,7 @@ /*! \qmlclass ShaderEffectSource ShaderEffectSource - \ingroup qmlshadersplugin + \ingroup qml-shader-elements \brief The ShaderEffectSource object encapsulates the source content for the ShaderEffectItem. ShaderEffectSource is available in the \bold{Qt.labs.shaders 1.0} module. @@ -273,10 +273,10 @@ void ShaderEffectSource::setHideSource(bool hide) This property defines the wrap parameter for the source after it has been mapped as a texture. \list - \o WrapMode.ClampToEdge - Causes texturecoordinates to be clamped to the range [ 1/2*N , 1 - 1/2*N ], where N is the texture width. - \o WrapMode.RepeatHorizontally - Causes the integer part of the horizontal texturecoordinate to be ignored; the GL uses only the fractional part, thereby creating a horizontal repeating pattern. - \o WrapMode.RepeatVertically - Causes the integer part of the vertical texturecoordinate to be ignored; the GL uses only the fractional part, thereby creating a vertical repeating pattern. - \o WrapMode.Repeat - Causes the integer part of both the horizontal and vertical texturecoordinates to be ignored; the GL uses only the fractional part, thereby creating a repeating pattern. + \o ShaderEffectSource.ClampToEdge - Causes texturecoordinates to be clamped to the range [ 1/2*N , 1 - 1/2*N ], where N is the texture width. + \o ShaderEffectSource.RepeatHorizontally - Causes the integer part of the horizontal texturecoordinate to be ignored; the GL uses only the fractional part, thereby creating a horizontal repeating pattern. + \o ShaderEffectSource.RepeatVertically - Causes the integer part of the vertical texturecoordinate to be ignored; the GL uses only the fractional part, thereby creating a vertical repeating pattern. + \o ShaderEffectSource.Repeat - Causes the integer part of both the horizontal and vertical texturecoordinates to be ignored; the GL uses only the fractional part, thereby creating a repeating pattern. \endlist The default value is ClampToEdge. -- cgit v0.12 From 3199ee59ad931b88a26657fc5c66d94c4fff606f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Niemel=C3=A4?= Date: Mon, 13 Jun 2011 15:57:49 +0300 Subject: Qmlshadersplugin examples added. Example application for OpenGL shading language and QML. Added also a link from qml examples main documents labs section. Reviewed-by: Kim Gronholm --- doc/src/declarative/examples.qdoc | 23 +-- doc/src/examples/qml-examples.qdoc | 10 ++ doc/src/images/qml-shadereffects-example.png | Bin 0 -> 271264 bytes examples/declarative/declarative.pro | 3 + examples/declarative/shadereffects/main.cpp | 76 +++++++++ examples/declarative/shadereffects/qml/Curtain.qml | 106 +++++++++++++ .../shadereffects/qml/CurtainEffect.qml | 97 ++++++++++++ .../declarative/shadereffects/qml/DropShadow.qml | 117 ++++++++++++++ .../shadereffects/qml/DropShadowEffect.qml | 174 +++++++++++++++++++++ .../declarative/shadereffects/qml/Grayscale.qml | 77 +++++++++ .../shadereffects/qml/GrayscaleEffect.qml | 62 ++++++++ .../declarative/shadereffects/qml/ImageMask.qml | 143 +++++++++++++++++ .../shadereffects/qml/ImageMaskEffect.qml | 60 +++++++ .../declarative/shadereffects/qml/RadialWave.qml | 85 ++++++++++ .../shadereffects/qml/RadialWaveEffect.qml | 81 ++++++++++ examples/declarative/shadereffects/qml/Water.qml | 60 +++++++ .../declarative/shadereffects/qml/WaterEffect.qml | 126 +++++++++++++++ .../shadereffects/qml/images/Curtain.jpg | Bin 0 -> 16112 bytes .../shadereffects/qml/images/DropShadow.jpg | Bin 0 -> 12975 bytes .../shadereffects/qml/images/Grayscale.jpg | Bin 0 -> 19048 bytes .../shadereffects/qml/images/ImageMask.jpg | Bin 0 -> 18751 bytes .../shadereffects/qml/images/RadialWave.jpg | Bin 0 -> 41406 bytes .../declarative/shadereffects/qml/images/Water.jpg | Bin 0 -> 17751 bytes .../declarative/shadereffects/qml/images/back.png | Bin 0 -> 370 bytes .../declarative/shadereffects/qml/images/bg.jpg | Bin 0 -> 10189 bytes .../shadereffects/qml/images/desaturate.jpg | Bin 0 -> 203942 bytes .../shadereffects/qml/images/drop_shadow.png | Bin 0 -> 219220 bytes .../shadereffects/qml/images/fabric.jpg | Bin 0 -> 163431 bytes .../shadereffects/qml/images/flower.png | Bin 0 -> 219220 bytes .../shadereffects/qml/images/image1.jpg | Bin 0 -> 115770 bytes .../shadereffects/qml/images/image2.jpg | Bin 0 -> 45837 bytes .../shadereffects/qml/images/qt-logo.png | Bin 0 -> 22746 bytes .../shadereffects/qml/images/shader_effects.jpg | Bin 0 -> 4906 bytes .../declarative/shadereffects/qml/images/sky.jpg | Bin 0 -> 36734 bytes .../shadereffects/qml/images/toolbar.png | Bin 0 -> 342 bytes .../declarative/shadereffects/qml/images/wave.jpg | Bin 0 -> 176681 bytes examples/declarative/shadereffects/qml/main.qml | 160 +++++++++++++++++++ .../declarative/shadereffects/shadereffects.pro | 21 +++ 38 files changed, 1470 insertions(+), 11 deletions(-) create mode 100644 doc/src/images/qml-shadereffects-example.png create mode 100755 examples/declarative/shadereffects/main.cpp create mode 100755 examples/declarative/shadereffects/qml/Curtain.qml create mode 100755 examples/declarative/shadereffects/qml/CurtainEffect.qml create mode 100755 examples/declarative/shadereffects/qml/DropShadow.qml create mode 100755 examples/declarative/shadereffects/qml/DropShadowEffect.qml create mode 100755 examples/declarative/shadereffects/qml/Grayscale.qml create mode 100755 examples/declarative/shadereffects/qml/GrayscaleEffect.qml create mode 100755 examples/declarative/shadereffects/qml/ImageMask.qml create mode 100755 examples/declarative/shadereffects/qml/ImageMaskEffect.qml create mode 100755 examples/declarative/shadereffects/qml/RadialWave.qml create mode 100755 examples/declarative/shadereffects/qml/RadialWaveEffect.qml create mode 100755 examples/declarative/shadereffects/qml/Water.qml create mode 100755 examples/declarative/shadereffects/qml/WaterEffect.qml create mode 100755 examples/declarative/shadereffects/qml/images/Curtain.jpg create mode 100755 examples/declarative/shadereffects/qml/images/DropShadow.jpg create mode 100755 examples/declarative/shadereffects/qml/images/Grayscale.jpg create mode 100755 examples/declarative/shadereffects/qml/images/ImageMask.jpg create mode 100755 examples/declarative/shadereffects/qml/images/RadialWave.jpg create mode 100755 examples/declarative/shadereffects/qml/images/Water.jpg create mode 100755 examples/declarative/shadereffects/qml/images/back.png create mode 100755 examples/declarative/shadereffects/qml/images/bg.jpg create mode 100755 examples/declarative/shadereffects/qml/images/desaturate.jpg create mode 100755 examples/declarative/shadereffects/qml/images/drop_shadow.png create mode 100755 examples/declarative/shadereffects/qml/images/fabric.jpg create mode 100755 examples/declarative/shadereffects/qml/images/flower.png create mode 100755 examples/declarative/shadereffects/qml/images/image1.jpg create mode 100755 examples/declarative/shadereffects/qml/images/image2.jpg create mode 100755 examples/declarative/shadereffects/qml/images/qt-logo.png create mode 100755 examples/declarative/shadereffects/qml/images/shader_effects.jpg create mode 100755 examples/declarative/shadereffects/qml/images/sky.jpg create mode 100755 examples/declarative/shadereffects/qml/images/toolbar.png create mode 100755 examples/declarative/shadereffects/qml/images/wave.jpg create mode 100755 examples/declarative/shadereffects/qml/main.qml create mode 100755 examples/declarative/shadereffects/shadereffects.pro diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 0e325e2..1003b22 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -33,7 +33,7 @@ Qt includes a set of examples and demos that show how to use various aspects -of QML. The examples are small demonstrations of particular QML components, +of QML. The examples are small demonstrations of particular QML components, while the demos contain more complete and functional applications. To run the examples and demos, open them in Qt Creator or use the included @@ -60,43 +60,43 @@ can be used to produce sophisticated interfaces and applications: \table \row -\o +\o \l{demos/declarative/calculator}{Calculator} \image qml-calculator-example-small.png -\o +\o \l{demos/declarative/flickr}{Flickr Mobile} \image qml-flickr-demo-small.png -\o +\o \l{demos/declarative/minehunt}{Minehunt} \image qml-minehunt-demo-small.png \row -\o +\o \l{demos/declarative/photoviewer}{Photo Viewer} \image qml-photoviewer-demo-small.png -\o +\o \l{demos/declarative/rssnews}{RSS News Reader} \image qml-rssnews-demo-small.png -\o +\o \l{demos/declarative/samegame}{Same Game} \image qml-samegame-demo-small.png \row -\o +\o \l{demos/declarative/snake}{Snake} \image qml-snake-demo-small.png -\o +\o \l{demos/declarative/twitter}{Twitter} \image qml-twitter-demo-small.png -\o +\o \l{demos/declarative/webbrowser}{Web Browser} \image qml-webbrowser-demo-small.png @@ -109,7 +109,7 @@ The demos can be found in Qt's \c demos/declarative directory. The QML examples are small, simple applications that show how to use a particular QML component or feature. If you are new -to QML, you may also find the \l{QML Tutorial}{Hello World} and +to QML, you may also find the \l{QML Tutorial}{Hello World} and \l {QML Advanced Tutorial}{Same Game} tutorials useful. The examples can be found in Qt's \c examples/declarative directory. @@ -234,6 +234,7 @@ The examples can be found in Qt's \c examples/declarative directory. \list \o \l{src/imports/folderlistmodel}{Folder List Model} - a C++ model plugin +\o \l{declarative/shadereffects}{Shader Effects} \endlist */ diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 00eeb43..a910266 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -714,3 +714,13 @@ \image qml-xmlhttprequest-example.png */ + +/*! + \title Labs: Shader Effects + \example declarative/shadereffects + + This example shows how to create visual effects by using OpenGL shading language together with QML using \l ShaderEffectItem and \l ShaderEffectSource APIs. + + \image qml-shadereffects-example.png +*/ + diff --git a/doc/src/images/qml-shadereffects-example.png b/doc/src/images/qml-shadereffects-example.png new file mode 100644 index 0000000..9649fe1 Binary files /dev/null and b/doc/src/images/qml-shadereffects-example.png differ diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro index e3d922c..f10e7a4 100644 --- a/examples/declarative/declarative.pro +++ b/examples/declarative/declarative.pro @@ -6,6 +6,9 @@ SUBDIRS = \ modelviews \ tutorials +# OpenGL shader examples requires opengl and they contain some C++ and need to be built +contains(QT_CONFIG, opengl): SUBDIRS += shadereffects + # plugins uses a 'Time' class that conflicts with symbian e32std.h also defining a class of the same name symbian:SUBDIRS -= plugins diff --git a/examples/declarative/shadereffects/main.cpp b/examples/declarative/shadereffects/main.cpp new file mode 100755 index 0000000..62bf505 --- /dev/null +++ b/examples/declarative/shadereffects/main.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 +#include +#include +#include + +int main(int argc, char *argv[]) +{ +// Depending on which is the recommended way for the platform, either use +// opengl graphics system or paint into QGLWidget. +#ifdef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM + QApplication::setGraphicsSystem("opengl"); +#endif + + QApplication app(argc, argv); + QDeclarativeView view; + +#ifndef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM + QGLFormat format = QGLFormat::defaultFormat(); + format.setSampleBuffers(false); + format.setSwapInterval(1); + QGLWidget* glWidget = new QGLWidget(format); + glWidget->setAutoFillBackground(false); + view.setViewport(glWidget); +#endif + + view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + view.setAttribute(Qt::WA_OpaquePaintEvent); + view.setAttribute(Qt::WA_NoSystemBackground); + view.setSource(QUrl::fromLocalFile(QLatin1String("qml/main.qml"))); + QObject::connect(view.engine(), SIGNAL(quit()), &view, SLOT(close())); + + view.show(); + + return app.exec(); +} diff --git a/examples/declarative/shadereffects/qml/Curtain.qml b/examples/declarative/shadereffects/qml/Curtain.qml new file mode 100755 index 0000000..8697951 --- /dev/null +++ b/examples/declarative/shadereffects/qml/Curtain.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + anchors.fill: parent + + Rectangle{ + id: bg + anchors.fill: parent + color: "black" + } + + Image { + source: "images/qt-logo.png" + anchors.centerIn: parent + } + + Image { + id: fabric + anchors.fill: parent + source: "images/fabric.jpg" + fillMode: Image.Tile + } + + CurtainEffect { + id: curtain + anchors.fill: fabric + bottomWidth: topWidth + source: ShaderEffectSource { sourceItem: fabric; hideSource: true } + + Behavior on bottomWidth { + SpringAnimation { easing.type: Easing.OutElastic; velocity: 250; mass: 1.5; spring: 0.5; damping: 0.05} + } + + SequentialAnimation on topWidth { + id: topWidthAnim + loops: Animation.Infinite + + NumberAnimation { to: 360; duration: 1000 } + PauseAnimation { duration: 2000 } + NumberAnimation { to: 180; duration: 1000 } + PauseAnimation { duration: 2000 } + } + } + + MouseArea { + anchors.fill: parent + + onPressed: { + topWidthAnim.stop() + curtain.topWidth = mouseX; + } + + onReleased: { + topWidthAnim.restart() + } + + onPositionChanged: { + if (pressed) { + curtain.topWidth = mouseX; + } + } + } +} diff --git a/examples/declarative/shadereffects/qml/CurtainEffect.qml b/examples/declarative/shadereffects/qml/CurtainEffect.qml new file mode 100755 index 0000000..7834a1a --- /dev/null +++ b/examples/declarative/shadereffects/qml/CurtainEffect.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +ShaderEffectItem { + anchors.fill: parent + property variant source + meshResolution: Qt.size(50, 50) + + property real topWidth: width / 2 + property real bottomWidth: width / 2 + property real originalWidth: width + property real originalHeight: height + property real amplitude: 0.1 + + vertexShader: " + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp mat4 qt_ModelViewProjectionMatrix; + varying highp vec2 qt_TexCoord0; + varying lowp float shade; + + uniform highp float topWidth; + uniform highp float bottomWidth; + uniform highp float originalWidth; + uniform highp float originalHeight; + uniform highp float amplitude; + + void main() { + qt_TexCoord0 = qt_MultiTexCoord0; + + highp vec4 shift = vec4(0, 0, 0, 0); + shift.x = qt_Vertex.x * ((originalWidth - topWidth) + (topWidth - bottomWidth) * (qt_Vertex.y / originalHeight)) / originalWidth; + + shade = sin(21.9911486 * qt_Vertex.x / originalWidth); + shift.y = amplitude * (originalWidth - topWidth + (topWidth - bottomWidth) * (qt_Vertex.y / originalHeight)) * shade; + + gl_Position = qt_ModelViewProjectionMatrix * (qt_Vertex - shift); + + shade = 0.2 * (2.0 - shade ) * (1.0 - (bottomWidth + (topWidth - bottomWidth) * (1.0 - qt_Vertex.y / originalHeight)) / originalWidth); + } + " + + fragmentShader: " + uniform sampler2D source; + varying highp vec2 qt_TexCoord0; + varying lowp float shade; + void main() { + highp vec4 color = texture2D(source, qt_TexCoord0); + color.rgb *= 1.0 - shade; + gl_FragColor = color; + } + " +} + + + diff --git a/examples/declarative/shadereffects/qml/DropShadow.qml b/examples/declarative/shadereffects/qml/DropShadow.qml new file mode 100755 index 0000000..054f193 --- /dev/null +++ b/examples/declarative/shadereffects/qml/DropShadow.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Item { + id: main + anchors.fill: parent + + Image { + id: background + anchors.fill: parent + source: "images/bg.jpg" + } + + DropShadowEffect { + id: layer + + property real distance: 0.0 + + width: photo.width + height: photo.height + sourceItem: photo + color: "black" + blur: distance / 10.0 + opacity: 1 - distance / 50.0 + + Binding { + target: layer + property: "x" + value: -0.4 * layer.distance + when: !dragArea.pressed + } + Binding { + target: layer + property: "y" + value: 0.9 * layer.distance + when: !dragArea.pressed + } + + SequentialAnimation on distance { + id: animation + running: true + loops: Animation.Infinite + + NumberAnimation { to: 30; duration: 2000 } + PauseAnimation { duration: 500 } + NumberAnimation { to: 0; duration: 2000 } + PauseAnimation { duration: 500 } + } + } + + Image { + id: photo + anchors.fill: parent + source: "images/drop_shadow.png" + smooth: true + } + + MouseArea { + id: dragArea + anchors.fill: parent + + property int startX + property int startY + + onPressed: { + startX = mouseX + startY = mouseY + } + + onPositionChanged: { + layer.x += mouseX - startX + layer.y += mouseY - startY + startX = mouseX + startY = mouseY + } + } +} diff --git a/examples/declarative/shadereffects/qml/DropShadowEffect.qml b/examples/declarative/shadereffects/qml/DropShadowEffect.qml new file mode 100755 index 0000000..b9903a3 --- /dev/null +++ b/examples/declarative/shadereffects/qml/DropShadowEffect.qml @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + property real blur: 0.0 + property alias color: shadowEffectWithHBlur.color + property alias sourceItem: source.sourceItem + + ShaderEffectSource { + id: source + smooth: true + hideSource: false + } + + ShaderEffectItem { + id: shadowEffectWithHBlur + anchors.fill: parent + + property color color: "grey" + property variant sourceTexture: source; + property real xStep: main.blur / main.width + + vertexShader:" + uniform highp mat4 qt_ModelViewProjectionMatrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp float xStep; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord4; + varying highp vec2 qt_TexCoord5; + varying highp vec2 qt_TexCoord6; + + void main(void) + { + highp vec2 shift = vec2(xStep, 0.); + qt_TexCoord0 = qt_MultiTexCoord0 - 2.5 * shift; + qt_TexCoord1 = qt_MultiTexCoord0 - 1.5 * shift; + qt_TexCoord2 = qt_MultiTexCoord0 - 0.5 * shift; + qt_TexCoord4 = qt_MultiTexCoord0 + 0.5 * shift; + qt_TexCoord5 = qt_MultiTexCoord0 + 1.5 * shift; + qt_TexCoord6 = qt_MultiTexCoord0 + 2.5 * shift; + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; + } + " + + fragmentShader:" + uniform highp vec4 color; + uniform lowp sampler2D sourceTexture; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord4; + varying highp vec2 qt_TexCoord5; + varying highp vec2 qt_TexCoord6; + + void main() { + highp vec4 sourceColor = (texture2D(sourceTexture, qt_TexCoord0) * 0.1 + + texture2D(sourceTexture, qt_TexCoord1) * 0.15 + + texture2D(sourceTexture, qt_TexCoord2) * 0.25 + + texture2D(sourceTexture, qt_TexCoord4) * 0.25 + + texture2D(sourceTexture, qt_TexCoord5) * 0.15 + + texture2D(sourceTexture, qt_TexCoord6) * 0.1); + gl_FragColor = mix(vec4(0), color, sourceColor.a); + } + " + } + + ShaderEffectSource { + id: hBlurredShadow + smooth: true + sourceItem: shadowEffectWithHBlur + hideSource: true + } + + ShaderEffectItem { + id: finalEffect + anchors.fill: parent + + property color color: "grey" + property variant sourceTexture: hBlurredShadow; + property real yStep: main.blur / main.height + + vertexShader:" + uniform highp mat4 qt_ModelViewProjectionMatrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp float yStep; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord4; + varying highp vec2 qt_TexCoord5; + varying highp vec2 qt_TexCoord6; + + void main(void) + { + highp vec2 shift = vec2(0., yStep); + qt_TexCoord0 = qt_MultiTexCoord0 - 2.5 * shift; + qt_TexCoord1 = qt_MultiTexCoord0 - 1.5 * shift; + qt_TexCoord2 = qt_MultiTexCoord0 - 0.5 * shift; + qt_TexCoord4 = qt_MultiTexCoord0 + 0.5 * shift; + qt_TexCoord5 = qt_MultiTexCoord0 + 1.5 * shift; + qt_TexCoord6 = qt_MultiTexCoord0 + 2.5 * shift; + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; + } + " + + fragmentShader:" + uniform highp vec4 color; + uniform lowp sampler2D sourceTexture; + uniform highp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord4; + varying highp vec2 qt_TexCoord5; + varying highp vec2 qt_TexCoord6; + + void main() { + highp vec4 sourceColor = (texture2D(sourceTexture, qt_TexCoord0) * 0.1 + + texture2D(sourceTexture, qt_TexCoord1) * 0.15 + + texture2D(sourceTexture, qt_TexCoord2) * 0.25 + + texture2D(sourceTexture, qt_TexCoord4) * 0.25 + + texture2D(sourceTexture, qt_TexCoord5) * 0.15 + + texture2D(sourceTexture, qt_TexCoord6) * 0.1); + gl_FragColor = sourceColor * qt_Opacity; + } + " + } +} diff --git a/examples/declarative/shadereffects/qml/Grayscale.qml b/examples/declarative/shadereffects/qml/Grayscale.qml new file mode 100755 index 0000000..d819a5d --- /dev/null +++ b/examples/declarative/shadereffects/qml/Grayscale.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + anchors.fill: parent + + GrayscaleEffect { + id: layer + anchors.fill: parent + + source: ShaderEffectSource { + sourceItem: Image { source: "images/desaturate.jpg" } + live: false + hideSource: true + } + + SequentialAnimation on ratio { + id: ratioAnimation + running: true + loops: Animation.Infinite + NumberAnimation { + easing.type: Easing.Linear + to: 0.0 + duration: 1500 + } + PauseAnimation { duration: 1000 } + NumberAnimation { + easing.type: Easing.Linear + to: 1.0 + duration: 1500 + } + PauseAnimation { duration: 1000 } + } + } +} diff --git a/examples/declarative/shadereffects/qml/GrayscaleEffect.qml b/examples/declarative/shadereffects/qml/GrayscaleEffect.qml new file mode 100755 index 0000000..34505ff --- /dev/null +++ b/examples/declarative/shadereffects/qml/GrayscaleEffect.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +ShaderEffectItem { + id: effect + property real ratio: 1.0 + property variant source: 0 + + fragmentShader: + " + varying highp vec2 qt_TexCoord0; + uniform sampler2D source; + uniform highp float ratio; + void main(void) + { + lowp vec4 textureColor = texture2D(source, qt_TexCoord0.st); + lowp float gray = dot(textureColor, vec4(0.299, 0.587, 0.114, 0.0)); + gl_FragColor = vec4(gray * ratio + textureColor.r * (1.0 - ratio), gray * ratio + textureColor.g * (1.0 - ratio), gray * ratio + textureColor.b * (1.0 - ratio), textureColor.a); + } + " +} diff --git a/examples/declarative/shadereffects/qml/ImageMask.qml b/examples/declarative/shadereffects/qml/ImageMask.qml new file mode 100755 index 0000000..ea9fa0a --- /dev/null +++ b/examples/declarative/shadereffects/qml/ImageMask.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + anchors.fill: parent + + Image { + id: bg + anchors.fill: parent + source: "images/image2.jpg" + } + + Item { + id: mask + anchors.fill: parent + + Text { + text: "Mask text" + font.pixelSize: 50 + font.bold: true + anchors.horizontalCenter: parent.horizontalCenter + + NumberAnimation on rotation { + running: true + loops: Animation.Infinite + from: 0 + to: 360 + duration: 3000 + } + + SequentialAnimation on y { + running: true + loops: Animation.Infinite + NumberAnimation { + to: main.height + duration: 3000 + } + NumberAnimation { + to: 0 + duration: 3000 + } + } + } + + Rectangle { + id: opaqueBox + width: 60 + height: parent.height + SequentialAnimation on x { + running: true + loops: Animation.Infinite + NumberAnimation { + to: main.width + duration: 2000 + easing.type: Easing.InOutCubic + } + NumberAnimation { + to: 0 + duration: 2000 + easing.type: Easing.InOutCubic + } + } + } + + Rectangle { + width: 100 + opacity: 0.5 + height: parent.height + SequentialAnimation on x { + PauseAnimation { duration: 100 } + + SequentialAnimation { + loops: Animation.Infinite + NumberAnimation { + to: main.width + duration: 2000 + easing.type: Easing.InOutCubic + } + NumberAnimation { + to: 0 + duration: 2000 + easing.type: Easing.InOutCubic + } + } + } + } + } + + ImageMaskEffect { + anchors.fill: parent + image: ShaderEffectSource { + sourceItem: Image { source: "images/image1.jpg" } + live: false + hideSource: true + } + mask: ShaderEffectSource { + sourceItem: mask + live: true + hideSource: true + } + } +} diff --git a/examples/declarative/shadereffects/qml/ImageMaskEffect.qml b/examples/declarative/shadereffects/qml/ImageMaskEffect.qml new file mode 100755 index 0000000..2dc0e75 --- /dev/null +++ b/examples/declarative/shadereffects/qml/ImageMaskEffect.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +ShaderEffectItem { + id: effect + property variant image: 0 + property variant mask: 0 + + fragmentShader: + " + varying highp vec2 qt_TexCoord0; + uniform sampler2D image; + uniform sampler2D mask; + void main(void) + { + gl_FragColor = texture2D(image, qt_TexCoord0.st) * (texture2D(mask, qt_TexCoord0.st).a); + } + " +} diff --git a/examples/declarative/shadereffects/qml/RadialWave.qml b/examples/declarative/shadereffects/qml/RadialWave.qml new file mode 100755 index 0000000..4487293 --- /dev/null +++ b/examples/declarative/shadereffects/qml/RadialWave.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + anchors.fill: parent + + ShaderEffectSource { + id: thesource + sourceItem: Image { source: "images/wave.jpg" } + live: false + hideSource: true + } + + RadialWaveEffect { + id: layer + anchors.fill: parent; + source: thesource + + wave: 0.0 + waveOriginX: 0.5 + waveOriginY: 0.5 + waveWidth: 0.01 + + NumberAnimation on wave { + id: waveAnim + running: true + loops: Animation.Infinite + easing.type: "Linear" + from: 0.0000; to: 2.0000; + duration: 2500 + } + } + + MouseArea { + anchors.fill: parent + onPressed: { + waveAnim.stop() + layer.waveOriginX = mouseX / main.width + layer.waveOriginY = mouseY / main.height + waveAnim.start() + } + } +} diff --git a/examples/declarative/shadereffects/qml/RadialWaveEffect.qml b/examples/declarative/shadereffects/qml/RadialWaveEffect.qml new file mode 100755 index 0000000..c415f69 --- /dev/null +++ b/examples/declarative/shadereffects/qml/RadialWaveEffect.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +ShaderEffectItem { + id: effect + + property real wave: 0.3 + property real waveOriginX: 0.5 + property real waveOriginY: 0.5 + property real waveWidth: 0.01 + property real aspectRatio: width/height + property variant source: 0 + + fragmentShader: + " + varying mediump vec2 qt_TexCoord0; + uniform sampler2D source; + uniform highp float wave; + uniform highp float waveWidth; + uniform highp float waveOriginX; + uniform highp float waveOriginY; + uniform highp float aspectRatio; + + void main(void) + { + mediump vec2 texCoord2 = qt_TexCoord0; + mediump vec2 origin = vec2(waveOriginX, (1.0 - waveOriginY) / aspectRatio); + + highp float fragmentDistance = distance(vec2(texCoord2.s, texCoord2.t / aspectRatio), origin); + highp float waveLength = waveWidth + fragmentDistance * 0.25; + + if ( fragmentDistance > wave && fragmentDistance < wave + waveLength) { + highp float distanceFromWaveEdge = min(abs(wave - fragmentDistance), abs(wave + waveLength - fragmentDistance)); + texCoord2 += sin(1.57075 * distanceFromWaveEdge / waveLength) * distanceFromWaveEdge * 0.08 / fragmentDistance; + } + + gl_FragColor = texture2D(source, texCoord2.st); + } + " +} diff --git a/examples/declarative/shadereffects/qml/Water.qml b/examples/declarative/shadereffects/qml/Water.qml new file mode 100755 index 0000000..8ad6c6a --- /dev/null +++ b/examples/declarative/shadereffects/qml/Water.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + anchors.fill: parent + + Image { + id: image + width: parent.width + height: parent.height * 0.65 + source: "images/sky.jpg" + smooth: true + } + WaterEffect { + sourceItem: image + intensity: 5 + height: parent.height - image.height + } +} diff --git a/examples/declarative/shadereffects/qml/WaterEffect.qml b/examples/declarative/shadereffects/qml/WaterEffect.qml new file mode 100755 index 0000000..84989eb --- /dev/null +++ b/examples/declarative/shadereffects/qml/WaterEffect.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: root + property alias sourceItem: effectsource.sourceItem + property real intensity: 1 + property bool waving: true + anchors.top: sourceItem.bottom + width: sourceItem.width + height: sourceItem.height + + ShaderEffectItem { + anchors.fill: parent + property variant source: effectsource + property real f: 0 + property real f2: 0 + property alias intensity: root.intensity + smooth: true + + ShaderEffectSource { + id: effectsource + hideSource: false + smooth: true + } + + fragmentShader: + " + varying highp vec2 qt_TexCoord0; + uniform sampler2D source; + uniform lowp float qt_Opacity; + uniform highp float f; + uniform highp float f2; + uniform highp float intensity; + + void main() { + const highp float twopi = 3.141592653589 * 2.0; + + highp float distanceFactorToPhase = pow(qt_TexCoord0.y + 0.5, 8.0) * 5.0; + highp float ofx = sin(f * twopi + distanceFactorToPhase) / 100.0; + highp float ofy = sin(f2 * twopi + distanceFactorToPhase * qt_TexCoord0.x) / 60.0; + + highp float intensityDampingFactor = (qt_TexCoord0.x + 0.1) * (qt_TexCoord0.y + 0.2); + highp float distanceFactor = (1.0 - qt_TexCoord0.y) * 4.0 * intensity * intensityDampingFactor; + + ofx *= distanceFactor; + ofy *= distanceFactor; + + highp float x = qt_TexCoord0.x + ofx; + highp float y = 1.0 - qt_TexCoord0.y + ofy; + + highp float fake = (sin((ofy + ofx) * twopi) + 0.5) * 0.05 * (1.2 - qt_TexCoord0.y) * intensity * intensityDampingFactor; + + highp vec4 pix = + texture2D(source, vec2(x, y)) * 0.6 + + texture2D(source, vec2(x-fake, y)) * 0.15 + + texture2D(source, vec2(x, y-fake)) * 0.15 + + texture2D(source, vec2(x+fake, y)) * 0.15 + + texture2D(source, vec2(x, y+fake)) * 0.15; + + highp float darken = 0.6 - (ofx - ofy) / 2.0; + pix.b *= 1.2 * darken; + pix.r *= 0.9 * darken; + pix.g *= darken; + + gl_FragColor = qt_Opacity * vec4(pix.r, pix.g, pix.b, 1.0); + } + " + + NumberAnimation on f { + running: root.waving + loops: Animation.Infinite + from: 0 + to: 1 + duration: 2410 + } + NumberAnimation on f2 { + running: root.waving + loops: Animation.Infinite + from: 0 + to: 1 + duration: 1754 + } + } +} diff --git a/examples/declarative/shadereffects/qml/images/Curtain.jpg b/examples/declarative/shadereffects/qml/images/Curtain.jpg new file mode 100755 index 0000000..40003cb Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/Curtain.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/DropShadow.jpg b/examples/declarative/shadereffects/qml/images/DropShadow.jpg new file mode 100755 index 0000000..c1e693a Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/DropShadow.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/Grayscale.jpg b/examples/declarative/shadereffects/qml/images/Grayscale.jpg new file mode 100755 index 0000000..c95cab4 Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/Grayscale.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/ImageMask.jpg b/examples/declarative/shadereffects/qml/images/ImageMask.jpg new file mode 100755 index 0000000..0da4c0d Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/ImageMask.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/RadialWave.jpg b/examples/declarative/shadereffects/qml/images/RadialWave.jpg new file mode 100755 index 0000000..fc51efc Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/RadialWave.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/Water.jpg b/examples/declarative/shadereffects/qml/images/Water.jpg new file mode 100755 index 0000000..38615c1 Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/Water.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/back.png b/examples/declarative/shadereffects/qml/images/back.png new file mode 100755 index 0000000..5dd3d22 Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/back.png differ diff --git a/examples/declarative/shadereffects/qml/images/bg.jpg b/examples/declarative/shadereffects/qml/images/bg.jpg new file mode 100755 index 0000000..4d22143 Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/bg.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/desaturate.jpg b/examples/declarative/shadereffects/qml/images/desaturate.jpg new file mode 100755 index 0000000..e5e99bb Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/desaturate.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/drop_shadow.png b/examples/declarative/shadereffects/qml/images/drop_shadow.png new file mode 100755 index 0000000..144c02d Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/drop_shadow.png differ diff --git a/examples/declarative/shadereffects/qml/images/fabric.jpg b/examples/declarative/shadereffects/qml/images/fabric.jpg new file mode 100755 index 0000000..ab65409 Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/fabric.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/flower.png b/examples/declarative/shadereffects/qml/images/flower.png new file mode 100755 index 0000000..144c02d Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/flower.png differ diff --git a/examples/declarative/shadereffects/qml/images/image1.jpg b/examples/declarative/shadereffects/qml/images/image1.jpg new file mode 100755 index 0000000..3442e77 Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/image1.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/image2.jpg b/examples/declarative/shadereffects/qml/images/image2.jpg new file mode 100755 index 0000000..23e5c5c Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/image2.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/qt-logo.png b/examples/declarative/shadereffects/qml/images/qt-logo.png new file mode 100755 index 0000000..41a304b Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/qt-logo.png differ diff --git a/examples/declarative/shadereffects/qml/images/shader_effects.jpg b/examples/declarative/shadereffects/qml/images/shader_effects.jpg new file mode 100755 index 0000000..19e8a39 Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/shader_effects.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/sky.jpg b/examples/declarative/shadereffects/qml/images/sky.jpg new file mode 100755 index 0000000..8fc19ed Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/sky.jpg differ diff --git a/examples/declarative/shadereffects/qml/images/toolbar.png b/examples/declarative/shadereffects/qml/images/toolbar.png new file mode 100755 index 0000000..773e3ea Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/toolbar.png differ diff --git a/examples/declarative/shadereffects/qml/images/wave.jpg b/examples/declarative/shadereffects/qml/images/wave.jpg new file mode 100755 index 0000000..c8083bb Binary files /dev/null and b/examples/declarative/shadereffects/qml/images/wave.jpg differ diff --git a/examples/declarative/shadereffects/qml/main.qml b/examples/declarative/shadereffects/qml/main.qml new file mode 100755 index 0000000..ee85570 --- /dev/null +++ b/examples/declarative/shadereffects/qml/main.qml @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: main + width: 360 + height: 640 + + Rectangle { + anchors.fill: parent + color: "black" + } + + Image { + id: header + source: "images/shader_effects.jpg" + } + + ListModel { + id: demoModel + ListElement { name: "ImageMask" } + ListElement { name: "RadialWave" } + ListElement { name: "Water" } + ListElement { name: "Grayscale" } + ListElement { name: "DropShadow" } + ListElement { name: "Curtain" } + } + + Grid { + id: menuGrid + anchors.top: header.bottom + anchors.bottom: toolbar.top + width: parent.width + columns: 2 + Repeater { + model: demoModel + Item { + width: main.width / 2 + height: menuGrid.height / 3 + clip: true + Image { + width: parent.width + height: width + source: "images/" + name + ".jpg" + opacity: mouseArea.pressed ? 0.6 : 1.0 + } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + demoLoader.source = name + ".qml" + main.state = "showDemo" + } + } + } + } + } + + Loader { + anchors.fill: parent + id: demoLoader + visible: false + Behavior on opacity { + NumberAnimation { duration: 300 } + } + } + + Image { + id: toolbar + source: "images/toolbar.png" + width: parent.width + anchors.bottom: parent.bottom + } + + Rectangle { + id: translucentToolbar + color: "black" + opacity: 0.3 + anchors.fill: toolbar + visible: !toolbar.visible + } + + Item { + height: toolbar.height + width: height + anchors.bottom: parent.bottom + + Image { + source: "images/back.png" + anchors.centerIn: parent + } + + MouseArea { + anchors.fill: parent + onClicked: { + if (main.state == "") Qt.quit(); else { + main.state = "" + demoLoader.source = "" + } + } + } + } + + states: State { + name: "showDemo" + PropertyChanges { + target: menuGrid + visible: false + } + PropertyChanges { + target: demoLoader + visible: true + } + PropertyChanges { + target: toolbar + visible: false + } + } +} diff --git a/examples/declarative/shadereffects/shadereffects.pro b/examples/declarative/shadereffects/shadereffects.pro new file mode 100755 index 0000000..1107887 --- /dev/null +++ b/examples/declarative/shadereffects/shadereffects.pro @@ -0,0 +1,21 @@ +TEMPLATE = app +TARGET = shadereffects +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative opengl + +# Input +SOURCES += main.cpp + +symbian { + DEFINES += SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM +} + + +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/shadereffects +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS shadereffects.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/shadereffects +qmlfiles.files = qml +qmlfiles.path = $$[QT_INSTALL_EXAMPLES]/declarative/shadereffects + +INSTALLS += target sources qmlfiles -- cgit v0.12 From 56cd5a428e47a49f56fbacbf7250299559d6f195 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 13 Jun 2011 14:57:54 +0300 Subject: Fix screen dimensions after orientation change in split screen mode. The client area dimensions reported by native side only encompass the screen not covered by virtual keyboard and ignore the status pane. Fixed by recalculating proper client area in handleClientAreaChange() using layout metrics. Task-number: QT-5105 Reviewed-by: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index b5db3d0..bf76a0e 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1427,6 +1427,24 @@ void QSymbianControl::handleClientAreaChange() SetExtentToWholeScreen(); } else if (qwidget->isMaximized() || (qwidget->isFullScreen() && cbaVisibilityHint)) { TRect r = static_cast(S60->appUi())->ClientRect(); + if (!S60->splitViewLastWidget && S60->partialKeyboardOpen) { + // For some curious reason, native side indicates that splitviewRect starts + // underneath statuspane. So, if statuspane is visible, move the splitview + // down a little bit. Note that if there is S60->splitViewLastWidget, it means + // the resizing is done by input context handling and this metrics calculation + // is not needed. + TRect statusPaneRect; + TRect mainRect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane, statusPaneRect); + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainRect); + int clientAreaHeight = mainRect.Height(); + CEikStatusPane *const s = S60->statusPane(); + if (s && s->IsVisible()) + r.Move(0, statusPaneRect.Height()); + else + clientAreaHeight += statusPaneRect.Height(); + r.SetHeight(clientAreaHeight); + } SetExtent(r.iTl, r.Size()); } else if (!qwidget->isMinimized()) { // Normal geometry if (!qwidget->testAttribute(Qt::WA_Resized)) { -- cgit v0.12 From 7cfeaa9de75e8e567cf01cca8dd70880ad404b55 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 14 Jun 2011 14:47:17 +0300 Subject: Fix SVG icons on softkeys in new Symbian devices SVG icons automatically resize to the size of the pixmap, so the size of the icon pixmap needs to be what the platform expects. Added custom pixel metrics for CBA icon size that can be utilized for this purpose. Task-number: QT-5115 Reviewed-by: Sami Merila --- src/gui/kernel/qsoftkeymanager_s60.cpp | 54 +++++++++++++++++++++++----------- src/gui/styles/qs60style.cpp | 12 ++++---- src/gui/styles/qs60style.h | 4 ++- src/gui/styles/qs60style_p.h | 2 +- 4 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index 773743a..e1abc32 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -53,6 +53,10 @@ #include #include +#ifndef QT_NO_STYLE_S60 +#include +#endif + #ifndef QT_NO_SOFTKEYMANAGER QT_BEGIN_NAMESPACE @@ -220,26 +224,42 @@ bool QSoftKeyManagerPrivateS60::isOrientationLandscape() QSize QSoftKeyManagerPrivateS60::cbaIconSize(CEikButtonGroupContainer *cba, int position) { - int index = position; index += isOrientationLandscape() ? 0 : 1; if(cachedCbaIconSize[index].isNull()) { - // Only way I figured out to get CBA icon size without RnD SDK, was - // to set some dummy icon to CBA first and then ask CBA button CCoeControl::Size() - // The returned value is cached to avoid unnecessary icon setting every time. - const bool left = (position == LSK_POSITION); - if(position == LSK_POSITION || position == RSK_POSITION) { - CEikImage* tmpImage = NULL; - QT_TRAP_THROWING(tmpImage = new (ELeave) CEikImage); - EikSoftkeyImage::SetImage(cba, *tmpImage, left); // Takes myimage ownership - int command = S60_COMMAND_START + position; - setNativeSoftkey(*cba, position, command, KNullDesC()); - cachedCbaIconSize[index] = qt_TSize2QSize(cba->ControlOrNull(command)->Size()); - EikSoftkeyImage::SetLabel(cba, left); - - if(cachedCbaIconSize[index] == QSize(138,72)) { - // Hack for S60 5.0 (5800) landscape orientation, which return wrong icon size - cachedCbaIconSize[index] = QSize(60,60); + if (QSysInfo::s60Version() >= QSysInfo::SV_S60_5_3) { + // S60 5.3 and later have fixed icon size on softkeys, while the button + // itself is bigger, so the automatic check doesn't work. + // Use custom pixel metrics to deduce the CBA icon size + int iconHeight = 30; + int iconWidth = 30; +#ifndef QT_NO_STYLE_S60 + QS60Style *s60Style = 0; + s60Style = qobject_cast(QApplication::style()); + if (s60Style) { + iconWidth = s60Style->pixelMetric((QStyle::PixelMetric)PM_CbaIconWidth); + iconHeight = s60Style->pixelMetric((QStyle::PixelMetric)PM_CbaIconHeight); + } +#endif + cachedCbaIconSize[index] = QSize(iconWidth, iconHeight); + } else { + // Only way I figured out to get CBA icon size without RnD SDK, was + // to set some dummy icon to CBA first and then ask CBA button CCoeControl::Size() + // The returned value is cached to avoid unnecessary icon setting every time. + const bool left = (position == LSK_POSITION); + if (position == LSK_POSITION || position == RSK_POSITION) { + CEikImage* tmpImage = NULL; + QT_TRAP_THROWING(tmpImage = new (ELeave) CEikImage); + EikSoftkeyImage::SetImage(cba, *tmpImage, left); // Takes tmpImage ownership + int command = S60_COMMAND_START + position; + setNativeSoftkey(*cba, position, command, KNullDesC()); + cachedCbaIconSize[index] = qt_TSize2QSize(cba->ControlOrNull(command)->Size()); + EikSoftkeyImage::SetLabel(cba, left); + + if (cachedCbaIconSize[index] == QSize(138,72)) { + // Hack for S60 5.0 landscape orientation, which return wrong icon size + cachedCbaIconSize[index] = QSize(60,60); + } } } } diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index d3e5957..6625416 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -106,12 +106,12 @@ const int QS60StylePrivate::m_numberOfLayouts = const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { // *** generated pixel metrics *** -{5,0,-909,0,0,2,0,2,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1,106}, -{5,0,-909,0,0,1,0,2,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1,106}, -{7,0,-909,0,0,2,0,5,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,11,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,3,3,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135}, -{7,0,-909,0,0,2,0,5,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,13,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,3,3,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135}, -{7,0,-909,0,0,2,0,2,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106}, -{9,0,-909,0,0,2,0,5,-1,30,99,76,51,51,25,352,-909,-909,-909,29,25,7,0,0,43,34,42,76,7,7,2,-909,-909,0,9,14,0,23,39,30,30,37,37,9,391,40,0,-909,-909,-909,-909,0,0,29,2,-909,0,0,-909,29,-909,-909,-909,-909,115,37,96,48,96,2,2,9,1,25,-909,9,101,24,9,0,7,7,7,16,7,7,-909,3,-909,-909,-909,-909,9,9,3,1,184} +{5,0,-909,0,0,2,0,2,-1,7,12,22,15,15,7,198,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1,106,30,30}, +{5,0,-909,0,0,1,0,2,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1,106,30,30}, +{7,0,-909,0,0,2,0,5,-1,25,69,46,37,37,9,258,-909,-909,-909,23,19,11,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,3,3,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135,30,30}, +{7,0,-909,0,0,2,0,5,-1,25,68,46,37,37,9,258,-909,-909,-909,31,19,13,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,3,3,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1,135,30,30}, +{7,0,-909,0,0,2,0,2,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1,106,30,30}, +{9,0,-909,0,0,2,0,5,-1,30,99,76,51,51,25,352,-909,-909,-909,29,25,7,0,0,43,34,42,76,7,7,2,-909,-909,0,9,14,0,23,39,30,30,37,37,9,391,40,0,-909,-909,-909,-909,0,0,29,2,-909,0,0,-909,29,-909,-909,-909,-909,115,37,96,48,96,2,2,9,1,25,-909,9,101,24,9,0,7,7,7,16,7,7,-909,3,-909,-909,-909,-909,9,9,3,1,184,30,30} // *** End of generated data *** }; diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index 6993bf4..8ec5eb9 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -57,7 +57,9 @@ enum { PM_FrameCornerHeight, PM_BoldLineWidth, PM_ThinLineWidth, - PM_MessageBoxHeight + PM_MessageBoxHeight, + PM_CbaIconWidth, + PM_CbaIconHeight }; class QS60StylePrivate; diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index ee981c0..b759fa7 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE const int MAX_NON_CUSTOM_PIXELMETRICS = 92; -const int CUSTOMVALUESCOUNT = 5; +const int CUSTOMVALUESCOUNT = 7; const int MAX_PIXELMETRICS = MAX_NON_CUSTOM_PIXELMETRICS + CUSTOMVALUESCOUNT; -- cgit v0.12 From a0af3a2d12828e69a23d3697a4a6c8c03d9bd92f Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 14 Jun 2011 15:40:01 +0300 Subject: Drop-down menu position is altered when Partial VKB is invoked When a new window is shown and splitview is open, native side claims that available screen area for the application is only the screen area above keyboard. However, since opening a new window, will eventually lead to keyboard getting closed, the new window will look strange occupying only top part of the screen. Fix it so that when a new window opens and splitview is open, window will still get its extent set to fullscreen area (minus native panes, if available). Task-number: QT-5103 Reviewed-by: Miikka Heikkinen --- src/gui/kernel/qapplication_s60.cpp | 53 ++++++++++++++++++++--------------- src/gui/kernel/qdesktopwidget_s60.cpp | 2 +- src/gui/kernel/qt_s60_p.h | 1 + src/gui/kernel/qwidget_s60.cpp | 12 ++++---- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index bf76a0e..6896b7d 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -134,7 +134,7 @@ void QS60Data::setStatusPaneAndButtonGroupVisibility(bool statusPaneVisible, boo s->MakeVisible(statusPaneVisible); } if (buttonGroupVisibilityChanged || statusPaneVisibilityChanged) { - const QSize size = qt_TRect2QRect(static_cast(S60->appUi())->ClientRect()).size(); + const QSize size = qt_TRect2QRect(S60->clientRect()).size(); const QSize oldSize; // note that QDesktopWidget::resizeEvent ignores the QResizeEvent contents QResizeEvent event(size, oldSize); QApplication::instance()->sendEvent(QApplication::desktop(), &event); @@ -231,6 +231,28 @@ void QS60Data::controlVisibilityChanged(CCoeControl *control, bool visible) } } +TRect QS60Data::clientRect() +{ + TRect r = static_cast(S60->appUi())->ClientRect(); + if (S60->partialKeyboardOpen) { + // Adjust client rect when splitview is open, since for some curious reason + // native side insists that clientRect starts from (0,0) even though status + // pane might be visible. + TRect statusPaneRect; + TRect mainRect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane, statusPaneRect); + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainRect); + int clientAreaHeight = mainRect.Height(); + CEikStatusPane *const s = S60->statusPane(); + if (s && s->IsVisible()) + r.Move(0, statusPaneRect.Height()); + else + clientAreaHeight += statusPaneRect.Height(); + r.SetHeight(clientAreaHeight); + } + return r; +} + bool qt_nograb() // application no-grab option { #if defined(QT_DEBUG) @@ -1426,25 +1448,9 @@ void QSymbianControl::handleClientAreaChange() if (qwidget->isFullScreen() && !cbaVisibilityHint) { SetExtentToWholeScreen(); } else if (qwidget->isMaximized() || (qwidget->isFullScreen() && cbaVisibilityHint)) { - TRect r = static_cast(S60->appUi())->ClientRect(); - if (!S60->splitViewLastWidget && S60->partialKeyboardOpen) { - // For some curious reason, native side indicates that splitviewRect starts - // underneath statuspane. So, if statuspane is visible, move the splitview - // down a little bit. Note that if there is S60->splitViewLastWidget, it means - // the resizing is done by input context handling and this metrics calculation - // is not needed. - TRect statusPaneRect; - TRect mainRect; - AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane, statusPaneRect); - AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainRect); - int clientAreaHeight = mainRect.Height(); - CEikStatusPane *const s = S60->statusPane(); - if (s && s->IsVisible()) - r.Move(0, statusPaneRect.Height()); - else - clientAreaHeight += statusPaneRect.Height(); - r.SetHeight(clientAreaHeight); - } + // Note that if there is S60->splitViewLastWidget, it means the resizing is done + // by input context handling and we can use just default ClientRect. + TRect r = (!S60->splitViewLastWidget) ? S60->clientRect() : static_cast(S60->appUi())->ClientRect(); SetExtent(r.iTl, r.Size()); } else if (!qwidget->isMinimized()) { // Normal geometry if (!qwidget->testAttribute(Qt::WA_Resized)) { @@ -1452,7 +1458,7 @@ void QSymbianControl::handleClientAreaChange() qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize } if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) { - TRect r = static_cast(S60->appUi())->ClientRect(); + TRect r = S60->clientRect(); SetPosition(r.iTl); qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position } @@ -1498,13 +1504,14 @@ void QSymbianControl::HandleResourceChange(int resourceType) if (!ic) { ic = qobject_cast(qApp->inputContext()); } - if (ic && isSplitViewWidget(widget)) { + if (ic) { if (resourceType == KSplitViewCloseEvent) { S60->partialKeyboardOpen = false; ic->resetSplitViewWidget(); } else { S60->partialKeyboardOpen = true; - ic->ensureFocusWidgetVisible(widget); + if (isSplitViewWidget(widget)) + ic->ensureFocusWidgetVisible(widget); } } } diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp index 156c970..86d8f3f 100644 --- a/src/gui/kernel/qdesktopwidget_s60.cpp +++ b/src/gui/kernel/qdesktopwidget_s60.cpp @@ -161,7 +161,7 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that) (*rects)[i] = r; QRect wr; if (i == 0) - wr = qt_TRect2QRect(static_cast(S60->appUi())->ClientRect()); + wr = qt_TRect2QRect(S60->clientRect()); else wr = rects->at(i); (*workrects)[i].setRect(wr.x(), wr.y(), wr.width(), wr.height()); diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index bb37d00..c4ddc26 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -189,6 +189,7 @@ public: static bool setRecursiveDecorationsVisibility(QWidget *window, Qt::WindowStates newState); #endif static void controlVisibilityChanged(CCoeControl *control, bool visible); + static TRect clientRect(); #ifdef Q_OS_SYMBIAN TTrapHandler *s60InstalledTrapHandler; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index ef492b3..5630706 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -348,7 +348,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de if (popup) flags |= Qt::WindowStaysOnTopHint; // a popup stays on top - TRect clientRect = static_cast(S60->appUi())->ClientRect(); + TRect clientRect = S60->clientRect(); int sw = clientRect.Width(); int sh = clientRect.Height(); @@ -523,8 +523,6 @@ void QWidgetPrivate::show_sys() QT_TRAP_THROWING( factory->CreateResourceIndependentFurnitureL(ui); - TRect boundingRect = static_cast(S60->appUi())->ClientRect(); - CEikButtonGroupContainer *cba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal,ui,R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); if (isFullscreen && !cbaRequested) @@ -577,11 +575,13 @@ void QWidgetPrivate::show_sys() // Fill client area if maximized OR // Put window below status pane unless the window has an explicit position. if (!isFullscreen) { + // Use QS60Data::clientRect to take into account that native keyboard + // might affect ClientRect() return value. if (q->windowState() & Qt::WindowMaximized) { - TRect r = static_cast(S60->appUi())->ClientRect(); + TRect r = S60->clientRect(); id->SetExtent(r.iTl, r.Size()); } else if (!q->testAttribute(Qt::WA_Moved) && q->windowType() != Qt::Dialog) { - id->SetPosition(static_cast(S60->appUi())->ClientRect().iTl); + id->SetPosition(S60->clientRect().iTl); } } @@ -1252,7 +1252,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) // normal mode after showing the status pane, the geometry would overlap so we should // move it if it never had an explicit position. if (!wasMoved && S60->statusPane() && decorationsVisible) { - TPoint tl = static_cast(S60->appUi())->ClientRect().iTl; + TPoint tl = S60->clientRect().iTl; normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY)); } #endif -- cgit v0.12 From fcfc19878a0a1a48194a786bba64da11606077d2 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 14 Jun 2011 19:24:19 +0200 Subject: Symbian: Fix QFontInfo::pixelSize() Unlike QFont::pixelSize(), which may return -1 if the font size was defined in points, QFontInfo::pixelSize() always needs to return a valid value. c4ef479906f073fa84999eb950f00e264ebd4e8e which was a fix for QTBUG-13009 tried to fix a similar issue, but failed to do that properly, which resulted in QTBUG-15513 and QTBUG-17844. This commit is supposed to fix all three bugs. Task-Number: QTBUG-13009 Task-Number: QTBUG-15513 Task-Number: QTBUG-17844 --- src/gui/text/qfontdatabase_s60.cpp | 4 ---- src/gui/text/qfontengine_s60.cpp | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index f73abcf..3514fd3 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -1014,10 +1014,6 @@ QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *d, const QF const QSymbianTypeFaceExtras *typeFaceExtras = dbExtras->extras(fontFamily, request.weight > QFont::Normal, request.style != QFont::StyleNormal); - // We need a valid pixelSize, e.g. for lineThickness() - if (request.pixelSize < 0) - request.pixelSize = request.pointSize * d->dpi / 72; - fe = new QFontEngineS60(request, typeFaceExtras); #else // QT_NO_FREETYPE Q_UNUSED(d) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 39ed0b1..8c60709 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -294,6 +294,7 @@ QFontEngineS60::QFontEngineS60(const QFontDef &request, const QSymbianTypeFaceEx , m_activeFont(0) { QFontEngine::fontDef = request; + QFontEngine::fontDef.pixelSize = m_originalFontSizeInPixels; // Needs a valid pixel size. QTBUG-13009, QTBUG-17844 setFontScale(1.0); cache_cost = sizeof(QFontEngineS60); } -- cgit v0.12 From e4c8505946debcb66f50e92c1441cbc77da60dd2 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Wed, 15 Jun 2011 13:02:00 +0300 Subject: QS60Style: QGroupBox is drawn as white box in upcoming Symbian release New Symbian root theme defines KAknsIIDQsnFrSetOpt as empty. Drawing the frame through native API produces white box. Since the frame is no longer used on the native side, skip drawing it from style. Task-number: QTBUG-19782 Reviewed-by: Tomi Vihria --- src/gui/styles/qs60style_s60.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index e0897f0..4018702 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1095,6 +1095,14 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme centerId.Set(KAknsIIDQsnFrPopupCenterSubmenu); frameId.Set(KAknsIIDQsnFrPopupSub); break; + case QS60StylePrivate::SF_SettingsList: + // Starting from S60_5_3, the root theme has been changed so that KAknsIIDQsnFrSetOpt is empty. + // Set the theme ID to None, to avoid theme server trying to draw the empty frame. + if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_2) { + centerId.Set(KAknsIIDNone); + frameId.Set(KAknsIIDNone); + } + break; case QS60StylePrivate::SF_PanelBackground: // remove center piece for panel graphics, so that only border is drawn centerId.Set(KAknsIIDNone); -- cgit v0.12 From 5e35452ad8420886f54df89d19205acb88ebb363 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 15 Jun 2011 14:57:33 +0300 Subject: Add inputcontext reset to orientation switch in Symbian Switching orientation double-committed any preedit string in progress, so added inputcontext reset to KEikDynamicLayoutVariantSwitch handling, ensuring the string will get only committed once. Task-number: QTBUG-19864 Reviewed-by: Sami Merila --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index b15dcac..947d77a 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -361,7 +361,8 @@ bool QCoeFepInputContext::symbianFilterEvent(QWidget *keyWidget, const QSymbianE } if (event->type() == QSymbianEvent::ResourceChangeEvent - && event->resourceChangeType() == KEikMessageFadeAllWindows) { + && (event->resourceChangeType() == KEikMessageFadeAllWindows + || event->resourceChangeType() == KEikDynamicLayoutVariantSwitch)) { reset(); } -- cgit v0.12 From 242db2799df091278517623b3823f0eefc0fa42e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 16 Jun 2011 11:08:30 +0300 Subject: Resizable graphicsview's background is drawn incorrectly in splitview Due to the fact that native side re-opens keyboard before sending rotation event, the original size of graphicsview before auto-translate, is stored incorrectly. We store the height of graphicsview in previous orientation. Now, if the window was maximized, graphicsview was drawn correctly, since closing vkb would change the window state back to maximized and thus force a resizing of the view. With fullscreen gv this didn't happen. Fullscreen graphicsview thus needs a forced resize back to fullscreen. Task-number: QTBUG-19856 Reviewed-by: Miikka Heikkinen --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 947d77a..3a12d26 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -463,7 +463,10 @@ void QCoeFepInputContext::resetSplitViewWidget(bool keepInputWidget) } } else { if (m_splitViewResizeBy) - gv->resize(gv->rect().width(), m_splitViewResizeBy); + if (m_splitViewPreviousWindowStates & Qt::WindowFullScreen) + gv->resize(gv->rect().width(), qApp->desktop()->height()); + else + gv->resize(gv->rect().width(), m_splitViewResizeBy); } // Resizing might have led to widget losing its original windowstate. // Restore previous window state. -- cgit v0.12 From 6afe7a233e66f0cae803590d536b4d379b7c1625 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 15 Jun 2011 17:27:55 +0200 Subject: Handle QVolatileImage-backed pixmaps optimally in drawPixmap(). When drawing such pixmaps (used by both the openvg and opengl graphics systems) onto another pixmap or to a QImage, the performance was sub-optimal due to missing and accidentally disabled support specific to QVolatileImage. This is now fixed and drawing pixmaps into a QImage is also made optimal by using the QS60PaintEngine for QImage too. This will cause a 5-7x (or even up to 12x on certain hardware and platform) increase in offscreen pixmap drawing performance. Task-number: QTBUG-19880 Reviewed-by: Jani Hautakangas --- src/gui/image/qimage.cpp | 8 ++++++++ src/gui/image/qpixmapdata.cpp | 5 +++++ src/gui/image/qpixmapdata_p.h | 2 +- src/gui/image/qvolatileimage.cpp | 35 +++++++++++++++++++++++------------ src/gui/image/qvolatileimage_p.h | 1 + src/gui/painting/qpaintengine_s60.cpp | 30 +++++++++++++++--------------- src/gui/painting/qpaintengine_s60_p.h | 2 +- src/opengl/qgl_symbian.cpp | 1 - src/openvg/qpixmapdata_vg.cpp | 3 ++- src/openvg/qpixmapdata_vg_p.h | 2 +- src/openvg/qvg_symbian.cpp | 5 +++++ 11 files changed, 62 insertions(+), 32 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 65793af..d7156a7 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -62,7 +62,11 @@ #include +#if defined(Q_OS_SYMBIAN) +#include +#else #include +#endif #include @@ -5706,7 +5710,11 @@ QPaintEngine *QImage::paintEngine() const return 0; if (!d->paintEngine) { +#ifdef Q_OS_SYMBIAN + d->paintEngine = new QS60PaintEngine(const_cast(this)); +#else d->paintEngine = new QRasterPaintEngine(const_cast(this)); +#endif } return d->paintEngine; diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index c46429c..934dbb8 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -276,6 +276,11 @@ QImage* QPixmapData::buffer() } #if defined(Q_OS_SYMBIAN) +QVolatileImage QPixmapData::toVolatileImage() const +{ + return QVolatileImage(); +} + void* QPixmapData::toNativeType(NativeType /* type */) { return 0; diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index 099c61c..cf089fb 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -138,7 +138,7 @@ public: } #if defined(Q_OS_SYMBIAN) - virtual QVolatileImage toVolatileImage() const { return QVolatileImage(); } + virtual QVolatileImage toVolatileImage() const; virtual void* toNativeType(NativeType type); virtual void fromNativeType(void* pixmap, NativeType type); #endif diff --git a/src/gui/image/qvolatileimage.cpp b/src/gui/image/qvolatileimage.cpp index b8612b1..9734c82 100644 --- a/src/gui/image/qvolatileimage.cpp +++ b/src/gui/image/qvolatileimage.cpp @@ -200,6 +200,16 @@ QImage &QVolatileImage::imageRef() // non-const, in order to cause a detach return d->image; } +/*! + Non-detaching version, for read-only access only. + Must be guarded by begin/endDataAccess(). + */ +const QImage &QVolatileImage::constImageRef() const +{ + const_cast(d.data())->ensureImage(); + return d->image; +} + void *QVolatileImage::duplicateNativeImage() const { return d->duplicateNativeImage(); @@ -289,12 +299,14 @@ bool QVolatileImagePaintEngine::end() void QVolatileImagePaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) { #ifdef Q_OS_SYMBIAN - void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage); - if (nativeData) { - QVolatileImage *img = static_cast(nativeData); - img->beginDataAccess(); - QRasterPaintEngine::drawImage(p, img->imageRef()); - img->endDataAccess(true); + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + // imageRef() would detach and since we received the QVolatileImage from + // toVolatileImage() by value, it would cause a copy which would ruin + // our goal. So use constImageRef() instead. + QRasterPaintEngine::drawImage(p, img.constImageRef()); + img.endDataAccess(true); } else { QRasterPaintEngine::drawPixmap(p, pm); } @@ -306,12 +318,11 @@ void QVolatileImagePaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) void QVolatileImagePaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { #ifdef Q_OS_SYMBIAN - void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage); - if (nativeData) { - QVolatileImage *img = static_cast(nativeData); - img->beginDataAccess(); - QRasterPaintEngine::drawImage(r, img->imageRef(), sr); - img->endDataAccess(true); + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + QRasterPaintEngine::drawImage(r, img.constImageRef(), sr); + img.endDataAccess(true); } else { QRasterPaintEngine::drawPixmap(r, pm, sr); } diff --git a/src/gui/image/qvolatileimage_p.h b/src/gui/image/qvolatileimage_p.h index 97d6ea6..bed2e91 100644 --- a/src/gui/image/qvolatileimage_p.h +++ b/src/gui/image/qvolatileimage_p.h @@ -87,6 +87,7 @@ public: bool ensureFormat(QImage::Format format); QImage toImage() const; QImage &imageRef(); + const QImage &constImageRef() const; QPaintEngine *paintEngine(); void setAlphaChannel(const QPixmap &alphaChannel); void fill(uint pixelValue); diff --git a/src/gui/painting/qpaintengine_s60.cpp b/src/gui/painting/qpaintengine_s60.cpp index 091e2e6..fd7bea2 100644 --- a/src/gui/painting/qpaintengine_s60.cpp +++ b/src/gui/painting/qpaintengine_s60.cpp @@ -60,7 +60,7 @@ bool QS60PaintEngine::begin(QPaintDevice *device) { Q_D(QS60PaintEngine); - if (pixmapData->classId() == QPixmapData::RasterClass) { + if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { pixmapData->beginDataAccess(); bool ret = QRasterPaintEngine::begin(device); // Make sure QPaintEngine::paintDevice() returns the proper device. @@ -69,13 +69,12 @@ bool QS60PaintEngine::begin(QPaintDevice *device) d->pdev = device; return ret; } - return QRasterPaintEngine::begin(device); } bool QS60PaintEngine::end() { - if (pixmapData->classId() == QPixmapData::RasterClass) { + if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { bool ret = QRasterPaintEngine::end(); pixmapData->endDataAccess(); return ret; @@ -91,12 +90,14 @@ void QS60PaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) QRasterPaintEngine::drawPixmap(p, pm); srcData->endDataAccess(); } else { - void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage); - if (nativeData) { - QVolatileImage *img = static_cast(nativeData); - img->beginDataAccess(); - QRasterPaintEngine::drawImage(p, img->imageRef()); - img->endDataAccess(true); + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + // imageRef() would detach and since we received the QVolatileImage + // from toVolatileImage() by value, it would cause a copy which + // would ruin our goal. So use constImageRef() instead. + QRasterPaintEngine::drawImage(p, img.constImageRef()); + img.endDataAccess(true); } else { QRasterPaintEngine::drawPixmap(p, pm); } @@ -111,12 +112,11 @@ void QS60PaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRect QRasterPaintEngine::drawPixmap(r, pm, sr); srcData->endDataAccess(); } else { - void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage); - if (nativeData) { - QVolatileImage *img = static_cast(nativeData); - img->beginDataAccess(); - QRasterPaintEngine::drawImage(r, img->imageRef(), sr); - img->endDataAccess(true); + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + QRasterPaintEngine::drawImage(r, img.constImageRef(), sr); + img.endDataAccess(true); } else { QRasterPaintEngine::drawPixmap(r, pm, sr); } diff --git a/src/gui/painting/qpaintengine_s60_p.h b/src/gui/painting/qpaintengine_s60_p.h index 2a3b443..5535c24 100644 --- a/src/gui/painting/qpaintengine_s60_p.h +++ b/src/gui/painting/qpaintengine_s60_p.h @@ -65,7 +65,7 @@ class QS60PaintEngine : public QRasterPaintEngine Q_DECLARE_PRIVATE(QS60PaintEngine) public: - QS60PaintEngine(QPaintDevice *device, QS60PixmapData* data); + QS60PaintEngine(QPaintDevice *device, QS60PixmapData *data = 0); bool begin(QPaintDevice *device); bool end(); diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp index 86176c9..20c2170 100644 --- a/src/opengl/qgl_symbian.cpp +++ b/src/opengl/qgl_symbian.cpp @@ -437,7 +437,6 @@ void* QGLPixmapData::toNativeType(NativeType type) m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied); return m_source.duplicateNativeImage(); } - return 0; } diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index a5d156d..1231abf 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -248,9 +248,10 @@ void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags // same. Detaching is needed to prevent issues with painting // onto this QPixmap later on. convertedImage.detach(); + if (convertedImage.isNull()) + qWarning("QVGPixmapData: Failed to convert image data (out of memory? try increasing heap size)"); source = QVolatileImage(convertedImage); } - recreate = true; } diff --git a/src/openvg/qpixmapdata_vg_p.h b/src/openvg/qpixmapdata_vg_p.h index 18846f3..4a969c0 100644 --- a/src/openvg/qpixmapdata_vg_p.h +++ b/src/openvg/qpixmapdata_vg_p.h @@ -138,7 +138,7 @@ public: QSize size() const { return QSize(w, h); } #if defined(Q_OS_SYMBIAN) - QVolatileImage toVolatileImage() const { return source; } + QVolatileImage toVolatileImage() const; void* toNativeType(NativeType type); void fromNativeType(void* pixmap, NativeType type); bool initFromNativeImageHandle(void *handle, const QString &type); diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp index 249b053..98a5869 100644 --- a/src/openvg/qvg_symbian.cpp +++ b/src/openvg/qvg_symbian.cpp @@ -288,6 +288,11 @@ void* QVGPixmapData::toNativeType(NativeType type) return 0; } +QVolatileImage QVGPixmapData::toVolatileImage() const +{ + return source; +} + QSymbianVGFontGlyphCache::QSymbianVGFontGlyphCache() : QVGFontGlyphCache() { #ifdef QT_SYMBIAN_HARDWARE_GLYPH_CACHE -- cgit v0.12 From cf429b48cf144a4f6fa1b7e96ed00f5ce3fe085b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 15 Jun 2011 17:39:20 +0200 Subject: Def update. Reviewed-by: TRUSTME --- src/s60installs/bwins/QtGuiu.def | 2 ++ src/s60installs/bwins/QtNetworku.def | 2 ++ src/s60installs/bwins/QtOpenGLu.def | 1 + src/s60installs/bwins/QtOpenVGu.def | 1 + src/s60installs/eabi/QtCoreu.def | 13 +++++++++++++ src/s60installs/eabi/QtGuiu.def | 2 ++ src/s60installs/eabi/QtNetworku.def | 2 ++ src/s60installs/eabi/QtOpenVGu.def | 1 + 8 files changed, 24 insertions(+) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index ca4af4a..9b70ee8 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -13111,4 +13111,6 @@ EXPORTS ?setInstantInvalidatePropagation@QGraphicsLayout@@SAX_N@Z @ 13110 NONAME ; void QGraphicsLayout::setInstantInvalidatePropagation(bool) ?instantInvalidatePropagation@QGraphicsLayout@@SA_NXZ @ 13111 NONAME ; bool QGraphicsLayout::instantInvalidatePropagation(void) ?hasBCM2727@QSymbianGraphicsSystemEx@@SA_NXZ @ 13112 NONAME ; bool QSymbianGraphicsSystemEx::hasBCM2727(void) + ?constImageRef@QVolatileImage@@QBEABVQImage@@XZ @ 13113 NONAME ; class QImage const & QVolatileImage::constImageRef(void) const + ?toVolatileImage@QPixmapData@@UBE?AVQVolatileImage@@XZ @ 13114 NONAME ; class QVolatileImage QPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def index b3137d8..274b821 100644 --- a/src/s60installs/bwins/QtNetworku.def +++ b/src/s60installs/bwins/QtNetworku.def @@ -1159,4 +1159,6 @@ EXPORTS ??4QIPv6Address@@QAEAAV0@ABV0@@Z @ 1158 NONAME ABSENT ; class QIPv6Address & QIPv6Address::operator=(class QIPv6Address const &) ??_EQNetworkAddressEntry@@QAE@I@Z @ 1159 NONAME ABSENT ; QNetworkAddressEntry::~QNetworkAddressEntry(unsigned int) ??_EQNetworkCookie@@QAE@I@Z @ 1160 NONAME ABSENT ; QNetworkCookie::~QNetworkCookie(unsigned int) + ?cleanup@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1161 NONAME ; void QNetworkConfigurationManagerPrivate::cleanup(void) + ?initialize@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1162 NONAME ; void QNetworkConfigurationManagerPrivate::initialize(void) diff --git a/src/s60installs/bwins/QtOpenGLu.def b/src/s60installs/bwins/QtOpenGLu.def index 75c0d5e..af25e7e 100644 --- a/src/s60installs/bwins/QtOpenGLu.def +++ b/src/s60installs/bwins/QtOpenGLu.def @@ -724,4 +724,5 @@ EXPORTS ?initFromNativeImageHandle@QGLPixmapData@@QAE_NPAXABVQString@@@Z @ 723 NONAME ; bool QGLPixmapData::initFromNativeImageHandle(void *, class QString const &) ?platformExtension@QGLGraphicsSystem@@UAEPAVQGraphicsSystemEx@@XZ @ 724 NONAME ; class QGraphicsSystemEx * QGLGraphicsSystem::platformExtension(void) ?releaseCachedGpuResources@QGLGraphicsSystem@@UAEXXZ @ 725 NONAME ; void QGLGraphicsSystem::releaseCachedGpuResources(void) + ?toVolatileImage@QGLPixmapData@@UBE?AVQVolatileImage@@XZ @ 726 NONAME ; class QVolatileImage QGLPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/bwins/QtOpenVGu.def b/src/s60installs/bwins/QtOpenVGu.def index f2433d6..9812757 100644 --- a/src/s60installs/bwins/QtOpenVGu.def +++ b/src/s60installs/bwins/QtOpenVGu.def @@ -184,4 +184,5 @@ EXPORTS ?createFromNativeImageHandleProvider@QVGPixmapData@@QAEXXZ @ 183 NONAME ; void QVGPixmapData::createFromNativeImageHandleProvider(void) ?releaseNativeImageHandle@QVGPixmapData@@QAEXXZ @ 184 NONAME ; void QVGPixmapData::releaseNativeImageHandle(void) ?forceToImage@QVGPixmapData@@IAEX_N@Z @ 185 NONAME ; void QVGPixmapData::forceToImage(bool) + ?toVolatileImage@QVGPixmapData@@UBE?AVQVolatileImage@@XZ @ 186 NONAME ; class QVolatileImage QVGPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index fce55dd..f92cb5a 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3717,4 +3717,17 @@ EXPORTS _ZN23QCoreApplicationPrivate18symbianCommandLineEv @ 3716 NONAME _ZNK11QMetaMethod8revisionEv @ 3717 NONAME _ZNK13QMetaProperty8revisionEv @ 3718 NONAME + _ZN5RHeap10Extension_EjRPvS0_ @ 3719 NONAME + _ZN5RHeap13DebugFunctionEiPvS0_ @ 3720 NONAME + _ZN5RHeap4FreeEPv @ 3721 NONAME + _ZN5RHeap5AllocEi @ 3722 NONAME + _ZN5RHeap5ResetEv @ 3723 NONAME + _ZN5RHeap7ReAllocEPvii @ 3724 NONAME + _ZN5RHeap8CompressEv @ 3725 NONAME + _ZN8UserHeap15OffsetChunkHeapE6RChunkiiiiiim @ 3726 NONAME + _ZN8UserHeap16CreateThreadHeapER24SStdEpocThreadCreateInfoRP5RHeapii @ 3727 NONAME + _ZN8UserHeap9ChunkHeapE6RChunkiiiiim @ 3728 NONAME + _ZNK5RHeap8AllocLenEPKv @ 3729 NONAME + _ZNK5RHeap9AllocSizeERi @ 3730 NONAME + _ZNK5RHeap9AvailableERi @ 3731 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index d0c789f..0f9442d 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12195,4 +12195,6 @@ EXPORTS _ZTI17QGraphicsSystemEx @ 12194 NONAME _ZTI24QSymbianGraphicsSystemEx @ 12195 NONAME _ZTV24QSymbianGraphicsSystemEx @ 12196 NONAME + _ZNK11QPixmapData15toVolatileImageEv @ 12197 NONAME + _ZNK14QVolatileImage13constImageRefEv @ 12198 NONAME diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def index f13fab3..86a61e8 100644 --- a/src/s60installs/eabi/QtNetworku.def +++ b/src/s60installs/eabi/QtNetworku.def @@ -1168,4 +1168,6 @@ EXPORTS _ZTV35QNetworkConfigurationManagerPrivate @ 1167 NONAME _ZThn8_N19QBearerEnginePluginD0Ev @ 1168 NONAME _ZThn8_N19QBearerEnginePluginD1Ev @ 1169 NONAME + _ZN35QNetworkConfigurationManagerPrivate10initializeEv @ 1170 NONAME + _ZN35QNetworkConfigurationManagerPrivate7cleanupEv @ 1171 NONAME diff --git a/src/s60installs/eabi/QtOpenVGu.def b/src/s60installs/eabi/QtOpenVGu.def index 08afd61..e169ff8 100644 --- a/src/s60installs/eabi/QtOpenVGu.def +++ b/src/s60installs/eabi/QtOpenVGu.def @@ -214,4 +214,5 @@ EXPORTS _ZN13QVGPixmapData25initFromNativeImageHandleEPvRK7QString @ 213 NONAME _ZN13QVGPixmapData35createFromNativeImageHandleProviderEv @ 214 NONAME _ZN13QVGPixmapData12forceToImageEb @ 215 NONAME + _ZNK13QVGPixmapData15toVolatileImageEv @ 216 NONAME -- cgit v0.12 From 980bceb279e0948ad33ccecd6e1601e428d01866 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 16 Jun 2011 11:22:51 +0200 Subject: Proper naming for raster pixmap and paintengine on Symbian. As QTBUG-19880 highlighted, the old S60 naming is not suitable for these classes anymore. Task-number: QTBUG-19913 Reviewed-by: Jani Hautakangas --- src/gui/image/image.pri | 4 +- src/gui/image/qimage.cpp | 4 +- src/gui/image/qpixmap.h | 2 +- src/gui/image/qpixmap_raster_symbian.cpp | 1042 ++++++++++++++++++++++ src/gui/image/qpixmap_raster_symbian_p.h | 140 +++ src/gui/image/qpixmap_s60.cpp | 1042 ---------------------- src/gui/image/qpixmap_s60_p.h | 141 --- src/gui/image/qpixmapdata_p.h | 2 +- src/gui/image/qpixmapdatafactory.cpp | 4 +- src/gui/kernel/qapplication_s60.cpp | 2 +- src/gui/painting/painting.pri | 4 +- src/gui/painting/qgraphicssystem.cpp | 4 +- src/gui/painting/qgraphicssystem_raster.cpp | 4 +- src/gui/painting/qpaintengine_raster_symbian.cpp | 147 +++ src/gui/painting/qpaintengine_raster_symbian_p.h | 84 ++ src/gui/painting/qpaintengine_s60.cpp | 145 --- src/gui/painting/qpaintengine_s60_p.h | 84 -- src/gui/painting/qwindowsurface_s60.cpp | 14 +- src/gui/styles/qs60style_s60.cpp | 2 +- src/gui/text/qfont_s60.cpp | 2 +- src/gui/text/qfontdatabase_s60.cpp | 2 +- src/gui/text/qfontengine_s60.cpp | 2 +- src/opengl/qgl_symbian.cpp | 3 +- 23 files changed, 1440 insertions(+), 1440 deletions(-) create mode 100644 src/gui/image/qpixmap_raster_symbian.cpp create mode 100644 src/gui/image/qpixmap_raster_symbian_p.h delete mode 100644 src/gui/image/qpixmap_s60.cpp delete mode 100644 src/gui/image/qpixmap_s60_p.h create mode 100644 src/gui/painting/qpaintengine_raster_symbian.cpp create mode 100644 src/gui/painting/qpaintengine_raster_symbian_p.h delete mode 100644 src/gui/painting/qpaintengine_s60.cpp delete mode 100644 src/gui/painting/qpaintengine_s60_p.h diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 00dccbe..d02d050 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -72,8 +72,8 @@ else:mac { SOURCES += image/qpixmap_mac.cpp } else:symbian { - HEADERS += image/qpixmap_s60_p.h - SOURCES += image/qpixmap_s60.cpp + HEADERS += image/qpixmap_raster_symbian_p.h + SOURCES += image/qpixmap_raster_symbian.cpp } !symbian|contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2) { diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d7156a7..5c83cf6 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -63,7 +63,7 @@ #include #if defined(Q_OS_SYMBIAN) -#include +#include #else #include #endif @@ -5711,7 +5711,7 @@ QPaintEngine *QImage::paintEngine() const if (!d->paintEngine) { #ifdef Q_OS_SYMBIAN - d->paintEngine = new QS60PaintEngine(const_cast(this)); + d->paintEngine = new QSymbianRasterPaintEngine(const_cast(this)); #else d->paintEngine = new QRasterPaintEngine(const_cast(this)); #endif diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 23b37f4..c25f3c1 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -265,7 +265,7 @@ private: friend class QPixmapData; friend class QX11PixmapData; friend class QMacPixmapData; - friend class QS60PixmapData; + friend class QSymbianRasterPixmapData; friend class QBitmap; friend class QPaintDevice; friend class QPainter; diff --git a/src/gui/image/qpixmap_raster_symbian.cpp b/src/gui/image/qpixmap_raster_symbian.cpp new file mode 100644 index 0000000..7eb6eca --- /dev/null +++ b/src/gui/image/qpixmap_raster_symbian.cpp @@ -0,0 +1,1042 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include + +#include +#include +#include +#include + +#include "qpixmap.h" +#include "qpixmap_raster_p.h" +#include +#include "qpixmap_raster_symbian_p.h" +#include "qnativeimage_p.h" +#include "qbitmap.h" +#include "qimage.h" +#include "qimage_p.h" + +#include + +QT_BEGIN_NAMESPACE + +const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, + 0x10, 0x20, 0x40, 0x80 }; + +static bool cleanup_function_registered = false; +static QSymbianRasterPixmapData *firstPixmap = 0; + +// static +void QSymbianRasterPixmapData::qt_symbian_register_pixmap(QSymbianRasterPixmapData *pd) +{ + if (!cleanup_function_registered) { + qAddPostRoutine(qt_symbian_release_pixmaps); + cleanup_function_registered = true; + } + + pd->next = firstPixmap; + pd->prev = 0; + if (firstPixmap) + firstPixmap->prev = pd; + firstPixmap = pd; +} + +// static +void QSymbianRasterPixmapData::qt_symbian_unregister_pixmap(QSymbianRasterPixmapData *pd) +{ + if (pd->next) + pd->next->prev = pd->prev; + if (pd->prev) + pd->prev->next = pd->next; + else + firstPixmap = pd->next; +} + +// static +void QSymbianRasterPixmapData::qt_symbian_release_pixmaps() +{ + // Scan all QSymbianRasterPixmapData objects in the system and destroy them. + QSymbianRasterPixmapData *pd = firstPixmap; + while (pd != 0) { + pd->release(); + pd = pd->next; + } +} + +/* + \class QSymbianFbsClient + \since 4.6 + \internal + + Symbian Font And Bitmap server client that is + used to lock the global bitmap heap. Only used in + S60 v3.1 and S60 v3.2. +*/ +_LIT(KFBSERVLargeBitmapAccessName,"FbsLargeBitmapAccess"); +class QSymbianFbsClient +{ +public: + + QSymbianFbsClient() : heapLocked(false) + { + heapLock.OpenGlobal(KFBSERVLargeBitmapAccessName); + } + + ~QSymbianFbsClient() + { + heapLock.Close(); + } + + bool lockHeap() + { + bool wasLocked = heapLocked; + + if (heapLock.Handle() && !heapLocked) { + heapLock.Wait(); + heapLocked = true; + } + + return wasLocked; + } + + bool unlockHeap() + { + bool wasLocked = heapLocked; + + if (heapLock.Handle() && heapLocked) { + heapLock.Signal(); + heapLocked = false; + } + + return wasLocked; + } + + +private: + + RMutex heapLock; + bool heapLocked; +}; + +Q_GLOBAL_STATIC(QSymbianFbsClient, qt_symbianFbsClient); + + + +// QSymbianFbsHeapLock + +QSymbianFbsHeapLock::QSymbianFbsHeapLock(LockAction a) +: action(a), wasLocked(false) +{ + QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); + if (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3) + wasLocked = qt_symbianFbsClient()->unlockHeap(); +} + +QSymbianFbsHeapLock::~QSymbianFbsHeapLock() +{ + // Do nothing +} + +void QSymbianFbsHeapLock::relock() +{ + QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); + if (wasLocked && (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3)) + qt_symbianFbsClient()->lockHeap(); +} + +/* + \class QSymbianBitmapDataAccess + \since 4.6 + \internal + + Data access class that is used to locks/unlocks pixel data + when drawing or modifying CFbsBitmap pixel data. +*/ +class QSymbianBitmapDataAccess +{ +public: + + static int heapRefCount; + QSysInfo::SymbianVersion symbianVersion; + + explicit QSymbianBitmapDataAccess() + { + symbianVersion = QSysInfo::symbianVersion(); + }; + + ~QSymbianBitmapDataAccess() {}; + + inline void beginDataAccess(CFbsBitmap *bitmap) + { + if (symbianVersion == QSysInfo::SV_9_2) { + if (heapRefCount == 0) + qt_symbianFbsClient()->lockHeap(); + } else { + bitmap->LockHeap(ETrue); + } + + heapRefCount++; + } + + inline void endDataAccess(CFbsBitmap *bitmap) + { + heapRefCount--; + + if (symbianVersion == QSysInfo::SV_9_2) { + if (heapRefCount == 0) + qt_symbianFbsClient()->unlockHeap(); + } else { + bitmap->UnlockHeap(ETrue); + } + } +}; + +int QSymbianBitmapDataAccess::heapRefCount = 0; + + +#define UPDATE_BUFFER() \ + { \ + beginDataAccess(); \ + endDataAccess(); \ +} + + +static CFbsBitmap* createSymbianCFbsBitmap(const TSize& size, TDisplayMode mode) +{ + QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); + + CFbsBitmap* bitmap = 0; + QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap); + + if (bitmap->Create(size, mode) != KErrNone) { + delete bitmap; + bitmap = 0; + } + + lock.relock(); + + return bitmap; +} + +static CFbsBitmap* uncompress(CFbsBitmap* bitmap) +{ + if(bitmap->IsCompressedInRAM()) { + QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); + + CFbsBitmap *uncompressed = 0; + QT_TRAP_THROWING(uncompressed = new (ELeave) CFbsBitmap); + + if (uncompressed->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) { + delete bitmap; + bitmap = 0; + lock.relock(); + + return bitmap; + } + + lock.relock(); + + CFbsBitmapDevice* bitmapDevice = 0; + CFbsBitGc *bitmapGc = 0; + QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(uncompressed)); + QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL()); + bitmapGc->Activate(bitmapDevice); + + bitmapGc->BitBlt(TPoint(), bitmap); + + delete bitmapGc; + delete bitmapDevice; + + return uncompressed; + } else { + return bitmap; + } +} + +QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h) +{ + CWsScreenDevice* screenDevice = S60->screenDevice(); + TSize screenSize = screenDevice->SizeInPixels(); + + TSize srcSize; + // Find out if this is one of our windows. + QSymbianControl *sControl; + sControl = winId->MopGetObject(sControl); + if (sControl && sControl->widget()->windowType() == Qt::Desktop) { + // Grabbing desktop widget + srcSize = screenSize; + } else { + TPoint relativePos = winId->PositionRelativeToScreen(); + x += relativePos.iX; + y += relativePos.iY; + srcSize = winId->Size(); + } + + TRect srcRect(TPoint(x, y), srcSize); + // Clip to the screen + srcRect.Intersection(TRect(screenSize)); + + if (w > 0 && h > 0) { + TRect subRect(TPoint(x, y), TSize(w, h)); + // Clip to the subRect + srcRect.Intersection(subRect); + } + + if (srcRect.IsEmpty()) + return QPixmap(); + + CFbsBitmap* temporary = createSymbianCFbsBitmap(srcRect.Size(), screenDevice->DisplayMode()); + + QPixmap pix; + + if (temporary && screenDevice->CopyScreenToBitmap(temporary, srcRect) == KErrNone) { + pix = QPixmap::fromSymbianCFbsBitmap(temporary); + } + + delete temporary; + return pix; +} + +/*! + \fn CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const + \since 4.6 + + Creates a \c CFbsBitmap that is equivalent to the QPixmap. Internally this + function will try to duplicate the handle instead of copying the data, + however in scenarios where this is not possible the data will be copied. + If the creation fails or the pixmap is null, then this function returns 0. + + It is the caller's responsibility to release the \c CFbsBitmap data + after use either by deleting the bitmap or calling \c Reset(). + + \warning On S60 3.1 and S60 3.2, semi-transparent pixmaps are always copied + and not duplicated. + \warning This function is only available on Symbian OS. + + \sa fromSymbianCFbsBitmap() +*/ +CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const +{ + QPixmapData *data = pixmapData(); + if (!data || data->isNull()) + return 0; + + return reinterpret_cast(data->toNativeType(QPixmapData::FbsBitmap)); +} + +/*! + \fn QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) + \since 4.6 + + Creates a QPixmap from a \c CFbsBitmap \a bitmap. Internally this function + will try to duplicate the bitmap handle instead of copying the data, however + in scenarios where this is not possible the data will be copied. + To be sure that QPixmap does not modify your original instance, you should + make a copy of your \c CFbsBitmap before calling this function. + If the CFbsBitmap is not valid this function will return a null QPixmap. + For performance reasons it is recommended to use a \a bitmap with a display + mode of EColor16MAP or EColor16MU whenever possible. + + \warning This function is only available on Symbian OS. + + \sa toSymbianCFbsBitmap(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} +*/ +QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) +{ + if (!bitmap) + return QPixmap(); + + QScopedPointer data(QPixmapData::create(0,0, QPixmapData::PixmapType)); + data->fromNativeType(reinterpret_cast(bitmap), QPixmapData::FbsBitmap); + QPixmap pixmap(data.take()); + return pixmap; +} + +QSymbianRasterPixmapData::QSymbianRasterPixmapData(PixelType type) : QRasterPixmapData(type), + symbianBitmapDataAccess(new QSymbianBitmapDataAccess), + cfbsBitmap(0), + pengine(0), + bytes(0), + formatLocked(false), + next(0), + prev(0) +{ + qt_symbian_register_pixmap(this); +} + +QSymbianRasterPixmapData::~QSymbianRasterPixmapData() +{ + release(); + delete symbianBitmapDataAccess; + qt_symbian_unregister_pixmap(this); +} + +void QSymbianRasterPixmapData::resize(int width, int height) +{ + if (width <= 0 || height <= 0) { + w = width; + h = height; + is_null = true; + + release(); + return; + } else if (!cfbsBitmap) { + TDisplayMode mode; + if (pixelType() == BitmapType) + mode = EGray2; + else + mode = EColor16MU; + + CFbsBitmap* bitmap = createSymbianCFbsBitmap(TSize(width, height), mode); + fromSymbianBitmap(bitmap); + } else { + + TSize newSize(width, height); + + if(cfbsBitmap->SizeInPixels() != newSize) { + cfbsBitmap->Resize(TSize(width, height)); + if(pengine) { + delete pengine; + pengine = 0; + } + } + + UPDATE_BUFFER(); + } +} + +void QSymbianRasterPixmapData::release() +{ + if (cfbsBitmap) { + QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); + delete cfbsBitmap; + lock.relock(); + } + + delete pengine; + image = QImage(); + cfbsBitmap = 0; + pengine = 0; + bytes = 0; +} + +/*! + * Takes ownership of bitmap. Used by window surface + */ +void QSymbianRasterPixmapData::fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat) +{ + Q_ASSERT(bitmap); + + release(); + + cfbsBitmap = bitmap; + formatLocked = lockFormat; + + setSerialNumber(cfbsBitmap->Handle()); + + UPDATE_BUFFER(); + + // Create default palette if needed + if (cfbsBitmap->DisplayMode() == EGray2) { + image.setColorCount(2); + image.setColor(0, QColor(Qt::color0).rgba()); + image.setColor(1, QColor(Qt::color1).rgba()); + + //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid + //So invert mono bitmaps so that masks work correctly. + image.invertPixels(); + } else if (cfbsBitmap->DisplayMode() == EGray256) { + for (int i=0; i < 256; ++i) + image.setColor(i, qRgb(i, i, i)); + } else if (cfbsBitmap->DisplayMode() == EColor256) { + const TColor256Util *palette = TColor256Util::Default(); + for (int i=0; i < 256; ++i) + image.setColor(i, (QRgb)(palette->Color256(i).Value())); + } +} + +QImage QSymbianRasterPixmapData::toImage(const QRect &r) const +{ + QSymbianRasterPixmapData *that = const_cast(this); + that->beginDataAccess(); + QImage copy = that->image.copy(r); + that->endDataAccess(); + + return copy; +} + +void QSymbianRasterPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) +{ + release(); + + QImage sourceImage; + + if (pixelType() == BitmapType) { + sourceImage = img.convertToFormat(QImage::Format_MonoLSB); + } else { + if (img.depth() == 1) { + sourceImage = img.hasAlphaChannel() + ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) + : img.convertToFormat(QImage::Format_RGB32); + } else { + + QImage::Format opaqueFormat = QNativeImage::systemFormat(); + QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; + + if (!img.hasAlphaChannel() + || ((flags & Qt::NoOpaqueDetection) == 0 + && !const_cast(img).data_ptr()->checkForAlphaPixels())) { + sourceImage = img.convertToFormat(opaqueFormat); + } else { + sourceImage = img.convertToFormat(alphaFormat); + } + } + } + + + QImage::Format destFormat = sourceImage.format(); + TDisplayMode mode; + switch (destFormat) { + case QImage::Format_MonoLSB: + mode = EGray2; + break; + case QImage::Format_RGB32: + mode = EColor16MU; + break; + case QImage::Format_ARGB32_Premultiplied: + if (S60->supportsPremultipliedAlpha) { + mode = Q_SYMBIAN_ECOLOR16MAP; + break; + } else { + destFormat = QImage::Format_ARGB32; + } + // Fall through intended + case QImage::Format_ARGB32: + mode = EColor16MA; + break; + case QImage::Format_Invalid: + return; + default: + qWarning("Image format not supported: %d", image.format()); + return; + } + + cfbsBitmap = createSymbianCFbsBitmap(TSize(sourceImage.width(), sourceImage.height()), mode); + if (!cfbsBitmap) { + qWarning("Could not create CFbsBitmap"); + release(); + return; + } + + setSerialNumber(cfbsBitmap->Handle()); + + const uchar *sptr = const_cast(sourceImage).bits(); + symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); + uchar *dptr = (uchar*)cfbsBitmap->DataAddress(); + Mem::Copy(dptr, sptr, sourceImage.byteCount()); + symbianBitmapDataAccess->endDataAccess(cfbsBitmap); + + UPDATE_BUFFER(); + + if (destFormat == QImage::Format_MonoLSB) { + image.setColorCount(2); + image.setColor(0, QColor(Qt::color0).rgba()); + image.setColor(1, QColor(Qt::color1).rgba()); + } else { + image.setColorTable(sourceImage.colorTable()); + } +} + +void QSymbianRasterPixmapData::copy(const QPixmapData *data, const QRect &rect) +{ + const QSymbianRasterPixmapData *s60Data = static_cast(data); + fromImage(s60Data->toImage(rect), Qt::AutoColor | Qt::OrderedAlphaDither); +} + +bool QSymbianRasterPixmapData::scroll(int dx, int dy, const QRect &rect) +{ + beginDataAccess(); + bool res = QRasterPixmapData::scroll(dx, dy, rect); + endDataAccess(); + return res; +} + +Q_GUI_EXPORT int qt_defaultDpiX(); +Q_GUI_EXPORT int qt_defaultDpiY(); + +int QSymbianRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const +{ + if (!cfbsBitmap) + return 0; + + switch (metric) { + case QPaintDevice::PdmWidth: + return cfbsBitmap->SizeInPixels().iWidth; + case QPaintDevice::PdmHeight: + return cfbsBitmap->SizeInPixels().iHeight; + case QPaintDevice::PdmWidthMM: + return qRound(cfbsBitmap->SizeInPixels().iWidth * 25.4 / qt_defaultDpiX()); + case QPaintDevice::PdmHeightMM: + return qRound(cfbsBitmap->SizeInPixels().iHeight * 25.4 / qt_defaultDpiY()); + case QPaintDevice::PdmNumColors: + return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode()); + case QPaintDevice::PdmDpiX: + case QPaintDevice::PdmPhysicalDpiX: + return qt_defaultDpiX(); + case QPaintDevice::PdmDpiY: + case QPaintDevice::PdmPhysicalDpiY: + return qt_defaultDpiY(); + case QPaintDevice::PdmDepth: + return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode()); + default: + qWarning("QPixmap::metric: Invalid metric command"); + } + return 0; + +} + +void QSymbianRasterPixmapData::fill(const QColor &color) +{ + if (color.alpha() != 255) { + QImage im(width(), height(), QImage::Format_ARGB32_Premultiplied); + im.fill(PREMUL(color.rgba())); + release(); + fromImage(im, Qt::AutoColor | Qt::OrderedAlphaDither); + } else { + beginDataAccess(); + QRasterPixmapData::fill(color); + endDataAccess(); + } +} + +void QSymbianRasterPixmapData::setMask(const QBitmap &mask) +{ + if (mask.size().isEmpty()) { + if (image.depth() != 1) { + QImage newImage = image.convertToFormat(QImage::Format_RGB32); + release(); + fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither); + } + } else if (image.depth() == 1) { + beginDataAccess(); + QRasterPixmapData::setMask(mask); + endDataAccess(); + } else { + const int w = image.width(); + const int h = image.height(); + + const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB); + QImage newImage = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); + for (int y = 0; y < h; ++y) { + const uchar *mscan = imageMask.scanLine(y); + QRgb *tscan = (QRgb *)newImage.scanLine(y); + for (int x = 0; x < w; ++x) { + if (!(mscan[x>>3] & qt_pixmap_bit_mask[x&7])) + tscan[x] = 0; + } + } + release(); + fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither); + } +} + +void QSymbianRasterPixmapData::setAlphaChannel(const QPixmap &alphaChannel) +{ + QImage img(toImage()); + img.setAlphaChannel(alphaChannel.toImage()); + release(); + fromImage(img, Qt::OrderedDither | Qt::OrderedAlphaDither); +} + +QImage QSymbianRasterPixmapData::toImage() const +{ + return toImage(QRect()); +} + +QPaintEngine* QSymbianRasterPixmapData::paintEngine() const +{ + if (!pengine) { + QSymbianRasterPixmapData *that = const_cast(this); + that->pengine = new QSymbianRasterPaintEngine(&that->image, that); + } + return pengine; +} + +void QSymbianRasterPixmapData::beginDataAccess() +{ + if(!cfbsBitmap) + return; + + symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); + + uchar* newBytes = (uchar*)cfbsBitmap->DataAddress(); + + TSize size = cfbsBitmap->SizeInPixels(); + + if (newBytes == bytes && image.width() == size.iWidth && image.height() == size.iHeight) + return; + + bytes = newBytes; + TDisplayMode mode = cfbsBitmap->DisplayMode(); + QImage::Format format = qt_TDisplayMode2Format(mode); + // On S60 3.1, premultiplied alpha pixels are stored in a bitmap with 16MA type. + // S60 window surface needs backing store pixmap for transparent window in ARGB32 format. + // In that case formatLocked is true. + if (!formatLocked && format == QImage::Format_ARGB32) + format = QImage::Format_ARGB32_Premultiplied; // pixel data is actually in premultiplied format + + QVector savedColorTable; + if (!image.isNull()) + savedColorTable = image.colorTable(); + + image = QImage(bytes, size.iWidth, size.iHeight, format); + + // Restore the palette or create a default + if (!savedColorTable.isEmpty()) { + image.setColorTable(savedColorTable); + } + + w = size.iWidth; + h = size.iHeight; + d = image.depth(); + is_null = (w <= 0 || h <= 0); + + if (pengine) { + QSymbianRasterPaintEngine *engine = static_cast(pengine); + engine->prepare(&image); + } +} + +void QSymbianRasterPixmapData::endDataAccess(bool readOnly) const +{ + Q_UNUSED(readOnly); + + if(!cfbsBitmap) + return; + + symbianBitmapDataAccess->endDataAccess(cfbsBitmap); +} + +/*! + \since 4.6 + + Returns a QPixmap that wraps given \a sgImage graphics resource. + The data should be valid even when original RSgImage handle has been + closed. + + \warning This function is only available on Symbian OS. + + \sa toSymbianRSgImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} +*/ + +QPixmap QPixmap::fromSymbianRSgImage(RSgImage *sgImage) +{ + // It is expected that RSgImage will + // CURRENTLY be used in conjuction with + // OpenVG graphics system + // + // Surely things might change in future + + if (!sgImage) + return QPixmap(); + + QScopedPointer data(QPixmapData::create(0,0, QPixmapData::PixmapType)); + data->fromNativeType(reinterpret_cast(sgImage), QPixmapData::SgImage); + QPixmap pixmap(data.take()); + return pixmap; +} + +/*! +\since 4.6 + +Returns a \c RSgImage that is equivalent to the QPixmap by copying the data. + +It is the caller's responsibility to close/delete the \c RSgImage after use. + +\warning This function is only available on Symbian OS. + +\sa fromSymbianRSgImage() +*/ + +RSgImage *QPixmap::toSymbianRSgImage() const +{ + // It is expected that RSgImage will + // CURRENTLY be used in conjuction with + // OpenVG graphics system + // + // Surely things might change in future + + if (isNull()) + return 0; + + RSgImage *sgImage = reinterpret_cast(pixmapData()->toNativeType(QPixmapData::SgImage)); + + return sgImage; +} + +void* QSymbianRasterPixmapData::toNativeType(NativeType type) +{ + if (type == QPixmapData::SgImage) { + return 0; + } else if (type == QPixmapData::FbsBitmap) { + + if (isNull() || !cfbsBitmap) + return 0; + + bool convertToArgb32 = false; + bool needsCopy = false; + + if (!(S60->supportsPremultipliedAlpha)) { + // Convert argb32_premultiplied to argb32 since Symbian 9.2 does + // not support premultipied format. + + if (image.format() == QImage::Format_ARGB32_Premultiplied) { + needsCopy = true; + convertToArgb32 = true; + } + } + + CFbsBitmap *bitmap = 0; + + TDisplayMode displayMode = cfbsBitmap->DisplayMode(); + + if(displayMode == EGray2) { + //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid + //So invert mono bitmaps so that masks work correctly. + beginDataAccess(); + image.invertPixels(); + endDataAccess(); + needsCopy = true; + } + + if (needsCopy) { + QImage source; + + if (convertToArgb32) { + beginDataAccess(); + source = image.convertToFormat(QImage::Format_ARGB32); + endDataAccess(); + displayMode = EColor16MA; + } else { + source = image; + } + + CFbsBitmap *newBitmap = createSymbianCFbsBitmap(TSize(source.width(), source.height()), displayMode); + const uchar *sptr = source.bits(); + symbianBitmapDataAccess->beginDataAccess(newBitmap); + + uchar *dptr = (uchar*)newBitmap->DataAddress(); + Mem::Copy(dptr, sptr, source.byteCount()); + + symbianBitmapDataAccess->endDataAccess(newBitmap); + + bitmap = newBitmap; + } else { + + QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap); + + TInt err = bitmap->Duplicate(cfbsBitmap->Handle()); + if (err != KErrNone) { + qWarning("Could not duplicate CFbsBitmap"); + delete bitmap; + bitmap = 0; + } + } + + if(displayMode == EGray2) { + // restore pixels + beginDataAccess(); + image.invertPixels(); + endDataAccess(); + } + + return reinterpret_cast(bitmap); + + } + + return 0; +} + +void QSymbianRasterPixmapData::fromNativeType(void* pixmap, NativeType nativeType) +{ + if (nativeType == QPixmapData::SgImage) { + return; + } else if (nativeType == QPixmapData::FbsBitmap && pixmap) { + + CFbsBitmap *bitmap = reinterpret_cast(pixmap); + + bool deleteSourceBitmap = false; + bool needsCopy = false; + +#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE + + // Rasterize extended bitmaps + + TUid extendedBitmapType = bitmap->ExtendedBitmapType(); + if (extendedBitmapType != KNullUid) { + CFbsBitmap *rasterBitmap = createSymbianCFbsBitmap(bitmap->SizeInPixels(), EColor16MA); + + CFbsBitmapDevice *rasterBitmapDev = 0; + QT_TRAP_THROWING(rasterBitmapDev = CFbsBitmapDevice::NewL(rasterBitmap)); + + CFbsBitGc *rasterBitmapGc = 0; + TInt err = rasterBitmapDev->CreateContext(rasterBitmapGc); + if (err != KErrNone) { + delete rasterBitmap; + delete rasterBitmapDev; + rasterBitmapDev = 0; + return; + } + + rasterBitmapGc->BitBlt(TPoint( 0, 0), bitmap); + + bitmap = rasterBitmap; + + delete rasterBitmapDev; + delete rasterBitmapGc; + + rasterBitmapDev = 0; + rasterBitmapGc = 0; + + deleteSourceBitmap = true; + } +#endif + + + deleteSourceBitmap = bitmap->IsCompressedInRAM(); + CFbsBitmap *sourceBitmap = uncompress(bitmap); + + TDisplayMode displayMode = sourceBitmap->DisplayMode(); + QImage::Format format = qt_TDisplayMode2Format(displayMode); + + QImage::Format opaqueFormat = QNativeImage::systemFormat(); + QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; + + if (format != opaqueFormat && format != alphaFormat && format != QImage::Format_MonoLSB) + needsCopy = true; + + + type = (format != QImage::Format_MonoLSB) + ? QPixmapData::PixmapType + : QPixmapData::BitmapType; + + if (needsCopy) { + + TSize size = sourceBitmap->SizeInPixels(); + int bytesPerLine = sourceBitmap->ScanLineLength(size.iWidth, displayMode); + + QSymbianBitmapDataAccess da; + da.beginDataAccess(sourceBitmap); + uchar *bytes = (uchar*)sourceBitmap->DataAddress(); + QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format); + img = img.copy(); + da.endDataAccess(sourceBitmap); + + if(displayMode == EGray2) { + //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid + //So invert mono bitmaps so that masks work correctly. + img.invertPixels(); + } else if(displayMode == EColor16M) { + img = img.rgbSwapped(); // EColor16M is BGR + } + + fromImage(img, Qt::AutoColor); + + if(deleteSourceBitmap) + delete sourceBitmap; + } else { + CFbsBitmap* duplicate = 0; + QT_TRAP_THROWING(duplicate = new (ELeave) CFbsBitmap); + + TInt err = duplicate->Duplicate(sourceBitmap->Handle()); + if (err != KErrNone) { + qWarning("Could not duplicate CFbsBitmap"); + + if(deleteSourceBitmap) + delete sourceBitmap; + + delete duplicate; + return; + } + + fromSymbianBitmap(duplicate); + + if(deleteSourceBitmap) + delete sourceBitmap; + } + } +} + +void QSymbianRasterPixmapData::convertToDisplayMode(int mode) +{ + const TDisplayMode displayMode = static_cast(mode); + if (!cfbsBitmap || cfbsBitmap->DisplayMode() == displayMode) + return; + if (image.depth() != TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)) { + qWarning("Cannot convert display mode due to depth mismatch"); + return; + } + + const TSize size = cfbsBitmap->SizeInPixels(); + QScopedPointer newBitmap(createSymbianCFbsBitmap(size, displayMode)); + + const uchar *sptr = const_cast(image).bits(); + symbianBitmapDataAccess->beginDataAccess(newBitmap.data()); + uchar *dptr = (uchar*)newBitmap->DataAddress(); + Mem::Copy(dptr, sptr, image.byteCount()); + symbianBitmapDataAccess->endDataAccess(newBitmap.data()); + + QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); + delete cfbsBitmap; + lock.relock(); + cfbsBitmap = newBitmap.take(); + setSerialNumber(cfbsBitmap->Handle()); + UPDATE_BUFFER(); +} + +QPixmapData *QSymbianRasterPixmapData::createCompatiblePixmapData() const +{ + return new QSymbianRasterPixmapData(pixelType()); +} + +QT_END_NAMESPACE diff --git a/src/gui/image/qpixmap_raster_symbian_p.h b/src/gui/image/qpixmap_raster_symbian_p.h new file mode 100644 index 0000000..7f4e53a --- /dev/null +++ b/src/gui/image/qpixmap_raster_symbian_p.h @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPIXMAP_RASTER_SYMBIAN_P_H +#define QPIXMAP_RASTER_SYMBIAN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class CFbsBitmap; +class CFbsBitmapDevice; +class CFbsBitGc; + +class QSymbianBitmapDataAccess; + +class QSymbianFbsHeapLock +{ +public: + + enum LockAction { + Unlock + }; + + explicit QSymbianFbsHeapLock(LockAction a); + ~QSymbianFbsHeapLock(); + void relock(); + +private: + + LockAction action; + bool wasLocked; +}; + +class QSymbianRasterPixmapData : public QRasterPixmapData +{ +public: + QSymbianRasterPixmapData(PixelType type); + ~QSymbianRasterPixmapData(); + + QPixmapData *createCompatiblePixmapData() const; + + void resize(int width, int height); + void fromImage(const QImage &image, Qt::ImageConversionFlags flags); + void copy(const QPixmapData *data, const QRect &rect); + bool scroll(int dx, int dy, const QRect &rect); + + int metric(QPaintDevice::PaintDeviceMetric metric) const; + void fill(const QColor &color); + void setMask(const QBitmap &mask); + void setAlphaChannel(const QPixmap &alphaChannel); + QImage toImage() const; + QPaintEngine* paintEngine() const; + + void beginDataAccess(); + void endDataAccess(bool readOnly=false) const; + + void* toNativeType(NativeType type); + void fromNativeType(void* pixmap, NativeType type); + + void convertToDisplayMode(int mode); + +private: + void release(); + void fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat=false); + QImage toImage(const QRect &r) const; + + QSymbianBitmapDataAccess *symbianBitmapDataAccess; + + CFbsBitmap *cfbsBitmap; + QPaintEngine *pengine; + uchar* bytes; + + bool formatLocked; + + QSymbianRasterPixmapData *next; + QSymbianRasterPixmapData *prev; + + static void qt_symbian_register_pixmap(QSymbianRasterPixmapData *pd); + static void qt_symbian_unregister_pixmap(QSymbianRasterPixmapData *pd); + static void qt_symbian_release_pixmaps(); + + friend class QPixmap; + friend class QS60WindowSurface; + friend class QSymbianRasterPaintEngine; + friend class QS60Data; +}; + +QT_END_NAMESPACE + +#endif // QPIXMAP_RASTER_SYMBIAN_P_H diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp deleted file mode 100644 index b55c599..0000000 --- a/src/gui/image/qpixmap_s60.cpp +++ /dev/null @@ -1,1042 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include - -#include -#include -#include -#include - -#include "qpixmap.h" -#include "qpixmap_raster_p.h" -#include -#include "qpixmap_s60_p.h" -#include "qnativeimage_p.h" -#include "qbitmap.h" -#include "qimage.h" -#include "qimage_p.h" - -#include - -QT_BEGIN_NAMESPACE - -const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, - 0x10, 0x20, 0x40, 0x80 }; - -static bool cleanup_function_registered = false; -static QS60PixmapData *firstPixmap = 0; - -// static -void QS60PixmapData::qt_symbian_register_pixmap(QS60PixmapData *pd) -{ - if (!cleanup_function_registered) { - qAddPostRoutine(qt_symbian_release_pixmaps); - cleanup_function_registered = true; - } - - pd->next = firstPixmap; - pd->prev = 0; - if (firstPixmap) - firstPixmap->prev = pd; - firstPixmap = pd; -} - -// static -void QS60PixmapData::qt_symbian_unregister_pixmap(QS60PixmapData *pd) -{ - if (pd->next) - pd->next->prev = pd->prev; - if (pd->prev) - pd->prev->next = pd->next; - else - firstPixmap = pd->next; -} - -// static -void QS60PixmapData::qt_symbian_release_pixmaps() -{ - // Scan all QS60PixmapData objects in the system and destroy them. - QS60PixmapData *pd = firstPixmap; - while (pd != 0) { - pd->release(); - pd = pd->next; - } -} - -/* - \class QSymbianFbsClient - \since 4.6 - \internal - - Symbian Font And Bitmap server client that is - used to lock the global bitmap heap. Only used in - S60 v3.1 and S60 v3.2. -*/ -_LIT(KFBSERVLargeBitmapAccessName,"FbsLargeBitmapAccess"); -class QSymbianFbsClient -{ -public: - - QSymbianFbsClient() : heapLocked(false) - { - heapLock.OpenGlobal(KFBSERVLargeBitmapAccessName); - } - - ~QSymbianFbsClient() - { - heapLock.Close(); - } - - bool lockHeap() - { - bool wasLocked = heapLocked; - - if (heapLock.Handle() && !heapLocked) { - heapLock.Wait(); - heapLocked = true; - } - - return wasLocked; - } - - bool unlockHeap() - { - bool wasLocked = heapLocked; - - if (heapLock.Handle() && heapLocked) { - heapLock.Signal(); - heapLocked = false; - } - - return wasLocked; - } - - -private: - - RMutex heapLock; - bool heapLocked; -}; - -Q_GLOBAL_STATIC(QSymbianFbsClient, qt_symbianFbsClient); - - - -// QSymbianFbsHeapLock - -QSymbianFbsHeapLock::QSymbianFbsHeapLock(LockAction a) -: action(a), wasLocked(false) -{ - QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); - if (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3) - wasLocked = qt_symbianFbsClient()->unlockHeap(); -} - -QSymbianFbsHeapLock::~QSymbianFbsHeapLock() -{ - // Do nothing -} - -void QSymbianFbsHeapLock::relock() -{ - QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion(); - if (wasLocked && (symbianVersion == QSysInfo::SV_9_2 || symbianVersion == QSysInfo::SV_9_3)) - qt_symbianFbsClient()->lockHeap(); -} - -/* - \class QSymbianBitmapDataAccess - \since 4.6 - \internal - - Data access class that is used to locks/unlocks pixel data - when drawing or modifying CFbsBitmap pixel data. -*/ -class QSymbianBitmapDataAccess -{ -public: - - static int heapRefCount; - QSysInfo::SymbianVersion symbianVersion; - - explicit QSymbianBitmapDataAccess() - { - symbianVersion = QSysInfo::symbianVersion(); - }; - - ~QSymbianBitmapDataAccess() {}; - - inline void beginDataAccess(CFbsBitmap *bitmap) - { - if (symbianVersion == QSysInfo::SV_9_2) { - if (heapRefCount == 0) - qt_symbianFbsClient()->lockHeap(); - } else { - bitmap->LockHeap(ETrue); - } - - heapRefCount++; - } - - inline void endDataAccess(CFbsBitmap *bitmap) - { - heapRefCount--; - - if (symbianVersion == QSysInfo::SV_9_2) { - if (heapRefCount == 0) - qt_symbianFbsClient()->unlockHeap(); - } else { - bitmap->UnlockHeap(ETrue); - } - } -}; - -int QSymbianBitmapDataAccess::heapRefCount = 0; - - -#define UPDATE_BUFFER() \ - { \ - beginDataAccess(); \ - endDataAccess(); \ -} - - -static CFbsBitmap* createSymbianCFbsBitmap(const TSize& size, TDisplayMode mode) -{ - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - - CFbsBitmap* bitmap = 0; - QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap); - - if (bitmap->Create(size, mode) != KErrNone) { - delete bitmap; - bitmap = 0; - } - - lock.relock(); - - return bitmap; -} - -static CFbsBitmap* uncompress(CFbsBitmap* bitmap) -{ - if(bitmap->IsCompressedInRAM()) { - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - - CFbsBitmap *uncompressed = 0; - QT_TRAP_THROWING(uncompressed = new (ELeave) CFbsBitmap); - - if (uncompressed->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) { - delete bitmap; - bitmap = 0; - lock.relock(); - - return bitmap; - } - - lock.relock(); - - CFbsBitmapDevice* bitmapDevice = 0; - CFbsBitGc *bitmapGc = 0; - QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(uncompressed)); - QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL()); - bitmapGc->Activate(bitmapDevice); - - bitmapGc->BitBlt(TPoint(), bitmap); - - delete bitmapGc; - delete bitmapDevice; - - return uncompressed; - } else { - return bitmap; - } -} - -QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h) -{ - CWsScreenDevice* screenDevice = S60->screenDevice(); - TSize screenSize = screenDevice->SizeInPixels(); - - TSize srcSize; - // Find out if this is one of our windows. - QSymbianControl *sControl; - sControl = winId->MopGetObject(sControl); - if (sControl && sControl->widget()->windowType() == Qt::Desktop) { - // Grabbing desktop widget - srcSize = screenSize; - } else { - TPoint relativePos = winId->PositionRelativeToScreen(); - x += relativePos.iX; - y += relativePos.iY; - srcSize = winId->Size(); - } - - TRect srcRect(TPoint(x, y), srcSize); - // Clip to the screen - srcRect.Intersection(TRect(screenSize)); - - if (w > 0 && h > 0) { - TRect subRect(TPoint(x, y), TSize(w, h)); - // Clip to the subRect - srcRect.Intersection(subRect); - } - - if (srcRect.IsEmpty()) - return QPixmap(); - - CFbsBitmap* temporary = createSymbianCFbsBitmap(srcRect.Size(), screenDevice->DisplayMode()); - - QPixmap pix; - - if (temporary && screenDevice->CopyScreenToBitmap(temporary, srcRect) == KErrNone) { - pix = QPixmap::fromSymbianCFbsBitmap(temporary); - } - - delete temporary; - return pix; -} - -/*! - \fn CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const - \since 4.6 - - Creates a \c CFbsBitmap that is equivalent to the QPixmap. Internally this - function will try to duplicate the handle instead of copying the data, - however in scenarios where this is not possible the data will be copied. - If the creation fails or the pixmap is null, then this function returns 0. - - It is the caller's responsibility to release the \c CFbsBitmap data - after use either by deleting the bitmap or calling \c Reset(). - - \warning On S60 3.1 and S60 3.2, semi-transparent pixmaps are always copied - and not duplicated. - \warning This function is only available on Symbian OS. - - \sa fromSymbianCFbsBitmap() -*/ -CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const -{ - QPixmapData *data = pixmapData(); - if (!data || data->isNull()) - return 0; - - return reinterpret_cast(data->toNativeType(QPixmapData::FbsBitmap)); -} - -/*! - \fn QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) - \since 4.6 - - Creates a QPixmap from a \c CFbsBitmap \a bitmap. Internally this function - will try to duplicate the bitmap handle instead of copying the data, however - in scenarios where this is not possible the data will be copied. - To be sure that QPixmap does not modify your original instance, you should - make a copy of your \c CFbsBitmap before calling this function. - If the CFbsBitmap is not valid this function will return a null QPixmap. - For performance reasons it is recommended to use a \a bitmap with a display - mode of EColor16MAP or EColor16MU whenever possible. - - \warning This function is only available on Symbian OS. - - \sa toSymbianCFbsBitmap(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} -*/ -QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) -{ - if (!bitmap) - return QPixmap(); - - QScopedPointer data(QPixmapData::create(0,0, QPixmapData::PixmapType)); - data->fromNativeType(reinterpret_cast(bitmap), QPixmapData::FbsBitmap); - QPixmap pixmap(data.take()); - return pixmap; -} - -QS60PixmapData::QS60PixmapData(PixelType type) : QRasterPixmapData(type), - symbianBitmapDataAccess(new QSymbianBitmapDataAccess), - cfbsBitmap(0), - pengine(0), - bytes(0), - formatLocked(false), - next(0), - prev(0) -{ - qt_symbian_register_pixmap(this); -} - -QS60PixmapData::~QS60PixmapData() -{ - release(); - delete symbianBitmapDataAccess; - qt_symbian_unregister_pixmap(this); -} - -void QS60PixmapData::resize(int width, int height) -{ - if (width <= 0 || height <= 0) { - w = width; - h = height; - is_null = true; - - release(); - return; - } else if (!cfbsBitmap) { - TDisplayMode mode; - if (pixelType() == BitmapType) - mode = EGray2; - else - mode = EColor16MU; - - CFbsBitmap* bitmap = createSymbianCFbsBitmap(TSize(width, height), mode); - fromSymbianBitmap(bitmap); - } else { - - TSize newSize(width, height); - - if(cfbsBitmap->SizeInPixels() != newSize) { - cfbsBitmap->Resize(TSize(width, height)); - if(pengine) { - delete pengine; - pengine = 0; - } - } - - UPDATE_BUFFER(); - } -} - -void QS60PixmapData::release() -{ - if (cfbsBitmap) { - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - delete cfbsBitmap; - lock.relock(); - } - - delete pengine; - image = QImage(); - cfbsBitmap = 0; - pengine = 0; - bytes = 0; -} - -/*! - * Takes ownership of bitmap. Used by window surface - */ -void QS60PixmapData::fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat) -{ - Q_ASSERT(bitmap); - - release(); - - cfbsBitmap = bitmap; - formatLocked = lockFormat; - - setSerialNumber(cfbsBitmap->Handle()); - - UPDATE_BUFFER(); - - // Create default palette if needed - if (cfbsBitmap->DisplayMode() == EGray2) { - image.setColorCount(2); - image.setColor(0, QColor(Qt::color0).rgba()); - image.setColor(1, QColor(Qt::color1).rgba()); - - //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid - //So invert mono bitmaps so that masks work correctly. - image.invertPixels(); - } else if (cfbsBitmap->DisplayMode() == EGray256) { - for (int i=0; i < 256; ++i) - image.setColor(i, qRgb(i, i, i)); - } else if (cfbsBitmap->DisplayMode() == EColor256) { - const TColor256Util *palette = TColor256Util::Default(); - for (int i=0; i < 256; ++i) - image.setColor(i, (QRgb)(palette->Color256(i).Value())); - } -} - -QImage QS60PixmapData::toImage(const QRect &r) const -{ - QS60PixmapData *that = const_cast(this); - that->beginDataAccess(); - QImage copy = that->image.copy(r); - that->endDataAccess(); - - return copy; -} - -void QS60PixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) -{ - release(); - - QImage sourceImage; - - if (pixelType() == BitmapType) { - sourceImage = img.convertToFormat(QImage::Format_MonoLSB); - } else { - if (img.depth() == 1) { - sourceImage = img.hasAlphaChannel() - ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) - : img.convertToFormat(QImage::Format_RGB32); - } else { - - QImage::Format opaqueFormat = QNativeImage::systemFormat(); - QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; - - if (!img.hasAlphaChannel() - || ((flags & Qt::NoOpaqueDetection) == 0 - && !const_cast(img).data_ptr()->checkForAlphaPixels())) { - sourceImage = img.convertToFormat(opaqueFormat); - } else { - sourceImage = img.convertToFormat(alphaFormat); - } - } - } - - - QImage::Format destFormat = sourceImage.format(); - TDisplayMode mode; - switch (destFormat) { - case QImage::Format_MonoLSB: - mode = EGray2; - break; - case QImage::Format_RGB32: - mode = EColor16MU; - break; - case QImage::Format_ARGB32_Premultiplied: - if (S60->supportsPremultipliedAlpha) { - mode = Q_SYMBIAN_ECOLOR16MAP; - break; - } else { - destFormat = QImage::Format_ARGB32; - } - // Fall through intended - case QImage::Format_ARGB32: - mode = EColor16MA; - break; - case QImage::Format_Invalid: - return; - default: - qWarning("Image format not supported: %d", image.format()); - return; - } - - cfbsBitmap = createSymbianCFbsBitmap(TSize(sourceImage.width(), sourceImage.height()), mode); - if (!cfbsBitmap) { - qWarning("Could not create CFbsBitmap"); - release(); - return; - } - - setSerialNumber(cfbsBitmap->Handle()); - - const uchar *sptr = const_cast(sourceImage).bits(); - symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); - uchar *dptr = (uchar*)cfbsBitmap->DataAddress(); - Mem::Copy(dptr, sptr, sourceImage.byteCount()); - symbianBitmapDataAccess->endDataAccess(cfbsBitmap); - - UPDATE_BUFFER(); - - if (destFormat == QImage::Format_MonoLSB) { - image.setColorCount(2); - image.setColor(0, QColor(Qt::color0).rgba()); - image.setColor(1, QColor(Qt::color1).rgba()); - } else { - image.setColorTable(sourceImage.colorTable()); - } -} - -void QS60PixmapData::copy(const QPixmapData *data, const QRect &rect) -{ - const QS60PixmapData *s60Data = static_cast(data); - fromImage(s60Data->toImage(rect), Qt::AutoColor | Qt::OrderedAlphaDither); -} - -bool QS60PixmapData::scroll(int dx, int dy, const QRect &rect) -{ - beginDataAccess(); - bool res = QRasterPixmapData::scroll(dx, dy, rect); - endDataAccess(); - return res; -} - -Q_GUI_EXPORT int qt_defaultDpiX(); -Q_GUI_EXPORT int qt_defaultDpiY(); - -int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const -{ - if (!cfbsBitmap) - return 0; - - switch (metric) { - case QPaintDevice::PdmWidth: - return cfbsBitmap->SizeInPixels().iWidth; - case QPaintDevice::PdmHeight: - return cfbsBitmap->SizeInPixels().iHeight; - case QPaintDevice::PdmWidthMM: - return qRound(cfbsBitmap->SizeInPixels().iWidth * 25.4 / qt_defaultDpiX()); - case QPaintDevice::PdmHeightMM: - return qRound(cfbsBitmap->SizeInPixels().iHeight * 25.4 / qt_defaultDpiY()); - case QPaintDevice::PdmNumColors: - return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode()); - case QPaintDevice::PdmDpiX: - case QPaintDevice::PdmPhysicalDpiX: - return qt_defaultDpiX(); - case QPaintDevice::PdmDpiY: - case QPaintDevice::PdmPhysicalDpiY: - return qt_defaultDpiY(); - case QPaintDevice::PdmDepth: - return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode()); - default: - qWarning("QPixmap::metric: Invalid metric command"); - } - return 0; - -} - -void QS60PixmapData::fill(const QColor &color) -{ - if (color.alpha() != 255) { - QImage im(width(), height(), QImage::Format_ARGB32_Premultiplied); - im.fill(PREMUL(color.rgba())); - release(); - fromImage(im, Qt::AutoColor | Qt::OrderedAlphaDither); - } else { - beginDataAccess(); - QRasterPixmapData::fill(color); - endDataAccess(); - } -} - -void QS60PixmapData::setMask(const QBitmap &mask) -{ - if (mask.size().isEmpty()) { - if (image.depth() != 1) { - QImage newImage = image.convertToFormat(QImage::Format_RGB32); - release(); - fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither); - } - } else if (image.depth() == 1) { - beginDataAccess(); - QRasterPixmapData::setMask(mask); - endDataAccess(); - } else { - const int w = image.width(); - const int h = image.height(); - - const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB); - QImage newImage = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); - for (int y = 0; y < h; ++y) { - const uchar *mscan = imageMask.scanLine(y); - QRgb *tscan = (QRgb *)newImage.scanLine(y); - for (int x = 0; x < w; ++x) { - if (!(mscan[x>>3] & qt_pixmap_bit_mask[x&7])) - tscan[x] = 0; - } - } - release(); - fromImage(newImage, Qt::AutoColor | Qt::OrderedAlphaDither); - } -} - -void QS60PixmapData::setAlphaChannel(const QPixmap &alphaChannel) -{ - QImage img(toImage()); - img.setAlphaChannel(alphaChannel.toImage()); - release(); - fromImage(img, Qt::OrderedDither | Qt::OrderedAlphaDither); -} - -QImage QS60PixmapData::toImage() const -{ - return toImage(QRect()); -} - -QPaintEngine* QS60PixmapData::paintEngine() const -{ - if (!pengine) { - QS60PixmapData *that = const_cast(this); - that->pengine = new QS60PaintEngine(&that->image, that); - } - return pengine; -} - -void QS60PixmapData::beginDataAccess() -{ - if(!cfbsBitmap) - return; - - symbianBitmapDataAccess->beginDataAccess(cfbsBitmap); - - uchar* newBytes = (uchar*)cfbsBitmap->DataAddress(); - - TSize size = cfbsBitmap->SizeInPixels(); - - if (newBytes == bytes && image.width() == size.iWidth && image.height() == size.iHeight) - return; - - bytes = newBytes; - TDisplayMode mode = cfbsBitmap->DisplayMode(); - QImage::Format format = qt_TDisplayMode2Format(mode); - // On S60 3.1, premultiplied alpha pixels are stored in a bitmap with 16MA type. - // S60 window surface needs backing store pixmap for transparent window in ARGB32 format. - // In that case formatLocked is true. - if (!formatLocked && format == QImage::Format_ARGB32) - format = QImage::Format_ARGB32_Premultiplied; // pixel data is actually in premultiplied format - - QVector savedColorTable; - if (!image.isNull()) - savedColorTable = image.colorTable(); - - image = QImage(bytes, size.iWidth, size.iHeight, format); - - // Restore the palette or create a default - if (!savedColorTable.isEmpty()) { - image.setColorTable(savedColorTable); - } - - w = size.iWidth; - h = size.iHeight; - d = image.depth(); - is_null = (w <= 0 || h <= 0); - - if (pengine) { - QS60PaintEngine *engine = static_cast(pengine); - engine->prepare(&image); - } -} - -void QS60PixmapData::endDataAccess(bool readOnly) const -{ - Q_UNUSED(readOnly); - - if(!cfbsBitmap) - return; - - symbianBitmapDataAccess->endDataAccess(cfbsBitmap); -} - -/*! - \since 4.6 - - Returns a QPixmap that wraps given \a sgImage graphics resource. - The data should be valid even when original RSgImage handle has been - closed. - - \warning This function is only available on Symbian OS. - - \sa toSymbianRSgImage(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} -*/ - -QPixmap QPixmap::fromSymbianRSgImage(RSgImage *sgImage) -{ - // It is expected that RSgImage will - // CURRENTLY be used in conjuction with - // OpenVG graphics system - // - // Surely things might change in future - - if (!sgImage) - return QPixmap(); - - QScopedPointer data(QPixmapData::create(0,0, QPixmapData::PixmapType)); - data->fromNativeType(reinterpret_cast(sgImage), QPixmapData::SgImage); - QPixmap pixmap(data.take()); - return pixmap; -} - -/*! -\since 4.6 - -Returns a \c RSgImage that is equivalent to the QPixmap by copying the data. - -It is the caller's responsibility to close/delete the \c RSgImage after use. - -\warning This function is only available on Symbian OS. - -\sa fromSymbianRSgImage() -*/ - -RSgImage *QPixmap::toSymbianRSgImage() const -{ - // It is expected that RSgImage will - // CURRENTLY be used in conjuction with - // OpenVG graphics system - // - // Surely things might change in future - - if (isNull()) - return 0; - - RSgImage *sgImage = reinterpret_cast(pixmapData()->toNativeType(QPixmapData::SgImage)); - - return sgImage; -} - -void* QS60PixmapData::toNativeType(NativeType type) -{ - if (type == QPixmapData::SgImage) { - return 0; - } else if (type == QPixmapData::FbsBitmap) { - - if (isNull() || !cfbsBitmap) - return 0; - - bool convertToArgb32 = false; - bool needsCopy = false; - - if (!(S60->supportsPremultipliedAlpha)) { - // Convert argb32_premultiplied to argb32 since Symbian 9.2 does - // not support premultipied format. - - if (image.format() == QImage::Format_ARGB32_Premultiplied) { - needsCopy = true; - convertToArgb32 = true; - } - } - - CFbsBitmap *bitmap = 0; - - TDisplayMode displayMode = cfbsBitmap->DisplayMode(); - - if(displayMode == EGray2) { - //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid - //So invert mono bitmaps so that masks work correctly. - beginDataAccess(); - image.invertPixels(); - endDataAccess(); - needsCopy = true; - } - - if (needsCopy) { - QImage source; - - if (convertToArgb32) { - beginDataAccess(); - source = image.convertToFormat(QImage::Format_ARGB32); - endDataAccess(); - displayMode = EColor16MA; - } else { - source = image; - } - - CFbsBitmap *newBitmap = createSymbianCFbsBitmap(TSize(source.width(), source.height()), displayMode); - const uchar *sptr = source.bits(); - symbianBitmapDataAccess->beginDataAccess(newBitmap); - - uchar *dptr = (uchar*)newBitmap->DataAddress(); - Mem::Copy(dptr, sptr, source.byteCount()); - - symbianBitmapDataAccess->endDataAccess(newBitmap); - - bitmap = newBitmap; - } else { - - QT_TRAP_THROWING(bitmap = new (ELeave) CFbsBitmap); - - TInt err = bitmap->Duplicate(cfbsBitmap->Handle()); - if (err != KErrNone) { - qWarning("Could not duplicate CFbsBitmap"); - delete bitmap; - bitmap = 0; - } - } - - if(displayMode == EGray2) { - // restore pixels - beginDataAccess(); - image.invertPixels(); - endDataAccess(); - } - - return reinterpret_cast(bitmap); - - } - - return 0; -} - -void QS60PixmapData::fromNativeType(void* pixmap, NativeType nativeType) -{ - if (nativeType == QPixmapData::SgImage) { - return; - } else if (nativeType == QPixmapData::FbsBitmap && pixmap) { - - CFbsBitmap *bitmap = reinterpret_cast(pixmap); - - bool deleteSourceBitmap = false; - bool needsCopy = false; - -#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE - - // Rasterize extended bitmaps - - TUid extendedBitmapType = bitmap->ExtendedBitmapType(); - if (extendedBitmapType != KNullUid) { - CFbsBitmap *rasterBitmap = createSymbianCFbsBitmap(bitmap->SizeInPixels(), EColor16MA); - - CFbsBitmapDevice *rasterBitmapDev = 0; - QT_TRAP_THROWING(rasterBitmapDev = CFbsBitmapDevice::NewL(rasterBitmap)); - - CFbsBitGc *rasterBitmapGc = 0; - TInt err = rasterBitmapDev->CreateContext(rasterBitmapGc); - if (err != KErrNone) { - delete rasterBitmap; - delete rasterBitmapDev; - rasterBitmapDev = 0; - return; - } - - rasterBitmapGc->BitBlt(TPoint( 0, 0), bitmap); - - bitmap = rasterBitmap; - - delete rasterBitmapDev; - delete rasterBitmapGc; - - rasterBitmapDev = 0; - rasterBitmapGc = 0; - - deleteSourceBitmap = true; - } -#endif - - - deleteSourceBitmap = bitmap->IsCompressedInRAM(); - CFbsBitmap *sourceBitmap = uncompress(bitmap); - - TDisplayMode displayMode = sourceBitmap->DisplayMode(); - QImage::Format format = qt_TDisplayMode2Format(displayMode); - - QImage::Format opaqueFormat = QNativeImage::systemFormat(); - QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; - - if (format != opaqueFormat && format != alphaFormat && format != QImage::Format_MonoLSB) - needsCopy = true; - - - type = (format != QImage::Format_MonoLSB) - ? QPixmapData::PixmapType - : QPixmapData::BitmapType; - - if (needsCopy) { - - TSize size = sourceBitmap->SizeInPixels(); - int bytesPerLine = sourceBitmap->ScanLineLength(size.iWidth, displayMode); - - QSymbianBitmapDataAccess da; - da.beginDataAccess(sourceBitmap); - uchar *bytes = (uchar*)sourceBitmap->DataAddress(); - QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format); - img = img.copy(); - da.endDataAccess(sourceBitmap); - - if(displayMode == EGray2) { - //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid - //So invert mono bitmaps so that masks work correctly. - img.invertPixels(); - } else if(displayMode == EColor16M) { - img = img.rgbSwapped(); // EColor16M is BGR - } - - fromImage(img, Qt::AutoColor); - - if(deleteSourceBitmap) - delete sourceBitmap; - } else { - CFbsBitmap* duplicate = 0; - QT_TRAP_THROWING(duplicate = new (ELeave) CFbsBitmap); - - TInt err = duplicate->Duplicate(sourceBitmap->Handle()); - if (err != KErrNone) { - qWarning("Could not duplicate CFbsBitmap"); - - if(deleteSourceBitmap) - delete sourceBitmap; - - delete duplicate; - return; - } - - fromSymbianBitmap(duplicate); - - if(deleteSourceBitmap) - delete sourceBitmap; - } - } -} - -void QS60PixmapData::convertToDisplayMode(int mode) -{ - const TDisplayMode displayMode = static_cast(mode); - if (!cfbsBitmap || cfbsBitmap->DisplayMode() == displayMode) - return; - if (image.depth() != TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)) { - qWarning("Cannot convert display mode due to depth mismatch"); - return; - } - - const TSize size = cfbsBitmap->SizeInPixels(); - QScopedPointer newBitmap(createSymbianCFbsBitmap(size, displayMode)); - - const uchar *sptr = const_cast(image).bits(); - symbianBitmapDataAccess->beginDataAccess(newBitmap.data()); - uchar *dptr = (uchar*)newBitmap->DataAddress(); - Mem::Copy(dptr, sptr, image.byteCount()); - symbianBitmapDataAccess->endDataAccess(newBitmap.data()); - - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - delete cfbsBitmap; - lock.relock(); - cfbsBitmap = newBitmap.take(); - setSerialNumber(cfbsBitmap->Handle()); - UPDATE_BUFFER(); -} - -QPixmapData *QS60PixmapData::createCompatiblePixmapData() const -{ - return new QS60PixmapData(pixelType()); -} - -QT_END_NAMESPACE diff --git a/src/gui/image/qpixmap_s60_p.h b/src/gui/image/qpixmap_s60_p.h deleted file mode 100644 index e481549..0000000 --- a/src/gui/image/qpixmap_s60_p.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPIXMAPDATA_S60_P_H -#define QPIXMAPDATA_S60_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class CFbsBitmap; -class CFbsBitmapDevice; -class CFbsBitGc; - -class QSymbianBitmapDataAccess; - -class QSymbianFbsHeapLock -{ -public: - - enum LockAction { - Unlock - }; - - explicit QSymbianFbsHeapLock(LockAction a); - ~QSymbianFbsHeapLock(); - void relock(); - -private: - - LockAction action; - bool wasLocked; -}; - -class QS60PixmapData : public QRasterPixmapData -{ -public: - QS60PixmapData(PixelType type); - ~QS60PixmapData(); - - QPixmapData *createCompatiblePixmapData() const; - - void resize(int width, int height); - void fromImage(const QImage &image, Qt::ImageConversionFlags flags); - void copy(const QPixmapData *data, const QRect &rect); - bool scroll(int dx, int dy, const QRect &rect); - - int metric(QPaintDevice::PaintDeviceMetric metric) const; - void fill(const QColor &color); - void setMask(const QBitmap &mask); - void setAlphaChannel(const QPixmap &alphaChannel); - QImage toImage() const; - QPaintEngine* paintEngine() const; - - void beginDataAccess(); - void endDataAccess(bool readOnly=false) const; - - void* toNativeType(NativeType type); - void fromNativeType(void* pixmap, NativeType type); - - void convertToDisplayMode(int mode); - -private: - void release(); - void fromSymbianBitmap(CFbsBitmap* bitmap, bool lockFormat=false); - QImage toImage(const QRect &r) const; - - QSymbianBitmapDataAccess *symbianBitmapDataAccess; - - CFbsBitmap *cfbsBitmap; - QPaintEngine *pengine; - uchar* bytes; - - bool formatLocked; - - QS60PixmapData *next; - QS60PixmapData *prev; - - static void qt_symbian_register_pixmap(QS60PixmapData *pd); - static void qt_symbian_unregister_pixmap(QS60PixmapData *pd); - static void qt_symbian_release_pixmaps(); - - friend class QPixmap; - friend class QS60WindowSurface; - friend class QS60PaintEngine; - friend class QS60Data; -}; - -QT_END_NAMESPACE - -#endif // QPIXMAPDATA_S60_P_H - diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index cf089fb..f868bad 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -158,7 +158,7 @@ protected: private: friend class QPixmap; friend class QX11PixmapData; - friend class QS60PixmapData; + friend class QSymbianRasterPixmapData; friend class QImagePixmapCleanupHooks; // Needs to set is_cached friend class QGLTextureCache; //Needs to check the reference count friend class QExplicitlySharedDataPointer; diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp index c74cb7c..060f7fd 100644 --- a/src/gui/image/qpixmapdatafactory.cpp +++ b/src/gui/image/qpixmapdatafactory.cpp @@ -54,7 +54,7 @@ # include #endif #ifdef Q_OS_SYMBIAN -# include +# include #endif #include "private/qapplication_p.h" @@ -83,7 +83,7 @@ QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type) #elif defined(Q_WS_MAC) return new QMacPixmapData(type); #elif defined(Q_OS_SYMBIAN) - return new QS60PixmapData(type); + return new QSymbianRasterPixmapData(type); #else #error QSimplePixmapDataFactory::create() not implemented #endif diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 6896b7d..96b82da 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1917,7 +1917,7 @@ void qt_cleanup() qt_S60Beep = 0; } QFontCache::cleanup(); // Has to happen now, since QFontEngineS60 has FBS handles - QPixmapCache::clear(); // Has to happen now, since QS60PixmapData has FBS handles + QPixmapCache::clear(); // Has to happen now, since QSymbianRasterPixmapData has FBS handles qt_cleanup_symbianFontDatabase(); // S60 structure and window server session are freed in eventdispatcher destructor as they are needed there diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index b3b647a..8ee65b5 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -184,12 +184,12 @@ embedded { symbian { SOURCES += \ - painting/qpaintengine_s60.cpp \ + painting/qpaintengine_raster_symbian.cpp \ painting/qregion_s60.cpp \ painting/qcolormap_s60.cpp HEADERS += \ - painting/qpaintengine_s60_p.h + painting/qpaintengine_raster_symbian_p.h } x11|embedded { diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index 22bf193..455f07b 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -51,7 +51,7 @@ # include #endif #ifdef Q_OS_SYMBIAN -# include +# include # include #else # include @@ -75,7 +75,7 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ #elif defined(Q_WS_MAC) return new QMacPixmapData(type); #elif defined(Q_OS_SYMBIAN) - return new QS60PixmapData(type); + return new QSymbianRasterPixmapData(type); #elif !defined(Q_WS_QWS) #error QGraphicsSystem::createDefaultPixmapData() not implemented #endif diff --git a/src/gui/painting/qgraphicssystem_raster.cpp b/src/gui/painting/qgraphicssystem_raster.cpp index 0edbe9f..addfff7 100644 --- a/src/gui/painting/qgraphicssystem_raster.cpp +++ b/src/gui/painting/qgraphicssystem_raster.cpp @@ -42,7 +42,7 @@ #include "qgraphicssystem_raster_p.h" #ifdef Q_OS_SYMBIAN -#include "private/qpixmap_s60_p.h" +#include "private/qpixmap_raster_symbian_p.h" #include "private/qwindowsurface_s60_p.h" #else #include "private/qpixmap_raster_p.h" @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE QPixmapData *QRasterGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { #ifdef Q_OS_SYMBIAN - return new QS60PixmapData(type); + return new QSymbianRasterPixmapData(type); #else return new QRasterPixmapData(type); #endif diff --git a/src/gui/painting/qpaintengine_raster_symbian.cpp b/src/gui/painting/qpaintengine_raster_symbian.cpp new file mode 100644 index 0000000..3b27077 --- /dev/null +++ b/src/gui/painting/qpaintengine_raster_symbian.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QSymbianRasterPaintEnginePrivate : public QRasterPaintEnginePrivate +{ +public: + QSymbianRasterPaintEnginePrivate() {} +}; + +QSymbianRasterPaintEngine::QSymbianRasterPaintEngine(QPaintDevice *device, QSymbianRasterPixmapData *data) + : QRasterPaintEngine(*(new QSymbianRasterPaintEnginePrivate), device), pixmapData(data) +{ +} + +bool QSymbianRasterPaintEngine::begin(QPaintDevice *device) +{ + Q_D(QSymbianRasterPaintEngine); + + if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { + pixmapData->beginDataAccess(); + bool ret = QRasterPaintEngine::begin(device); + // Make sure QPaintEngine::paintDevice() returns the proper device. + // QRasterPaintEngine changes pdev to QImage in case of RasterClass QPixmapData + // which is incorrect in Symbian. + d->pdev = device; + return ret; + } + return QRasterPaintEngine::begin(device); +} + +bool QSymbianRasterPaintEngine::end() +{ + if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { + bool ret = QRasterPaintEngine::end(); + pixmapData->endDataAccess(); + return ret; + } + return QRasterPaintEngine::end(); +} + +void QSymbianRasterPaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) +{ + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QSymbianRasterPixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawPixmap(p, pm); + srcData->endDataAccess(); + } else { + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + // imageRef() would detach and since we received the QVolatileImage + // from toVolatileImage() by value, it would cause a copy which + // would ruin our goal. So use constImageRef() instead. + QRasterPaintEngine::drawImage(p, img.constImageRef()); + img.endDataAccess(true); + } else { + QRasterPaintEngine::drawPixmap(p, pm); + } + } +} + +void QSymbianRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) +{ + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QSymbianRasterPixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawPixmap(r, pm, sr); + srcData->endDataAccess(); + } else { + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + QRasterPaintEngine::drawImage(r, img.constImageRef(), sr); + img.endDataAccess(true); + } else { + QRasterPaintEngine::drawPixmap(r, pm, sr); + } + } +} + +void QSymbianRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) +{ + if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { + QSymbianRasterPixmapData *srcData = static_cast(pm.pixmapData()); + srcData->beginDataAccess(); + QRasterPaintEngine::drawTiledPixmap(r, pm, sr); + srcData->endDataAccess(); + } else { + QRasterPaintEngine::drawTiledPixmap(r, pm, sr); + } +} + +// used by QSymbianRasterPixmapData::beginDataAccess() +void QSymbianRasterPaintEngine::prepare(QImage *image) +{ + QRasterBuffer *buffer = d_func()->rasterBuffer.data(); + if (buffer) + buffer->prepare(image); +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengine_raster_symbian_p.h b/src/gui/painting/qpaintengine_raster_symbian_p.h new file mode 100644 index 0000000..cb51ecb --- /dev/null +++ b/src/gui/painting/qpaintengine_raster_symbian_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPAINTENGINE_RASTER_SYMBIAN_P_H +#define QPAINTENGINE_RASTER_SYMBIAN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qpaintengine_raster_p.h" + +QT_BEGIN_NAMESPACE + +class QSymbianRasterPaintEnginePrivate; +class QSymbianRasterPixmapData; + +class QSymbianRasterPaintEngine : public QRasterPaintEngine +{ + Q_DECLARE_PRIVATE(QSymbianRasterPaintEngine) + +public: + QSymbianRasterPaintEngine(QPaintDevice *device, QSymbianRasterPixmapData *data = 0); + bool begin(QPaintDevice *device); + bool end(); + + void drawPixmap(const QPointF &p, const QPixmap &pm); + void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); + void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr); + + void prepare(QImage* image); + +private: + QSymbianRasterPixmapData *pixmapData; +}; + +QT_END_NAMESPACE + +#endif // QPAINTENGINE_RASTER_SYMBIAN_P_H diff --git a/src/gui/painting/qpaintengine_s60.cpp b/src/gui/painting/qpaintengine_s60.cpp deleted file mode 100644 index fd7bea2..0000000 --- a/src/gui/painting/qpaintengine_s60.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QS60PaintEnginePrivate : public QRasterPaintEnginePrivate -{ -public: - QS60PaintEnginePrivate() {} -}; - -QS60PaintEngine::QS60PaintEngine(QPaintDevice *device, QS60PixmapData *data) - : QRasterPaintEngine(*(new QS60PaintEnginePrivate), device), pixmapData(data) -{ -} - -bool QS60PaintEngine::begin(QPaintDevice *device) -{ - Q_D(QS60PaintEngine); - - if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { - pixmapData->beginDataAccess(); - bool ret = QRasterPaintEngine::begin(device); - // Make sure QPaintEngine::paintDevice() returns the proper device. - // QRasterPaintEngine changes pdev to QImage in case of RasterClass QPixmapData - // which is incorrect in Symbian. - d->pdev = device; - return ret; - } - return QRasterPaintEngine::begin(device); -} - -bool QS60PaintEngine::end() -{ - if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { - bool ret = QRasterPaintEngine::end(); - pixmapData->endDataAccess(); - return ret; - } - return QRasterPaintEngine::end(); -} - -void QS60PaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) -{ - if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawPixmap(p, pm); - srcData->endDataAccess(); - } else { - QVolatileImage img = pm.pixmapData()->toVolatileImage(); - if (!img.isNull()) { - img.beginDataAccess(); - // imageRef() would detach and since we received the QVolatileImage - // from toVolatileImage() by value, it would cause a copy which - // would ruin our goal. So use constImageRef() instead. - QRasterPaintEngine::drawImage(p, img.constImageRef()); - img.endDataAccess(true); - } else { - QRasterPaintEngine::drawPixmap(p, pm); - } - } -} - -void QS60PaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) -{ - if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawPixmap(r, pm, sr); - srcData->endDataAccess(); - } else { - QVolatileImage img = pm.pixmapData()->toVolatileImage(); - if (!img.isNull()) { - img.beginDataAccess(); - QRasterPaintEngine::drawImage(r, img.constImageRef(), sr); - img.endDataAccess(true); - } else { - QRasterPaintEngine::drawPixmap(r, pm, sr); - } - } -} - -void QS60PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) -{ - if (pm.pixmapData()->classId() == QPixmapData::RasterClass) { - QS60PixmapData *srcData = static_cast(pm.pixmapData()); - srcData->beginDataAccess(); - QRasterPaintEngine::drawTiledPixmap(r, pm, sr); - srcData->endDataAccess(); - } else { - QRasterPaintEngine::drawTiledPixmap(r, pm, sr); - } -} - -void QS60PaintEngine::prepare(QImage *image) -{ - QRasterBuffer *buffer = d_func()->rasterBuffer.data(); - if (buffer) - buffer->prepare(image); -} - -QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengine_s60_p.h b/src/gui/painting/qpaintengine_s60_p.h deleted file mode 100644 index 5535c24..0000000 --- a/src/gui/painting/qpaintengine_s60_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPAINTENGINE_S60_P_H -#define QPAINTENGINE_S60_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qpaintengine_raster_p.h" - -QT_BEGIN_NAMESPACE - -class QS60PaintEnginePrivate; -class QS60PixmapData; - -class QS60PaintEngine : public QRasterPaintEngine -{ - Q_DECLARE_PRIVATE(QS60PaintEngine) - -public: - QS60PaintEngine(QPaintDevice *device, QS60PixmapData *data = 0); - bool begin(QPaintDevice *device); - bool end(); - - void drawPixmap(const QPointF &p, const QPixmap &pm); - void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); - void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr); - - void prepare(QImage* image); - -private: - QS60PixmapData *pixmapData; -}; - -QT_END_NAMESPACE - -#endif // QPAINTENGINE_S60_P_H diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 5b280ad..116962f 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -91,7 +91,7 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget) CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) ); - QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType); + QSymbianRasterPixmapData *data = new QSymbianRasterPixmapData(QPixmapData::PixmapType); if (data) { data->fromSymbianBitmap(bitmap, true); d_ptr->device = QPixmap(data); @@ -132,7 +132,7 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn) QWidgetPrivate *windowPrivate = qt_widget_private(window()); if (!windowPrivate->isOpaque || blitWriteAlpha(windowPrivate)) { - QS60PixmapData *pixmapData = static_cast(d_ptr->device.data_ptr().data()); + QSymbianRasterPixmapData *pixmapData = static_cast(d_ptr->device.data_ptr().data()); TDisplayMode mode = displayMode(false); if (pixmapData->cfbsBitmap->DisplayMode() != mode) @@ -170,7 +170,7 @@ QImage* QS60WindowSurface::buffer(const QWidget *widget) return 0; const QPoint off = offset(widget); - QImage *img = &(static_cast(d_ptr->device.data_ptr().data())->image); + QImage *img = &(static_cast(d_ptr->device.data_ptr().data())->image); QRect rect(off, widget->size()); rect &= QRect(QPoint(), img->size()); @@ -218,7 +218,7 @@ bool QS60WindowSurface::scroll(const QRegion &area, int dx, int dy) if (d_ptr->device.isNull()) return false; - QS60PixmapData *data = static_cast(d_ptr->device.data_ptr().data()); + QSymbianRasterPixmapData *data = static_cast(d_ptr->device.data_ptr().data()); data->scroll(dx, dy, rect); return true; @@ -234,7 +234,7 @@ void QS60WindowSurface::setGeometry(const QRect& rect) if (rect == geometry()) return; - QS60PixmapData *data = static_cast(d_ptr->device.data_ptr().data()); + QSymbianRasterPixmapData *data = static_cast(d_ptr->device.data_ptr().data()); data->resize(rect.width(), rect.height()); QWindowSurface::setGeometry(rect); @@ -242,7 +242,7 @@ void QS60WindowSurface::setGeometry(const QRect& rect) CFbsBitmap* QS60WindowSurface::symbianBitmap() const { - QS60PixmapData *data = static_cast(d_ptr->device.data_ptr().data()); + QSymbianRasterPixmapData *data = static_cast(d_ptr->device.data_ptr().data()); return data->cfbsBitmap; } diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 4018702..5699dbb 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -45,7 +45,7 @@ #include "qstyleoption.h" #include "qstyle.h" #include "private/qt_s60_p.h" -#include "private/qpixmap_s60_p.h" +#include "private/qpixmap_raster_symbian_p.h" #include "private/qcore_symbian_p.h" #include "private/qvolatileimage_p.h" #include "qapplication.h" diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp index 8d0ed75..a7a2547 100644 --- a/src/gui/text/qfont_s60.cpp +++ b/src/gui/text/qfont_s60.cpp @@ -42,7 +42,7 @@ #include "qfont.h" #include "qfont_p.h" #include -#include +#include #include "qmutex.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 3514fd3..6ede1f1 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -47,7 +47,7 @@ #include "qdesktopservices.h" #include "qtemporaryfile.h" #include "qtextcodec.h" -#include +#include #include #include "qendian.h" #include diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 8c60709..6b93efa 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -46,7 +46,7 @@ #include #include "qimage.h" #include -#include +#include #include #include diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp index 20c2170..21671a6 100644 --- a/src/opengl/qgl_symbian.cpp +++ b/src/opengl/qgl_symbian.cpp @@ -39,11 +39,10 @@ ** ****************************************************************************/ - #include "qgl.h" #include #include -#include +#include #include #include #include -- cgit v0.12 From a4ff08bd1eb0ca91d795792cdd7454fcda4ca15d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 16 Jun 2011 15:16:41 +0200 Subject: Improving warning messages in QVolatileImage. Reviewed-by: Jani Hautakangas --- src/gui/image/qvolatileimagedata_symbian.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gui/image/qvolatileimagedata_symbian.cpp b/src/gui/image/qvolatileimagedata_symbian.cpp index 6984722..c20c417 100644 --- a/src/gui/image/qvolatileimagedata_symbian.cpp +++ b/src/gui/image/qvolatileimagedata_symbian.cpp @@ -53,8 +53,11 @@ static CFbsBitmap *rasterizeBitmap(CFbsBitmap *bitmap, TDisplayMode newMode) return 0; } QScopedPointer newBitmap(new CFbsBitmap); - if (newBitmap->Create(bitmap->SizeInPixels(), newMode) != KErrNone) { - qWarning("QVolatileImage: Failed to create new bitmap"); + const TSize size = bitmap->SizeInPixels(); + TInt err = newBitmap->Create(size, newMode); + if (err != KErrNone) { + qWarning("QVolatileImage: Failed to create new bitmap (w %d h %d dispmode %d err %d)", + size.iWidth, size.iHeight, newMode, err); return 0; } CFbsBitmapDevice *bitmapDevice = 0; @@ -97,6 +100,7 @@ static inline TDisplayMode format2TDisplayMode(QImage::Format format) mode = Q_SYMBIAN_ECOLOR16MAP; break; default: + qWarning("QVolatileImage: Unknown image format %d", format); mode = ENone; break; } @@ -109,8 +113,9 @@ static CFbsBitmap *imageToBitmap(const QImage &image) return 0; } CFbsBitmap *bitmap = new CFbsBitmap; - if (bitmap->Create(TSize(image.width(), image.height()), - format2TDisplayMode(image.format())) == KErrNone) { + TInt err = bitmap->Create(TSize(image.width(), image.height()), + format2TDisplayMode(image.format())); + if (err == KErrNone) { bitmap->BeginDataAccess(); uchar *dptr = reinterpret_cast(bitmap->DataAddress()); int bmpLineLen = bitmap->DataStride(); @@ -128,7 +133,8 @@ static CFbsBitmap *imageToBitmap(const QImage &image) } bitmap->EndDataAccess(); } else { - qWarning("QVolatileImage: Failed to create source bitmap"); + qWarning("QVolatileImage: Failed to create source bitmap (w %d h %d fmt %d err %d)", + image.width(), image.height(), image.format(), err); delete bitmap; bitmap = 0; } @@ -155,8 +161,9 @@ static CFbsBitmap *convertData(const QVolatileImageData &source, QImage::Format static CFbsBitmap *duplicateBitmap(const CFbsBitmap &sourceBitmap) { CFbsBitmap *bitmap = new CFbsBitmap; - if (bitmap->Duplicate(sourceBitmap.Handle()) != KErrNone) { - qWarning("QVolatileImage: Failed to duplicate source bitmap"); + TInt err = bitmap->Duplicate(sourceBitmap.Handle()); + if (err != KErrNone) { + qWarning("QVolatileImage: Failed to duplicate source bitmap (%d)", err); delete bitmap; bitmap = 0; } @@ -166,8 +173,10 @@ static CFbsBitmap *duplicateBitmap(const CFbsBitmap &sourceBitmap) static CFbsBitmap *createBitmap(int w, int h, QImage::Format format) { CFbsBitmap *bitmap = new CFbsBitmap; - if (bitmap->Create(TSize(w, h), format2TDisplayMode(format)) != KErrNone) { - qWarning("QVolatileImage: Failed to create source bitmap %d,%d (%d)", w, h, format); + TInt err = bitmap->Create(TSize(w, h), format2TDisplayMode(format)); + if (err != KErrNone) { + qWarning("QVolatileImage: Failed to create source bitmap (w %d h %d fmt %d err %d)", + w, h, format, err); delete bitmap; bitmap = 0; } -- cgit v0.12 From be681e71510de948dfc32a647ecef5def6c01118 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 16 Jun 2011 23:40:56 +0200 Subject: Revert "Symbian: Fix QFontInfo::pixelSize()" This reverts commit fcfc19878a0a1a48194a786bba64da11606077d2. I am happy that this commit fixed three bugs at once. But Actually, I am not sure if QTBUG-15513 should be fixed at this point. Fact is that the patch as it is would have changed the point->pixels calculation back to how it was in Qt 4.6. This means that the fonts which are defined with pointSize would now (in Qt 4.7.4) suddenly be bigger than they were in Qt 4.7.3. Imho this is unacceptable, as it would break all layouts which were developed for Qt 4.7 apps, when point size (instead of pixle size) was used. I will need to fix QTBUG-17844 without fixing QTBUG-13009 If QTBUG-13009 will be fixed for 4.8 will be discussed. --- src/gui/text/qfontdatabase_s60.cpp | 4 ++++ src/gui/text/qfontengine_s60.cpp | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 6ede1f1..1eb4242 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -1014,6 +1014,10 @@ QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *d, const QF const QSymbianTypeFaceExtras *typeFaceExtras = dbExtras->extras(fontFamily, request.weight > QFont::Normal, request.style != QFont::StyleNormal); + // We need a valid pixelSize, e.g. for lineThickness() + if (request.pixelSize < 0) + request.pixelSize = request.pointSize * d->dpi / 72; + fe = new QFontEngineS60(request, typeFaceExtras); #else // QT_NO_FREETYPE Q_UNUSED(d) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 6b93efa..36eb7c0 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -294,7 +294,6 @@ QFontEngineS60::QFontEngineS60(const QFontDef &request, const QSymbianTypeFaceEx , m_activeFont(0) { QFontEngine::fontDef = request; - QFontEngine::fontDef.pixelSize = m_originalFontSizeInPixels; // Needs a valid pixel size. QTBUG-13009, QTBUG-17844 setFontScale(1.0); cache_cost = sizeof(QFontEngineS60); } -- cgit v0.12 From f1d0c5bbd4a33bb0f6398915d11dc93dc659ecf6 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Thu, 16 Jun 2011 11:06:36 +0300 Subject: Remove unnecessary resizes during orientation change Orientation change causes unnecessary resize to top level window on Symbian. This causes recreation of EGL surfaces which is not wanted. Task-number: QTBUG-19911 Reviewed-by: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 3 ++- src/gui/kernel/qt_s60_p.h | 2 ++ src/gui/s60framework/qs60mainappui.cpp | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 96b82da..98f00fb 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1524,7 +1524,8 @@ void QSymbianControl::HandleResourceChange(int resourceType) // client area. if (S60->statusPane() && (S60->statusPane()->IsVisible() || m_lastStatusPaneVisibility)) { m_lastStatusPaneVisibility = S60->statusPane()->IsVisible(); - handleClientAreaChange(); + if (S60->handleStatusPaneResizeNotifications) + handleClientAreaChange(); } if (IsFocused() && IsVisible()) { qwidget->d_func()->setWindowIcon_sys(true); diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index c4ddc26..fccb44d 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -154,6 +154,7 @@ public: int orientationSet : 1; int partial_keyboard : 1; int partialKeyboardOpen : 1; + int handleStatusPaneResizeNotifications : 1; QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type QPointer splitViewLastWidget; @@ -343,6 +344,7 @@ inline QS60Data::QS60Data() orientationSet(0), partial_keyboard(0), partialKeyboardOpen(0), + handleStatusPaneResizeNotifications(1), s60ApplicationFactory(0) #ifdef Q_OS_SYMBIAN ,s60InstalledTrapHandler(0) diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index 4f08fe2..e2ec78c 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -315,7 +315,21 @@ TRect QS60MainAppUi::ApplicationRect() const */ void QS60MainAppUi::HandleScreenDeviceChangedL() { + // This function triggers AppUi relayout which also generates + // HandleStatusPaneSizeChange(). We don't want to handle + // status pane resizes at this point because it causes + // Qt window resize and thus EGL surface resize in the middle of + // incomplete layout process causing unnecessary overhead. + // To prevent status pane resize handling while layout is still + // in progress, we guard relayouting with handleStatusPaneResizeNotifications + // flag. QSymbianControl checks this flag before doing Qt window + // resize due to status pane change. + // Eventually when layout is ready, Symbian framework calls + // HandleResourceChangeL(KEikDynamicLayoutVariantSwitch) which triggers + // resize to Qt window and to its EGL surface. + S60->handleStatusPaneResizeNotifications = false; QS60MainAppUiBase::HandleScreenDeviceChangedL(); + S60->handleStatusPaneResizeNotifications = true; } /*! -- cgit v0.12 From 261e23dc3291c5d20b684719ee0831960a77d51e Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Fri, 17 Jun 2011 09:59:43 +0300 Subject: Fix trailing whitespace Reviewed-by: TRUSTME --- src/gui/s60framework/qs60mainappui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index e2ec78c..8a8a03d 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -326,7 +326,7 @@ void QS60MainAppUi::HandleScreenDeviceChangedL() // resize due to status pane change. // Eventually when layout is ready, Symbian framework calls // HandleResourceChangeL(KEikDynamicLayoutVariantSwitch) which triggers - // resize to Qt window and to its EGL surface. + // resize to Qt window and to its EGL surface. S60->handleStatusPaneResizeNotifications = false; QS60MainAppUiBase::HandleScreenDeviceChangedL(); S60->handleStatusPaneResizeNotifications = true; -- cgit v0.12 From e679ab37529794d5629700f731bb25343002b730 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 17 Jun 2011 09:56:50 +0200 Subject: Revert "Def update." This reverts commit cf429b48cf144a4f6fa1b7e96ed00f5ce3fe085b. --- src/s60installs/bwins/QtGuiu.def | 2 -- src/s60installs/bwins/QtNetworku.def | 2 -- src/s60installs/bwins/QtOpenGLu.def | 1 - src/s60installs/bwins/QtOpenVGu.def | 1 - src/s60installs/eabi/QtCoreu.def | 13 ------------- src/s60installs/eabi/QtGuiu.def | 2 -- src/s60installs/eabi/QtNetworku.def | 2 -- src/s60installs/eabi/QtOpenVGu.def | 1 - 8 files changed, 24 deletions(-) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 9b70ee8..ca4af4a 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -13111,6 +13111,4 @@ EXPORTS ?setInstantInvalidatePropagation@QGraphicsLayout@@SAX_N@Z @ 13110 NONAME ; void QGraphicsLayout::setInstantInvalidatePropagation(bool) ?instantInvalidatePropagation@QGraphicsLayout@@SA_NXZ @ 13111 NONAME ; bool QGraphicsLayout::instantInvalidatePropagation(void) ?hasBCM2727@QSymbianGraphicsSystemEx@@SA_NXZ @ 13112 NONAME ; bool QSymbianGraphicsSystemEx::hasBCM2727(void) - ?constImageRef@QVolatileImage@@QBEABVQImage@@XZ @ 13113 NONAME ; class QImage const & QVolatileImage::constImageRef(void) const - ?toVolatileImage@QPixmapData@@UBE?AVQVolatileImage@@XZ @ 13114 NONAME ; class QVolatileImage QPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def index 274b821..b3137d8 100644 --- a/src/s60installs/bwins/QtNetworku.def +++ b/src/s60installs/bwins/QtNetworku.def @@ -1159,6 +1159,4 @@ EXPORTS ??4QIPv6Address@@QAEAAV0@ABV0@@Z @ 1158 NONAME ABSENT ; class QIPv6Address & QIPv6Address::operator=(class QIPv6Address const &) ??_EQNetworkAddressEntry@@QAE@I@Z @ 1159 NONAME ABSENT ; QNetworkAddressEntry::~QNetworkAddressEntry(unsigned int) ??_EQNetworkCookie@@QAE@I@Z @ 1160 NONAME ABSENT ; QNetworkCookie::~QNetworkCookie(unsigned int) - ?cleanup@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1161 NONAME ; void QNetworkConfigurationManagerPrivate::cleanup(void) - ?initialize@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1162 NONAME ; void QNetworkConfigurationManagerPrivate::initialize(void) diff --git a/src/s60installs/bwins/QtOpenGLu.def b/src/s60installs/bwins/QtOpenGLu.def index af25e7e..75c0d5e 100644 --- a/src/s60installs/bwins/QtOpenGLu.def +++ b/src/s60installs/bwins/QtOpenGLu.def @@ -724,5 +724,4 @@ EXPORTS ?initFromNativeImageHandle@QGLPixmapData@@QAE_NPAXABVQString@@@Z @ 723 NONAME ; bool QGLPixmapData::initFromNativeImageHandle(void *, class QString const &) ?platformExtension@QGLGraphicsSystem@@UAEPAVQGraphicsSystemEx@@XZ @ 724 NONAME ; class QGraphicsSystemEx * QGLGraphicsSystem::platformExtension(void) ?releaseCachedGpuResources@QGLGraphicsSystem@@UAEXXZ @ 725 NONAME ; void QGLGraphicsSystem::releaseCachedGpuResources(void) - ?toVolatileImage@QGLPixmapData@@UBE?AVQVolatileImage@@XZ @ 726 NONAME ; class QVolatileImage QGLPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/bwins/QtOpenVGu.def b/src/s60installs/bwins/QtOpenVGu.def index 9812757..f2433d6 100644 --- a/src/s60installs/bwins/QtOpenVGu.def +++ b/src/s60installs/bwins/QtOpenVGu.def @@ -184,5 +184,4 @@ EXPORTS ?createFromNativeImageHandleProvider@QVGPixmapData@@QAEXXZ @ 183 NONAME ; void QVGPixmapData::createFromNativeImageHandleProvider(void) ?releaseNativeImageHandle@QVGPixmapData@@QAEXXZ @ 184 NONAME ; void QVGPixmapData::releaseNativeImageHandle(void) ?forceToImage@QVGPixmapData@@IAEX_N@Z @ 185 NONAME ; void QVGPixmapData::forceToImage(bool) - ?toVolatileImage@QVGPixmapData@@UBE?AVQVolatileImage@@XZ @ 186 NONAME ; class QVolatileImage QVGPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index f92cb5a..fce55dd 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3717,17 +3717,4 @@ EXPORTS _ZN23QCoreApplicationPrivate18symbianCommandLineEv @ 3716 NONAME _ZNK11QMetaMethod8revisionEv @ 3717 NONAME _ZNK13QMetaProperty8revisionEv @ 3718 NONAME - _ZN5RHeap10Extension_EjRPvS0_ @ 3719 NONAME - _ZN5RHeap13DebugFunctionEiPvS0_ @ 3720 NONAME - _ZN5RHeap4FreeEPv @ 3721 NONAME - _ZN5RHeap5AllocEi @ 3722 NONAME - _ZN5RHeap5ResetEv @ 3723 NONAME - _ZN5RHeap7ReAllocEPvii @ 3724 NONAME - _ZN5RHeap8CompressEv @ 3725 NONAME - _ZN8UserHeap15OffsetChunkHeapE6RChunkiiiiiim @ 3726 NONAME - _ZN8UserHeap16CreateThreadHeapER24SStdEpocThreadCreateInfoRP5RHeapii @ 3727 NONAME - _ZN8UserHeap9ChunkHeapE6RChunkiiiiim @ 3728 NONAME - _ZNK5RHeap8AllocLenEPKv @ 3729 NONAME - _ZNK5RHeap9AllocSizeERi @ 3730 NONAME - _ZNK5RHeap9AvailableERi @ 3731 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 0f9442d..d0c789f 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12195,6 +12195,4 @@ EXPORTS _ZTI17QGraphicsSystemEx @ 12194 NONAME _ZTI24QSymbianGraphicsSystemEx @ 12195 NONAME _ZTV24QSymbianGraphicsSystemEx @ 12196 NONAME - _ZNK11QPixmapData15toVolatileImageEv @ 12197 NONAME - _ZNK14QVolatileImage13constImageRefEv @ 12198 NONAME diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def index 86a61e8..f13fab3 100644 --- a/src/s60installs/eabi/QtNetworku.def +++ b/src/s60installs/eabi/QtNetworku.def @@ -1168,6 +1168,4 @@ EXPORTS _ZTV35QNetworkConfigurationManagerPrivate @ 1167 NONAME _ZThn8_N19QBearerEnginePluginD0Ev @ 1168 NONAME _ZThn8_N19QBearerEnginePluginD1Ev @ 1169 NONAME - _ZN35QNetworkConfigurationManagerPrivate10initializeEv @ 1170 NONAME - _ZN35QNetworkConfigurationManagerPrivate7cleanupEv @ 1171 NONAME diff --git a/src/s60installs/eabi/QtOpenVGu.def b/src/s60installs/eabi/QtOpenVGu.def index e169ff8..08afd61 100644 --- a/src/s60installs/eabi/QtOpenVGu.def +++ b/src/s60installs/eabi/QtOpenVGu.def @@ -214,5 +214,4 @@ EXPORTS _ZN13QVGPixmapData25initFromNativeImageHandleEPvRK7QString @ 213 NONAME _ZN13QVGPixmapData35createFromNativeImageHandleProviderEv @ 214 NONAME _ZN13QVGPixmapData12forceToImageEb @ 215 NONAME - _ZNK13QVGPixmapData15toVolatileImageEv @ 216 NONAME -- cgit v0.12 From be24f3c83e03118fb2dba3e59db44b1f600a6a63 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 17 Jun 2011 10:10:28 +0200 Subject: Def update for gui, openvg, and opengl. --- src/s60installs/bwins/QtGuiu.def | 2 ++ src/s60installs/bwins/QtOpenGLu.def | 1 + src/s60installs/bwins/QtOpenVGu.def | 1 + src/s60installs/eabi/QtGuiu.def | 2 ++ src/s60installs/eabi/QtOpenVGu.def | 1 + 5 files changed, 7 insertions(+) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index ca4af4a..9b70ee8 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -13111,4 +13111,6 @@ EXPORTS ?setInstantInvalidatePropagation@QGraphicsLayout@@SAX_N@Z @ 13110 NONAME ; void QGraphicsLayout::setInstantInvalidatePropagation(bool) ?instantInvalidatePropagation@QGraphicsLayout@@SA_NXZ @ 13111 NONAME ; bool QGraphicsLayout::instantInvalidatePropagation(void) ?hasBCM2727@QSymbianGraphicsSystemEx@@SA_NXZ @ 13112 NONAME ; bool QSymbianGraphicsSystemEx::hasBCM2727(void) + ?constImageRef@QVolatileImage@@QBEABVQImage@@XZ @ 13113 NONAME ; class QImage const & QVolatileImage::constImageRef(void) const + ?toVolatileImage@QPixmapData@@UBE?AVQVolatileImage@@XZ @ 13114 NONAME ; class QVolatileImage QPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/bwins/QtOpenGLu.def b/src/s60installs/bwins/QtOpenGLu.def index 75c0d5e..af25e7e 100644 --- a/src/s60installs/bwins/QtOpenGLu.def +++ b/src/s60installs/bwins/QtOpenGLu.def @@ -724,4 +724,5 @@ EXPORTS ?initFromNativeImageHandle@QGLPixmapData@@QAE_NPAXABVQString@@@Z @ 723 NONAME ; bool QGLPixmapData::initFromNativeImageHandle(void *, class QString const &) ?platformExtension@QGLGraphicsSystem@@UAEPAVQGraphicsSystemEx@@XZ @ 724 NONAME ; class QGraphicsSystemEx * QGLGraphicsSystem::platformExtension(void) ?releaseCachedGpuResources@QGLGraphicsSystem@@UAEXXZ @ 725 NONAME ; void QGLGraphicsSystem::releaseCachedGpuResources(void) + ?toVolatileImage@QGLPixmapData@@UBE?AVQVolatileImage@@XZ @ 726 NONAME ; class QVolatileImage QGLPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/bwins/QtOpenVGu.def b/src/s60installs/bwins/QtOpenVGu.def index f2433d6..9812757 100644 --- a/src/s60installs/bwins/QtOpenVGu.def +++ b/src/s60installs/bwins/QtOpenVGu.def @@ -184,4 +184,5 @@ EXPORTS ?createFromNativeImageHandleProvider@QVGPixmapData@@QAEXXZ @ 183 NONAME ; void QVGPixmapData::createFromNativeImageHandleProvider(void) ?releaseNativeImageHandle@QVGPixmapData@@QAEXXZ @ 184 NONAME ; void QVGPixmapData::releaseNativeImageHandle(void) ?forceToImage@QVGPixmapData@@IAEX_N@Z @ 185 NONAME ; void QVGPixmapData::forceToImage(bool) + ?toVolatileImage@QVGPixmapData@@UBE?AVQVolatileImage@@XZ @ 186 NONAME ; class QVolatileImage QVGPixmapData::toVolatileImage(void) const diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index d0c789f..0f9442d 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12195,4 +12195,6 @@ EXPORTS _ZTI17QGraphicsSystemEx @ 12194 NONAME _ZTI24QSymbianGraphicsSystemEx @ 12195 NONAME _ZTV24QSymbianGraphicsSystemEx @ 12196 NONAME + _ZNK11QPixmapData15toVolatileImageEv @ 12197 NONAME + _ZNK14QVolatileImage13constImageRefEv @ 12198 NONAME diff --git a/src/s60installs/eabi/QtOpenVGu.def b/src/s60installs/eabi/QtOpenVGu.def index 08afd61..e169ff8 100644 --- a/src/s60installs/eabi/QtOpenVGu.def +++ b/src/s60installs/eabi/QtOpenVGu.def @@ -214,4 +214,5 @@ EXPORTS _ZN13QVGPixmapData25initFromNativeImageHandleEPvRK7QString @ 213 NONAME _ZN13QVGPixmapData35createFromNativeImageHandleProviderEv @ 214 NONAME _ZN13QVGPixmapData12forceToImageEb @ 215 NONAME + _ZNK13QVGPixmapData15toVolatileImageEv @ 216 NONAME -- cgit v0.12 From b133f1b45638dd10bd5400393d83ca1bed1985c4 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 17 Jun 2011 12:23:09 +0300 Subject: Ensure visibility of input widget in QML app when doing layout switch When QML application changes orientation, it usually switches to a new layout that lays out widgets differently (ie. in portrait, one vertical column; in landscape, horizontal multi-column layout). This easily breaks splitview translation logic, since it tries to ensure the visibility of the input widget before the new layout has been applied. Additionally, the logic failed, when connected signal was fired, since it assumed that the new translation would have translated the view above from where it started from (i.e. window below the translated view would have been exposed) and thus, it didn't do anything. As a fix, when translation logic seems to indicate that the translation would fail (and thus previously wouldn't do anything), reset the existing translation and try again. Task-number: QTBUG-16785 Reviewed-by: Miikka Heikkinen --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 3a12d26..fcb809c 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -912,8 +912,14 @@ void QCoeFepInputContext::translateInputWidget() qreal dy = -(qMin(maxY, (cursor.bottom() - vkbRect.top() / 2))); // Do not allow transform above screen top. - if (m_transformation.height() + dy > 0) + if (m_transformation.height() + dy > 0) { + // If we already have some transformation, remove it. + if (m_transformation.height() < 0) { + rootItem->resetTransform(); + translateInputWidget(); + } return; + } rootItem->setTransform(QTransform::fromTranslate(0, dy), true); } -- cgit v0.12 From 9a3f592966b9227f099e752f578a157500989146 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 20 Jun 2011 09:08:32 +0200 Subject: Disable antialiasing for tiled image drawing. Task-number: QTBUG-19821 Reviewed-by: Jani Hautakangas --- src/openvg/qpaintengine_vg.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 0047aa3..e1e53f9 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -3110,7 +3110,7 @@ static void drawImageTiled(QVGPaintEnginePrivate *d, VGImage tileWithOpacity = VG_INVALID_HANDLE; if (d->opacity != 1) { tileWithOpacity = pool->createPermanentImage(VG_sARGB_8888_PRE, - tileWidth, tileHeight, VG_IMAGE_QUALITY_FASTER); + tileWidth, tileHeight, VG_IMAGE_QUALITY_NONANTIALIASED); if (tileWithOpacity == VG_INVALID_HANDLE) qWarning("drawImageTiled: Failed to create extra tile, ignoring opacity"); } @@ -3123,6 +3123,10 @@ static void drawImageTiled(QVGPaintEnginePrivate *d, VGfloat scaleY = r.height() / sourceRect.height(); d->setImageOptions(); + VGImageQuality oldImageQuality = d->imageQuality; + VGRenderingQuality oldRenderingQuality = d->renderingQuality; + d->setImageQuality(VG_IMAGE_QUALITY_NONANTIALIASED); + d->setRenderingQuality(VG_RENDERING_QUALITY_NONANTIALIASED); for (int y = sourceRect.y(); y < sourceRect.height(); y += tileHeight) { int h = qMin(tileHeight, sourceRect.height() - y); @@ -3162,6 +3166,9 @@ static void drawImageTiled(QVGPaintEnginePrivate *d, vgDestroyImage(tile); if (tileWithOpacity != VG_INVALID_HANDLE) vgDestroyImage(tileWithOpacity); + + d->setImageQuality(oldImageQuality); + d->setRenderingQuality(oldRenderingQuality); } // Used by qpixmapfilter_vg.cpp to draw filtered VGImage's. -- cgit v0.12 From 38db40d9a2db44e47b0aabd9487284cd1106b353 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 21 Jun 2011 14:50:08 +0100 Subject: Workaround webkit deadlock on macos x The webkit AtomicallyInitializedStatic and Qt's Q_GLOBAL_STATIC can deadlock on the Mac, as the mac compiler inserts calls to __cxa_guard_acquire and __cxa_guard_release around initialisation of local statics. In Q_GLOBAL_STATIC case, this is the QGlobalStaticDeleter local static Whereas webkit AtomicallyInitializedStatic is a local static variable in any case. Problem is triggered because webkit constructs QNetworkConfigurationManager inside the constructor of a local static - networkStateNotifier And the generic bearer plugin calls QNetworkInterface::allInterfaces in the bearer thread, which needs an initialised Q_GLOBAL_STATIC. Reviewed-by: Laszlo Agocs --- src/plugins/bearer/generic/qgenericengine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 7e97ffe..13f2b4c 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -147,6 +147,9 @@ static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interf QGenericEngine::QGenericEngine(QObject *parent) : QBearerEngineImpl(parent) { + //workaround for deadlock in __cxa_guard_acquire with webkit on macos x + //initialise the Q_GLOBAL_STATIC in same thread as the AtomicallyInitializedStatic + (void)QNetworkInterface::interfaceFromIndex(0); } QGenericEngine::~QGenericEngine() -- cgit v0.12 From 460195183522f97e01e17cad008665517cb91c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Niemel=C3=A4?= Date: Thu, 23 Jun 2011 09:40:34 +0300 Subject: Added qmlshadersplugin to Symbian qt.iby-file. Task-number: QTBUG-18346 Reviewed-by: Sami Merila --- src/s60installs/qt.iby | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby index 9f2c979..f3a1446 100644 --- a/src/s60installs/qt.iby +++ b/src/s60installs/qt.iby @@ -74,14 +74,17 @@ data=EPOCROOT##epoc32\data\z\resource\qt\plugins\iconengines\qsvgicon.qtplugin file=ABI_DIR\BUILD_DIR\qmlfolderlistmodelplugin.dll SHARED_LIB_DIR\qmlfolderlistmodelplugin.dll file=ABI_DIR\BUILD_DIR\qmlgesturesplugin.dll SHARED_LIB_DIR\qmlgesturesplugin.dll file=ABI_DIR\BUILD_DIR\qmlparticlesplugin.dll SHARED_LIB_DIR\qmlparticlesplugin.dll +file=ABI_DIR\BUILD_DIR\qmlshadersplugin.dll SHARED_LIB_DIR\qmlshadersplugin.dll data=EPOCROOT##epoc32\data\z\resource\qt\imports\Qt\labs\folderlistmodel\qmlfolderlistmodelplugin.qtplugin resource\qt\imports\Qt\labs\folderlistmodel\qmlfolderlistmodelplugin.qtplugin data=EPOCROOT##epoc32\data\z\resource\qt\imports\Qt\labs\gestures\qmlgesturesplugin.qtplugin resource\qt\imports\Qt\labs\gestures\qmlgesturesplugin.qtplugin data=EPOCROOT##epoc32\data\z\resource\qt\imports\Qt\labs\particles\qmlparticlesplugin.qtplugin resource\qt\imports\Qt\labs\particles\qmlparticlesplugin.qtplugin +data=EPOCROOT##epoc32\data\z\resource\qt\imports\Qt\labs\shaders\qmlshadersplugin.qtplugin resource\qt\imports\Qt\labs\shaders\qmlshadersplugin.qtplugin data=EPOCROOT##epoc32\data\z\resource\qt\imports\Qt\labs\folderlistmodel\qmldir resource\qt\imports\Qt\labs\folderlistmodel\qmldir data=EPOCROOT##epoc32\data\z\resource\qt\imports\Qt\labs\gestures\qmldir resource\qt\imports\Qt\labs\gestures\qmldir data=EPOCROOT##epoc32\data\z\resource\qt\imports\Qt\labs\particles\qmldir resource\qt\imports\Qt\labs\particles\qmldir +data=EPOCROOT##epoc32\data\z\resource\qt\imports\Qt\labs\shaders\qmldir resource\qt\imports\Qt\labs\shaders\qmldir // graphicssystems data=EPOCROOT##epoc32\data\z\resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin -- cgit v0.12 From 17487a4d11146d0c501b0b13695c3d4d18aa580a Mon Sep 17 00:00:00 2001 From: Guoqing Zhang Date: Thu, 23 Jun 2011 09:41:50 +0300 Subject: Support clipboard function on Symbian Task-number: QTBUG-19996 Reviewed-by: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 98f00fb..b98bdbc 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -930,6 +930,15 @@ TKeyResponse QSymbianControl::sendSymbianKeyEvent(const TKeyEvent &keyEvent, QEv } Qt::KeyboardModifiers mods = mapToQtModifiers(keyEvent.iModifiers); + + TInt code = keyEvent.iCode; + + if (mods == Qt::ControlModifier) { + //only support ctrl+a .. ctrl+z, 0x40 is the key value before Qt::Key_A + if (code > 0 && code < 27) + keyCode = 0x40 + code; + } + QKeyEventEx qKeyEvent(type, keyCode, mods, qt_keymapper_private()->translateKeyEvent(keyCode, mods), (keyEvent.iRepeats != 0), 1, keyEvent.iScanCode, s60Keysym, keyEvent.iModifiers); QWidget *widget; -- cgit v0.12 From 18da8a264f9a155332940c9e7b416db0b0b5058d Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 23 Jun 2011 10:38:02 +0300 Subject: Splitview - Auto-translation rules changed When using "splitview" (virtual keyboard with non-fullscreen editing mode), it is currently auto-translating the cursor to the center of the screen if possible. It would be preferable, if the translation would only be minimal, just enough for cursor to be visible. This makes scrolling of input widget (i.e. large editor) easier to use, as text flows naturally (row-by-row) and not in "jumps" like it used to do. Additionally, limit the translation to the end of input widget boundary. Task-number: QTBUG-20034 Reviewed-by: Miikka Heikkinen --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 33 ++++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index fcb809c..07d68a4 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -901,20 +901,35 @@ void QCoeFepInputContext::translateInputWidget() m_transformation = (rootItem->transform().isTranslating()) ? QRectF(0,0, gv->width(), rootItem->transform().dy()) : QRectF(); - // Do nothing if the cursor is visible in the splitview area. - if (splitViewRect.contains(cursorP.boundingRect())) + // Adjust cursor bounding rect to be lower, so that view translates if the cursor gets near + // the splitview border. + QRect cursorRect = cursorP.boundingRect().adjusted(0, cursor.height(), 0, cursor.height()); + if (splitViewRect.contains(cursorRect)) return; - // New Y position should be ideally at the center of the splitview area. - // If that would expose unpainted canvas, limit the tranformation to the visible scene bottom. + // New Y position should be ideally just above the keyboard. + // If that would expose unpainted canvas, limit the tranformation to the visible scene rect or + // to the focus item's shape/clip path. - const qreal maxY = gv->sceneRect().bottom() - splitViewRect.bottom() + m_transformation.height(); - qreal dy = -(qMin(maxY, (cursor.bottom() - vkbRect.top() / 2))); + const QPainterPath path = gv->scene()->focusItem()->isClipped() ? + gv->scene()->focusItem()->clipPath() : gv->scene()->focusItem()->shape(); + const qreal itemHeight = path.boundingRect().height(); - // Do not allow transform above screen top. - if (m_transformation.height() + dy > 0) { + // Limit the maximum translation so that underlaying window content is not exposed. + qreal maxY = gv->sceneRect().bottom() - splitViewRect.bottom(); + maxY = m_transformation.height() ? (qMin(itemHeight, maxY) + m_transformation.height()) : maxY; + if (maxY < 0) + maxY = 0; + + // Translation should happen row-by-row, but initially it needs to ensure that cursor is visible. + const qreal translation = m_transformation.height() ? + cursor.height() : (cursorRect.bottom() - vkbRect.top()); + const qreal dy = -(qMin(maxY, translation)); + + // Do not allow transform above screen top, nor beyond scenerect + if (m_transformation.height() + dy > 0 || gv->sceneRect().bottom() + m_transformation.height() < 0) { // If we already have some transformation, remove it. - if (m_transformation.height() < 0) { + if (m_transformation.height() < 0 || gv->sceneRect().bottom() + m_transformation.height() < 0) { rootItem->resetTransform(); translateInputWidget(); } -- cgit v0.12 From a3f97ba985c80b147bcc902416304544f1d0ec58 Mon Sep 17 00:00:00 2001 From: mread Date: Wed, 22 Jun 2011 11:39:23 +0100 Subject: QTBUG-17776, reporting terminated threads as not running on Symbian On Symbian app shutdown all threads are terminated and their stack memory is released, but there is no time for notification of exit of these threads. So any attempt to access stack data in such a thread from static data destruction will cause a crash. This was happening with the XmlQuery thread. It was testing if the thread was still running, and QThread thought it was because there was no notification. So when the XmlQuery thread was asked to exit, and QThread::exit tried to access a stack based QEventLoop, there was a crash. By adding a test if the thread has been terminated to QThread::isRunning(), clients can now rely on this to know that it is safe to call exit() on a thread. The existing code is made safe again. Task-number: QTBUG-17776 Reviewed-by: Shane Kearns --- src/corelib/thread/qthread.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 2cdaca0..2f96920 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -431,6 +431,12 @@ bool QThread::isRunning() const { Q_D(const QThread); QMutexLocker locker(&d->mutex); +#ifdef Q_OS_SYMBIAN + // app shutdown on Symbian can terminate threads and invalidate their stacks without notification, + // check the thread is still alive. + if (d->data->symbian_thread_handle.Handle() && d->data->symbian_thread_handle.ExitType() != EExitPending) + return false; +#endif return d->running; } -- cgit v0.12 From 276040334edc919fa443e8fe6bb6bb49eb1e79a2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 23 Jun 2011 15:33:42 +0300 Subject: Use numeric virtual keyboard for all number entry modes. Qt::DialableCharactersOnly and Qt::ImhFormattedNumbersOnly now use numeric mode virtual keyboard as they are supposed to. '*' and '#' keys can be used to enter the non-digit characters allowed in these modes. Task-number: QT-5085 Reviewed-by: Sami Merila --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 07d68a4..aa87955 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -697,11 +697,6 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) } else if (anynumbermodes) { flags |= EAknEditorNumericInputMode; - if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 - && ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly))) { - //workaround - the * key does not launch the symbols menu, making it impossible to use these modes unless text mode is enabled. - flags |= EAknEditorTextInputMode; - } } else if (anytextmodes) { flags |= EAknEditorTextInputMode; @@ -782,8 +777,6 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG); } else if (needsCharMap) { m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); - } else if ((hints & ImhFormattedNumbersOnly) || (hints & ImhDialableCharactersOnly)) { - m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); } else { m_fepState->SetSpecialCharacterTableResourceId(0); } -- cgit v0.12