Page flipping API for QPlatformScreen
authorPaul Olav Tvete <paul.tvete@nokia.com>
Thu, 22 Sep 2011 12:30:40 +0000 (14:30 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 23 Sep 2011 08:37:49 +0000 (10:37 +0200)
Adding a page flipping API for platform plugins. This
enables Wayland compositors to show full-screen client windows directly
without copying any data - if supported by the platform.

Change-Id: I19abe366434140f9e20a0655fe7cd41ea9264fca
Reviewed-on: http://codereview.qt-project.org/5385
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/gui/kernel/qplatformscreen_qpa.cpp
src/gui/kernel/qplatformscreen_qpa.h

index 8fb4259..e25e3f3 100644 (file)
@@ -181,3 +181,41 @@ QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window
     Reimplement in subclass to return the image format which corresponds to the screen format
 */
 
+
+/*!
+    \class QPlatformScreenPageFlipper
+    \since 5.0
+    \internal
+    \preliminary
+    \ingroup qpa
+
+    \brief The QPlatformScreenPageFlipper class provides an abstract interface for display buffer swapping
+
+    Implement the displayBuffer() function to initiate a buffer swap. The
+    bufferDisplayed() signal should be emitted once the buffer is actually displayed on
+    the screen. The bufferReleased() signal should be emitted when the buffer data is no
+    longer owned by the display hardware.
+*/
+
+/*!  \fn bool QPlatformScreenPageFlipper::displayBuffer(void *bufferHandle)
+
+Implemented in subclasses to display the buffer referenced by \a bufferHandle directly on
+the screen. Returns \c true if it is possible to display the buffer, and \c false if the
+buffer cannot be displayed.
+
+If this function returns true, the buffer must not be modified or destroyed before the
+bufferReleased() signal is emitted.  The signal bufferDisplayed() is emitted when the buffer
+is displayed on the screen. The two signals may be emitted in either order.
+
+This function is allowed to block.
+*/
+
+
+/*!
+  Implemented in subclasses to return a page flipper object for the screen, or 0 if the
+  hardware does not support page flipping. The default implementation returns 0.
+ */
+QPlatformScreenPageFlipper *QPlatformScreen::pageFlipper() const
+{
+    return 0;
+}
index 3851b18..9919ca5 100644 (file)
@@ -67,6 +67,17 @@ class QPlatformWindow;
 class QScreen;
 class QSurfaceFormat;
 
+class QPlatformScreenPageFlipper : public QObject
+{
+    Q_OBJECT
+public:
+    virtual bool displayBuffer(void *bufferHandle) = 0;
+
+    signals:
+    void bufferDisplayed(void *bufferHandle);
+    void bufferReleased(void *bufferHandle);
+};
+
 class Q_GUI_EXPORT QPlatformScreen
 {
     Q_DECLARE_PRIVATE(QPlatformScreen)
@@ -95,6 +106,8 @@ public:
 
     virtual QString name() const { return QString(); }
 
+    virtual QPlatformScreenPageFlipper *pageFlipper() const;
+
 protected:
     QScopedPointer<QPlatformScreenPrivate> d_ptr;