7#include <QtWaylandClient/private/qwaylandbuffer_p.h>
8#include <QtWaylandClient/private/qwaylandscreen_p.h>
11#include <QtGui/private/qeglconvenience_p.h>
13#include <QtGui/QWindow>
14#include <qpa/qwindowsysteminterface.h>
16#include <EGL/eglext_brcm.h>
18#include "wayland-brcm-client-protocol.h"
32 struct wl_event_queue *eventQueue)
35 , m_eventQueue(eventQueue)
37 wl_array_init(&m_array);
38 m_data =
static_cast<EGLint *>(wl_array_add(&m_array, count *
sizeof(EGLint)));
40 for (
int i = 0; i < count; ++i)
43 mBuffer = qt_brcm_create_buffer(brcm, size.width(), size.height(), &m_array);
44 wl_proxy_set_queue(
reinterpret_cast<
struct wl_proxy*>(mBuffer), m_eventQueue);
46 static const struct wl_buffer_listener buffer_listener = {
47 QWaylandBrcmBuffer::buffer_release
50 wl_buffer_add_listener(mBuffer, &buffer_listener,
this);
55 wl_array_release(&m_array);
56 wl_buffer_destroy(mBuffer);
72 wl_display_dispatch_queue(m_display->wl_display(), m_eventQueue);
85 bool m_released =
true;
87 EGLint *m_data =
nullptr;
88 QWaylandDisplay *m_display =
nullptr;
89 struct wl_event_queue *m_eventQueue =
nullptr;
93 : QWaylandWindow(window, display)
94 , m_eglIntegration(
static_cast<QWaylandBrcmEglIntegration *>(mDisplay->clientBufferIntegration()))
95 , m_format(window->format())
96 , m_eventQueue(wl_display_create_queue(mDisplay->wl_display()))
102 destroyEglSurfaces();
107 return QWaylandWindow::Egl;
112 destroyEglSurfaces();
113 QWaylandWindow::setGeometry(rect);
123 for (
int i = 0; i < m_count; ++i) {
124 if (m_eglSurfaces[i]) {
125 eglDestroySurface(m_eglIntegration
->eglDisplay(), m_eglSurfaces[i]);
126 m_eglSurfaces[i] = 0;
139 QSurfaceFormat format = f;
140 format.setRedBufferSize(8);
141 format.setGreenBufferSize(8);
142 format.setBlueBufferSize(8);
143 format.setAlphaBufferSize(8);
149 QSize size(geometry().size());
151 m_count = window()->format().swapBehavior() == QSurfaceFormat::TripleBuffer ? 3 : 2;
153 EGLConfig eglConfig = q_configFromGLFormat(m_eglIntegration
->eglDisplay(), brcmFixFormat(window()->format()),
true, EGL_PIXMAP_BIT);
155 m_format = q_glFormatFromConfig(m_eglIntegration->eglDisplay(), eglConfig);
157 EGLint pixel_format = EGL_PIXEL_FORMAT_ARGB_8888_BRCM;
160 eglGetConfigAttrib(m_eglIntegration
->eglDisplay(), eglConfig, EGL_RENDERABLE_TYPE, &rt);
162 if (rt & EGL_OPENGL_ES_BIT) {
163 pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES_BRCM;
164 pixel_format |= EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM;
167 if (rt & EGL_OPENGL_ES2_BIT) {
168 pixel_format |= EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM;
169 pixel_format |= EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM;
172 if (rt & EGL_OPENVG_BIT) {
173 pixel_format |= EGL_PIXEL_FORMAT_RENDER_VG_BRCM;
174 pixel_format |= EGL_PIXEL_FORMAT_VG_IMAGE_BRCM;
177 if (rt & EGL_OPENGL_BIT) {
178 pixel_format |= EGL_PIXEL_FORMAT_RENDER_GL_BRCM;
181 memset(m_globalImages, 0, 5 * m_count *
sizeof(EGLint));
182 for (
int i = 0; i < m_count; ++i) {
183 m_eglIntegration->eglCreateGlobalImageBRCM(size.width(), size.height(), pixel_format,
184 0, size.width() * 4, &m_globalImages[5*i]);
186 m_globalImages[5*i+2] = size.width();
187 m_globalImages[5*i+3] = size.height();
188 m_globalImages[5*i+4] = pixel_format;
191 EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB,
192 EGL_VG_ALPHA_FORMAT, pixel_format & EGL_PIXEL_FORMAT_ARGB_8888_PRE_BRCM ? EGL_VG_ALPHA_FORMAT_PRE : EGL_VG_ALPHA_FORMAT_NONPRE,
196 m_eglSurfaces[i] = eglCreatePixmapSurface(m_eglIntegration
->eglDisplay(), eglConfig, (EGLNativePixmapType)&m_globalImages[5*i], attrs);
197 if (m_eglSurfaces[i] == EGL_NO_SURFACE)
198 qFatal(
"eglCreatePixmapSurface failed: %x, global image id: %d %d\n", eglGetError(), m_globalImages[5*i], m_globalImages[5*i+1]);
199 m_buffers[i] =
new QWaylandBrcmBuffer(mDisplay, m_eglIntegration->waylandBrcm(), size, &m_globalImages[5*i], 5, m_eventQueue);
205 if (m_eglIntegration->eglFlushBRCM) {
206 m_eglIntegration->eglFlushBRCM();
216 commit(m_buffers[m_current], QRegion(0, 0, geometry().size().width(), geometry().size().height()));
218 m_current = (m_current + 1) % m_count;
226 return eglMakeCurrent(m_eglIntegration
->eglDisplay(), m_eglSurfaces[m_current], m_eglSurfaces[m_current], context);
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)
EGLDisplay eglDisplay() 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.
QSurfaceFormat format() const override
Returns the actual surface format of the window.
Combined button and popup list for selecting options.
QSurfaceFormat brcmFixFormat(const QSurfaceFormat &f)