6#include <QtGui/QOpenGLContext>
7#include <QtGui/QOpenGLTexture>
8#include <hybris/eglplatformcommon/hybris_nativebufferext.h>
9#include <wayland-server-core.h>
14 , m_integration(integration)
21 m_hybris_format = QtWaylandServer::qt_libhybris_egl_server_buffer::format_RGBA32;
22 egl_format = HYBRIS_PIXEL_FORMAT_RGBA_8888;
25 qWarning(
"LibHybrisEglServerBuffer: unsupported format");
26 m_hybris_format = QtWaylandServer::qt_libhybris_egl_server_buffer::format_RGBA32;
27 egl_format = HYBRIS_PIXEL_FORMAT_RGBA_8888;
32 qWarning(
"LibHybrisEglServerBuffer: Failed to create egl buffer");
43 m_image = m_integration->
eglCreateImageKHR(EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, m_buffer, 0);
46 qWarning(
"LibHybrisEglServerBuffer: No current context when creating buffer. Texture loading will fail");
65 auto *bufferResource = resourceMap().value(client);
66 if (!bufferResource) {
67 auto integrationResource = m_integration->resourceMap().value(client);
68 if (!integrationResource) {
69 qWarning(
"LibHybrisEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the libhybris_egl interface");
72 struct ::wl_resource *egl_integration_resource = integrationResource->handle;
73 Resource *resource =
add(client, 1);
74 wl_resource *bufRes = wl_resource_create(client, &qt_libhybris_buffer_interface,-1, 0);
76 m_integration->send_server_buffer_created(egl_integration_resource, resource->handle, bufRes, m_fds.
size(),
QByteArray((
char *)m_ints.
data(), m_ints.
size() *
sizeof(int32_t)),
79 for (
int i = 0;
i < m_fds.
size(); ++
i) {
80 send_add_fd(resource->handle, m_fds.
at(
i));
83 return resource->handle;
85 return bufferResource->handle;
106 if (!m_egl_display) {
107 qWarning(
"Can't initialize libhybris egl server buffer integration. Missing egl display from platform plugin");
111 m_egl_create_buffer =
reinterpret_cast<PFNEGLHYBRISCREATENATIVEBUFFERPROC
>(eglGetProcAddress(
"eglHybrisCreateNativeBuffer"));
112 if (!m_egl_create_buffer) {
113 qWarning(
"Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisCreateNativeBuffer.\n");
116 m_egl_get_buffer_info =
reinterpret_cast<PFNEGLHYBRISGETNATIVEBUFFERINFOPROC
>(eglGetProcAddress(
"eglHybrisGetNativeBufferInfo"));
117 if (!m_egl_get_buffer_info) {
118 qWarning(
"Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisGetNativeBufferInfo.\n");
121 m_egl_serialize_buffer =
reinterpret_cast<PFNEGLHYBRISSERIALIZENATIVEBUFFERPROC
>(eglGetProcAddress(
"eglHybrisSerializeNativeBuffer"));
122 if (!m_egl_serialize_buffer) {
123 qWarning(
"Failed to initialize libhybris egl server buffer integration. Could not find eglHybrisSerializeNativeBuffer.\n");
127 const char *extensionString = eglQueryString(m_egl_display, EGL_EXTENSIONS);
128 if (!extensionString || !strstr(extensionString,
"EGL_KHR_image")) {
129 qWarning(
"Failed to initialize libhybris egl server buffer integration. There is no EGL_KHR_image extension.\n");
132 m_egl_create_image =
reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC
>(eglGetProcAddress(
"eglCreateImageKHR"));
133 m_egl_destroy_image =
reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC
>(eglGetProcAddress(
"eglDestroyImageKHR"));
134 if (!m_egl_create_image || !m_egl_destroy_image) {
135 qWarning(
"Failed to initialize libhybris egl server buffer integration. Could not resolve eglCreateImageKHR or eglDestroyImageKHR");
139 m_gl_egl_image_target_texture_2d =
reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC
>(eglGetProcAddress(
"glEGLImageTargetTexture2DOES"));
140 if (!m_gl_egl_image_target_texture_2d) {
141 qWarning(
"Failed to initialize libhybris egl server buffer integration. Could not find glEGLImageTargetTexture2DOES.\n");
145 QtWaylandServer::qt_libhybris_egl_server_buffer::init(
compositor->display(), 1);
EGLBoolean eglHybrisCreateNativeBuffer(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint *stride, EGLClientBuffer *buffer)
~LibHybrisEglServerBufferIntegration()
void eglHybrisSerializeNativeBuffer(EGLClientBuffer buffer, int *ints, int *fds)
EGLImageKHR eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
bool supportsFormat(QtWayland::ServerBuffer::Format format) const override
LibHybrisEglServerBufferIntegration()
void eglHybrisGetNativeBufferInfo(EGLClientBuffer buffer, int *num_ints, int *num_fds)
QtWayland::ServerBuffer * createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override
bool initializeHardware(QWaylandCompositor *)
void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
QOpenGLTexture * toOpenGlTexture() override
LibHybrisEglServerBuffer(LibHybrisEglServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format)
struct::wl_resource * resourceForClient(struct ::wl_client *) override
static QPlatformNativeInterface * platformNativeInterface()
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
const uchar * constBits() const
Returns a pointer to the first pixel data.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void resize(qsizetype size)
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
void release()
Unbinds this texture from the currently active texture unit.
bool create()
Creates the underlying OpenGL texture object.
void bind()
Binds this texture to the currently active texture unit ready for rendering.
void setSize(int width, int height=1, int depth=1)
Sets the dimensions of this texture object to width, height, and depth.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
EGLint EGLint EGLint format
Combined button and popup list for selecting options.
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
static QOpenGLCompositor * compositor
GLenum GLuint GLintptr GLsizeiptr size
[1]
static void add(QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)