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

Commit d4d9c6fc authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: move EGL initialization into RE

This defers EGL initialization a bit, from before EventThread
initialization to after.

Test: SurfaceFlinger_test
Change-Id: Icbe9b78d1db189ce5e6aeedf902fe7b62ea2004e
parent 2b6386e1
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -47,8 +47,13 @@ static bool findExtension(const char* exts, const char* name) {
    return false;
}

std::unique_ptr<RenderEngine> RenderEngine::create(EGLDisplay display,
        int hwcFormat, uint32_t featureFlags) {
std::unique_ptr<RenderEngine> RenderEngine::create(int hwcFormat, uint32_t featureFlags) {
    // initialize EGL for the default display
    EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (!eglInitialize(display, NULL, NULL)) {
        LOG_ALWAYS_FATAL("failed to initialize EGL");
    }

    // EGL_ANDROIDX_no_config_context is an experimental extension with no
    // written specification. It will be replaced by something more formal.
    // SurfaceFlinger is using it to allow a single EGLContext to render to
+1 −2
Original line number Diff line number Diff line
@@ -67,8 +67,7 @@ public:
    enum FeatureFlag {
        WIDE_COLOR_SUPPORT = 1 << 0 // Platform has a wide color display
    };
    static std::unique_ptr<RenderEngine> create(EGLDisplay display,
            int hwcFormat, uint32_t featureFlags);
    static std::unique_ptr<RenderEngine> create(int hwcFormat, uint32_t featureFlags);

    static EGLConfig chooseEglConfig(EGLDisplay display, int format, bool logConfig);

+4 −10
Original line number Diff line number Diff line
@@ -594,10 +594,6 @@ void SurfaceFlinger::init() {

    Mutex::Autolock _l(mStateLock);

    // initialize EGL for the default display
    mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    eglInitialize(mEGLDisplay, NULL, NULL);

    // start the EventThread
    sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
            vsyncPhaseOffsetNs, true, "app");
@@ -618,16 +614,14 @@ void SurfaceFlinger::init() {
    }

    // Get a RenderEngine for the given display / config (can't fail)
    mRenderEngine = RenderEngine::create(mEGLDisplay,
            HAL_PIXEL_FORMAT_RGBA_8888,
    mRenderEngine = RenderEngine::create(HAL_PIXEL_FORMAT_RGBA_8888,
            hasWideColorDisplay ? RenderEngine::WIDE_COLOR_SUPPORT : 0);
    LOG_ALWAYS_FATAL_IF(mRenderEngine == nullptr, "couldn't create RenderEngine");

    // retrieve the EGL context that was selected/created
    // retrieve the EGL display/context that was selected/created
    mEGLDisplay = mRenderEngine->getEGLDisplay();
    mEGLContext = mRenderEngine->getEGLContext();

    LOG_ALWAYS_FATAL_IF(mEGLContext == EGL_NO_CONTEXT,
            "couldn't create EGLContext");

    LOG_ALWAYS_FATAL_IF(mVrFlingerRequestsDisplay,
            "Starting with vr flinger active is not currently supported.");
    mHwc.reset(new HWComposer(mHwcServiceName));