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

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

Merge "SF: Initialize DisplayDevice with the active config index" into pi-dev

parents 370b0a10 3c085a07
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -30,8 +30,9 @@

#include <android/configuration.h>

#include <algorithm>
#include <inttypes.h>
#include <algorithm>
#include <iterator>
#include <set>

using android::Fence;
@@ -338,6 +339,31 @@ Error Display::getActiveConfig(
    return Error::None;
}

Error Display::getActiveConfigIndex(int* outIndex) const {
    ALOGV("[%" PRIu64 "] getActiveConfigIndex", mId);
    hwc2_config_t configId = 0;
    auto intError = mComposer.getActiveConfig(mId, &configId);
    auto error = static_cast<Error>(intError);

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

    auto pos = mConfigs.find(configId);
    if (pos != mConfigs.end()) {
        *outIndex = std::distance(mConfigs.begin(), pos);
    } else {
        ALOGE("[%" PRIu64 "] getActiveConfig returned unknown config %u", mId, configId);
        // Return no error, but the caller needs to check for a negative index
        // to detect this case
        *outIndex = -1;
    }

    return Error::None;
}

Error Display::getChangedCompositionTypes(
        std::unordered_map<Layer*, Composition>* outTypes)
{
+2 −4
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <map>

namespace android {
    class Fence;
@@ -207,6 +206,7 @@ public:
    [[clang::warn_unused_result]] Error destroyLayer(Layer* layer);
    [[clang::warn_unused_result]] Error getActiveConfig(
            std::shared_ptr<const Config>* outConfig) const;
    [[clang::warn_unused_result]] Error getActiveConfigIndex(int* outIndex) const;
    [[clang::warn_unused_result]] Error getChangedCompositionTypes(
            std::unordered_map<Layer*, Composition>* outTypes);
    [[clang::warn_unused_result]] Error getColorModes(
@@ -288,9 +288,7 @@ private:
    bool mIsConnected;
    DisplayType mType;
    std::unordered_map<hwc2_layer_t, std::unique_ptr<Layer>> mLayers;
    // The ordering in this map matters, for getConfigs(), when it is
    // converted to a vector
    std::map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
    std::unordered_map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
};

// Convenience C++ class to access hwc2_device_t Layer functions directly.
+22 −0
Original line number Diff line number Diff line
@@ -318,6 +318,28 @@ std::shared_ptr<const HWC2::Display::Config>
    return config;
}

int HWComposer::getActiveConfigIndex(int32_t displayId) const {
    if (!isValidDisplay(displayId)) {
        ALOGV("getActiveConfigIndex: Attempted to access invalid display %d", displayId);
        return -1;
    }
    int index;
    auto error = mDisplayData[displayId].hwcDisplay->getActiveConfigIndex(&index);
    if (error == HWC2::Error::BadConfig) {
        ALOGE("getActiveConfigIndex: No config active, returning -1");
        return -1;
    } else if (error != HWC2::Error::None) {
        ALOGE("getActiveConfigIndex failed for display %d: %s (%d)", displayId,
              to_string(error).c_str(), static_cast<int32_t>(error));
        return -1;
    } else if (index < 0) {
        ALOGE("getActiveConfigIndex returned an unknown config for display %d", displayId);
        return -1;
    }

    return index;
}

std::vector<ui::ColorMode> HWComposer::getColorModes(int32_t displayId) const {
    RETURN_IF_INVALID_DISPLAY(displayId, {});

+1 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ public:

    std::shared_ptr<const HWC2::Display::Config>
            getActiveConfig(int32_t displayId) const;
    int getActiveConfigIndex(int32_t displayId) const;

    std::vector<ui::ColorMode> getColorModes(int32_t displayId) const;

+3 −0
Original line number Diff line number Diff line
@@ -2414,6 +2414,9 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
    }
    setActiveColorModeInternal(hw, defaultColorMode, defaultDataSpace,
                               RenderIntent::COLORIMETRIC);
    if (state.type < DisplayDevice::DISPLAY_VIRTUAL) {
        hw->setActiveConfig(getHwComposer().getActiveConfigIndex(state.type));
    }
    hw->setLayerStack(state.layerStack);
    hw->setProjection(state.orientation, state.viewport, state.frame);
    hw->setDisplayName(state.displayName);
Loading