Renamed bindBufferToTexture to createTextureFromBuffer
authorJørgen Lind <jorgen.lind@nokia.com>
Fri, 11 Mar 2011 15:12:03 +0000 (16:12 +0100)
committerJørgen Lind <jorgen.lind@nokia.com>
Fri, 11 Mar 2011 15:12:03 +0000 (16:12 +0100)
src/qt-compositor/dri2_xcb/dri2xcbhwintegration.cpp
src/qt-compositor/dri2_xcb/dri2xcbhwintegration.h
src/qt-compositor/graphicshardwareintegration.h
src/qt-compositor/mesa_egl/mesaeglintegration.cpp
src/qt-compositor/mesa_egl/mesaeglintegration.h
src/qt-compositor/private/wlcompositor.cpp
src/qt-compositor/private/wlsurface.cpp

index 123ef28..21c0cd7 100644 (file)
@@ -111,11 +111,15 @@ void Dri2XcbHWIntegration::initializeHardware(Wayland::Display *waylandDisplay)
     waylandDisplay->addGlobalObject(m_drm_object->base(),&wl_drm_interface,&drm_interface,post_drm_device);
 }
 
-void Dri2XcbHWIntegration::bindBufferToTexture(wl_buffer *buffer, GLuint textureId)
+GLuint Dri2XcbHWIntegration::createTextureFromBuffer(wl_buffer *buffer)
 {
     Dri2XcbBuffer *dri2Buffer = Wayland::wayland_cast<Dri2XcbBuffer *>(buffer);
 
+    GLuint textureId = 0;
+    glGenTextures(1,&textureId);
     glBindTexture(GL_TEXTURE_2D, textureId);
 
     glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, dri2Buffer->image());
+
+    return textureId;
 }
index 3fd5dfc..ae013ba 100644 (file)
@@ -12,7 +12,7 @@ public:
 
     void initializeHardware(Wayland::Display *waylandDisplay);
 
-    void bindBufferToTexture(wl_buffer *buffer, GLuint textureId);
+    GLuint createTextureFromBuffer(wl_buffer *buffer);
 
 private:
     DrmObject *m_drm_object;
index 040e47d..08d6859 100644 (file)
@@ -57,7 +57,7 @@ public:
     /** Bind the Wayland buffer to the textureId. The correct context is the current context,
         so there is no need to do makeCurrent in this function.
      **/
-    virtual void bindBufferToTexture(struct wl_buffer *buffer, GLuint textureId) = 0;
+    virtual GLuint createTextureFromBuffer(struct wl_buffer *buffer) = 0;
 
 protected:
     WaylandCompositor *m_compositor;
index 1bd41e3..f3d7d7a 100644 (file)
@@ -88,18 +88,21 @@ void MesaEglIntegration::initializeHardware(Wayland::Display *waylandDisplay)
     }
 }
 
-void MesaEglIntegration::bindBufferToTexture(wl_buffer *buffer, GLuint textureId)
+GLuint MesaEglIntegration::createTextureFromBuffer(wl_buffer *buffer)
 {
     Q_D(MesaEglIntegration);
     EGLImageKHR image = eglCreateImageKHR(d->egl_display, d->egl_context,
                                           EGL_WAYLAND_BUFFER_WL,
                                           buffer, NULL);
 
+    GLuint textureId;
+    glGenTextures(1,&textureId);
+
     glBindTexture(GL_TEXTURE_2D, textureId);
 
     glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
 
     eglDestroyImageKHR(d->egl_display, image);
 
-
+    return textureId;
 }
index 9ad677f..8faba18 100644 (file)
@@ -54,7 +54,7 @@ public:
 
     void initializeHardware(Wayland::Display *waylandDisplay);
 
-    void bindBufferToTexture(wl_buffer *buffer, GLuint textureId);
+    GLuint createTextureFromBuffer(wl_buffer *buffer);
 
 private:
     Q_DISABLE_COPY(MesaEglIntegration)
index 3d9652e..a4b6293 100644 (file)
@@ -311,6 +311,7 @@ void Compositor::setInputFocus(uint winId)
 
 void Compositor::surfaceDamaged(Surface *surface, const QRect &rect)
 {
+    surface->commit();
     m_qt_compositor->surfaceDamaged(surface->id(), rect);
 }
 
index 4bc75ab..e2ba676 100644 (file)
@@ -64,13 +64,7 @@ public:
         current.type = State::Invalid;
         staged.type = State::Invalid;
 #ifdef QT_COMPOSITOR_WAYLAND_GL
-        if (QWidget *topLevel = m_compositor->topLevelWidget()) {
-            if (topLevel->platformWindow() && topLevel->platformWindow()->glContext()) {
-                topLevel->platformWindow()->glContext()->makeCurrent();
-                glGenTextures(1,&current.texture_id);
-                staged.texture_id = current.texture_id;
-            }
-        }
+        staged.texture_id = current.texture_id = 0;
 #endif
     }
 
@@ -202,13 +196,14 @@ void Surface::attachHWBuffer(struct wl_buffer *buffer)
     Q_D(Surface);
     d->staged.type = SurfacePrivate::State::Texture;
     d->current.type = d->staged.type;
-    d->current.texture_id = d->staged.texture_id;
 
     //make current for the topLevel. We could have used the eglContext,
     //but then we would need to handle eglSurfaces as well.
     d->m_compositor->topLevelWidget()->platformWindow()->glContext()->makeCurrent();
 
-    d->m_compositor->graphicsHWIntegration()->bindBufferToTexture(buffer,d->current.texture_id);
+    glDeleteTextures(1,&d->staged.texture_id);
+
+    d->staged.texture_id = d->m_compositor->graphicsHWIntegration()->createTextureFromBuffer(buffer);
     d->m_compositor->surfaceResized(this,QSize(buffer->width,buffer->height));
 }
 
@@ -243,7 +238,9 @@ void Surface::mapTopLevel()
 void Surface::commit()
 {
     Q_D(Surface);
+    SurfacePrivate::State tmpState = d->current;
     d->current = d->staged;
+    d->staged = tmpState;
 }
 
 }