Пример #1
0
void QEglFSIntegration::initialize()
{
    qt_egl_device_integration()->platformInit();

    m_display = qt_egl_device_integration()->createDisplay(nativeDisplay());
    if (m_display == EGL_NO_DISPLAY)
        qFatal("Could not open egl display");

    EGLint major, minor;
    if (!eglInitialize(m_display, &major, &minor))
        qFatal("Could not initialize egl display");

    m_inputContext = QPlatformInputContextFactory::create();

    m_vtHandler.reset(new QFbVtHandler);

    if (qt_egl_device_integration()->usesDefaultScreen())
        addScreen(new QEglFSScreen(display()));
    else
        qt_egl_device_integration()->screenInit();

    // Input code may rely on the screens, so do it only after the screen init.
    if (!m_disableInputHandlers)
        createInputHandlers();
}
void X11Helper::createPixmap(Pixmap* handleId, const EGLint id, bool hasAlpha, const IntSize& size)
{
    VisualID visualId = static_cast<VisualID>(id);

    if (!visualId)
        return;

    // EGL has suggested a visual id, so get the rest of the visual info for that id.
    XVisualInfo visualInfoTemplate;
    memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
    visualInfoTemplate.visualid = visualId;
    int matchingCount = 0;
    OwnPtrX11<XVisualInfo> matchingVisuals(XGetVisualInfo(nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount));
    XVisualInfo* foundVisual = 0;
    int requiredDepth = hasAlpha ? 32 : 24;

    if (matchingVisuals) {
        for (int i = 0; i< matchingCount; i++) {
            XVisualInfo* temp = &matchingVisuals[i];

            if (temp->visualid == visualId && temp->depth == requiredDepth) {
                foundVisual = temp;
                break;
            }
        }

        if (foundVisual)
            createPixmap(handleId, *foundVisual, size);
    }
}
void X11Helper::createPixmap(Pixmap* handleId, const XVisualInfo& visualInfo, const IntSize& size)
{
    Display* display = nativeDisplay();
    if (!display)
        return;

    if (!visualInfo.visual) {
        LOG_ERROR("Failed to find valid XVisual.");
        return;
    }

    Window xWindow = offscreenRootWindow();
    if (!xWindow) {
        LOG_ERROR("Failed to create offscreen root window.");
        return;
    }

    Pixmap tempHandleId = XCreatePixmap(display, xWindow, size.width(), size.height(), visualInfo.depth);

    if (!tempHandleId) {
        LOG_ERROR("Failed to create offscreen pixmap.");
        return;
    }

    *handleId = tempHandleId;
    XSync(X11Helper::nativeDisplay(), false);
}
Пример #4
0
EGLDisplay QEgl::display()
{
    static EGLDisplay dpy = EGL_NO_DISPLAY;
    if (!QEglContextTracker::displayOpened()) {
        dpy = eglGetDisplay(nativeDisplay());
        QEglContextTracker::setDisplayOpened();
        if (dpy == EGL_NO_DISPLAY) {
            qWarning("QEgl::display(): Falling back to EGL_DEFAULT_DISPLAY");
            dpy = eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY));
        }
        if (dpy == EGL_NO_DISPLAY) {
            qWarning("QEgl::display(): Can't even open the default display");
            return EGL_NO_DISPLAY;
        }

        if (!eglInitialize(dpy, NULL, NULL)) {
            qWarning() << "QEgl::display(): Cannot initialize EGL display:" << QEgl::errorString();
            return EGL_NO_DISPLAY;
        }

        // Resolve the egl extension function pointers:
#if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES)
        if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_base")) {
            qt_eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR");
            qt_eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR");
        }
#endif

        if (QEgl::hasExtension("EGL_NOK_swap_region2")) {
            qt_eglSwapBuffersRegion2NOK = (_eglSwapBuffersRegion2NOK) eglGetProcAddress("eglSwapBuffersRegion2NOK");
        }
    }

    return dpy;
}
void X11Helper::destroyWindow(const uint32_t windowId)
{
    if (!windowId)
        return;

    Display* display = nativeDisplay();
    if (!display)
        return;

    XDestroyWindow(display, windowId);
}
void X11Helper::destroyPixmap(const uint32_t pixmapId)
{
    if (!pixmapId)
        return;

    Display* display = nativeDisplay();
    if (!display)
        return;

    XFreePixmap(display, pixmapId);
    XSync(X11Helper::nativeDisplay(), false);
}
Пример #7
0
void QEGLPlatformIntegration::initialize()
{
    m_display = eglGetDisplay(nativeDisplay());
    if (m_display == EGL_NO_DISPLAY)
        qFatal("Could not open egl display");

    EGLint major, minor;
    if (!eglInitialize(m_display, &major, &minor))
        qFatal("Could not initialize egl display");

    m_inputContext = QPlatformInputContextFactory::create();

    m_vtHandler.reset(new QFbVtHandler);
}
Пример #8
0
void *EglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QScreen *)
{
    void *result = 0;

    switch (resourceType(resource)) {
    case XlibDisplay:
        // Play nice when using the x11 hooks: Be compatible with xcb that allows querying
        // the X Display pointer, which is nothing but our native display.
        result = reinterpret_cast<void*>(nativeDisplay());
        break;
    default:
        break;
    }

    return result;
}
Пример #9
0
void *QEGLPlatformIntegration::nativeResourceForIntegration(const QByteArray &resource)
{
    void *result = 0;

    switch (resourceType(resource)) {
    case EglDisplay:
        result = display();
        break;
    case NativeDisplay:
        result = reinterpret_cast<void*>(nativeDisplay());
        break;
    default:
        break;
    }

    return result;
}
Пример #10
0
void QBBScreen::newWindowCreated(screen_window_t window)
{
    Q_ASSERT(thread() == QThread::currentThread());
    screen_display_t display = 0;
    if (screen_get_window_property_pv(window, SCREEN_PROPERTY_DISPLAY, (void**)&display) != 0) {
        qWarning("QBBScreen: Failed to get screen for window, errno=%d", errno);
        return;
    }

    if (display == nativeDisplay()) {
        // A window was created on this screen. If we don't know about this window yet, it means
        // it was not created by Qt, but by some foreign library like the multimedia renderer, which
        // creates an overlay window when playing a video.
        // Treat all foreign windows as overlays here.
        if (!findWindow(window))
            addOverlayWindow(window);
    }
}
bool X11Helper::isXRenderExtensionSupported()
{
    static bool queryDone = false;
    static bool supportsXRenderExtension = false;

    if (!queryDone) {
        queryDone = true;
#if USE(GRAPHICS_SURFACE) && USE(GLX)
        Display* display = nativeDisplay();

        if (display) {
            int eventBasep, errorBasep;
            supportsXRenderExtension = XRenderQueryExtension(display, &eventBasep, &errorBasep);
        }
#endif
    }

    return supportsXRenderExtension;
}
void X11Helper::createOffScreenWindow(uint32_t* handleId, const XVisualInfo& visInfo, const IntSize& size)
{
#if USE(GRAPHICS_SURFACE)
    Display* display = nativeDisplay();
    if (!display)
        return;

    if (!visInfo.visual) {
        LOG_ERROR("Failed to find valid XVisual.");
        return;
    }

    Window xWindow = offscreenRootWindow();
    if (!xWindow)
        return;

    Colormap cmap = XCreateColormap(display, xWindow, visInfo.visual, AllocNone);
    XSetWindowAttributes attribute;
    attribute.background_pixel = WhitePixel(display, 0);
    attribute.border_pixel = BlackPixel(display, 0);
    attribute.colormap = cmap;
#if USE(GLX)
    attribute.event_mask = ResizeRedirectMask;
#endif
    uint32_t tempHandleId = XCreateWindow(display, xWindow, 0, 0, size.width(), size.height(), 0, visInfo.depth, InputOutput, visInfo.visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);

    if (!tempHandleId) {
        LOG_ERROR("Failed to create offscreen window.");
        return;
    }

    XSetWindowBackgroundPixmap(display, tempHandleId, 0);
#if USE(GLX)
    XCompositeRedirectWindow(display, tempHandleId, CompositeRedirectManual);
#endif
    XMapWindow(display, tempHandleId);
    *handleId = tempHandleId;
#else
    UNUSED_PARAM(handleId);
    UNUSED_PARAM(visInfo);
    UNUSED_PARAM(size);
#endif
}
Пример #13
0
void *EglFSIntegration::nativeResourceForIntegration(const QByteArray &resource)
{
    void *result = 0;

    switch (resourceType(resource)) {
    case EglDisplay:
        result = display();
        break;
    case NativeDisplay:
        result = reinterpret_cast<void*>(nativeDisplay());
        break;
    case WaylandDisplay:
        result = egl_device_integration()->wlDisplay();
        break;
    default:
        break;
    }

    return result;
}
void X11Helper::createOffScreenWindow(uint32_t* handleId, const EGLint id, bool supportsAlpha, const IntSize& size)
{
#if USE(GRAPHICS_SURFACE)
    VisualID visualId = static_cast<VisualID>(id);

    if (!visualId)
        return;

    // EGL has suggested a visual id, so get the rest of the visual info for that id.
    XVisualInfo visualInfoTemplate;
    memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
    visualInfoTemplate.visualid = visualId;
    int matchingCount = 0;
    OwnPtrX11<XVisualInfo> matchingVisuals(XGetVisualInfo(nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount));
    XVisualInfo* foundVisual = 0;

    if (matchingVisuals) {
        for (int i = 0; i< matchingCount; i++) {
            XVisualInfo* temp = &matchingVisuals[i];
            int matchingdepth = supportsAlpha ? 32 : 24;

            if (temp->visualid == visualId && temp->depth == matchingdepth) {
                foundVisual = temp;
                break;
            }
        }

        if (foundVisual)
            createOffScreenWindow(handleId, *foundVisual, size);
    }
#else
    UNUSED_PARAM(handleId);
    UNUSED_PARAM(id);
    UNUSED_PARAM(size);
#endif
}
void X11Helper::resizeWindow(const IntRect& newRect, const uint32_t windowId)
{
    XResizeWindow(nativeDisplay(), windowId, newRect.width(), newRect.height());
    XFlush(nativeDisplay());
}