summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-03-24 09:41:55 (GMT)
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-03-24 09:41:55 (GMT)
commit359c59db1a21d4279ca254a77eb1ac5c6a6c1ff9 (patch)
treecffdc1ccec703ac8344ad2cc7478f07cf6e68bcc
parent9a42d9815b73e5ceb25360af02936bcb0454a965 (diff)
downloadQt-359c59db1a21d4279ca254a77eb1ac5c6a6c1ff9.zip
Qt-359c59db1a21d4279ca254a77eb1ac5c6a6c1ff9.tar.gz
Qt-359c59db1a21d4279ca254a77eb1ac5c6a6c1ff9.tar.bz2
Call FixNativeOrientation on Symbian for certain fullscreen qml views.
For fullscreen QDeclarativeViews that lock their orientation to the native orientation of the device an additional performance gain can be achieved by calling FixNativeOrientation on the underlying RWindow. Such apps will either work in a single orientation only, or they will handle rotation themselves, by using QPainter transformations and opting out from the standard Avkon auto-rotation. In any of these cases there is no need for the lower level layers of the system to handle graphics surface rotation, the app is "fixed" to the native orientation from their point of view, therefore it is safe to call FixNativeOrientation(). Task-number: QTBUG-17742 Reviewed-by: Jason Barron
-rw-r--r--src/corelib/global/qglobal.h4
-rw-r--r--src/gui/kernel/qapplication_s60.cpp29
-rw-r--r--src/gui/kernel/qt_s60_p.h25
-rw-r--r--src/gui/kernel/qwidget.cpp4
-rw-r--r--src/gui/kernel/qwidget_p.h1
-rw-r--r--src/gui/kernel/qwidget_s60.cpp8
6 files changed, 69 insertions, 2 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index e85bbfc..69fe958 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -2459,6 +2459,10 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
#define Q_SYMBIAN_SUPPORTS_MULTIPLE_SCREENS
#endif
+#ifdef SYMBIAN_GRAPHICS_FIXNATIVEORIENTATION
+#define Q_SYMBIAN_SUPPORTS_FIXNATIVEORIENTATION
+#endif
+
//Symbian does not support data imports from a DLL
#define Q_NO_DATA_RELOCATION
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 2b10d63..5071cb5 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -1455,6 +1455,35 @@ bool QSymbianControl::isControlActive()
return IsActivated() ? true : false;
}
+void QSymbianControl::ensureFixNativeOrientation()
+{
+#if defined(Q_SYMBIAN_SUPPORTS_FIXNATIVEORIENTATION)
+ // Call FixNativeOrientation() for fullscreen QDeclarativeViews that
+ // have a locked orientation matching the native orientation of the device.
+ // This avoids unnecessary window rotation on wserv level.
+ if (!qwidget->isWindow() || qwidget->windowType() == Qt::Desktop
+ || !qwidget->inherits("QDeclarativeView")
+ || S60->screenNumberForWidget(qwidget) > 0)
+ return;
+ const bool isFullScreen = qwidget->windowState().testFlag(Qt::WindowFullScreen);
+ const bool isFixed = qwidget->d_func()->fixNativeOrientationCalled;
+ const bool matchesNative = qwidget->testAttribute(
+ S60->nativeOrientationIsPortrait ? Qt::WA_LockPortraitOrientation
+ : Qt::WA_LockLandscapeOrientation);
+ if (isFullScreen && matchesNative) {
+ if (!isFixed) {
+ Window().FixNativeOrientation();
+ qwidget->d_func()->fixNativeOrientationCalled = true;
+ }
+ } else if (isFixed) {
+ qwidget->d_func()->fixNativeOrientationCalled = false;
+ qwidget->hide();
+ qwidget->d_func()->create_sys(0, false, true);
+ qwidget->show();
+ }
+#endif
+}
+
/*!
\typedef QApplication::QS60MainApplicationFactory
\since 4.6
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index 3bb27c3..102c0ca 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -189,6 +189,8 @@ public:
int screenHeightInPixelsForScreen[qt_symbian_max_screens];
int screenWidthInTwipsForScreen[qt_symbian_max_screens];
int screenHeightInTwipsForScreen[qt_symbian_max_screens];
+
+ bool nativeOrientationIsPortrait;
};
Q_AUTOTEST_EXPORT QS60Data* qGlobalS60Data();
@@ -233,6 +235,8 @@ public:
bool isControlActive();
+ void ensureFixNativeOrientation();
+
#ifdef Q_WS_S60
void FadeBehindPopup(bool fade){ popupFader.FadeBehindPopup( this, this, fade); }
void HandleStatusPaneSizeChange();
@@ -327,9 +331,11 @@ inline QS60Data::QS60Data()
inline void QS60Data::updateScreenSize()
{
+ CWsScreenDevice *dev = S60->screenDevice();
+ int screenModeCount = dev->NumScreenModes();
+ int mode = dev->CurrentScreenMode();
TPixelsTwipsAndRotation params;
- int mode = S60->screenDevice()->CurrentScreenMode();
- S60->screenDevice()->GetScreenModeSizeAndRotation(mode, params);
+ dev->GetScreenModeSizeAndRotation(mode, params);
S60->screenWidthInPixels = params.iPixelSize.iWidth;
S60->screenHeightInPixels = params.iPixelSize.iHeight;
S60->screenWidthInTwips = params.iTwipsSize.iWidth;
@@ -352,6 +358,21 @@ inline void QS60Data::updateScreenSize()
S60->screenWidthInTwipsForScreen[i] = params.iTwipsSize.iWidth;
S60->screenHeightInTwipsForScreen[i] = params.iTwipsSize.iHeight;
}
+
+ // Look for a screen mode with rotation 0
+ // in order to decide what the native orientation is.
+ int nativeScreenWidthInPixels = 0;
+ int nativeScreenHeightInPixels = 0;
+ for (mode = 0; mode < screenModeCount; ++mode) {
+ TPixelsAndRotation sizeAndRotation;
+ dev->GetScreenModeSizeAndRotation(mode, sizeAndRotation);
+ if (sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationNormal) {
+ nativeScreenWidthInPixels = sizeAndRotation.iPixelSize.iWidth;
+ nativeScreenHeightInPixels = sizeAndRotation.iPixelSize.iHeight;
+ break;
+ }
+ }
+ S60->nativeOrientationIsPortrait = nativeScreenWidthInPixels <= nativeScreenHeightInPixels;
}
inline RWsSession& QS60Data::wsSession()
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index e8d9efd..0a73481 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -306,6 +306,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
, qd_hd(0)
#elif defined(Q_OS_SYMBIAN)
, symbianScreenNumber(0)
+ , fixNativeOrientationCalled(false)
#endif
{
if (!qApp) {
@@ -10866,6 +10867,9 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation));
S60->orientationSet = true;
+ QSymbianControl *window = static_cast<QSymbianControl *>(internalWinId());
+ if (window)
+ window->ensureFixNativeOrientation();
#endif
break;
}
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 13e2349..377e3a7 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -883,6 +883,7 @@ public:
static QWidget *mouseGrabber;
static QWidget *keyboardGrabber;
int symbianScreenNumber; // only valid for desktop widget and top-levels
+ bool fixNativeOrientationCalled;
void s60UpdateIsOpaque();
void reparentChildren();
void registerTouchWindow();
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index b65ae4d..f00b1e5 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -278,6 +278,8 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h)));
topData()->normalGeometry = data.crect;
}
+ QSymbianControl *window = static_cast<QSymbianControl *>(q->internalWinId());
+ window->ensureFixNativeOrientation();
} else {
data.crect.setRect(x, y, w, h);
@@ -1273,6 +1275,12 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
if (newstate & Qt::WindowActive)
activateWindow();
+ if (isWindow()) {
+ // Now that the new state is set, fix the display memory layout, if needed.
+ QSymbianControl *window = static_cast<QSymbianControl *>(effectiveWinId());
+ window->ensureFixNativeOrientation();
+ }
+
QWindowStateChangeEvent e(oldstate);
QApplication::sendEvent(this, &e);
}