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()
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()
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,
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);
QWaylandDrmBuffer::~QWaylandDrmBuffer(void)
{
+ glDeleteFramebuffers(1, &mFbo);
+ glDeleteRenderbuffers(1, &mRbo);
glDeleteTextures(1, &mTexture);
eglDestroyImageKHR(mDisplay->eglDisplay(), mImage);
wl_buffer_destroy(mBuffer);
+ eglDestroyContext(mDisplay->eglDisplay(), mContext);
}
, 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()