summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2010-10-27 21:38:03 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-01-25 17:59:06 (GMT)
commit8288733d680bba6be762ed0e26aa4e95cdfe68e8 (patch)
treef0ce0e761f79d87fc9cc9563a0befcb1369ca2fb /src/plugins/platforms
parent4e417fd2d89c99184c939296d969a6fd312c9257 (diff)
downloadQt-8288733d680bba6be762ed0e26aa4e95cdfe68e8.zip
Qt-8288733d680bba6be762ed0e26aa4e95cdfe68e8.tar.gz
Qt-8288733d680bba6be762ed0e26aa4e95cdfe68e8.tar.bz2
Wayland: put context & drawing objects into the drm surface
Even GL widgets will allocate window surfaces, so share everything there. This still leaves a hole when we mix GL widgets and the raster back end (the created platform GL context won't have a DRM buffer to use for its objects & context), but that won't work right now anyway...
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp34
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindowsurface.cpp19
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindowsurface.h2
3 files changed, 27 insertions, 28 deletions
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
index 9ac22e8..6842dbf 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.cpp
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -510,42 +510,21 @@ public:
QPlatformWindowFormat platformWindowFormat() const { return mFormat; }
private:
- EGLContext mContext;
QPlatformWindowFormat mFormat;
QWaylandDisplay *mDisplay;
QWaylandWindow *mWindow;
- GLuint mFbo, mRbo;
};
QWaylandGLContext::QWaylandGLContext(QWaylandDisplay *wd, QWaylandWindow *window, const QPlatformWindowFormat &format)
: QPlatformGLContext()
- , mContext(0)
, mFormat(format)
, mDisplay(wd)
, mWindow(window)
{
- EGLDisplay eglDisplay;
- static const EGLint contextAttribs[] = {
- EGL_CONTEXT_CLIENT_VERSION, 2,
- EGL_NONE
- };
-
- eglBindAPI(EGL_OPENGL_ES_API);
- eglDisplay = mDisplay->eglDisplay();
- mContext = eglCreateContext(eglDisplay, NULL,
- EGL_NO_CONTEXT, contextAttribs);
- eglMakeCurrent(eglDisplay, NULL, NULL, mContext);
-
- glGenFramebuffers(1, &mFbo);
- glGenRenderbuffers(1, &mRbo);
}
QWaylandGLContext::~QWaylandGLContext()
{
- if (mContext)
- eglDestroyContext(mDisplay->eglDisplay(), mContext);
- glDeleteFramebuffers(1, &mFbo);
- glDeleteRenderbuffers(1, &mRbo);
}
void QWaylandGLContext::makeCurrent()
@@ -553,21 +532,20 @@ void QWaylandGLContext::makeCurrent()
QWaylandDrmBuffer *mBuffer = (QWaylandDrmBuffer *)mWindow->getBuffer();
QRect geometry = mWindow->geometry();
- eglMakeCurrent(mDisplay->eglDisplay(), 0, 0, mContext);
if (!mBuffer)
return;
- glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
- glBindRenderbuffer(GL_RENDERBUFFER, mRbo);
+
+ eglMakeCurrent(mDisplay->eglDisplay(), 0, 0, mBuffer->mContext);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, mBuffer->mFbo);
+ glBindRenderbuffer(GL_RENDERBUFFER, mBuffer->mRbo);
glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, mBuffer->mImage);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_RENDERBUFFER, mRbo);
+ GL_RENDERBUFFER, mBuffer->mRbo);
}
void QWaylandGLContext::doneCurrent()
{
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- glBindRenderbuffer(GL_RENDERBUFFER, 0);
- eglMakeCurrent(mDisplay->eglDisplay(), 0, 0, mContext);
}
void QWaylandGLContext::swapBuffers()
diff --git a/src/plugins/platforms/wayland/qwaylandwindowsurface.cpp b/src/plugins/platforms/wayland/qwaylandwindowsurface.cpp
index 6e7fa89..4ae04be 100644
--- a/src/plugins/platforms/wayland/qwaylandwindowsurface.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindowsurface.cpp
@@ -201,6 +201,10 @@ QWaylandDrmBuffer::QWaylandDrmBuffer(QWaylandDisplay *display,
Q_UNUSED(format);
EGLint name, stride;
+ static const EGLint contextAttribs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
EGLint imageAttribs[] = {
EGL_WIDTH, 0,
EGL_HEIGHT, 0,
@@ -209,9 +213,16 @@ QWaylandDrmBuffer::QWaylandDrmBuffer(QWaylandDisplay *display,
EGL_NONE
};
+ eglBindAPI(EGL_OPENGL_ES_API);
+ mContext = eglCreateContext(mDisplay->eglDisplay(), NULL,
+ EGL_NO_CONTEXT, contextAttribs);
+ eglMakeCurrent(mDisplay->eglDisplay(), 0, 0, mContext);
+
imageAttribs[1] = size.width();
imageAttribs[3] = size.height();
mImage = eglCreateDRMImageMESA(mDisplay->eglDisplay(), imageAttribs);
+ glGenFramebuffers(1, &mFbo);
+ glGenRenderbuffers(1, &mRbo);
glGenTextures(1, &mTexture);
glBindTexture(GL_TEXTURE_2D, mTexture);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, mImage);
@@ -225,9 +236,12 @@ QWaylandDrmBuffer::QWaylandDrmBuffer(QWaylandDisplay *display,
QWaylandDrmBuffer::~QWaylandDrmBuffer(void)
{
+ glDeleteFramebuffers(1, &mFbo);
+ glDeleteRenderbuffers(1, &mRbo);
glDeleteTextures(1, &mTexture);
eglDestroyImageKHR(mDisplay->eglDisplay(), mImage);
wl_buffer_destroy(mBuffer);
+ eglDestroyContext(mDisplay->eglDisplay(), mContext);
}
@@ -237,7 +251,12 @@ QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window,
, mBuffer(0)
, mDisplay(display)
{
+ QWaylandWindow *ww = (QWaylandWindow *) window->platformWindow();
+ QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format();
+
mPaintDevice = new QWaylandPaintDevice(display, window);
+ mBuffer = new QWaylandDrmBuffer(mDisplay, window->size(), format);
+ ww->attach(mBuffer);
}
QWaylandDrmWindowSurface::~QWaylandDrmWindowSurface()
diff --git a/src/plugins/platforms/wayland/qwaylandwindowsurface.h b/src/plugins/platforms/wayland/qwaylandwindowsurface.h
index a033531..c8ccdb1 100644
--- a/src/plugins/platforms/wayland/qwaylandwindowsurface.h
+++ b/src/plugins/platforms/wayland/qwaylandwindowsurface.h
@@ -93,11 +93,13 @@ public:
QWaylandDrmBuffer(QWaylandDisplay *display,
const QSize &size, QImage::Format format);
~QWaylandDrmBuffer();
+ EGLContext mContext;
EGLImageKHR mImage;
GLuint mTexture;
QWaylandDisplay *mDisplay;
QGLFramebufferObject *pdev;
QSize mSize;
+ GLuint mFbo, mRbo;
};
class QWaylandDrmWindowSurface : public QWindowSurface