6#include <QtWaylandClient/private/qwaylandbuffer_p.h>
7#include <QtWaylandClient/private/qwaylandscreen_p.h>
10#include <QtGui/private/qeglconvenience_p.h>
12#include <QtGui/QWindow>
13#include <qpa/qwindowsysteminterface.h>
15#include <EGL/eglext_brcm.h>
17#include "wayland-brcm-client-protocol.h"
31 struct wl_event_queue *eventQueue)
34 , m_eventQueue(eventQueue)
36 wl_array_init(&m_array);
37 m_data =
static_cast<EGLint *
>(wl_array_add(&m_array,
count *
sizeof(EGLint)));
42 mBuffer = qt_brcm_create_buffer(brcm,
size.width(),
size.height(), &m_array);
43 wl_proxy_set_queue(
reinterpret_cast<struct wl_proxy*
>(
mBuffer), m_eventQueue);
45 static const struct wl_buffer_listener buffer_listener = {
49 wl_buffer_add_listener(
mBuffer, &buffer_listener,
this);
54 wl_array_release(&m_array);
71 wl_display_dispatch_queue(m_display->
wl_display(), m_eventQueue);
84 bool m_released =
true;
88 struct wl_event_queue *m_eventQueue =
nullptr;
95 , m_eventQueue(wl_display_create_queue(mDisplay->wl_display()))
101 destroyEglSurfaces();
111 destroyEglSurfaces();
120void QWaylandBrcmEglWindow::destroyEglSurfaces()
122 for (
int i = 0;
i < m_count; ++
i) {
123 if (m_eglSurfaces[
i]) {
124 eglDestroySurface(m_eglIntegration->
eglDisplay(), m_eglSurfaces[
i]);
125 m_eglSurfaces[
i] = 0;
139 format.setRedBufferSize(8);
140 format.setGreenBufferSize(8);
141 format.setBlueBufferSize(8);
142 format.setAlphaBufferSize(8);
146void QWaylandBrcmEglWindow::createEglSurfaces()
156 EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM;
159 eglGetConfigAttrib(m_eglIntegration->
eglDisplay(), eglConfig, EGL_RENDERABLE_TYPE, &rt);
161 if (rt & EGL_OPENGL_ES_BIT) {
162 pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM;
163 pixel_format |= EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM;
166 if (rt & EGL_OPENGL_ES2_BIT) {
167 pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM;
168 pixel_format |= EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM;
171 if (rt & EGL_OPENVG_BIT) {
172 pixel_format |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM;
173 pixel_format |= EGL_PIXEL_FORMAT_VG_IMAGE_BRCM;
176 if (rt & EGL_OPENGL_BIT) {
177 pixel_format |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM;
180 memset(m_globalImages, 0, 5 * m_count *
sizeof(EGLint));
181 for (
int i = 0;
i < m_count; ++
i) {
183 0,
size.width() * 4, &m_globalImages[5*
i]);
185 m_globalImages[5*
i+2] =
size.width();
186 m_globalImages[5*
i+3] =
size.height();
187 m_globalImages[5*
i+4] = pixel_format;
190 EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB,
191 EGL_VG_ALPHA_FORMAT, pixel_format & EGL_PIXEL_FORMAT_ARGB_8888_PRE_BRCM ? EGL_VG_ALPHA_FORMAT_PRE : EGL_VG_ALPHA_FORMAT_NONPRE,
195 m_eglSurfaces[
i] = eglCreatePixmapSurface(m_eglIntegration->
eglDisplay(), eglConfig, (EGLNativePixmapType)&m_globalImages[5*
i],
attrs);
196 if (m_eglSurfaces[
i] == EGL_NO_SURFACE)
197 qFatal(
"eglCreatePixmapSurface failed: %x, global image id: %d %d\n", eglGetError(), m_globalImages[5*
i], m_globalImages[5*
i+1]);
198 m_buffers[
i] =
new QWaylandBrcmBuffer(
mDisplay, m_eglIntegration->
waylandBrcm(),
size, &m_globalImages[5*
i], 5, m_eventQueue);
214 m_buffers[m_current]->
bind();
217 m_current = (m_current + 1) % m_count;
225 return eglMakeCurrent(m_eglIntegration->
eglDisplay(), m_eglSurfaces[m_current], m_eglSurfaces[m_current],
context);
\inmodule QtCore\reentrant
The QRegion class specifies a clip region for a painter.
QSurfaceFormat format() const override
Returns the actual format of this window.
QWaylandBrcmBuffer(QWaylandDisplay *display, struct qt_brcm *brcm, const QSize &size, EGLint *data, int count, struct wl_event_queue *eventQueue)
static void buffer_release(void *data, wl_buffer *buffer)
PFNEGLCREATEGLOBALIMAGEBRCMPROC eglCreateGlobalImageBRCM
EGLDisplay eglDisplay() const
PFNEGLFLUSHBRCMPROC eglFlushBRCM
struct qt_brcm * waylandBrcm() const
WindowType windowType() const override
bool makeCurrent(EGLContext context)
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QWaylandBrcmEglWindow(QWindow *window, QWaylandDisplay *display)
QSurfaceFormat format() const override
Returns the actual surface format of the window.
struct wl_buffer * mBuffer
struct wl_display * wl_display() const
QWaylandDisplay * mDisplay
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
struct wl_display * display
Combined button and popup list for selecting options.
QSurfaceFormat brcmFixFormat(const QSurfaceFormat &f)
EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType)
QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat)
static struct AttrInfo attrs[]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format