{
Q_OBJECT
public:
- QmlCompositor() : WaylandCompositor(this, const_cast<QOpenGLContext *>(QOpenGLContext::currentContext())) {
+ QmlCompositor() : WaylandCompositor(this) {
//setMouseTracking(true);
setSource(QUrl(QLatin1String("qrc:qml/QmlCompositor/main.qml")));
setResizeMode(QQuickView::SizeRootObjectToView);
#include <QMouseEvent>
#ifdef QT_COMPOSITOR_WAYLAND_GL
-#include <QGLContext>
+#include <QOpenGLContext>
#include <QGLWidget>
#endif
Q_OBJECT
public:
QWidgetCompositor()
- : WaylandCompositor(windowHandle(),const_cast<QGLContext *>(context())->contextHandle())
+ : WaylandCompositor(windowHandle())
, m_moveSurface(0)
, m_dragSourceSurface(0)
{
for (int i = 0; i < m_surfaces.size(); ++i) {
if (m_surfaces.at(i)->type() == WaylandSurface::Texture) {
#ifdef QT_COMPOSITOR_WAYLAND_GL
- drawTexture(m_surfaces.at(i)->geometry(), m_surfaces.at(i)->texture());
+ drawTexture(m_surfaces.at(i)->geometry(), m_surfaces.at(i)->texture(QOpenGLContext::currentContext()));
break;
#endif //QT_COMPOSITOR_WAYLAND_GL
} else if (m_surfaces.at(i)->type() == WaylandSurface::Shm) {
#HEADERS += $$TOUCHSCREEN_BASE/qtouchscreen.h
#INCLUDEPATH += $$TOUCHSCREEN_BASE
#LIBS += -ludev -lmtdev
-QT += gui-private widgets widgets-private
+QT += gui-private widgets widgets-private opengl opengl-private
target.path += $$[QT_INSTALL_DATA]/bin
INSTALLS += target
#include <QTouchEvent>
QWindowCompositor::QWindowCompositor(QOpenGLWindow *window)
- : WaylandCompositor(window, window->context())
+ : WaylandCompositor(window)
, m_window(window)
{
m_backgroundImage = QImage(QLatin1String(":/background.jpg"));
//If type == WaylandSurface::Texture draw textureId at geometry
foreach (WaylandSurface *surface, m_surfaces) {
if (surface->type() == WaylandSurface::Texture)
- m_renderer->drawTexture(surface->texture(), surface->geometry(), 1); //depth argument should be dynamic (focused should be top).
+ m_renderer->drawTexture(surface->texture(QOpenGLContext::currentContext()), surface->geometry(), 1); //depth argument should be dynamic (focused should be top).
else if (surface->type() == WaylandSurface::Shm)
m_renderer->drawImage(surface->image(), surface->geometry());
}
!isEmpty(QT.core.MAJOR_VERSION):greaterThan(QT.core.MAJOR_VERSION, 4) {
QT += core-private
- contains(QT, declarative):QT += declarative-private opengl-private gui-private
+ contains(QT, declarative):QT += declarative-private gui-private
}
#include "waylandsurfaceitem.h"
#endif
-WaylandCompositor::WaylandCompositor(QWindow *window, QOpenGLContext *context, const char *socketName)
+WaylandCompositor::WaylandCompositor(QWindow *window, const char *socketName)
: m_compositor(0)
- , m_glContext(context)
, m_toplevel_widget(window)
, m_socket_name(socketName)
{
return surf ? surf->handle() : 0;
}
-QOpenGLContext * WaylandCompositor::glContext() const
-{
- return m_glContext;
-}
-
QWindow * WaylandCompositor::window() const
{
return m_toplevel_widget;
#include <QObject>
#include <QImage>
#include <QRect>
-#include <QOpenGLContext>
-class QGLContext;
class QWidget;
class QMimeData;
class WaylandSurface;
class WaylandCompositor
{
public:
- WaylandCompositor(QWindow *window = 0, QOpenGLContext *context = 0, const char *socketName = 0);
+ WaylandCompositor(QWindow *window = 0, const char *socketName = 0);
virtual ~WaylandCompositor();
void frameFinished(WaylandSurface *surface = 0);
void setDirectRenderSurface(WaylandSurface *surface);
WaylandSurface *directRenderSurface() const;
- QOpenGLContext *glContext() const;
QWindow *window()const;
virtual void surfaceCreated(WaylandSurface *surface) = 0;
static void retainedSelectionChanged(QMimeData *mimeData, void *param);
Wayland::Compositor *m_compositor;
- QOpenGLContext *m_glContext;
QWindow *m_toplevel_widget;
QByteArray m_socket_name;
};
}
#ifdef QT_COMPOSITOR_WAYLAND_GL
-GLuint WaylandSurface::texture() const
+GLuint WaylandSurface::texture(QOpenGLContext *context) const
{
Q_D(const WaylandSurface);
- return d->surface->textureId();
+ return d->surface->textureId(context);
}
#else //QT_COMPOSITOR_WAYLAND_GL
-uint WaylandSurface::texture() const
+uint WaylandSurface::texture(QOpenGLContext *) const
{
return 0;
}
-
#endif
Wayland::Surface * WaylandSurface::handle() const
#include <QtCore/QVariantMap>
#ifdef QT_COMPOSITOR_WAYLAND_GL
-#include <QtOpenGL/QGLContext>
+#include <QtGui/QOpenGLContext>
+#include <QtGui/qopengl.h>
#endif
class WaylandSurfacePrivate;
QImage image() const;
#ifdef QT_COMPOSITOR_WAYLAND_GL
- GLuint texture() const;
+ GLuint texture(QOpenGLContext *context) const;
#else
- uint texture() const;
+ uint texture(QOpenGLContext *context) const;
#endif
void sendMousePressEvent(const QPoint &pos, Qt::MouseButton button);
if (m_damaged) {
QSGTexture *oldTexture = m_texture;
if (m_surface->type() == WaylandSurface::Texture) {
+ QOpenGLContext *context = QOpenGLContext::currentContext();
+
QSGEngine::TextureOption opt = useTextureAlpha() ? QSGEngine::TextureHasAlphaChannel : QSGEngine::TextureOption(0);
- m_texture = canvas()->sceneGraphEngine()->createTextureFromId(m_surface->texture(),
+ m_texture = canvas()->sceneGraphEngine()->createTextureFromId(m_surface->texture(context),
m_surface->geometry().size(),
opt);
} else {
waylandDisplay->addGlobalObject(m_drm_object->base(),&wl_drm_interface,&drm_interface,post_drm_device);
}
-GLuint Dri2XcbHWIntegration::createTextureFromBuffer(wl_buffer *buffer)
+GLuint Dri2XcbHWIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *)
{
Dri2XcbBuffer *dri2Buffer = Wayland::wayland_cast<Dri2XcbBuffer *>(buffer);
void initializeHardware(Wayland::Display *waylandDisplay);
- GLuint createTextureFromBuffer(wl_buffer *buffer);
+ GLuint createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context);
private:
DrmObject *m_drm_object;
/** Bind the Wayland buffer to the textureId. The correct context is the current context,
so there is no need to do makeCurrent in this function.
**/
- virtual GLuint createTextureFromBuffer(struct wl_buffer *buffer) = 0;
+ virtual GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context) = 0;
virtual bool isYInverted(struct wl_buffer *) const { return true; }
virtual bool setDirectRenderSurface(WaylandSurface *) {return false;}
$$PWD/graphicshardwareintegration.cpp
DEFINES += QT_COMPOSITOR_WAYLAND_GL
- QT += opengl
isEqual(QT_WAYLAND_GL_CONFIG, custom) {
QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG
public:
WaylandEglIntegrationPrivate()
: egl_display(EGL_NO_DISPLAY)
- , egl_context(EGL_NO_CONTEXT)
{ }
EGLDisplay egl_display;
- EGLContext egl_context;
bool valid;
};
void WaylandEglIntegration::initializeHardware(Wayland::Display *waylandDisplay)
{
Q_D(WaylandEglIntegration);
- //We need a window id now :)
- m_compositor->window()->winId();
QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
if (nativeInterface) {
if (!d->valid)
qWarning("Failed to initialize egl display\n");
-
- d->egl_context = nativeInterface->nativeResourceForContext("EglContext", m_compositor->glContext());
}
}
-GLuint WaylandEglIntegration::createTextureFromBuffer(wl_buffer *buffer)
+GLuint WaylandEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context)
{
Q_D(WaylandEglIntegration);
if (!d->valid) {
return 0;
}
- EGLImageKHR image = eglCreateImageKHR(d->egl_display, d->egl_context,
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ EGLContext egl_context = nativeInterface->nativeResourceForContext("EglContext", context);
+
+ EGLImageKHR image = eglCreateImageKHR(d->egl_display, egl_context,
EGL_WAYLAND_BUFFER_WL,
buffer, NULL);
void initializeHardware(Wayland::Display *waylandDisplay);
- GLuint createTextureFromBuffer(wl_buffer *buffer);
+ GLuint createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *context);
bool setDirectRenderSurface(WaylandSurface *);
bool postBuffer(struct wl_buffer *);
waylandDisplay->addGlobalObject(handler->base(), &wl_xcomposite_interface, &XCompositeHandler::xcomposite_interface,XCompositeHandler::send_root_information);
}
-GLuint XCompositeEglIntegration::createTextureFromBuffer(wl_buffer *buffer)
+GLuint XCompositeEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *)
{
XCompositeBuffer *compositorBuffer = Wayland::wayland_cast<XCompositeBuffer *>(buffer);
Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window());
void initializeHardware(Wayland::Display *waylandDisplay);
- GLuint createTextureFromBuffer(struct wl_buffer *buffer);
+ GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context);
bool isYInverted(wl_buffer *) const;
private:
delete glContext;
}
-GLuint XCompositeGLXIntegration::createTextureFromBuffer(wl_buffer *buffer)
+GLuint XCompositeGLXIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGLContext *)
{
XCompositeBuffer *compositorBuffer = Wayland::wayland_cast<XCompositeBuffer *>(buffer);
Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window());
void initializeHardware(Wayland::Display *waylandDisplay);
- GLuint createTextureFromBuffer(struct wl_buffer *buffer);
+ GLuint createTextureFromBuffer(struct wl_buffer *buffer, QOpenGLContext *context);
bool isYInverted(wl_buffer *) const;
private:
if (d->compositor->graphicsHWIntegration()) {
if (d->type() == WaylandSurface::Texture) {
- if (textureId()) {
+ //if (textureId()) {
return d->compositor->graphicsHWIntegration()->isYInverted(d->buffer());
- }
+ //}
} else if (d->type() == WaylandSurface::Direct) {
return d->compositor->graphicsHWIntegration()->isYInverted(d->buffer());
}
}
#ifdef QT_COMPOSITOR_WAYLAND_GL
-GLuint Surface::textureId() const
+GLuint Surface::textureId(QOpenGLContext *context) const
{
Q_D(const Surface);
if (d->compositor->graphicsHWIntegration() && d->type() == WaylandSurface::Texture
Surface *that = const_cast<Surface *>(this);
GraphicsHardwareIntegration *hwIntegration = d->compositor->graphicsHWIntegration();
that->d_func()->previousBuffer = d->buffer();
- that->d_func()->texture_id = hwIntegration->createTextureFromBuffer(d->buffer());
+ that->d_func()->texture_id = hwIntegration->createTextureFromBuffer(d->buffer(), context);
that->d_func()->textureCreatedForBuffer = true;
}
return d->texture_id;
#include <QtCore/QMetaType>
#ifdef QT_COMPOSITOR_WAYLAND_GL
-#include <QtOpenGL/QGLContext>
+#include <QtGui/QOpenGLContext>
+#include <QtGui/qopengl.h>
#endif
namespace Wayland {
QImage image() const;
#ifdef QT_COMPOSITOR_WAYLAND_GL
- GLuint textureId() const;
+ GLuint textureId(QOpenGLContext *context) const;
#endif
void sendMousePressEvent(int x, int y, Qt::MouseButton button);