diff options
author | Karim Pinter <karim.pinter@digia.com> | 2013-02-27 12:21:46 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-04 06:31:56 (GMT) |
commit | aae206bd70e581f9ba2756e22f7f838d2ae2d1b6 (patch) | |
tree | a424ae5e844b496cd22e206a84bf124682dc290d | |
parent | d997d68bc8ea6f5c1e98015b7af80838b87fe283 (diff) | |
download | Qt-aae206bd70e581f9ba2756e22f7f838d2ae2d1b6.zip Qt-aae206bd70e581f9ba2756e22f7f838d2ae2d1b6.tar.gz Qt-aae206bd70e581f9ba2756e22f7f838d2ae2d1b6.tar.bz2 |
Adding transformed support for QNX QWS plugin
It implements the setDirty function which is called by the transformed
plugin when the screen is rotated. The rotated image is in the surface
memory, just the bliting is done here.
Task-number: QTBUG-29949
Change-Id: I0be2d037d6e1ef85106175aa47cc548b99b05a94
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@digia.com>
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
-rw-r--r-- | src/gui/embedded/qmouseqnx_qws.cpp | 21 | ||||
-rw-r--r-- | src/gui/embedded/qmouseqnx_qws.h | 3 | ||||
-rw-r--r-- | src/gui/embedded/qscreenqnx_qws.cpp | 54 | ||||
-rw-r--r-- | src/gui/embedded/qscreenqnx_qws.h | 4 |
4 files changed, 70 insertions, 12 deletions
diff --git a/src/gui/embedded/qmouseqnx_qws.cpp b/src/gui/embedded/qmouseqnx_qws.cpp index 0172c03..2de5be0 100644 --- a/src/gui/embedded/qmouseqnx_qws.cpp +++ b/src/gui/embedded/qmouseqnx_qws.cpp @@ -40,6 +40,9 @@ ****************************************************************************/ #include "qmouseqnx_qws.h" +#ifndef QT_NO_QWS_TRANSFORMED +#include "qscreen_qws.h" +#endif #include "qplatformdefs.h" #include "qsocketnotifier.h" @@ -113,6 +116,9 @@ QQnxMouseHandler::QQnxMouseHandler(const QString & driver, const QString &device qDebug("QQnxMouseHandler: connected."); } +#ifndef QT_NO_QWS_TRANSFORMED + transformedMousePos = QPoint(qt_screen->deviceWidth() / 2, qt_screen->deviceHeight() / 2); +#endif } /*! @@ -146,7 +152,11 @@ void QQnxMouseHandler::suspend() */ void QQnxMouseHandler::socketActivated() { +#ifndef QT_NO_QWS_TRANSFORMED + QPoint queuedPos = transformedMousePos; +#else QPoint queuedPos = mousePos; +#endif // _mouse_packet is a QNX structure. devi-hid is nice enough to translate // the raw byte data from mouse devices into generic format for us. @@ -196,13 +206,24 @@ void QQnxMouseHandler::socketActivated() // send the MouseEvent to avoid missing any clicks mouseChanged(queuedPos, buttons, 0); // mousePos updated by the mouseChanged() +#ifndef QT_NO_QWS_TRANSFORMED + queuedPos = transformedMousePos; +#else queuedPos = mousePos; +#endif mouseButtons = buttons; } } +#ifndef QT_NO_QWS_TRANSFORMED + if (queuedPos != transformedMousePos) { + mouseChanged(queuedPos, mouseButtons, 0); + transformedMousePos = queuedPos; + } +#else if (queuedPos != mousePos) mouseChanged(queuedPos, mouseButtons, 0); +#endif } QT_END_NAMESPACE diff --git a/src/gui/embedded/qmouseqnx_qws.h b/src/gui/embedded/qmouseqnx_qws.h index 930d361..20a01d6 100644 --- a/src/gui/embedded/qmouseqnx_qws.h +++ b/src/gui/embedded/qmouseqnx_qws.h @@ -72,6 +72,9 @@ private: int mouseFD; int mouseButtons; bool absolutePositioning; +#ifndef QT_NO_QWS_TRANSFORMED + QPoint transformedMousePos; +#endif }; QT_END_NAMESPACE diff --git a/src/gui/embedded/qscreenqnx_qws.cpp b/src/gui/embedded/qscreenqnx_qws.cpp index 04ac885..1f4141f 100644 --- a/src/gui/embedded/qscreenqnx_qws.cpp +++ b/src/gui/embedded/qscreenqnx_qws.cpp @@ -502,6 +502,10 @@ void QQnxScreen::exposeRegion(QRegion r, int changing) // the region on our in-memory surface QScreen::exposeRegion(r, changing); +#ifndef QT_NO_QWS_TRANSFORMED + if (qt_screen->isTransformed()) + return; +#endif // now our in-memory surface should be up to date with the latest changes. if (!d->hwSurface) @@ -509,33 +513,61 @@ void QQnxScreen::exposeRegion(QRegion r, int changing) // the code below copies the region from the in-memory surface to the hardware. - // just get the bounding rectangle of the region. Most screen updates are rectangular - // anyways. Code could be optimized to blit each and every member of the region - // individually, but in real life, the speed-up is neglectable - const QRect br = r.boundingRect(); - if (br.isEmpty()) - return; // ignore empty regions because gf_draw_blit2 doesn't like 0x0 dimensions - // start drawing. int ret = gf_draw_begin(d->context); if (ret != GF_ERR_OK) { qWarning("QQnxScreen: gf_draw_begin() failed with error code %d", ret); return; } + QVector<QRect> rects = r.rects(); + Q_FOREACH (QRect rect, rects) { + if (!rect.isEmpty()) { + // blit the changed region from the memory surface to the hardware surface + ret = gf_draw_blit2(d->context, d->memSurface, d->hwSurface, + rect.x(), rect.y(), rect.right(), rect.bottom(), rect.x(), rect.y()); + if (ret != GF_ERR_OK) + qWarning("QQnxScreen: gf_draw_blit2() failed with error code %d", ret); + } + } + // flush all drawing commands (in our case, a single blit) + ret = gf_draw_flush(d->context); + if (ret != GF_ERR_OK) + qWarning("QQnxScreen: gf_draw_flush() failed with error code %d", ret); + + // tell QNX that we're done drawing. + gf_draw_end(d->context); +} + +#ifndef QT_NO_QWS_TRANSFORMED +void QQnxScreen::setDirty(const QRect &r) +{ + //This function is called only when the screen is transformed + if (!qt_screen->isTransformed()) + return; + + if (!d->hwSurface) + return; + + int ret = gf_draw_begin(d->context); + + if (ret != GF_ERR_OK) { + qWarning("QQnxScreen: gf_draw_begin() failed with error code %d in setDirty", ret); + return; + } // blit the changed region from the memory surface to the hardware surface ret = gf_draw_blit2(d->context, d->memSurface, d->hwSurface, - br.x(), br.y(), br.right(), br.bottom(), br.x(), br.y()); + r.x(), r.y(), r.x()+ r.width(), r.y()+r.height(), r.x(), r.y()); if (ret != GF_ERR_OK) - qWarning("QQnxScreen: gf_draw_blit2() failed with error code %d", ret); + qWarning("QQnxScreen: gf_draw_blit2() failed with error code %d in setDirty", ret); - // flush all drawing commands (in our case, a single blit) ret = gf_draw_flush(d->context); if (ret != GF_ERR_OK) - qWarning("QQnxScreen: gf_draw_flush() failed with error code %d", ret); + qWarning("QQnxScreen: gf_draw_flush() failed with error code %d in setDirty", ret); // tell QNX that we're done drawing. gf_draw_end(d->context); } +#endif QT_END_NAMESPACE diff --git a/src/gui/embedded/qscreenqnx_qws.h b/src/gui/embedded/qscreenqnx_qws.h index 147b2a4..a2ff897 100644 --- a/src/gui/embedded/qscreenqnx_qws.h +++ b/src/gui/embedded/qscreenqnx_qws.h @@ -69,7 +69,9 @@ public: void blank(bool on); void exposeRegion(QRegion r, int changing); - +#ifndef QT_NO_QWS_TRANSFORMED + void setDirty(const QRect&); +#endif private: QQnxScreenContext * const d; }; |