summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorJani Hautakangas <ext-jani.hautakangas@nokia.com>2010-05-20 09:46:46 (GMT)
committerJani Hautakangas <ext-jani.hautakangas@nokia.com>2010-05-20 09:46:46 (GMT)
commit98972c1b271de1292b4e46484fe689d62a8b8e62 (patch)
tree0949cdc38127261bdd28cee8cb3084052bd8c461 /src/gui/kernel
parentb4b4cb3248b987dd6c15908f0b46e131dc2b7cde (diff)
downloadQt-98972c1b271de1292b4e46484fe689d62a8b8e62.zip
Qt-98972c1b271de1292b4e46484fe689d62a8b8e62.tar.gz
Qt-98972c1b271de1292b4e46484fe689d62a8b8e62.tar.bz2
QRuntimeGraphicsSystem
QRuntimeGraphicsSystem is a proxy graphics system which can dynamically switch underlying graphics system on runtime. For example, switch from hardware accelerated graphics system to raster graphics system on low GPU memory situation. This feature is currently supported on Symbian platform. Task-number: QT-3276 Reviewed-by: Jason Barron
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qapplication.cpp13
-rw-r--r--src/gui/kernel/qapplication_s60.cpp66
-rw-r--r--src/gui/kernel/qt_s60_p.h1
-rw-r--r--src/gui/kernel/qwidget.cpp9
4 files changed, 85 insertions, 4 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index ec635d4..590b000 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -70,6 +70,10 @@
#include "qmessagebox.h"
#include <QtGui/qgraphicsproxywidget.h>
+#ifdef QT_GRAPHICSSYSTEM_RUNTIME
+#include "private/qgraphicssystem_runtime_p.h"
+#endif
+
#include "qinputcontext.h"
#include "qkeymapper_p.h"
@@ -1561,7 +1565,14 @@ QStyle* QApplication::setStyle(const QString& style)
void QApplication::setGraphicsSystem(const QString &system)
{
- QApplicationPrivate::graphics_system_name = system;
+#ifdef QT_GRAPHICSSYSTEM_RUNTIME
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) {
+ QRuntimeGraphicsSystem *r =
+ static_cast<QRuntimeGraphicsSystem *>(QApplicationPrivate::graphics_system);
+ r->setGraphicsSystem(system);
+ } else
+#endif
+ QApplicationPrivate::graphics_system_name = system;
}
/*!
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index f4c7304..1134a9b 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -62,6 +62,10 @@
#include "qpaintengine.h"
#include "private/qmenubar_p.h"
#include "private/qsoftkeymanager_p.h"
+#ifdef QT_GRAPHICSSYSTEM_RUNTIME
+#include "private/qgraphicssystem_runtime_p.h"
+#endif
+
#include "apgwgnam.h" // For CApaWindowGroupName
#include <mdaaudiotoneplayer.h> // For CMdaAudioToneUtility
@@ -83,6 +87,10 @@
QT_BEGIN_NAMESPACE
+// Goom Events through Window Server
+static const int KGoomMemoryLowEvent = 0x10282DBF;
+static const int KGoomMemoryGoodEvent = 0x20026790;
+
#if defined(QT_DEBUG)
static bool appNoGrab = false; // Grabbing enabled
#endif
@@ -855,7 +863,16 @@ void QSymbianControl::Draw(const TRect& controlRect) const
const TRect backingStoreRect(TPoint(backingStoreBase.x(), backingStoreBase.y()), controlRect.Size());
if (engine->type() == QPaintEngine::Raster) {
- QS60WindowSurface *s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface());
+ QS60WindowSurface *s60Surface;
+#ifdef QT_GRAPHICSSYSTEM_RUNTIME
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) {
+ QRuntimeWindowSurface *rtSurface =
+ static_cast<QRuntimeWindowSurface*>(qwidget->windowSurface());
+ s60Surface = static_cast<QS60WindowSurface *>(rtSurface->m_windowSurface);
+ } else
+#endif
+ s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface());
+
CFbsBitmap *bitmap = s60Surface->symbianBitmap();
CWindowGc &gc = SystemGc();
@@ -1738,6 +1755,53 @@ int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent
}
#endif
break;
+ case KGoomMemoryLowEvent:
+#ifdef QT_DEBUG
+ qDebug() << "QApplicationPrivate::symbianProcessWsEvent - KGoomMemoryLowEvent";
+#endif
+ if (callSymbianEventFilters(symbianEvent))
+ return 1;
+#ifdef QT_GRAPHICSSYSTEM_RUNTIME
+ if(QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) {
+ bool switchToSwRendering(false);
+
+ foreach (QWidget *w, QApplication::topLevelWidgets()) {
+ if(w->d_func()->topData()->backingStore) {
+ switchToSwRendering = true;
+ break;
+ }
+ }
+
+ if (switchToSwRendering) {
+ QRuntimeGraphicsSystem *gs =
+ static_cast<QRuntimeGraphicsSystem*>(QApplicationPrivate::graphics_system);
+
+ uint memoryUsage = gs->memoryUsage();
+ uint memoryForFullscreen = ( S60->screenDepth / 8 )
+ * S60->screenWidthInPixels
+ * S60->screenHeightInPixels;
+
+ S60->memoryLimitForHwRendering = memoryUsage - memoryForFullscreen;
+ gs->setGraphicsSystem(QLatin1String("raster"));
+ }
+ }
+#endif
+ break;
+ case KGoomMemoryGoodEvent:
+#ifdef QT_DEBUG
+ qDebug() << "QApplicationPrivate::symbianProcessWsEvent - KGoomMemoryGoodEvent";
+#endif
+ if (callSymbianEventFilters(symbianEvent))
+ return 1;
+#ifdef QT_GRAPHICSSYSTEM_RUNTIME
+ if(QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) {
+ QRuntimeGraphicsSystem *gs =
+ static_cast<QRuntimeGraphicsSystem*>(QApplicationPrivate::graphics_system);
+ gs->setGraphicsSystem(QLatin1String("openvg"), S60->memoryLimitForHwRendering);
+ S60->memoryLimitForHwRendering = 0;
+ }
+#endif
+ break;
default:
break;
}
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index 58da302..645e969 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -123,6 +123,7 @@ public:
int supportsPremultipliedAlpha : 1;
int avkonComponentsSupportTransparency : 1;
int menuBeingConstructed : 1;
+ int memoryLimitForHwRendering;
QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type
static inline void updateScreenSize();
static inline RWsSession& wsSession();
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 60f38f2..064bf03 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -248,9 +248,14 @@ QWidgetPrivate::~QWidgetPrivate()
QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
{
Q_Q(QWidget);
+
+ QWindowSurface *surface;
if (QApplicationPrivate::graphicsSystem())
- return QApplicationPrivate::graphicsSystem()->createWindowSurface(q);
- return createDefaultWindowSurface_sys();
+ surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q);
+ else
+ surface = createDefaultWindowSurface_sys();
+
+ return surface;
}
/*!