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");
48 vgDestroyImage(m_image);
49 eglDestroySurface(m_display, m_renderTarget);
50 eglDestroyContext(m_display, m_context);
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;
78 eglSwapBuffers(m_display, m_renderTarget);
84 vgGetImageSubData(m_image, readbackImage.
bits(), readbackImage.
bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, m_size.
width(), m_size.
height());
qsizetype bytesPerLine() const
Returns the number of bytes per image scanline.
uchar * bits()
Returns a pointer to the first pixel data.
@ Format_ARGB32_Premultiplied
QOpenVGOffscreenSurface(const QSize &size)
~QOpenVGOffscreenSurface()
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]