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

Commit fad9d8cd authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter
Browse files

Add support for multiple color modes

Bug: 29044347
Change-Id: Iea048eaa62f072a9bbefc4f3a6c29a9e593eab69
parent 1d6c0e97
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -359,6 +359,27 @@ std::shared_ptr<const HWC2::Display::Config>
    return config;
}

std::vector<int32_t> HWComposer::getColorModes(int32_t displayId) const {
    std::vector<int32_t> modes;

    if (!isValidDisplay(displayId)) {
        ALOGE("getColorModes: Attempted to access invalid display %d",
                displayId);
        return modes;
    }
    const std::shared_ptr<HWC2::Display>& hwcDisplay =
            mDisplayData[displayId].hwcDisplay;

    auto error = hwcDisplay->getColorModes(&modes);
    if (error != HWC2::Error::None) {
        ALOGE("getColorModes failed for display %d: %s (%d)", displayId,
                to_string(error).c_str(), static_cast<int32_t>(error));
        return std::vector<int32_t>();
    }

    return modes;
}

void HWComposer::setVsyncEnabled(int32_t disp, HWC2::Vsync enabled) {
    if (disp < 0 || disp >= HWC_DISPLAY_VIRTUAL) {
        ALOGD("setVsyncEnabled: Ignoring for virtual display %d", disp);
+2 −0
Original line number Diff line number Diff line
@@ -149,6 +149,8 @@ public:
    std::shared_ptr<const HWC2::Display::Config>
            getActiveConfig(int32_t displayId) const;

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

    // for debugging ----------------------------------------------------------
    void dump(String8& out) const;

+12 −4
Original line number Diff line number Diff line
@@ -614,9 +614,6 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
        info.fps = 1e9 / hwConfig->getVsyncPeriod();
        info.appVsyncOffset = VSYNC_EVENT_PHASE_OFFSET_NS;

        // TODO: Hook this back up
        info.colorTransform = 0;

        // This is how far in advance a buffer must be queued for
        // presentation at a given time.  If you want a buffer to appear
        // on the screen at time N, you must submit the buffer before
@@ -635,8 +632,19 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
        // All non-virtual displays are currently considered secure.
        info.secure = true;

        // DisplayManager expects each color mode to be its own display
        // info record.
        std::vector<int32_t> modes = getHwComposer().getColorModes(type);

        if (modes.size() == 0) {
            info.colorTransform = 0;
            configs->push_back(info);
        }
        for (int32_t mode : modes) {
            info.colorTransform = mode;
            configs->push_back(info);
        }
    }

    return NO_ERROR;
}