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

Commit ba4d1d22 authored by Peiyong Lin's avatar Peiyong Lin Committed by Android (Google) Code Review
Browse files

Merge changes I09f4a157,I738be45b

* changes:
  [SurfaceFlinger] Remove saturation matrix of Adaptive mode.
  [SurfaceFlinger] Remove usage of legacy data spaces.
parents 0b647b2f c1ccb0bf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ TEST_F(SurfaceTest, QueryConsumerUsage) {
}

TEST_F(SurfaceTest, QueryDefaultBuffersDataSpace) {
    const android_dataspace TEST_DATASPACE = HAL_DATASPACE_SRGB;
    const android_dataspace TEST_DATASPACE = HAL_DATASPACE_V0_SRGB;
    sp<IGraphicBufferProducer> producer;
    sp<IGraphicBufferConsumer> consumer;
    BufferQueue::createBufferQueue(&producer, &consumer);
+1 −1
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ static android_dataspace dataSpaceFromEGLColorSpace(EGLint colorspace) {
    if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
        return HAL_DATASPACE_UNKNOWN;
    } else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) {
        return HAL_DATASPACE_SRGB;
        return HAL_DATASPACE_V0_SRGB;
    } else if (colorspace == EGL_GL_COLORSPACE_DISPLAY_P3_EXT) {
        return HAL_DATASPACE_DISPLAY_P3;
    } else if (colorspace == EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT) {
+13 −14
Original line number Diff line number Diff line
@@ -431,26 +431,25 @@ Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime
    }

    ui::Dataspace dataSpace = getDrawingDataSpace();
    // treat modern dataspaces as legacy dataspaces whenever possible, until
    // we can trust the buffer producers
    // translate legacy dataspaces to modern dataspaces
    switch (dataSpace) {
        case ui::Dataspace::V0_SRGB:
            dataSpace = ui::Dataspace::SRGB;
        case ui::Dataspace::SRGB:
            dataSpace = ui::Dataspace::V0_SRGB;
            break;
        case ui::Dataspace::V0_SRGB_LINEAR:
            dataSpace = ui::Dataspace::SRGB_LINEAR;
        case ui::Dataspace::SRGB_LINEAR:
            dataSpace = ui::Dataspace::V0_SRGB_LINEAR;
            break;
        case ui::Dataspace::V0_JFIF:
            dataSpace = ui::Dataspace::JFIF;
        case ui::Dataspace::JFIF:
            dataSpace = ui::Dataspace::V0_JFIF;
            break;
        case ui::Dataspace::V0_BT601_625:
            dataSpace = ui::Dataspace::BT601_625;
        case ui::Dataspace::BT601_625:
            dataSpace = ui::Dataspace::V0_BT601_625;
            break;
        case ui::Dataspace::V0_BT601_525:
            dataSpace = ui::Dataspace::BT601_525;
        case ui::Dataspace::BT601_525:
            dataSpace = ui::Dataspace::V0_BT601_525;
            break;
        case ui::Dataspace::V0_BT709:
            dataSpace = ui::Dataspace::BT709;
        case ui::Dataspace::BT709:
            dataSpace = ui::Dataspace::V0_BT709;
            break;
        default:
            break;
+2 −2
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ const std::array<RenderIntent, 2> sHdrRenderIntents = {
Dataspace colorModeToDataspace(ColorMode mode) {
    switch (mode) {
        case ColorMode::SRGB:
            return Dataspace::SRGB;
            return Dataspace::V0_SRGB;
        case ColorMode::DISPLAY_P3:
            return Dataspace::DISPLAY_P3;
        case ColorMode::DISPLAY_BT2020:
@@ -817,7 +817,7 @@ void DisplayDevice::populateColorModes(
bool DisplayDevice::hasRenderIntent(RenderIntent intent) const {
    // assume a render intent is supported when SRGB supports it; we should
    // get rid of that assumption.
    auto iter = mColorModes.find(getColorModeKey(Dataspace::SRGB, intent));
    auto iter = mColorModes.find(getColorModeKey(Dataspace::V0_SRGB, intent));
    return iter != mColorModes.end() && iter->second.renderIntent == intent;
}

+2 −34
Original line number Diff line number Diff line
@@ -734,24 +734,6 @@ void SurfaceFlinger::init() {
        ALOGE("Run StartPropertySetThread failed!");
    }

    // This is a hack. Per definition of getDataspaceSaturationMatrix, the returned matrix
    // is used to saturate legacy sRGB content. However, to make sure the same color under
    // Display P3 will be saturated to the same color, we intentionally break the API spec
    // and apply this saturation matrix on Display P3 content. Unless the risk of applying
    // such saturation matrix on Display P3 is understood fully, the API should always return
    // identify matrix.
    mEnhancedSaturationMatrix =
            getHwComposer().getDataspaceSaturationMatrix(*display->getId(), Dataspace::SRGB_LINEAR);

    // we will apply this on Display P3.
    if (mEnhancedSaturationMatrix != mat4()) {
        ColorSpace srgb(ColorSpace::sRGB());
        ColorSpace displayP3(ColorSpace::DisplayP3());
        mat4 srgbToP3 = mat4(ColorSpaceConnector(srgb, displayP3).getTransform());
        mat4 p3ToSrgb = mat4(ColorSpaceConnector(displayP3, srgb).getTransform());
        mEnhancedSaturationMatrix = srgbToP3 * mEnhancedSaturationMatrix * p3ToSrgb;
    }

    ALOGV("Done initializing");
}

@@ -2106,7 +2088,7 @@ void SurfaceFlinger::rebuildLayerStacks() {
//  - Dataspace::BT2020_PQ
Dataspace SurfaceFlinger::getBestDataspace(const sp<const DisplayDevice>& display,
                                           Dataspace* outHdrDataSpace) const {
    Dataspace bestDataSpace = Dataspace::SRGB;
    Dataspace bestDataSpace = Dataspace::V0_SRGB;
    *outHdrDataSpace = Dataspace::UNKNOWN;

    for (const auto& layer : display->getVisibleLayersSortedByZ()) {
@@ -2431,7 +2413,7 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
    Dataspace defaultDataSpace = Dataspace::UNKNOWN;
    if (display->hasWideColorGamut()) {
        defaultColorMode = ColorMode::SRGB;
        defaultDataSpace = Dataspace::SRGB;
        defaultDataSpace = Dataspace::V0_SRGB;
    }
    setActiveColorModeInternal(display, defaultColorMode, defaultDataSpace,
                               RenderIntent::COLORIMETRIC);
@@ -3085,7 +3067,6 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& display) {

    mat4 colorMatrix;
    bool applyColorMatrix = false;
    bool needsEnhancedColorMatrix = false;

    // Framebuffer will live in this scope for GPU composition.
    std::unique_ptr<renderengine::BindNativeBufferAsFramebuffer> fbo;
@@ -3132,16 +3113,6 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& display) {
            colorMatrix = mDrawingState.colorMatrix;
        }

        // The current enhanced saturation matrix is designed to enhance Display P3,
        // thus we only apply this matrix when the render intent is not colorimetric
        // and the output color space is Display P3.
        needsEnhancedColorMatrix =
            (display->getActiveRenderIntent() >= RenderIntent::ENHANCE &&
             outputDataspace == Dataspace::DISPLAY_P3);
        if (needsEnhancedColorMatrix) {
            colorMatrix *= mEnhancedSaturationMatrix;
        }

        display->setViewportAndProjection();

        // Never touch the framebuffer if we don't have any framebuffer layers
@@ -3216,9 +3187,6 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& display) {
                            tmpMatrix = mDrawingState.colorMatrix;
                        }
                        tmpMatrix *= layer->getColorTransform();
                        if (needsEnhancedColorMatrix) {
                            tmpMatrix *= mEnhancedSaturationMatrix;
                        }
                        getRenderEngine().setColorTransform(tmpMatrix);
                    } else {
                        getRenderEngine().setColorTransform(colorMatrix);
Loading