Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qeglpbuffer.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtGui/qoffscreensurface.h>
5#include "qeglpbuffer_p.h"
6#include "qeglconvenience_p.h"
7
9
23 QEGLPlatformContext::Flags flags)
24 : QPlatformOffscreenSurface(offscreenSurface)
25 , m_format(format)
26 , m_display(display)
27 , m_pbuffer(EGL_NO_SURFACE)
28{
29 m_hasSurfaceless = !flags.testFlag(QEGLPlatformContext::NoSurfaceless)
30 && q_hasEglExtension(display, "EGL_KHR_surfaceless_context");
31
32 if (m_hasSurfaceless)
33 return;
34
35 EGLConfig config = q_configFromGLFormat(m_display, m_format, false, EGL_PBUFFER_BIT);
36
37 if (config) {
38 const EGLint attributes[] = {
39 EGL_WIDTH, offscreenSurface->size().width(),
40 EGL_HEIGHT, offscreenSurface->size().height(),
41 EGL_LARGEST_PBUFFER, EGL_FALSE,
42 EGL_NONE
43 };
44
45 m_pbuffer = eglCreatePbufferSurface(m_display, config, attributes);
46
47 if (m_pbuffer != EGL_NO_SURFACE)
48 m_format = q_glFormatFromConfig(m_display, config);
49 }
50}
51
53{
54 if (m_pbuffer != EGL_NO_SURFACE)
55 eglDestroySurface(m_display, m_pbuffer);
56}
57
59{
60 return m_pbuffer != EGL_NO_SURFACE || m_hasSurfaceless;
61}
62
bool isValid() const override
Returns true if the platform offscreen surface has been allocated.
QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface, QEGLPlatformContext::Flags flags={ })
\inmodule QtGui
QSize size() const override
Returns the size of the offscreen surface.
QOffscreenSurface * offscreenSurface() const
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType)
QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat)
bool q_hasEglExtension(EGLDisplay display, const char *extensionName)
EGLConfig config
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
GLbitfield flags
GLint GLsizei GLsizei GLenum format