Use the new QPlatformNativeInterface native resource function getter
authorJørgen Lind <jorgen.lind@nokia.com>
Tue, 17 Apr 2012 07:07:09 +0000 (09:07 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Thu, 5 Jul 2012 11:34:59 +0000 (13:34 +0200)
Change-Id: I5b4e0a48247573e3fc03a87a53c02fa5b5a984d9
Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
src/compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp

index 6554073..fb25d26 100644 (file)
@@ -104,6 +104,8 @@ public:
     PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image;
 
     PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_egl_image_target_texture_2d;
+
+    QPlatformNativeInterface::NativeResourceForContextFunction get_egl_context;
 };
 
 WaylandEglIntegration::WaylandEglIntegration(WaylandCompositor *compositor)
@@ -123,6 +125,10 @@ void WaylandEglIntegration::initializeHardware(Wayland::Display *waylandDisplay)
             const char *extensionString = eglQueryString(d->egl_display, EGL_EXTENSIONS);
             if (extensionString && strstr(extensionString, "EGL_WL_bind_wayland_display"))
             {
+                d->get_egl_context = nativeInterface->nativeResourceFunctionForContext("get_egl_context");
+                if (!d->get_egl_context) {
+                    qWarning("Failed to retrieve the get_egl_context function");
+                }
                 d->egl_bind_wayland_display =
                         reinterpret_cast<PFNEGLBINDWAYLANDDISPLAYWL>(eglGetProcAddress("eglBindWaylandDisplayWL"));
                 d->egl_unbind_wayland_display =
@@ -135,6 +141,7 @@ void WaylandEglIntegration::initializeHardware(Wayland::Display *waylandDisplay)
                         reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
 
                 if (d->egl_bind_wayland_display
+                        && d->get_egl_context
                         && d->egl_unbind_wayland_display
                         && d->egl_create_image
                         && d->egl_destroy_image
@@ -160,8 +167,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);
+    EGLContext egl_context = d->get_egl_context(context);
 
     EGLImageKHR image = d->egl_create_image(d->egl_display, egl_context,
                                           EGL_WAYLAND_BUFFER_WL,
@@ -228,8 +234,7 @@ void *WaylandEglIntegration::lockNativeBuffer(struct wl_buffer *buffer, QOpenGLC
     Q_D(const WaylandEglIntegration);
 
     QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
-//#####jl: fix to use functions pointer
-    EGLContext egl_context = nativeInterface->nativeResourceForContext("EglContext", context);
+    EGLContext egl_context = d->get_egl_context(context);
 
     EGLImageKHR image = d->egl_create_image(d->egl_display, egl_context,
                                           EGL_WAYLAND_BUFFER_WL,