diff --git a/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/Transform.aidl b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/Transform.aidl index 5c3d4cb16f..359c655e00 100644 --- a/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/Transform.aidl +++ b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/Transform.aidl @@ -34,6 +34,7 @@ package android.hardware.graphics.common; @Backing(type="int") @VintfStability enum Transform { + NONE = 0, FLIP_H = 1, FLIP_V = 2, ROT_90 = 4, diff --git a/graphics/common/aidl/android/hardware/graphics/common/Transform.aidl b/graphics/common/aidl/android/hardware/graphics/common/Transform.aidl index 325816c98a..4b3a1b11fe 100644 --- a/graphics/common/aidl/android/hardware/graphics/common/Transform.aidl +++ b/graphics/common/aidl/android/hardware/graphics/common/Transform.aidl @@ -22,6 +22,11 @@ package android.hardware.graphics.common; @VintfStability @Backing(type="int") enum Transform { + /** + * Identity transform (i.e. no rotation or flip). + */ + NONE = 0, + /** * Horizontal flip. FLIP_H/FLIP_V is applied before ROT_90. */ diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl index e9d9745dff..37af84a44d 100644 --- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl +++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl @@ -51,6 +51,7 @@ interface IComposerClient { int getDisplayVsyncPeriod(long display); android.hardware.graphics.composer3.DisplayContentSample getDisplayedContentSample(long display, long maxFrames, long timestamp); android.hardware.graphics.composer3.DisplayContentSamplingAttributes getDisplayedContentSamplingAttributes(long display); + android.hardware.graphics.common.Transform getDisplayPhysicalOrientation(long display); android.hardware.graphics.composer3.HdrCapabilities getHdrCapabilities(long display); int getMaxVirtualDisplayCount(); android.hardware.graphics.composer3.PerFrameMetadataKey[] getPerFrameMetadataKeys(long display); diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl index 3ab6329bff..fd2627e353 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; @@ -353,6 +354,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. 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 c61693e458..6e42e86b73 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 @@ -904,6 +904,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::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());