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

Commit 53a9de75 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix HWC2to1Adapter crashing dragon at startup"

parents 9d19176b b7432cc5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -52,7 +52,11 @@ ifeq ($(TARGET_USES_HWC2),true)
    LOCAL_SRC_FILES += \
        SurfaceFlinger.cpp \
        DisplayHardware/HWComposer.cpp
    ifeq ($(TARGET_USES_HWC2ON1ADAPTER), true)
        LOCAL_CFLAGS += -DBYPASS_IHWC
    endif
else
    LOCAL_CFLAGS += -DBYPASS_IHWC
    LOCAL_SRC_FILES += \
        SurfaceFlinger_hwc1.cpp \
        DisplayHardware/HWComposer_hwc1.cpp
+2 −0
Original line number Diff line number Diff line
@@ -614,6 +614,8 @@ Error Display::getActiveConfig(
    auto error = static_cast<Error>(intError);

    if (error != Error::None) {
        ALOGE("Unable to get active config for mId:[%" PRIu64 "]", mId);
        *outConfig = nullptr;
        return error;
    }

+0 −4
Original line number Diff line number Diff line
@@ -17,10 +17,6 @@
#ifndef ANDROID_SF_HWC2_H
#define ANDROID_SF_HWC2_H

#ifndef USE_HWC2
#define BYPASS_IHWC
#endif

#define HWC2_INCLUDE_STRINGIFICATION
#define HWC2_USE_CPP11
#include <hardware/hwcomposer2.h>
+30 −20
Original line number Diff line number Diff line
@@ -1841,17 +1841,24 @@ void HWC2On1Adapter::Display::initializeActiveConfig()

    auto activeConfig = mDevice.mHwc1Device->getActiveConfig(
            mDevice.mHwc1Device, mHwc1Id);
    if (activeConfig >= 0) {

    // Some devices startup without an activeConfig:
    // We need to set one ourselves.
    if (activeConfig == HWC_ERROR) {
        ALOGV("There is no active configuration: Picking the first one: 0.");
        const int defaultIndex = 0;
        mDevice.mHwc1Device->setActiveConfig(mDevice.mHwc1Device, mHwc1Id, defaultIndex);
        activeConfig = defaultIndex;
    }

    for (const auto& config : mConfigs) {
        if (config->hasHwc1Id(activeConfig)) {
                ALOGV("Setting active config to %d for HWC1 config %u",
                        config->getId(), activeConfig);
            ALOGE("Setting active config to %d for HWC1 config %u", config->getId(), activeConfig);
            mActiveConfig = config;
            if (config->getColorModeForHwc1Id(activeConfig, &mActiveColorMode) != Error::None) {
                // This should never happen since we checked for the config's presence before
                // setting it as active.
                    ALOGE("Unable to find color mode for active HWC1 config %d",
                            config->getId());
                ALOGE("Unable to find color mode for active HWC1 config %d", config->getId());
                mActiveColorMode = HAL_COLOR_MODE_NATIVE;
            }
            break;
@@ -1863,7 +1870,10 @@ void HWC2On1Adapter::Display::initializeActiveConfig()
        mActiveConfig = mConfigs[0];
        mActiveColorMode = HAL_COLOR_MODE_NATIVE;
    }
    }




}

void HWC2On1Adapter::Display::reallocateHwc1Contents()
+2 −2
Original line number Diff line number Diff line
@@ -346,14 +346,14 @@ std::vector<std::shared_ptr<const HWC2::Display::Config>>
std::shared_ptr<const HWC2::Display::Config>
        HWComposer::getActiveConfig(int32_t displayId) const {
    if (!isValidDisplay(displayId)) {
        ALOGE("getActiveConfigs: Attempted to access invalid display %d",
        ALOGV("getActiveConfigs: Attempted to access invalid display %d",
                displayId);
        return nullptr;
    }
    std::shared_ptr<const HWC2::Display::Config> config;
    auto error = mDisplayData[displayId].hwcDisplay->getActiveConfig(&config);
    if (error == HWC2::Error::BadConfig) {
        ALOGV("getActiveConfig: No config active, returning null");
        ALOGE("getActiveConfig: No config active, returning null");
        return nullptr;
    } else if (error != HWC2::Error::None) {
        ALOGE("getActiveConfig failed for display %d: %s (%d)", displayId,