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

Commit 2bee6043 authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Merge "Adjustments to composer apis for HDR:"

parents fed37540 60564e18
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
/**
 * Copyright 2021, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.graphics.composer3;
@VintfStability
parcelable DisplayBrightness {
  float brightness;
}
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ parcelable DisplayCommand {
  long display;
  android.hardware.graphics.composer3.LayerCommand[] layers;
  @nullable float[] colorTransformMatrix;
  @nullable android.hardware.graphics.composer3.DisplayBrightness brightness;
  @nullable android.hardware.graphics.composer3.ClientTarget clientTarget;
  @nullable android.hardware.graphics.composer3.Buffer virtualDisplayOutputBuffer;
  @nullable android.hardware.graphics.composer3.ClockMonotonicTimestamp expectedPresentTime;
+26 −0
Original line number Diff line number Diff line
/**
 * Copyright 2021, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.graphics.composer3;

@VintfStability
parcelable DisplayBrightness {
    /**
     * A number between 0.0f (minimum brightness) and 1.0f (maximum brightness), a negative value to
     * turn the backlight off.
     */
    float brightness;
}
+24 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.hardware.graphics.composer3;
import android.hardware.graphics.composer3.Buffer;
import android.hardware.graphics.composer3.ClientTarget;
import android.hardware.graphics.composer3.ClockMonotonicTimestamp;
import android.hardware.graphics.composer3.DisplayBrightness;
import android.hardware.graphics.composer3.LayerCommand;

@VintfStability
@@ -68,6 +69,29 @@ parcelable DisplayCommand {
     */
    @nullable float[] colorTransformMatrix;

    /**
     * Sets the desired brightness of the display.
     *
     * Ideally, the brightness of the display will take effect within this frame so that it can be
     * aligned with color transforms. Some display architectures may take multiple frames to apply
     * the display brightness, for example when internally switching the display between multiple
     * power modes to achieve higher luminance. In those cases, the underlying display panel's real
     * brightness may not be applied atomically; however, layer dimming when mixing HDR and SDR
     * content must be synchronized.
     *
     * As an illustrative example: suppose two layers have white
     * points of 200 nits and 1000 nits respectively, the old display luminance is 200 nits, and the
     * new display luminance is 1000 nits. If the new display luminance takes two frames to apply,
     * then: In the first frame, there must not be any relative dimming of layers (treat both layers
     * as 200 nits as the maximum luminance of the display is 200 nits). In the second frame, there
     * dimming should be applied to ensure that the first layer does not become perceptually
     * brighter during the transition.
     *
     * The display luminance must be updated by this command even if there is not pending validate
     * or present command.
     */
    @nullable DisplayBrightness brightness;

    /**
     * Sets the buffer handle which will receive the output of client
     * composition.  Layers marked as Composition.CLIENT must be composited
+49 −31
Original line number Diff line number Diff line
@@ -568,37 +568,6 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSample) {
    }
}

/*
 * Test that if brightness operations are supported, setDisplayBrightness works as expected.
 */
TEST_P(GraphicsComposerAidlTest, setDisplayBrightness) {
    std::vector<DisplayCapability> capabilities;
    auto error = mComposerClient->getDisplayCapabilities(mPrimaryDisplay, &capabilities);
    ASSERT_TRUE(error.isOk());
    bool brightnessSupport = std::find(capabilities.begin(), capabilities.end(),
                                       DisplayCapability::BRIGHTNESS) != capabilities.end();
    if (!brightnessSupport) {
        EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 0.5f)
                          .getServiceSpecificError(),
                  IComposerClient::EX_UNSUPPORTED);
        GTEST_SUCCEED() << "Brightness operations are not supported";
        return;
    }

    EXPECT_TRUE(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 0.0f).isOk());
    EXPECT_TRUE(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 0.5f).isOk());
    EXPECT_TRUE(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 1.0f).isOk());
    EXPECT_TRUE(mComposerClient->setDisplayBrightness(mPrimaryDisplay, -1.0f).isOk());

    error = mComposerClient->setDisplayBrightness(mPrimaryDisplay, +2.0f);
    EXPECT_FALSE(error.isOk());
    EXPECT_EQ(error.getServiceSpecificError(), IComposerClient::EX_BAD_PARAMETER);

    error = mComposerClient->setDisplayBrightness(mPrimaryDisplay, -2.0f);
    EXPECT_FALSE(error.isOk());
    EXPECT_EQ(error.getServiceSpecificError(), IComposerClient::EX_BAD_PARAMETER);
}

TEST_P(GraphicsComposerAidlTest, getDisplayConnectionType) {
    DisplayConnectionType type;
    EXPECT_FALSE(mComposerClient->getDisplayConnectionType(mInvalidDisplayId, &type).isOk());
@@ -1494,6 +1463,55 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerColorTransform) {
    }
}

TEST_P(GraphicsComposerAidlCommandTest, SetDisplayBrightness) {
    std::vector<DisplayCapability> capabilities;
    auto error = mComposerClient->getDisplayCapabilities(mPrimaryDisplay, &capabilities);
    ASSERT_TRUE(error.isOk());
    bool brightnessSupport = std::find(capabilities.begin(), capabilities.end(),
                                       DisplayCapability::BRIGHTNESS) != capabilities.end();
    if (!brightnessSupport) {
        mWriter.setDisplayBrightness(mPrimaryDisplay, 0.5f);
        execute();
        const auto errors = mReader.takeErrors();
        EXPECT_EQ(1, errors.size());
        EXPECT_EQ(EX_UNSUPPORTED_OPERATION, errors[0].errorCode);
        GTEST_SUCCEED() << "SetDisplayBrightness is not supported";
        return;
    }

    mWriter.setDisplayBrightness(mPrimaryDisplay, 0.0f);
    execute();
    EXPECT_TRUE(mReader.takeErrors().empty());

    mWriter.setDisplayBrightness(mPrimaryDisplay, 0.5f);
    execute();
    EXPECT_TRUE(mReader.takeErrors().empty());

    mWriter.setDisplayBrightness(mPrimaryDisplay, 1.0f);
    execute();
    EXPECT_TRUE(mReader.takeErrors().empty());

    mWriter.setDisplayBrightness(mPrimaryDisplay, -1.0f);
    execute();
    EXPECT_TRUE(mReader.takeErrors().empty());

    mWriter.setDisplayBrightness(mPrimaryDisplay, 2.0f);
    execute();
    {
        const auto errors = mReader.takeErrors();
        EXPECT_EQ(1, errors.size());
        EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, errors[0].errorCode);
    }

    mWriter.setDisplayBrightness(mPrimaryDisplay, -2.0f);
    execute();
    {
        const auto errors = mReader.takeErrors();
        EXPECT_EQ(1, errors.size());
        EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, errors[0].errorCode);
    }
}

TEST_P(GraphicsComposerAidlCommandTest, SET_CLIENT_TARGET) {
    EXPECT_TRUE(
            mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kBufferSlotCount).isOk());
Loading