Don't create a hardware integration if the compositor is raster based.
authorSamuel Rødal <samuel.rodal@nokia.com>
Fri, 20 May 2011 07:33:06 +0000 (09:33 +0200)
committerSamuel Rødal <samuel.rodal@nokia.com>
Fri, 20 May 2011 07:46:17 +0000 (09:46 +0200)
src/qt-compositor/wayland_wrapper/wlcompositor.cpp
src/qt-compositor/wayland_wrapper/wlsurface.cpp

index e46f749..d3e1a76 100644 (file)
@@ -180,11 +180,13 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
     , m_pointerFocusSurface(0)
     , m_keyFocusSurface(0)
     , m_directRenderSurface(0)
+    , m_graphics_hw_integration(0)
 {
     compositor = this;
 
 #if defined (QT_COMPOSITOR_WAYLAND_GL)
-    m_graphics_hw_integration = GraphicsHardwareIntegration::createGraphicsHardwareIntegration(qt_compositor);
+    if (qt_compositor->topLevelWidget()->platformWindowFormat().windowApi() != QPlatformWindowFormat::Raster)
+        m_graphics_hw_integration = GraphicsHardwareIntegration::createGraphicsHardwareIntegration(qt_compositor);
 #endif
     m_windowManagerWaylandProtocol = new WindowManagerServerIntegration(this);
 
@@ -363,7 +365,8 @@ GraphicsHardwareIntegration * Compositor::graphicsHWIntegration() const
 void Compositor::initializeHardwareIntegration()
 {
 #ifdef QT_COMPOSITOR_WAYLAND_GL
-    m_graphics_hw_integration->initializeHardware(m_display);
+    if (m_graphics_hw_integration)
+        m_graphics_hw_integration->initializeHardware(m_display);
 #endif
 }
 
@@ -375,7 +378,7 @@ void Compositor::initializeWindowManagerProtocol()
 bool Compositor::setDirectRenderSurface(Surface *surface)
 {
 #ifdef QT_COMPOSITOR_WAYLAND_GL
-    if (m_graphics_hw_integration->setDirectRenderSurface(surface ? surface->handle() : 0)) {
+    if (m_graphics_hw_integration && m_graphics_hw_integration->setDirectRenderSurface(surface ? surface->handle() : 0)) {
         m_directRenderSurface = surface;
         return true;
     }
index d26cd01..0fb93fc 100644 (file)
@@ -184,7 +184,8 @@ Surface::~Surface()
     Q_D(Surface);
     d->compositor->surfaceDestroyed(this);
 #ifdef QT_COMPOSITOR_WAYLAND_GL
-    glDeleteTextures(1,&d->texture_id);
+    if (d->compositor->graphicsHWIntegration())
+        glDeleteTextures(1,&d->texture_id);
 #endif
     delete d->qtSurface;
 }
@@ -200,12 +201,14 @@ bool Surface::isYInverted() const
 #ifdef QT_COMPOSITOR_WAYLAND_GL
     Q_D(const Surface);
 
-    if (d->type() == WaylandSurface::Texture) {
-        if (textureId()) {
+    if (d->compositor->graphicsHWIntegration()) {
+        if (d->type() == WaylandSurface::Texture) {
+            if (textureId()) {
+                return d->compositor->graphicsHWIntegration()->isYInverted(d->buffer());
+            }
+        } else if (d->type() == WaylandSurface::Direct) {
             return d->compositor->graphicsHWIntegration()->isYInverted(d->buffer());
         }
-    } else if (d->type() == WaylandSurface::Direct) {
-        return d->compositor->graphicsHWIntegration()->isYInverted(d->buffer());
     }
 #endif
     //shm surfaces are not flipped (in our "world")
@@ -217,7 +220,7 @@ void Surface::damage(const QRect &rect)
     Q_D(Surface);
 
 #ifdef QT_COMPOSITOR_WAYLAND_GL
-    if (d->type() == WaylandSurface::Direct) {
+    if (d->compositor->graphicsHWIntegration() && d->type() == WaylandSurface::Direct) {
         //should the texture be deleted here, or should we explicitly delete it
         //when going into direct mode...
         if (d->textureCreatedForBuffer) {
@@ -225,7 +228,7 @@ void Surface::damage(const QRect &rect)
             d->textureCreatedForBuffer = false;
         }
         if (d->compositor->graphicsHWIntegration()->postBuffer(d->directRenderBuffer))
-                return;
+            return;
     }
 #endif
 
@@ -258,8 +261,8 @@ QImage Surface::image() const
 GLuint Surface::textureId() const
 {
     Q_D(const Surface);
-    if ( d->type() == WaylandSurface::Texture
-            && !d->textureCreatedForBuffer) {
+    if (d->compositor->graphicsHWIntegration() && d->type() == WaylandSurface::Texture
+         && !d->textureCreatedForBuffer) {
         glDeleteTextures(1,&d->texture_id);
         Surface *that = const_cast<Surface *>(this);
         GraphicsHardwareIntegration *hwIntegration = d->compositor->graphicsHWIntegration();