Use the new page flipping API
authorPaul Olav Tvete <paul.tvete@nokia.com>
Thu, 22 Sep 2011 13:48:47 +0000 (15:48 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Thu, 22 Sep 2011 14:46:17 +0000 (16:46 +0200)
Change-Id: I99bdbcef9395747ccd550e693bc6b84eccc54a40
Reviewed-on: http://codereview.qt-project.org/5392
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/qt-compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp
src/qt-compositor/hardware_integration/wayland_egl/waylandeglintegration.h
src/qt-compositor/wayland_wrapper/wlcompositor.cpp
src/qt-compositor/wayland_wrapper/wlsurface.cpp

index e20c262..497c7eb 100644 (file)
@@ -43,6 +43,7 @@
 #include <QtGui/QPlatformNativeInterface>
 #include <QtGui/QGuiApplication>
 #include <QtGui/QOpenGLContext>
+#include <QtGui/QPlatformScreen>
 
 #define EGL_EGLEXT_PROTOTYPES
 #include <EGL/egl.h>
@@ -51,6 +52,7 @@
 #define GL_GLEXT_PROTOTYPES
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
+#include <QDebug>
 
 GraphicsHardwareIntegration * GraphicsHardwareIntegration::createGraphicsHardwareIntegration(WaylandCompositor *compositor)
 {
@@ -124,3 +126,18 @@ GLuint WaylandEglIntegration::createTextureFromBuffer(wl_buffer *buffer)
 
     return textureId;
 }
+
+bool WaylandEglIntegration::setDirectRenderSurface(WaylandSurface *)
+{
+    QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(m_compositor->window());
+    return screen && screen->pageFlipper();
+}
+
+
+bool WaylandEglIntegration::postBuffer(struct wl_buffer *buffer)
+{
+    QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(m_compositor->window());
+    QPlatformScreenPageFlipper *flipper = screen->pageFlipper();
+
+    return flipper ? flipper->displayBuffer(buffer) : false;
+}
index f727051..4e98d18 100644 (file)
@@ -56,6 +56,9 @@ public:
 
     GLuint createTextureFromBuffer(wl_buffer *buffer);
 
+    bool setDirectRenderSurface(WaylandSurface *);
+    bool postBuffer(struct wl_buffer *);
+
 private:
     Q_DISABLE_COPY(WaylandEglIntegration)
     QScopedPointer<WaylandEglIntegrationPrivate> d_ptr;
index 453a9ac..1bab077 100644 (file)
@@ -360,6 +360,8 @@ void Compositor::surfaceDestroyed(Surface *surface)
         setKeyFocus(0);
     if (m_pointerFocusSurface == surface)
         setPointerFocus(0);
+    if (m_directRenderSurface == surface)
+        setDirectRenderSurface(0);
 }
 
 void Compositor::markSurfaceAsDirty(Wayland::Surface *surface)
index dc01c0a..cf8a443 100644 (file)
@@ -99,7 +99,7 @@ public:
 
     void attach(struct wl_buffer *buffer) {
         bool emitMap = !surfaceBuffer;
-        if (surfaceBuffer && ! textureCreatedForBuffer) {
+        if (surfaceBuffer && ! textureCreatedForBuffer && surfaceBuffer != directRenderBuffer) {
             qWarning() << "### WaylandSurface::attach() releasing undisplayed buffer ###";
              wl_client_post_event(client,&surfaceBuffer->resource.object,WL_BUFFER_RELEASE);
         }
@@ -216,12 +216,12 @@ void Surface::damage(const QRect &rect)
             if (d->previousBuffer) {
                 wl_client_post_event(d->client,&d->previousBuffer->resource.object,WL_BUFFER_RELEASE);
             }
-            d->previousBuffer = d->buffer();
+            d->directRenderBuffer = d->previousBuffer = d->buffer();
             return;
         }
     }
 #endif
-
+    d->directRenderBuffer = 0;
     d->compositor->markSurfaceAsDirty(this);
 
     emit d->qtSurface->damaged(rect);