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

Commit 265f96fb authored by Ayush Jain's avatar Ayush Jain Committed by Android (Google) Code Review
Browse files

Revert "Remove incorrect isDataSpaceValid"

This reverts commit e4f832e2.

Reason for revert: 
DroidMonitor: Potential culprit for Bug b/277122111 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.”

Change-Id: I0fc4f98eb83448562c57433aa68018bcfee746bf
parent e4f832e2
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -79,6 +79,27 @@ static int64_t query64(ANativeWindow* window, int what) {
    return res < 0 ? res : value;
}

static bool isDataSpaceValid(ANativeWindow* window, int32_t dataSpace) {
    bool supported = false;
    switch (dataSpace) {
        case HAL_DATASPACE_UNKNOWN:
        case HAL_DATASPACE_V0_SRGB:
            return true;
        // These data space need wide gamut support.
        case HAL_DATASPACE_V0_SCRGB_LINEAR:
        case HAL_DATASPACE_V0_SCRGB:
        case HAL_DATASPACE_DISPLAY_P3:
            native_window_get_wide_color_support(window, &supported);
            return supported;
        // These data space need HDR support.
        case HAL_DATASPACE_BT2020_PQ:
            native_window_get_hdr_support(window, &supported);
            return supported;
        default:
            return false;
    }
}

/**************************************************************************************************
 * NDK
 **************************************************************************************************/
@@ -198,7 +219,8 @@ int32_t ANativeWindow_setBuffersDataSpace(ANativeWindow* window, int32_t dataSpa
    static_assert(static_cast<int>(ADATASPACE_DEPTH) == static_cast<int>(HAL_DATASPACE_DEPTH));
    static_assert(static_cast<int>(ADATASPACE_DYNAMIC_DEPTH) == static_cast<int>(HAL_DATASPACE_DYNAMIC_DEPTH));

    if (!window || !query(window, NATIVE_WINDOW_IS_VALID)) {
    if (!window || !query(window, NATIVE_WINDOW_IS_VALID) ||
            !isDataSpaceValid(window, dataSpace)) {
        return -EINVAL;
    }
    return native_window_set_buffers_data_space(window,