diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2012-04-16 19:30:04 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2012-04-17 15:20:20 +0200 |
commit | df7d34d4b4d713c5b26871e31e0bec950480f2b9 (patch) | |
tree | 7aaf805ec86934c5c92ccc723532f2746d4a9748 /src/compositor/hardware_integration | |
parent | 56758f210dc090d9b306d20c221fdc35f3b3a917 (diff) |
Implement nativeBufferLocking
This is needed to be able to post directly to the framebuffer.
Change-Id: I6d19a6c8d9736a513a22dfa71358e6c4c7968e15
Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
Diffstat (limited to 'src/compositor/hardware_integration')
3 files changed, 34 insertions, 6 deletions
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 <GLES2/gl2.h> #include <GLES2/gl2ext.h> + 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<PFNEGLUNBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglUnbindWaylandDisplayWL")); d->egl_create_image = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR")); - d->egl_destory_image = + d->egl_destroy_image = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR")); d->gl_egl_image_target_texture_2d = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(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<EGLImageKHR>(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<WaylandEglIntegrationPrivate> d_ptr; |