diff options
author | Haamed Gheibi <haamed@google.com> | 2022-02-04 13:47:26 -0800 |
---|---|---|
committer | Haamed Gheibi <haamed@google.com> | 2022-02-04 13:55:47 -0800 |
commit | f99b35c293439db0b7436b47b939eb8c7bf21b51 (patch) | |
tree | 6cd9b0719554809447c845616317cca5409b93ae /graphics/composer/aidl/android/hardware | |
parent | a028272dee9220e6810cbdcfb2328c34f8afe4c2 (diff) | |
parent | 332dead340bb196c6ba3f6978e8fb53966c74bf7 (diff) |
Merge TP1A.220120.003
Change-Id: Ie5eba313ee102e452f5f96942ed2f3a7bb4e8f01
Diffstat (limited to 'graphics/composer/aidl/android/hardware')
13 files changed, 327 insertions, 141 deletions
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Color.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Color.aidl index 979f677379..151a8540c9 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/Color.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Color.aidl @@ -16,10 +16,13 @@ package android.hardware.graphics.composer3; +/** + * Color representation as a floating point number in the range [0.0 - 1.0] + */ @VintfStability parcelable Color { - byte r; - byte g; - byte b; - byte a; + float r; + float g; + float b; + float a; } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/WhitePointNits.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayBrightness.aidl index 2a1d1c666c..f66b235098 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/WhitePointNits.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayBrightness.aidl @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021, The Android Open Source Project + * 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. @@ -17,13 +17,10 @@ package android.hardware.graphics.composer3; @VintfStability -parcelable WhitePointNits { +parcelable DisplayBrightness { /** - * The desired white point for the layer. This is intended to be used when presenting - * an SDR layer alongside HDR content. The HDR content will be presented at the display - * brightness in nits, and accordingly SDR content shall be dimmed to the desired white point - * provided. - * @see LayerCommand.whitePointNits. + * A number between 0.0f (minimum brightness) and 1.0f (maximum brightness), a negative value to + * turn the backlight off. */ - float nits; + float brightness; } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCapability.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCapability.aidl index eacf1068e1..249fed03a0 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCapability.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCapability.aidl @@ -75,4 +75,8 @@ enum DisplayCapability { * PowerMode.ON_SUSPEND and PowerMode.DOZE_SUSPEND must be supported. */ SUSPEND = 6, + /** + * Indicates that the display supports Composition.DISPLAY_DECORATION. + */ + DISPLAY_DECORATION = 7, } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCommand.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCommand.aidl index 18461aded7..f1ce1a7dad 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCommand.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCommand.aidl @@ -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 @@ -69,6 +70,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 * into this buffer prior to the call to PRESENT_DISPLAY, and layers not diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp index d34b4051fa..d2cabff346 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Hidl2AidlAsserts.cpp @@ -25,7 +25,6 @@ #include "aidl/android/hardware/graphics/composer3/DisplayAttribute.h" #include "aidl/android/hardware/graphics/composer3/DisplayCapability.h" #include "aidl/android/hardware/graphics/composer3/DisplayConnectionType.h" -#include "aidl/android/hardware/graphics/composer3/FloatColor.h" #include "aidl/android/hardware/graphics/composer3/FormatColorComponent.h" #include "aidl/android/hardware/graphics/composer3/IComposer.h" #include "aidl/android/hardware/graphics/composer3/PerFrameMetadata.h" diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl index ab7f39781e..c86b9bdaec 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl @@ -16,6 +16,7 @@ package android.hardware.graphics.composer3; +import android.hardware.graphics.common.Transform; import android.hardware.graphics.composer3.ClientTargetProperty; import android.hardware.graphics.composer3.ColorMode; import android.hardware.graphics.composer3.CommandResultPayload; @@ -354,6 +355,23 @@ interface IComposerClient { DisplayContentSamplingAttributes getDisplayedContentSamplingAttributes(long display); /** + * Queries the physical orientation of a display. Orientation 'Transform::NONE' + * represents a display that doesn't require any transformation on layers + * to be presented at their natural orientation. + * + * @param display is the display where the physical orientation is queried. + * + * @return is one of the below values: + * Transform::NONE + * Transform::ROT_90 + * Transform::ROT_180 + * Transform::ROT_270 + * + * @exception EX_BAD_DISPLAY when an invalid display was passed in. + */ + Transform getDisplayPhysicalOrientation(long display); + + /** * Returns the high dynamic range (HDR) capabilities of the given display, * which are invariant with regard to the active configuration. * @@ -549,6 +567,58 @@ interface IComposerClient { long display, int config, in VsyncPeriodChangeConstraints vsyncPeriodChangeConstraints); /** + * Sets the display config in which the device boots. + * + * If the device is unable to boot in this config for any reason (example HDMI display changed), + * the implementation should try to find a config which matches the resolution and refresh-rate + * of this config. If no such config exists, the implementation's preferred display config + * should be used. + * + * @param display is the display for which the boot config is set. + * @param config is the new boot config for the display. + * + * @exception EX_BAD_DISPLAY when an invalid display handle was passed in. + * @exception EX_BAD_CONFIG when an invalid config id was passed in. + * + * @see getDisplayConfigs + * @see clearBootDisplayConfig + * @see getPreferredBootDisplayConfig + */ + void setBootDisplayConfig(long display, int config); + + /** + * Clears the boot display config. + * + * The device should boot in the implementation's preferred display config. + * + * @param display is the display for which the cached boot config is cleared. + * + * @exception EX_BAD_DISPLAY when an invalid display handle was passed in. + * + * @see getDisplayConfigs + * @see setBootDisplayConfig + * @see getPreferredBootDisplayConfig + */ + void clearBootDisplayConfig(long display); + + /** + * Returns the implementation's preferred display config. + * + * This is the display config used by the implementation at boot time, if the boot display + * config has not been requested yet, or if it has been previously cleared. + * + * @param display is the display to which the preferred config is queried. + * @return the implementation's preferred display config. + * + * @exception EX_BAD_DISPLAY when an invalid display handle was passed in. + * + * @see getDisplayConfigs + * @see setBootDisplayConfig + * @see clearBootDisplayConfig + */ + int getPreferredBootDisplayConfig(long display); + + /** * Requests the display to enable/disable its low latency mode. * * If the display is connected via HDMI 2.1, then Auto Low Latency Mode should be triggered. If @@ -616,25 +686,6 @@ interface IComposerClient { void setContentType(long display, ContentType type); /** - * Sets the brightness of a display. - * - * Ideally, the brightness change should take effect in the next frame post (so that it can be - * aligned with color transforms). - * - * @param display - * The display whose brightness is set. - * @param brightness - * A number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or -1.0 to - * turn the backlight off. - * - * @exception EX_BAD_DISPLAY when the display is invalid, or - * @exception EX_UNSUPPORTED when brightness operations are not supported, or - * @exception EX_BAD_PARAMETER when the brightness is invalid, or - * @exception EX_NO_RESOURCES when the brightness cannot be applied. - */ - void setDisplayBrightness(long display, float brightness); - - /** * Enables or disables the collection of color content statistics * on this display. * diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl index 44fd4dcb9a..0a2711b056 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl @@ -22,7 +22,7 @@ import android.hardware.graphics.common.Point; import android.hardware.graphics.common.Rect; import android.hardware.graphics.composer3.Buffer; import android.hardware.graphics.composer3.Color; -import android.hardware.graphics.composer3.FloatColor; +import android.hardware.graphics.composer3.Luminance; import android.hardware.graphics.composer3.ParcelableBlendMode; import android.hardware.graphics.composer3.ParcelableComposition; import android.hardware.graphics.composer3.ParcelableDataspace; @@ -30,7 +30,6 @@ import android.hardware.graphics.composer3.ParcelableTransform; import android.hardware.graphics.composer3.PerFrameMetadata; import android.hardware.graphics.composer3.PerFrameMetadataBlob; import android.hardware.graphics.composer3.PlaneAlpha; -import android.hardware.graphics.composer3.WhitePointNits; import android.hardware.graphics.composer3.ZOrder; @VintfStability @@ -114,13 +113,6 @@ parcelable LayerCommand { @nullable Color color; /** - * Sets the color of the given layer. If the composition type of the layer - * is not Composition.SOLID_COLOR, this call must succeed and have no - * other effect. - */ - @nullable FloatColor floatColor; - - /** * Sets the desired composition type of the given layer. During * validateDisplay, the device may request changes to the composition * types of any of the layers as described in the definition of @@ -243,7 +235,7 @@ parcelable LayerCommand { * brightness in nits, and accordingly SDR content shall be dimmed to the desired white point * provided. */ - @nullable WhitePointNits whitePointNits; + @nullable Luminance whitePointNits; /** * Sets the PerFrameMetadata for the display. This metadata must be used @@ -264,4 +256,15 @@ parcelable LayerCommand { * This command may be called every frame. */ @nullable PerFrameMetadataBlob[] perFrameMetadataBlob; + + /** + * Specifies a region of the layer that is transparent and may be skipped + * by the DPU, e.g. using a blocking region, in order to save power. This + * is only a hint, so the composition of the layer must look the same + * whether or not this region is skipped. + * + * The region is in screen space and must not exceed the dimensions of + * the screen. + */ + @nullable Rect[] blockingRegion; } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/FloatColor.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Luminance.aidl index a0a1d4b179..5b1c1b40fe 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/FloatColor.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Luminance.aidl @@ -16,14 +16,11 @@ package android.hardware.graphics.composer3; -/** - * Color representation as a floating point number in the range [0.0 - 1.0] - */ - @VintfStability -parcelable FloatColor { - float r; - float g; - float b; - float a; +parcelable Luminance { + /** + * Photometric measure of luminous intensity per unit area of light. + * Units are nits, or cd/m^2. + */ + float nits; } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp index 0ece1d55a4..e519221159 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp @@ -922,35 +922,30 @@ class GraphicsBlendModeCompositionTest auto layer = mLayers[1]; BlendMode blendMode = layer->getBlendMode(); - float alpha = mTopLayerColor.a / 255.0f * layer->getAlpha(); + float alpha = mTopLayerColor.a * layer->getAlpha(); if (blendMode == BlendMode::NONE) { for (auto& expectedColor : expectedColors) { - expectedColor.r = mTopLayerColor.r * static_cast<int8_t>(layer->getAlpha()); - expectedColor.g = mTopLayerColor.g * static_cast<int8_t>(layer->getAlpha()); - expectedColor.b = mTopLayerColor.b * static_cast<int8_t>(layer->getAlpha()); - expectedColor.a = static_cast<int8_t>(alpha * 255.0); + expectedColor.r = mTopLayerColor.r * layer->getAlpha(); + expectedColor.g = mTopLayerColor.g * layer->getAlpha(); + expectedColor.b = mTopLayerColor.b * layer->getAlpha(); + expectedColor.a = alpha; } } else if (blendMode == BlendMode::PREMULTIPLIED) { for (auto& expectedColor : expectedColors) { - expectedColor.r = static_cast<int8_t>( - mTopLayerColor.r * static_cast<int8_t>(layer->getAlpha()) + - mBackgroundColor.r * (1.0 - alpha)); - expectedColor.g = static_cast<int8_t>(mTopLayerColor.g * layer->getAlpha() + - mBackgroundColor.g * (1.0 - alpha)); - expectedColor.b = static_cast<int8_t>(mTopLayerColor.b * layer->getAlpha() + - mBackgroundColor.b * (1.0 - alpha)); - expectedColor.a = static_cast<int8_t>(alpha + mBackgroundColor.a * (1.0 - alpha)); + expectedColor.r = + mTopLayerColor.r * layer->getAlpha() + mBackgroundColor.r * (1.0f - alpha); + expectedColor.g = + mTopLayerColor.g * layer->getAlpha() + mBackgroundColor.g * (1.0f - alpha); + expectedColor.b = + mTopLayerColor.b * layer->getAlpha() + mBackgroundColor.b * (1.0f - alpha); + expectedColor.a = alpha + mBackgroundColor.a * (1.0f - alpha); } } else if (blendMode == BlendMode::COVERAGE) { for (auto& expectedColor : expectedColors) { - expectedColor.r = static_cast<int8_t>(mTopLayerColor.r * alpha + - mBackgroundColor.r * (1.0 - alpha)); - expectedColor.g = static_cast<int8_t>(mTopLayerColor.g * alpha + - mBackgroundColor.g * (1.0 - alpha)); - expectedColor.b = static_cast<int8_t>(mTopLayerColor.b * alpha + - mBackgroundColor.b * (1.0 - alpha)); - expectedColor.a = static_cast<int8_t>(mTopLayerColor.a * alpha + - mBackgroundColor.a * (1.0 - alpha)); + expectedColor.r = mTopLayerColor.r * alpha + mBackgroundColor.r * (1.0f - alpha); + expectedColor.g = mTopLayerColor.g * alpha + mBackgroundColor.g * (1.0f - alpha); + expectedColor.b = mTopLayerColor.b * alpha + mBackgroundColor.b * (1.0f - alpha); + expectedColor.a = mTopLayerColor.a * alpha + mBackgroundColor.a * (1.0f - alpha); } } } @@ -1083,7 +1078,7 @@ class GraphicsTransformCompositionTest : public GraphicsCompositionTest { GraphicsCompositionTest::SetUp(); auto backgroundLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay); - backgroundLayer->setColor({0, 0, 0, 0}); + backgroundLayer->setColor({0.0f, 0.0f, 0.0f, 0.0f}); backgroundLayer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight}); backgroundLayer->setZOrder(0); diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp index 4dbe191f0c..1cfd3f95bb 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp @@ -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()); @@ -747,6 +716,61 @@ TEST_P(GraphicsComposerAidlTest, setActiveConfigWithConstraints_BadConfig) { } } +TEST_P(GraphicsComposerAidlTest, setBootDisplayConfig_BadDisplay) { + int32_t config = 0; + auto const error = mComposerClient->setBootDisplayConfig(mInvalidDisplayId, config); + + EXPECT_FALSE(error.isOk()); + EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError()); +} + +TEST_P(GraphicsComposerAidlTest, setBootDisplayConfig_BadConfig) { + for (VtsDisplay& display : mDisplays) { + int32_t invalidConfigId = GetInvalidConfigId(); + const auto error = mComposerClient->setBootDisplayConfig(display.get(), invalidConfigId); + EXPECT_FALSE(error.isOk()); + EXPECT_EQ(IComposerClient::EX_BAD_CONFIG, error.getServiceSpecificError()); + } +} + +TEST_P(GraphicsComposerAidlTest, setBootDisplayConfig) { + std::vector<int32_t> configs; + EXPECT_TRUE(mComposerClient->getDisplayConfigs(mPrimaryDisplay, &configs).isOk()); + for (auto config : configs) { + EXPECT_TRUE(mComposerClient->setBootDisplayConfig(mPrimaryDisplay, config).isOk()); + } +} + +TEST_P(GraphicsComposerAidlTest, clearBootDisplayConfig_BadDisplay) { + auto const error = mComposerClient->clearBootDisplayConfig(mInvalidDisplayId); + + EXPECT_FALSE(error.isOk()); + EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError()); +} + +TEST_P(GraphicsComposerAidlTest, clearBootDisplayConfig) { + EXPECT_TRUE(mComposerClient->clearBootDisplayConfig(mPrimaryDisplay).isOk()); +} + +TEST_P(GraphicsComposerAidlTest, getPreferredBootDisplayConfig_BadDisplay) { + int32_t config; + auto const error = mComposerClient->getPreferredBootDisplayConfig(mInvalidDisplayId, &config); + + EXPECT_FALSE(error.isOk()); + EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError()); +} + +TEST_P(GraphicsComposerAidlTest, getPreferredBootDisplayConfig) { + int32_t preferredDisplayConfig = 0; + auto const error = mComposerClient->getPreferredBootDisplayConfig(mPrimaryDisplay, + &preferredDisplayConfig); + EXPECT_TRUE(error.isOk()); + + std::vector<int32_t> configs; + EXPECT_TRUE(mComposerClient->getDisplayConfigs(mPrimaryDisplay, &configs).isOk()); + EXPECT_NE(configs.end(), std::find(configs.begin(), configs.end(), preferredDisplayConfig)); +} + TEST_P(GraphicsComposerAidlTest, setAutoLowLatencyModeBadDisplay) { EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, mComposerClient->setAutoLowLatencyMode(mInvalidDisplayId, true) @@ -935,6 +959,33 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayName) { EXPECT_TRUE(mComposerClient->getDisplayName(mPrimaryDisplay, &displayName).isOk()); } +TEST_P(GraphicsComposerAidlTest, GetDisplayPhysicalOrientationBadDisplay) { + Transform displayOrientation; + const auto error = + mComposerClient->getDisplayPhysicalOrientation(mInvalidDisplayId, &displayOrientation); + + EXPECT_FALSE(error.isOk()); + ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError()); +} + +TEST_P(GraphicsComposerAidlTest, GetDisplayPhysicalOrientation) { + const auto allowedDisplayOrientations = std::array<Transform, 4>{ + Transform::NONE, + Transform::ROT_90, + Transform::ROT_180, + Transform::ROT_270, + }; + + Transform displayOrientation; + const auto error = + mComposerClient->getDisplayPhysicalOrientation(mPrimaryDisplay, &displayOrientation); + + EXPECT_TRUE(error.isOk()); + EXPECT_NE(std::find(allowedDisplayOrientations.begin(), allowedDisplayOrientations.end(), + displayOrientation), + allowedDisplayOrientations.end()); +} + TEST_P(GraphicsComposerAidlTest, SetClientTargetSlotCount) { EXPECT_TRUE( mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kBufferSlotCount).isOk()); @@ -1457,8 +1508,7 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { presentFence2->waitForever(LOG_TAG); const auto actualPresentTime = presentFence2->getSignalTime(); - const auto presentError = std::abs(expectedPresentTime - actualPresentTime); - EXPECT_LE(presentError, vsyncPeriod / 2); + EXPECT_GE(actualPresentTime, expectedPresentTime - vsyncPeriod / 2); ASSERT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::OFF).isOk()); } @@ -1494,6 +1544,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(); + ASSERT_EQ(1, errors.size()); + EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, errors[0].errorCode); + } + + mWriter.setDisplayBrightness(mPrimaryDisplay, -2.0f); + execute(); + { + const auto errors = mReader.takeErrors(); + ASSERT_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()); @@ -1681,6 +1780,26 @@ TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_SURFACE_DAMAGE) { ASSERT_TRUE(mReader.takeErrors().empty()); } +TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_BLOCKING_REGION) { + int64_t layer; + EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk()); + + Rect empty{0, 0, 0, 0}; + Rect unit{0, 0, 1, 1}; + + mWriter.setLayerBlockingRegion(mPrimaryDisplay, layer, std::vector<Rect>(1, empty)); + execute(); + ASSERT_TRUE(mReader.takeErrors().empty()); + + mWriter.setLayerBlockingRegion(mPrimaryDisplay, layer, std::vector<Rect>(1, unit)); + execute(); + ASSERT_TRUE(mReader.takeErrors().empty()); + + mWriter.setLayerBlockingRegion(mPrimaryDisplay, layer, std::vector<Rect>()); + execute(); + ASSERT_TRUE(mReader.takeErrors().empty()); +} + TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_BLEND_MODE) { int64_t layer; EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk()); @@ -1702,13 +1821,11 @@ TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_COLOR) { int64_t layer; EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk()); - mWriter.setLayerColor(mPrimaryDisplay, layer, - Color{static_cast<int8_t>(0xff), static_cast<int8_t>(0xff), - static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)}); + mWriter.setLayerColor(mPrimaryDisplay, layer, Color{1.0f, 1.0f, 1.0f, 1.0f}); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerColor(mPrimaryDisplay, layer, Color{0, 0, 0, 0}); + mWriter.setLayerColor(mPrimaryDisplay, layer, Color{0.0f, 0.0f, 0.0f, 0.0f}); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp index 5eb912bb3f..ee597a1b1c 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp @@ -22,6 +22,7 @@ #include <aidl/android/hardware/graphics/common/BufferUsage.h> #include "include/RenderEngineVts.h" #include "renderengine/ExternalTexture.h" +#include "renderengine/impl/ExternalTexture.h" // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic pop // ignored "-Wconversion @@ -131,12 +132,12 @@ void ReadbackHelper::fillBuffer(uint32_t width, uint32_t height, uint32_t stride int offset = (row * static_cast<int32_t>(stride) + col) * bytesPerPixel; uint8_t* pixelColor = (uint8_t*)bufferData + offset; - pixelColor[0] = static_cast<uint8_t>(srcColor.r); - pixelColor[1] = static_cast<uint8_t>(srcColor.g); - pixelColor[2] = static_cast<uint8_t>(srcColor.b); + pixelColor[0] = static_cast<uint8_t>(std::round(255.0f * srcColor.r)); + pixelColor[1] = static_cast<uint8_t>(std::round(255.0f * srcColor.g)); + pixelColor[2] = static_cast<uint8_t>(std::round(255.0f * srcColor.b)); if (bytesPerPixel == 4) { - pixelColor[3] = static_cast<uint8_t>(srcColor.a); + pixelColor[3] = static_cast<uint8_t>(std::round(255.0f * srcColor.a)); } } } @@ -184,13 +185,11 @@ void ReadbackHelper::compareColorBuffers(std::vector<Color>& expectedColors, voi auto pixel = row * static_cast<int32_t>(width) + col; int offset = (row * stride + col) * bytesPerPixel; uint8_t* pixelColor = (uint8_t*)bufferData + offset; + const Color expectedColor = expectedColors[static_cast<size_t>(pixel)]; - ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].r), - pixelColor[0]); - ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].g), - pixelColor[1]); - ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].b), - pixelColor[2]); + ASSERT_EQ(std::round(255.0f * expectedColor.r), pixelColor[0]); + ASSERT_EQ(std::round(255.0f * expectedColor.g), pixelColor[1]); + ASSERT_EQ(std::round(255.0f * expectedColor.b), pixelColor[2]); } } } @@ -262,12 +261,8 @@ void TestColorLayer::write(ComposerClientWriter& writer) { LayerSettings TestColorLayer::toRenderEngineLayerSettings() { LayerSettings layerSettings = TestLayer::toRenderEngineLayerSettings(); - layerSettings.source.solidColor = - ::android::half3(static_cast<::android::half>(mColor.r) / 255.0, - static_cast<::android::half>(mColor.g) / 255.0, - static_cast<::android::half>(mColor.b) / 255.0); - layerSettings.alpha = - mAlpha * static_cast<float>((static_cast<::android::half>(mColor.a) / 255.0)); + layerSettings.source.solidColor = ::android::half3(mColor.r, mColor.g, mColor.b); + layerSettings.alpha = mAlpha * mColor.a; return layerSettings; } @@ -306,12 +301,13 @@ void TestBufferLayer::write(ComposerClientWriter& writer) { LayerSettings TestBufferLayer::toRenderEngineLayerSettings() { LayerSettings layerSettings = TestLayer::toRenderEngineLayerSettings(); - layerSettings.source.buffer.buffer = std::make_shared<::android::renderengine::ExternalTexture>( - ::android::sp<::android::GraphicBuffer>::make( - mGraphicBuffer->handle, ::android::GraphicBuffer::CLONE_HANDLE, mWidth, mHeight, - static_cast<int32_t>(mPixelFormat), 1, mUsage, mStride), - mRenderEngine.getInternalRenderEngine(), - ::android::renderengine::ExternalTexture::Usage::READABLE); + layerSettings.source.buffer.buffer = + std::make_shared<::android::renderengine::impl::ExternalTexture>( + ::android::sp<::android::GraphicBuffer>::make( + mGraphicBuffer->handle, ::android::GraphicBuffer::CLONE_HANDLE, mWidth, + mHeight, static_cast<int32_t>(mPixelFormat), 1, mUsage, mStride), + mRenderEngine.getInternalRenderEngine(), + ::android::renderengine::impl::ExternalTexture::Usage::READABLE); layerSettings.source.buffer.usePremultipliedAlpha = mBlendMode == BlendMode::PREMULTIPLIED; diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/RenderEngineVts.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/RenderEngineVts.cpp index 50ce462459..6ff064f93c 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/RenderEngineVts.cpp +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/RenderEngineVts.cpp @@ -15,6 +15,7 @@ */ #include "include/RenderEngineVts.h" +#include "renderengine/impl/ExternalTexture.h" namespace aidl::android::hardware::graphics::composer3::vts { @@ -62,9 +63,9 @@ void TestRenderEngine::drawLayers() { std::back_insert_iterator(compositionLayers), [](::android::renderengine::LayerSettings& settings) -> ::android::renderengine::LayerSettings { return settings; }); - auto texture = std::make_shared<::android::renderengine::ExternalTexture>( + auto texture = std::make_shared<::android::renderengine::impl::ExternalTexture>( mGraphicBuffer, *mRenderEngine, - ::android::renderengine::ExternalTexture::Usage::WRITEABLE); + ::android::renderengine::impl::ExternalTexture::Usage::WRITEABLE); auto [status, readyFence] = mRenderEngine ->drawLayers(mDisplaySettings, compositionLayers, texture, true, std::move(bufferFence)) diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h index 60a036e3fd..0fac2b3bfe 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h @@ -41,13 +41,12 @@ using common::Dataspace; using common::PixelFormat; using IMapper2_1 = ::android::hardware::graphics::mapper::V2_1::IMapper; -static const Color BLACK = {0, 0, 0, static_cast<int8_t>(0xff)}; -static const Color RED = {static_cast<int8_t>(0xff), 0, 0, static_cast<int8_t>(0xff)}; -static const Color TRANSLUCENT_RED = {static_cast<int8_t>(0xff), 0, 0, 0x33}; -static const Color GREEN = {0, static_cast<int8_t>(0xff), 0, static_cast<int8_t>(0xff)}; -static const Color BLUE = {0, 0, static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)}; -static const Color WHITE = {static_cast<int8_t>(0xff), static_cast<int8_t>(0xff), - static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)}; +static const Color BLACK = {0.0f, 0.0f, 0.0f, 1.0f}; +static const Color RED = {1.0f, 0.0f, 0.0f, 1.0f}; +static const Color TRANSLUCENT_RED = {1.0f, 0.0f, 0.0f, 0.3f}; +static const Color GREEN = {0.0f, 1.0f, 0.0f, 1.0f}; +static const Color BLUE = {0.0f, 0.0f, 1.0f, 1.0f}; +static const Color WHITE = {1.0f, 1.0f, 1.0f, 1.0f}; class TestRenderEngine; |