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
qdirectfb_egl.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
4#include "qdirectfb_egl.h"
5#include "qdirectfbwindow.h"
6#include "qdirectfbscreen.h"
7#include "qdirectfbeglhooks.h"
8
9#include <QtGui/QOpenGLContext>
10#include <qpa/qplatformopenglcontext.h>
11#include <qpa/qwindowsysteminterface.h>
12#include <QtGui/QScreen>
13
14#include <QtGui/private/qeglplatformcontext_p.h>
15#include <QtGui/private/qeglconvenience_p.h>
16
17#include <QtGui/private/qt_egl_p.h>
18
20
21#ifdef DIRECTFB_PLATFORM_HOOKS
22extern QDirectFBEGLHooks platform_hook;
23static QDirectFBEGLHooks *hooks = &platform_hook;
24#else
25static QDirectFBEGLHooks *hooks = nullptr;
26#endif
27
37public:
40
41 // EGL helper
43
44private:
45 void initializeEGL();
46 void platformInit();
47 void platformDestroy();
48
49private:
50 EGLDisplay m_eglDisplay;
51};
52
54public:
55 QDirectFbWindowEGL(QWindow *tlw, QDirectFbInput *inputhandler);
57
59
60 // EGL. Subclass it instead to have different GL integrations?
62
63 QSurfaceFormat format() const;
64
65private:
66 EGLSurface m_eglSurface;
67};
68
79
82 , m_eglDisplay(EGL_NO_DISPLAY)
83{}
84
86{
87 platformDestroy();
88}
89
91{
92 if (m_eglDisplay == EGL_NO_DISPLAY)
93 initializeEGL();
94 return m_eglDisplay;
95}
96
97void QDirectFbScreenEGL::initializeEGL()
98{
99 m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
100 if (m_eglDisplay == EGL_NO_DISPLAY)
101 return;
102
103 platformInit();
104
105 EGLint major, minor;
106 eglBindAPI(EGL_OPENGL_ES_API);
107 eglInitialize(m_eglDisplay, &major, &minor);
108 return;
109}
110
111void QDirectFbScreenEGL::platformInit()
112{
113 if (hooks)
114 hooks->platformInit();
115}
116
117void QDirectFbScreenEGL::platformDestroy()
118{
119 if (hooks)
120 hooks->platformDestroy();
121}
122
124 : QDirectFbWindow(tlw, input)
125 , m_eglSurface(EGL_NO_SURFACE)
126{}
127
129{
130 if (m_eglSurface != EGL_NO_SURFACE) {
131 QDirectFbScreenEGL *dfbScreen;
132 dfbScreen = static_cast<QDirectFbScreenEGL*>(screen());
133 eglDestroySurface(dfbScreen->eglDisplay(), m_eglSurface);
134 }
135}
136
138{
139 // Use the default for the raster surface.
140 if (window()->surfaceType() == QSurface::RasterSurface)
142
144
145 DFBWindowDescription description;
146 memset(&description, 0, sizeof(DFBWindowDescription));
147 description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH | DWDESC_HEIGHT|
148 DWDESC_POSX | DWDESC_POSY|
149 DWDESC_PIXELFORMAT | DWDESC_SURFACE_CAPS);
150 description.width = qMax(1, window()->width());
151 description.height = qMax(1, window()->height());
152 description.posx = window()->x();
153 description.posy = window()->y();
154
155 description.surface_caps = DSCAPS_GL;
156 description.pixelformat = DSPF_RGB16;
157
158 IDirectFBDisplayLayer *layer;
160 DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr());
161 if (result != DFB_OK)
162 DirectFBError("QDirectFbWindow: failed to create window", result);
163
164 m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);
166}
167
169{
170 if (m_eglSurface == EGL_NO_SURFACE) {
171 QDirectFbScreenEGL *dfbScreen = static_cast<QDirectFbScreenEGL *>(screen());
172 EGLConfig config = q_configFromGLFormat(dfbScreen->eglDisplay(), format(), true);
173 m_eglSurface = eglCreateWindowSurface(dfbScreen->eglDisplay(), config, dfbSurface(), NULL);
174
175 if (m_eglSurface == EGL_NO_SURFACE)
176 eglGetError();
177 }
178
179 return m_eglSurface;
180}
181
183{
184 return window()->requestedFormat();
185}
186
187
192
198
199QPlatformWindow *QDirectFbIntegrationEGL::createPlatformWindow(QWindow *window) const
200{
201 QDirectFbWindow *dfbWindow = new QDirectFbWindowEGL(window, m_input.data());
202 dfbWindow->createDirectFBWindow();
203 return dfbWindow;
204}
205
206QPlatformOpenGLContext *QDirectFbIntegrationEGL::createPlatformOpenGLContext(QOpenGLContext *context) const
207{
209 screen = static_cast<QDirectFbScreenEGL*>(context->screen()->handle());
211}
212
213void QDirectFbIntegrationEGL::initializeScreen()
214{
215 m_primaryScreen.reset(new QDirectFbScreenEGL(0));
216 QWindowSystemInterface::handleScreenAdded(m_primaryScreen.data());
217}
218
219bool QDirectFbIntegrationEGL::hasCapability(QPlatformIntegration::Capability cap) const
220{
221 // We assume that devices will have more and not less capabilities
222 if (hooks && hooks->hasCapability(cap))
223 return true;
225}
226
QDirectFbEGLContext(QDirectFbScreenEGL *screen, QOpenGLContext *context)
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
void addWindow(IDirectFBWindow *window, QWindow *platformWindow)
bool hasCapability(Capability cap) const override
QDirectFbScreenEGL(int display)
EGLDisplay eglDisplay()
IDirectFBDisplayLayer * dfbLayer() const
EGLSurface eglSurface()
QDirectFbWindowEGL(QWindow *tlw, QDirectFbInput *inputhandler)
QSurfaceFormat format() const
Returns the actual surface format of the window.
QDirectFbInput * m_inputHandler
QDirectFBPointer< IDirectFBWindow > m_dfbWindow
virtual void createDirectFBWindow()
IDirectFBSurface * dfbSurface()
An EGL context implementation.
\inmodule QtGui
Capability
Capabilities are used to determine specific features of a platform integration.
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
QOpenGLContext * context() const
The QPlatformSurface class provides an abstraction for a surface.
The QPlatformWindow class provides an abstraction for top-level windows.
QWindow * window() const
Returns the window which belongs to the QPlatformWindow.
QPlatformScreen * screen() const override
Returns the platform screen handle corresponding to this platform window, or null if the window is no...
T * data() const noexcept
Returns the value of the pointer referenced by this object.
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
@ RasterSurface
Definition qsurface.h:31
static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary=false)
Should be called by the implementation whenever a new screen is added.
\inmodule QtGui
Definition qwindow.h:63
int x
the x position of the window's geometry
Definition qwindow.h:80
int y
the y position of the window's geometry
Definition qwindow.h:81
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
static void * context
static QT_BEGIN_NAMESPACE QDirectFBEGLHooks * hooks
QDirectFbScreen * toDfbScreen(QWindow *window)
EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType)
EGLConfig config
typedef EGLSurface(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
EGLOutputLayerEXT layer
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint GLsizei GLsizei height
GLint GLsizei width
GLint GLsizei GLsizei GLenum format
GLuint64EXT * result
[6]
GLenum GLenum GLenum input
GLenum cap
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScreen * screen
[1]
Definition main.cpp:29
aWidget window() -> setWindowTitle("New Window Title")
[2]