Inform the platform plugin when direct rendering is active
authorPaul Olav Tvete <paul.tvete@nokia.com>
Thu, 10 May 2012 15:50:12 +0000 (17:50 +0200)
committerPaul Olav Tvete <paul.tvete@nokia.com>
Thu, 10 May 2012 16:05:25 +0000 (18:05 +0200)
Change-Id: I58f7e65dc755c99f5bb83dae2c68254727653a1c
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/wayland_wrapper/wlcompositor.h
src/compositor/wayland_wrapper/wlsurface.cpp

index d43b402..df19698 100644 (file)
@@ -125,6 +125,7 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
     , m_orientation(Qt::PrimaryOrientation)
     , m_directRenderSurface(0)
     , m_directRenderContext(0)
+    , m_directRenderActive(false)
 #if defined (QT_COMPOSITOR_WAYLAND_GL)
     , m_graphics_hw_integration(0)
 #endif
@@ -340,6 +341,9 @@ bool Compositor::setDirectRenderSurface(Surface *surface, QOpenGLContext *contex
         m_pageFlipper = QGuiApplication::primaryScreen()->handle()->pageFlipper();
     }
 
+    if (!surface)
+        setDirectRenderingActive(false);
+
     if (m_graphics_hw_integration && m_graphics_hw_integration->setDirectRenderSurface(surface ? surface->waylandSurface() : 0)) {
         m_directRenderSurface = surface;
         m_directRenderContext = context;
@@ -351,6 +355,16 @@ bool Compositor::setDirectRenderSurface(Surface *surface, QOpenGLContext *contex
     return false;
 }
 
+void Compositor::setDirectRenderingActive(bool active)
+{
+    if (m_directRenderActive == active)
+        return;
+    m_directRenderActive = active;
+
+    if (m_pageFlipper)
+        QMetaObject::invokeMethod(m_pageFlipper, "setDirectRenderingActive", Q_ARG(bool, active));
+}
+
 QList<struct wl_client *> Compositor::clients() const
 {
     QList<struct wl_client *> list;
index 7712485..c0c1772 100644 (file)
@@ -108,6 +108,7 @@ public:
     Surface *directRenderSurface() const {return m_directRenderSurface;}
     QOpenGLContext *directRenderContext() const {return m_directRenderContext;}
     QPlatformScreenPageFlipper *pageFlipper() const { return m_pageFlipper; }
+    void setDirectRenderingActive(bool active);
 
     QList<Surface*> surfaces() const { return m_surfaces; }
     QList<Surface*> surfacesForClient(wl_client* client);
@@ -181,6 +182,7 @@ private:
 
     Surface *m_directRenderSurface;
     QOpenGLContext *m_directRenderContext;
+    bool m_directRenderActive;
 
 #ifdef QT_COMPOSITOR_WAYLAND_GL
     GraphicsHardwareIntegration *m_graphics_hw_integration;
index a027397..f0dca77 100644 (file)
@@ -381,6 +381,7 @@ bool Surface::postBuffer() {
         if (surfaceBuffer && m_compositor->pageFlipper()) {
             if (m_compositor->pageFlipper()->displayBuffer(surfaceBuffer)) {
                 surfaceBuffer->setPageFlipperHasBuffer(true);
+                m_compositor->setDirectRenderingActive(true);
                 return true;
             } else {
                 qDebug() << "could not post buffer";