25class BrcmEglIntegrationPrivate
28 BrcmEglIntegrationPrivate() =
default;
30 static BrcmEglIntegrationPrivate *get(BrcmEglIntegration *integration);
32 EGLDisplay egl_display = EGL_NO_DISPLAY;
34 PFNEGLQUERYGLOBALIMAGEBRCMPROC eglQueryGlobalImageBRCM;
35 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
36 PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
37 PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
47 Q_D(BrcmEglIntegration);
49 QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
50 if (nativeInterface) {
51 d->egl_display = nativeInterface->nativeResourceForIntegration(
"EglDisplay");
53 qWarning(
"Failed to acquire EGL display from platform integration");
55 d->eglQueryGlobalImageBRCM = (PFNEGLQUERYGLOBALIMAGEBRCMPROC) eglGetProcAddress(
"eglQueryGlobalImageBRCM");
57 if (!d->eglQueryGlobalImageBRCM) {
58 qWarning(
"Failed to resolve eglQueryGlobalImageBRCM");
62 d->glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress(
"glEGLImageTargetTexture2DOES");
64 if (!d->glEGLImageTargetTexture2DOES) {
65 qWarning(
"Failed to resolve glEGLImageTargetTexture2DOES");
69 d->eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress(
"eglCreateImageKHR");
71 if (!d->eglCreateImageKHR) {
72 qWarning(
"Failed to resolve eglCreateImageKHR");
76 d->eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress(
"eglDestroyImageKHR");
78 if (!d->eglDestroyImageKHR) {
79 qWarning(
"Failed to resolve eglDestroyImageKHR");
103 auto d = BrcmEglIntegrationPrivate::get(m_integration);
105 qWarning(
"bindTextureToBuffer failed!");
109 BrcmBuffer *brcmBuffer = BrcmBuffer::fromResource(m_buffer);
111 if (!d->eglQueryGlobalImageBRCM(brcmBuffer->handle(), brcmBuffer->handle() + 2)) {
112 qWarning(
"eglQueryGlobalImageBRCM failed!");
116 EGLImageKHR image = d->eglCreateImageKHR(d->egl_display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)brcmBuffer->handle(), NULL);
117 if (image == EGL_NO_IMAGE_KHR)
118 qWarning(
"eglCreateImageKHR() failed: %x\n", eglGetError());
121 m_texture =
new QOpenGLTexture(QOpenGLTexture::Target2D);
127 d->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
129 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
130 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
134 d->eglDestroyImageKHR(d->egl_display, image);
145 new BrcmBuffer(resource->client(), id, QSize(width, height),
static_cast<EGLint *>(data->data), data->size /
sizeof(EGLint));