From 666ac28257a2ecbff9c4c1be218801324633f840 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B8rgen=20Lind?= Date: Fri, 11 Mar 2011 16:12:03 +0100 Subject: [PATCH] Renamed bindBufferToTexture to createTextureFromBuffer --- src/qt-compositor/dri2_xcb/dri2xcbhwintegration.cpp | 6 +++++- src/qt-compositor/dri2_xcb/dri2xcbhwintegration.h | 2 +- src/qt-compositor/graphicshardwareintegration.h | 2 +- src/qt-compositor/mesa_egl/mesaeglintegration.cpp | 7 +++++-- src/qt-compositor/mesa_egl/mesaeglintegration.h | 2 +- src/qt-compositor/private/wlcompositor.cpp | 1 + src/qt-compositor/private/wlsurface.cpp | 15 ++++++--------- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/qt-compositor/dri2_xcb/dri2xcbhwintegration.cpp b/src/qt-compositor/dri2_xcb/dri2xcbhwintegration.cpp index 123ef28..21c0cd7 100644 --- a/src/qt-compositor/dri2_xcb/dri2xcbhwintegration.cpp +++ b/src/qt-compositor/dri2_xcb/dri2xcbhwintegration.cpp @@ -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(buffer); + GLuint textureId = 0; + glGenTextures(1,&textureId); glBindTexture(GL_TEXTURE_2D, textureId); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, dri2Buffer->image()); + + return textureId; } diff --git a/src/qt-compositor/dri2_xcb/dri2xcbhwintegration.h b/src/qt-compositor/dri2_xcb/dri2xcbhwintegration.h index 3fd5dfc..ae013ba 100644 --- a/src/qt-compositor/dri2_xcb/dri2xcbhwintegration.h +++ b/src/qt-compositor/dri2_xcb/dri2xcbhwintegration.h @@ -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; diff --git a/src/qt-compositor/graphicshardwareintegration.h b/src/qt-compositor/graphicshardwareintegration.h index 040e47d..08d6859 100644 --- a/src/qt-compositor/graphicshardwareintegration.h +++ b/src/qt-compositor/graphicshardwareintegration.h @@ -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; diff --git a/src/qt-compositor/mesa_egl/mesaeglintegration.cpp b/src/qt-compositor/mesa_egl/mesaeglintegration.cpp index 1bd41e3..f3d7d7a 100644 --- a/src/qt-compositor/mesa_egl/mesaeglintegration.cpp +++ b/src/qt-compositor/mesa_egl/mesaeglintegration.cpp @@ -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; } diff --git a/src/qt-compositor/mesa_egl/mesaeglintegration.h b/src/qt-compositor/mesa_egl/mesaeglintegration.h index 9ad677f..8faba18 100644 --- a/src/qt-compositor/mesa_egl/mesaeglintegration.h +++ b/src/qt-compositor/mesa_egl/mesaeglintegration.h @@ -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) diff --git a/src/qt-compositor/private/wlcompositor.cpp b/src/qt-compositor/private/wlcompositor.cpp index 3d9652e..a4b6293 100644 --- a/src/qt-compositor/private/wlcompositor.cpp +++ b/src/qt-compositor/private/wlcompositor.cpp @@ -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); } diff --git a/src/qt-compositor/private/wlsurface.cpp b/src/qt-compositor/private/wlsurface.cpp index 4bc75ab..e2ba676 100644 --- a/src/qt-compositor/private/wlsurface.cpp +++ b/src/qt-compositor/private/wlsurface.cpp @@ -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,¤t.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; } } -- 2.7.4