Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52e21483 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

handle EGL errors

for now we just restart the runtime.

bug: 7225248
Change-Id: I7638ffe82075a4db9e7e6f9e35cf48afcb5a387a
parent 500407a2
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -205,27 +205,34 @@ void DisplayDevice::flip(const Region& dirty) const
}
}


void DisplayDevice::swapBuffers(HWComposer& hwc) const {
void DisplayDevice::swapBuffers(HWComposer& hwc) const {
    EGLBoolean success = EGL_TRUE;
    if (hwc.initCheck() != NO_ERROR) {
    if (hwc.initCheck() != NO_ERROR) {
        // no HWC, we call eglSwapBuffers()
        // no HWC, we call eglSwapBuffers()
        eglSwapBuffers(mDisplay, mSurface);
        success = eglSwapBuffers(mDisplay, mSurface);
    } else {
    } else {
        // We have a valid HWC, but not all displays can use it, in particular
        // We have a valid HWC, but not all displays can use it, in particular
        // the virtual displays are on their own.
        // the virtual displays are on their own.
        // TODO: HWC 1.2 will allow virtual displays
        // TODO: HWC 1.2 will allow virtual displays
        if (mType >= DisplayDevice::DISPLAY_VIRTUAL) {
        if (mType >= DisplayDevice::DISPLAY_VIRTUAL) {
            // always call eglSwapBuffers() for virtual displays
            // always call eglSwapBuffers() for virtual displays
            eglSwapBuffers(mDisplay, mSurface);
            success = eglSwapBuffers(mDisplay, mSurface);
        } else if (hwc.supportsFramebufferTarget()) {
        } else if (hwc.supportsFramebufferTarget()) {
            // as of hwc 1.1 we always call eglSwapBuffers if we have some
            // as of hwc 1.1 we always call eglSwapBuffers if we have some
            // GLES layers
            // GLES layers
            if (hwc.hasGlesComposition(mType)) {
            if (hwc.hasGlesComposition(mType)) {
                eglSwapBuffers(mDisplay, mSurface);
                success = eglSwapBuffers(mDisplay, mSurface);
            }
            }
        } else {
        } else {
            // HWC doesn't have the framebuffer target, we don't call
            // HWC doesn't have the framebuffer target, we don't call
            // eglSwapBuffers(), since this is handled by HWComposer::commit().
            // eglSwapBuffers(), since this is handled by HWComposer::commit().
        }
        }
    }
    }

    // TODO: we should at least handle EGL_CONTEXT_LOST, by recreating the
    // context and resetting our state.
    LOG_ALWAYS_FATAL_IF(!success,
            "eglSwapBuffers(%p, %p) failed with 0x%8x",
            mDisplay, mSurface, eglGetError());
}
}


void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {
void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {