Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandbrcmglcontext.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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// Qt-Security score:significant reason:default
4
6
7#include <QtWaylandClient/private/qwaylanddisplay_p.h>
8#include <QtWaylandClient/private/qwaylandwindow_p.h>
10
11#include <QtGui/private/qeglconvenience_p.h>
12
13#include <qpa/qplatformopenglcontext.h>
14#include <QtGui/QSurfaceFormat>
15
16#include <dlfcn.h>
17
18QT_BEGIN_NAMESPACE
19
20namespace QtWaylandClient {
21
22extern QSurfaceFormat brcmFixFormat(const QSurfaceFormat &format);
23
25
26QWaylandBrcmGLContext::QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share)
28 , m_eglDisplay(eglDisplay)
29 , m_config(q_configFromGLFormat(m_eglDisplay, brcmFixFormat(format), true))
31{
32 EGLContext shareEGLContext = share ? static_cast<QWaylandBrcmGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
33
34 eglBindAPI(EGL_OPENGL_ES_API);
35
36 QList<EGLint> eglContextAttrs;
37 eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
38 eglContextAttrs.append(format.majorVersion() == 1 ? 1 : 2);
39 eglContextAttrs.append(EGL_NONE);
40
41 m_context = eglCreateContext(m_eglDisplay, m_config, shareEGLContext, eglContextAttrs.constData());
42}
43
45{
46 eglDestroyContext(m_eglDisplay, m_context);
47}
48
49bool QWaylandBrcmGLContext::makeCurrent(QPlatformSurface *surface)
50{
51 return static_cast<QWaylandBrcmEglWindow *>(surface)->makeCurrent(m_context);
52}
53
55{
56 eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
57}
58
59void QWaylandBrcmGLContext::swapBuffers(QPlatformSurface *surface)
60{
61 static_cast<QWaylandBrcmEglWindow *>(surface)->swapBuffers();
62}
63
65{
66 QFunctionPointer proc = (QFunctionPointer) eglGetProcAddress(procName);
67 if (!proc)
68 proc = (QFunctionPointer) dlsym(RTLD_DEFAULT, procName);
69 return proc;
70}
71
73{
74 return m_config;
75}
76
77}
78
79QT_END_NAMESPACE
void swapBuffers(QPlatformSurface *surface) override
Reimplement in subclass to native swap buffers calls.
bool makeCurrent(QPlatformSurface *surface) override
QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share)
QFunctionPointer getProcAddress(const char *procName) override
Reimplement in subclass to allow dynamic querying of OpenGL symbols.
QSurfaceFormat brcmFixFormat(const QSurfaceFormat &f)