From 44bc32d9c57244d50d6bdba649ad1a5f1b1b1130 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 29 May 2012 19:14:43 +0200 Subject: directfb: Allocate a special surface for OpenGL Allocate an RGB16 surface when we need to use OpenGL, set the custom DSCAPS_GL for this EGL mode. The broadcom hardware would allow us to use ABGR but we have some issues with the QSurfaceFormat to select the right kind of surface. Change-Id: I0fff7906154f3d7afb35b2b5d2bb91510cf3aa4d Reviewed-by: Girish Ramakrishnan --- src/plugins/platforms/directfb/qdirectfb_egl.cpp | 33 ++++++++++++++++++++++++ src/plugins/platforms/directfb/qdirectfbwindow.h | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/directfb/qdirectfb_egl.cpp b/src/plugins/platforms/directfb/qdirectfb_egl.cpp index 65112a4ccd..f5547d56c4 100644 --- a/src/plugins/platforms/directfb/qdirectfb_egl.cpp +++ b/src/plugins/platforms/directfb/qdirectfb_egl.cpp @@ -92,6 +92,8 @@ public: QDirectFbWindowEGL(QWindow *tlw, QDirectFbInput *inputhandler); ~QDirectFbWindowEGL(); + void createDirectFBWindow(); + // EGL. Subclass it instead to have different GL integrations? EGLSurface eglSurface(); @@ -169,6 +171,37 @@ QDirectFbWindowEGL::~QDirectFbWindowEGL() } } +void QDirectFbWindowEGL::createDirectFBWindow() +{ + // Use the default for the raster surface. + if (window()->surfaceType() == QSurface::RasterSurface) + return QDirectFbWindow::createDirectFBWindow(); + + Q_ASSERT(!m_dfbWindow.data()); + + DFBWindowDescription description; + memset(&description, 0, sizeof(DFBWindowDescription)); + description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH | DWDESC_HEIGHT| + DWDESC_POSX | DWDESC_POSY| + DWDESC_PIXELFORMAT | DWDESC_SURFACE_CAPS); + description.width = qMax(1, window()->width()); + description.height = qMax(1, window()->height()); + description.posx = window()->x(); + description.posy = window()->y(); + + description.surface_caps = DSCAPS_GL; + description.pixelformat = DSPF_RGB16; + + IDirectFBDisplayLayer *layer; + layer = toDfbScreen(window())->dfbLayer(); + DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr()); + if (result != DFB_OK) + DirectFBError("QDirectFbWindow: failed to create window", result); + + m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff); + m_inputHandler->addWindow(m_dfbWindow.data(), window()); +} + EGLSurface QDirectFbWindowEGL::eglSurface() { if (m_eglSurface == EGL_NO_SURFACE) { diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.h b/src/plugins/platforms/directfb/qdirectfbwindow.h index f02f937462..0c429c9021 100644 --- a/src/plugins/platforms/directfb/qdirectfbwindow.h +++ b/src/plugins/platforms/directfb/qdirectfbwindow.h @@ -73,7 +73,7 @@ public: // helper to get access to DirectFB types IDirectFBSurface *dfbSurface(); -private: +protected: QDirectFBPointer m_dfbSurface; QDirectFBPointer m_dfbWindow; QDirectFbInput *m_inputHandler; -- cgit v1.2.3