15 m_display = eglGetCurrentDisplay();
16 m_image = vgCreateImage(VG_sARGB_8888_PRE, m_size.
width(), m_size.
height(), VG_IMAGE_QUALITY_BETTER);
18 const EGLint configAttribs[] = {
19 EGL_CONFORMANT, EGL_OPENVG_BIT,
20 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
25 EGL_ALPHA_MASK_SIZE, 8,
29 EGLConfig pbufferConfig;
31 eglChooseConfig(m_display, configAttribs, &pbufferConfig, 1, &numConfig);
33 m_context = eglCreateContext(m_display, pbufferConfig, eglGetCurrentContext(), 0);
34 if (m_context == EGL_NO_CONTEXT)
35 qWarning(
"QOpenVGOffscreenSurface: failed to create EGLContext");
37 m_renderTarget = eglCreatePbufferFromClientBuffer(m_display,
39 reinterpret_cast<EGLClientBuffer
>(uintptr_t(m_image)),
42 if (m_renderTarget == EGL_NO_SURFACE)
43 qWarning(
"QOpenVGOffscreenSurface: failed to create EGLSurface from VGImage");
55 EGLContext currentContext = eglGetCurrentContext();
56 if (m_context != currentContext) {
57 m_previousContext = eglGetCurrentContext();
58 m_previousReadSurface = eglGetCurrentSurface(EGL_READ);
59 m_previousDrawSurface = eglGetCurrentSurface(EGL_DRAW);
61 eglMakeCurrent(m_display, m_renderTarget, m_renderTarget, m_context);
67 EGLContext currentContext = eglGetCurrentContext();
68 if (m_context == currentContext) {
69 eglMakeCurrent(m_display, m_previousDrawSurface, m_previousReadSurface, m_previousContext);
70 m_previousContext = EGL_NO_CONTEXT;
71 m_previousReadSurface = EGL_NO_SURFACE;
72 m_previousDrawSurface = EGL_NO_SURFACE;