From df7d34d4b4d713c5b26871e31e0bec950480f2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 16 Apr 2012 19:30:04 +0200 Subject: Implement nativeBufferLocking This is needed to be able to post directly to the framebuffer. Change-Id: I6d19a6c8d9736a513a22dfa71358e6c4c7968e15 Reviewed-by: Paul Olav Tvete --- .../graphicshardwareintegration.h | 3 +- .../wayland_egl/waylandeglintegration.cpp | 34 ++++++++++++++++++---- .../wayland_egl/waylandeglintegration.h | 3 ++ 3 files changed, 34 insertions(+), 6 deletions(-) (limited to 'src/compositor/hardware_integration') diff --git a/src/compositor/hardware_integration/graphicshardwareintegration.h b/src/compositor/hardware_integration/graphicshardwareintegration.h index bc1ec4223..4b0510d5d 100644 --- a/src/compositor/hardware_integration/graphicshardwareintegration.h +++ b/src/compositor/hardware_integration/graphicshardwareintegration.h @@ -64,7 +64,8 @@ public: virtual bool setDirectRenderSurface(WaylandSurface *) {return false;} - virtual void *toNativeBufferHandle(struct wl_buffer *) { return 0; } + virtual void *lockNativeBuffer(struct wl_buffer *, QOpenGLContext *) const { return 0; } + virtual void unlockNativeBuffer(void *, QOpenGLContext *) const { return; } static GraphicsHardwareIntegration *createGraphicsHardwareIntegration(WaylandCompositor *compositor); diff --git a/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp b/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp index c9bbbe14a..8de4d086a 100644 --- a/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp +++ b/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp @@ -57,6 +57,7 @@ #include #include + GraphicsHardwareIntegration * GraphicsHardwareIntegration::createGraphicsHardwareIntegration(WaylandCompositor *compositor) { return new WaylandEglIntegration(compositor); @@ -87,7 +88,7 @@ public: , egl_bind_wayland_display(0) , egl_unbind_wayland_display(0) , egl_create_image(0) - , egl_destory_image(0) + , egl_destroy_image(0) , gl_egl_image_target_texture_2d(0) { } EGLDisplay egl_display; @@ -100,7 +101,7 @@ public: PFNEGLUNBINDWAYLANDDISPLAYWL egl_unbind_wayland_display; PFNEGLCREATEIMAGEKHRPROC egl_create_image; - PFNEGLDESTROYIMAGEKHRPROC egl_destory_image; + PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image; PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_egl_image_target_texture_2d; }; @@ -128,7 +129,7 @@ void WaylandEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) reinterpret_cast(eglGetProcAddress("eglUnbindWaylandDisplayWL")); d->egl_create_image = reinterpret_cast(eglGetProcAddress("eglCreateImageKHR")); - d->egl_destory_image = + d->egl_destroy_image = reinterpret_cast(eglGetProcAddress("eglDestroyImageKHR")); d->gl_egl_image_target_texture_2d = reinterpret_cast(eglGetProcAddress("glEGLImageTargetTexture2DOES")); @@ -136,7 +137,7 @@ void WaylandEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) if (d->egl_bind_wayland_display && d->egl_unbind_wayland_display && d->egl_create_image - && d->egl_destory_image + && d->egl_destroy_image && d->gl_egl_image_target_texture_2d) { if (d->egl_bind_wayland_display(d->egl_display, waylandDisplay->handle())) { d->valid = true; @@ -159,6 +160,7 @@ GLuint WaylandEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGL } QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); +//#####jl: fix to use functions pointer EGLContext egl_context = nativeInterface->nativeResourceForContext("EglContext", context); EGLImageKHR image = d->egl_create_image(d->egl_display, egl_context, @@ -177,7 +179,7 @@ GLuint WaylandEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGL glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - d->egl_destory_image(d->egl_display, image); + d->egl_destroy_image(d->egl_display, image); return textureId; } @@ -221,3 +223,25 @@ bool WaylandEglIntegration::setDirectRenderSurface(WaylandSurface *surface) return flipper; } +void *WaylandEglIntegration::lockNativeBuffer(struct wl_buffer *buffer, QOpenGLContext *context) const +{ + Q_D(const WaylandEglIntegration); + + QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); +//#####jl: fix to use functions pointer + EGLContext egl_context = nativeInterface->nativeResourceForContext("EglContext", context); + + EGLImageKHR image = d->egl_create_image(d->egl_display, egl_context, + EGL_WAYLAND_BUFFER_WL, + buffer, NULL); + return image; +} + +void WaylandEglIntegration::unlockNativeBuffer(void *native_buffer, QOpenGLContext *) const +{ + Q_D(const WaylandEglIntegration); + EGLImageKHR image = static_cast(native_buffer); + + d->egl_destroy_image(d->egl_display, image); +} + diff --git a/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.h b/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.h index 77f728180..0333ae163 100644 --- a/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.h +++ b/src/compositor/hardware_integration/wayland_egl/waylandeglintegration.h @@ -59,6 +59,9 @@ public: bool setDirectRenderSurface(WaylandSurface *); + virtual void *lockNativeBuffer(struct wl_buffer *buffer, QOpenGLContext *context) const; + virtual void unlockNativeBuffer(void *native_buffer, QOpenGLContext *context) const; + private: Q_DISABLE_COPY(WaylandEglIntegration) QScopedPointer d_ptr; -- cgit v1.2.3