Direct rendering changes
authorPaul Olav Tvete <paul.tvete@nokia.com>
Mon, 5 Dec 2011 16:31:30 +0000 (17:31 +0100)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 6 Dec 2011 15:33:39 +0000 (16:33 +0100)
Change-Id: Ie3bebae680e370d5351279a988945c6a5d65ed75
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

index 0b55571..a232c48 100644 (file)
 
 #include "waylandeglintegration.h"
 #include "wayland_wrapper/wlcompositor.h"
-
+#include "wayland_wrapper/wlsurface.h"
+#include "compositor_api/waylandsurface.h"
 #include <QtGui/QPlatformNativeInterface>
 #include <QtGui/QGuiApplication>
 #include <QtGui/QOpenGLContext>
 #include <QtGui/QPlatformScreen>
 #include <QtGui/QWindow>
+#include <QtCore/QWeakPointer>
+
+#include <QDebug>
 
 #define EGL_EGLEXT_PROTOTYPES
 #include <EGL/egl.h>
@@ -69,6 +73,9 @@ public:
     EGLDisplay egl_display;
     bool valid;
     bool flipperConnected;
+#ifdef EGL_WL_request_client_buffer_format
+    QWeakPointer<WaylandSurface> directRenderSurface;
+#endif
 };
 
 WaylandEglIntegration::WaylandEglIntegration(WaylandCompositor *compositor)
@@ -130,7 +137,17 @@ GLuint WaylandEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGL
     return textureId;
 }
 
-bool WaylandEglIntegration::setDirectRenderSurface(WaylandSurface *)
+bool WaylandEglIntegration::isYInverted(struct wl_buffer *buffer) const
+{
+#ifdef EGL_WL_request_client_buffer_format
+    return eglGetBufferYInvertedWL(buffer);
+#else
+    return GraphicsHardwareIntegration::isYInverted(buffer);
+#endif
+}
+
+
+bool WaylandEglIntegration::setDirectRenderSurface(WaylandSurface *surface)
 {
     Q_D(WaylandEglIntegration);
 
@@ -140,6 +157,20 @@ bool WaylandEglIntegration::setDirectRenderSurface(WaylandSurface *)
         QObject::connect(flipper, SIGNAL(bufferReleased(void*)), m_compositor->handle(), SLOT(releaseBuffer(void*)));
         d->flipperConnected = true;
     }
+#ifdef EGL_WL_request_client_buffer_format
+    int buffer_format = surface ? EGL_SCANOUT_FORMAT_WL : EGL_RENDER_FORMAT_WL;
+    struct wl_client *client = 0;
+    if (surface) {
+        client = surface->handle()->clientHandle();
+    } else {
+        WaylandSurface *oldSurface = d->directRenderSurface.data();
+        if (oldSurface)
+            client = oldSurface->handle()->clientHandle();
+    }
+    if (client)
+        eglRequestClientBufferFormatWL(d->egl_display, client, buffer_format);
+    d->directRenderSurface = surface;
+#endif
     return flipper;
 }
 
index 39a63c6..7add3df 100644 (file)
@@ -55,6 +55,7 @@ public:
     void initializeHardware(Wayland::Display *waylandDisplay);
 
     GLuint createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context);
+    bool isYInverted(struct wl_buffer *) const;
 
     bool setDirectRenderSurface(WaylandSurface *);
     bool postBuffer(struct wl_buffer *);
index 60dabc0..1680947 100644 (file)
@@ -247,7 +247,7 @@ void Compositor::releaseBuffer(void *bufferHandle)
 {
     struct wl_buffer *buffer = static_cast<struct wl_buffer*>(bufferHandle);
     if (buffer) {
-        qDebug() << "WL_BUFFER_RELEASE" << buffer<< buffer->resource.client;
+        //qDebug() << "WL_BUFFER_RELEASE" << buffer<< buffer->resource.client;
         wl_resource_post_event(&buffer->resource, WL_BUFFER_RELEASE);
     }