diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/egl/qegl.cpp | 37 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 23 |
3 files changed, 52 insertions, 11 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index bf9f530..671a568 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -42,6 +42,7 @@ #include <QtGui/qpaintdevice.h> #include <QtGui/qpixmap.h> #include <QtGui/qwidget.h> +#include <QtCore/qatomic.h> #include <QtCore/qdebug.h> #include "qegl_p.h" @@ -50,6 +51,34 @@ QT_BEGIN_NAMESPACE + +/* + QEglContextTracker is used to track the EGL contexts that we + create internally in Qt, so that we can call eglTerminate() to + free additional EGL resources when the last context is destroyed. +*/ + +class QEglContextTracker +{ +public: + static void ref() { contexts.ref(); } + static void deref() { + if (!contexts.deref()) { + eglTerminate(QEgl::display()); + displayOpen = 0; + } + } + static void setDisplayOpened() { displayOpen = 1; } + static bool displayOpened() { return displayOpen; } + +private: + static QAtomicInt contexts; + static QAtomicInt displayOpen; +}; + +QAtomicInt QEglContextTracker::contexts = 0; +QAtomicInt QEglContextTracker::displayOpen = 0; + // Current GL and VG contexts. These are used to determine if // we can avoid an eglMakeCurrent() after a call to lazyDoneCurrent(). // If a background thread modifies the value, the worst that will @@ -66,6 +95,7 @@ QEglContext::QEglContext() , ownsContext(true) , sharing(false) { + QEglContextTracker::ref(); } QEglContext::~QEglContext() @@ -76,6 +106,7 @@ QEglContext::~QEglContext() currentGLContext = 0; if (currentVGContext == this) currentVGContext = 0; + QEglContextTracker::deref(); } bool QEglContext::isValid() const @@ -505,11 +536,9 @@ static _eglDestroyImageKHR qt_eglDestroyImageKHR = 0; EGLDisplay QEgl::display() { static EGLDisplay dpy = EGL_NO_DISPLAY; - static bool openedDisplay = false; - - if (!openedDisplay) { + if (!QEglContextTracker::displayOpened()) { dpy = eglGetDisplay(nativeDisplay()); - openedDisplay = true; + QEglContextTracker::setDisplayOpened(); if (dpy == EGL_NO_DISPLAY) { qWarning("QEgl::display(): Falling back to EGL_DEFAULT_DISPLAY"); dpy = eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 01abe54..e30b6be 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -581,7 +581,8 @@ public: void _q_readRX71MultiTouchEvents(); #endif -#if defined(Q_WS_S60) +#if defined(Q_OS_SYMBIAN) + int pressureSupported; int maxTouchPressure; QList<QTouchEvent::TouchPoint> appAllTouchPoints; #endif diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index fa07b1a..dc8d8f7 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -408,15 +408,22 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent *event) { QApplicationPrivate *d = QApplicationPrivate::instance(); + qreal pressure; + if(d->pressureSupported + && event->Pressure() > 0) //workaround for misconfigured HAL + pressure = event->Pressure() / qreal(d->maxTouchPressure); + else + pressure = qreal(1.0); QRect screenGeometry = qApp->desktop()->screenGeometry(qwidget); - while (d->appAllTouchPoints.count() <= event->PointerNumber()) - d->appAllTouchPoints.append(QTouchEvent::TouchPoint(d->appAllTouchPoints.count())); + QList<QTouchEvent::TouchPoint> points = d->appAllTouchPoints; + while (points.count() <= event->PointerNumber()) + points.append(QTouchEvent::TouchPoint(points.count())); Qt::TouchPointStates allStates = 0; - for (int i = 0; i < d->appAllTouchPoints.count(); ++i) { - QTouchEvent::TouchPoint &touchPoint = d->appAllTouchPoints[i]; + for (int i = 0; i < points.count(); ++i) { + QTouchEvent::TouchPoint &touchPoint = points[i]; if (touchPoint.id() == event->PointerNumber()) { Qt::TouchPointStates state; @@ -446,7 +453,7 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(), screenPos.y() / screenGeometry.height())); - touchPoint.setPressure(event->Pressure() / qreal(d->maxTouchPressure)); + touchPoint.setPressure(pressure); } else if (touchPoint.state() != Qt::TouchPointReleased) { // all other active touch points should be marked as stationary touchPoint.setState(Qt::TouchPointStationary); @@ -458,11 +465,13 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased) { // all touch points released d->appAllTouchPoints.clear(); + } else { + d->appAllTouchPoints = points; } QApplicationPrivate::translateRawTouchEvent(qwidget, QTouchEvent::TouchScreen, - d->appAllTouchPoints); + points); } #endif @@ -1983,6 +1992,8 @@ TUint QApplicationPrivate::resolveS60ScanCode(TInt scanCode, TUint keysym) void QApplicationPrivate::initializeMultitouch_sys() { #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER + if (HAL::Get(HALData::EPointer3DPressureSupported, pressureSupported) != KErrNone) + pressureSupported = 0; if (HAL::Get(HALData::EPointer3DMaxPressure, maxTouchPressure) != KErrNone) maxTouchPressure = KMaxTInt; #endif |