コード例 #1
0
ファイル: PlatformDisplay.cpp プロジェクト: eocanha/webkit
void PlatformDisplay::initializeEGLDisplay()
{
    m_eglDisplayInitialized = true;

    if (m_eglDisplay == EGL_NO_DISPLAY) {
        // EGL is optionally soft linked on Windows.
#if PLATFORM(WIN)
        auto eglGetDisplay = eglGetDisplayPtr();
        if (!eglGetDisplay)
            return;
#endif
        m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
        if (m_eglDisplay == EGL_NO_DISPLAY)
            return;
    }

    EGLint majorVersion, minorVersion;
    if (eglInitialize(m_eglDisplay, &majorVersion, &minorVersion) == EGL_FALSE) {
        LOG_ERROR("EGLDisplay Initialization failed.");
        terminateEGLDisplay();
        return;
    }

    m_eglMajorVersion = majorVersion;
    m_eglMinorVersion = minorVersion;

    eglDisplays().add(this);

    static bool eglAtexitHandlerInitialized = false;
    if (!eglAtexitHandlerInitialized) {
        // EGL registers atexit handlers to cleanup its global display list.
        // Since the global PlatformDisplay instance is created before,
        // when the PlatformDisplay destructor is called, EGL has already removed the
        // display from the list, causing eglTerminate() to crash. So, here we register
        // our own atexit handler, after EGL has been initialized and after the global
        // instance has been created to ensure we call eglTerminate() before the other
        // EGL atexit handlers and the PlatformDisplay destructor.
        // See https://bugs.webkit.org/show_bug.cgi?id=157973.
        eglAtexitHandlerInitialized = true;
        std::atexit([] {
            while (!eglDisplays().isEmpty()) {
                auto* display = eglDisplays().takeAny();
                display->terminateEGLDisplay();
            }
        });
    }
}
コード例 #2
0
void PlatformDisplay::initializeEGLDisplay()
{
    m_eglDisplayInitialized = true;

    if (m_eglDisplay == EGL_NO_DISPLAY) {
// EGL is optionally soft linked on Windows.
#if PLATFORM(WIN)
        auto eglGetDisplay = eglGetDisplayPtr();
        if (!eglGetDisplay)
            return;
#endif
        m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
        if (m_eglDisplay == EGL_NO_DISPLAY)
            return;
    }

    if (eglInitialize(m_eglDisplay, 0, 0) == EGL_FALSE) {
        LOG_ERROR("EGLDisplay Initialization failed.");
        terminateEGLDisplay();
        return;
    }

#if USE(OPENGL_ES_2)
    static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API;
#else
    static const EGLenum eglAPIVersion = EGL_OPENGL_API;
#endif
    if (eglBindAPI(eglAPIVersion) == EGL_FALSE) {
        LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
        terminateEGLDisplay();
        return;
    }

    // EGL registers atexit handlers to cleanup its global display list.
    // Since the global PlatformDisplay instance is created before,
    // when the PlatformDisplay destructor is called, EGL has already removed the
    // display from the list, causing eglTerminate() to crash. So, here we register
    // our own atexit handler, after EGL has been initialized and after the global
    // instance has been created to ensure we call eglTerminate() before the other
    // EGL atexit handlers and the PlatformDisplay destructor.
    // See https://bugs.webkit.org/show_bug.cgi?id=157973.
    std::atexit([] { PlatformDisplay::sharedDisplay().terminateEGLDisplay(); });
}