ui: Deduplicate rotation types
Introduce ui::Rotation, replacing ISurfaceComposer::Rotation as well as
DISPLAY_ORIENTATION_* and DisplayState::eOrientation* constants.
libinput has widespread use of int32_t for orientation, so move
DISPLAY_ORIENTATION_* to input/DisplayViewport.h for now.
Bug: 144601064
Test: go/wm-smoke
Test: screencap
Change-Id: Ic4b8494e37c9d79c00d5b4be5eb88585f09efebf
diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp
index b1bb7fd..f618873 100644
--- a/services/surfaceflinger/tests/Credentials_test.cpp
+++ b/services/surfaceflinger/tests/Credentials_test.cpp
@@ -23,7 +23,6 @@
namespace {
const String8 DISPLAY_NAME("Credentials Display Test");
const String8 SURFACE_NAME("Test Surface Name");
-const uint32_t ROTATION = 0;
const float FRAME_SCALE = 1.0f;
} // namespace
@@ -262,7 +261,7 @@
sp<GraphicBuffer> outBuffer;
return ScreenshotClient::capture(display, ui::Dataspace::V0_SRGB,
ui::PixelFormat::RGBA_8888, Rect(), 0 /*reqWidth*/,
- 0 /*reqHeight*/, false, ROTATION, &outBuffer);
+ 0 /*reqHeight*/, false, ui::ROTATION_0, &outBuffer);
};
ASSERT_NO_FATAL_FAILURE(checkWithPrivileges<status_t>(condition, NO_ERROR, PERMISSION_DENIED));
}
diff --git a/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp b/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp
index 627de7a..92698f0 100644
--- a/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp
+++ b/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp
@@ -189,12 +189,12 @@
}
TEST_P(LayerRenderTypeTransactionTest, CreateLayer_BufferState) {
- uint32_t transformHint = ui::Transform::orientation_flags::ROT_INVALID;
+ uint32_t transformHint = ui::Transform::ROT_INVALID;
sp<SurfaceControl> layer;
ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32,
ISurfaceComposerClient::eFXSurfaceBufferState,
/*parent*/ nullptr, &transformHint));
- ASSERT_NE(ui::Transform::orientation_flags::ROT_INVALID, transformHint);
+ ASSERT_NE(ui::Transform::ROT_INVALID, transformHint);
}
void LayerRenderTypeTransactionTest::setRelativeZBasicHelper(uint32_t layerType) {
diff --git a/services/surfaceflinger/tests/LayerTransaction_test.cpp b/services/surfaceflinger/tests/LayerTransaction_test.cpp
index 35c51e1..7816c66 100644
--- a/services/surfaceflinger/tests/LayerTransaction_test.cpp
+++ b/services/surfaceflinger/tests/LayerTransaction_test.cpp
@@ -53,7 +53,7 @@
ASSERT_EQ(NO_ERROR,
composer->captureScreen(mDisplay, &outBuffer, outCapturedSecureLayers,
ui::Dataspace::V0_SRGB, ui::PixelFormat::RGBA_8888, Rect(), 0,
- 0, false, ISurfaceComposer::eRotateNone, true));
+ 0, false, ui::ROTATION_0, true));
ASSERT_EQ(true, outCapturedSecureLayers);
ScreenCapture sc(outBuffer);
sc.expectColor(Rect(0, 0, 32, 32), Color::RED);
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
index 76e8171..55c3ab8 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
@@ -2040,8 +2040,8 @@
TEST_F(HandleTransactionLockedTest, processesDisplayTransformChanges) {
using Case = NonHwcVirtualDisplayCase;
- constexpr int oldTransform = 0;
- constexpr int newTransform = 2;
+ constexpr ui::Rotation oldTransform = ui::ROTATION_0;
+ constexpr ui::Rotation newTransform = ui::ROTATION_180;
// --------------------------------------------------------------------
// Preconditions
@@ -2414,7 +2414,7 @@
TEST_F(DisplayTransactionTest, setDisplayStateLockedDoesNothingIfProjectionDidNotChange) {
using Case = SimplePrimaryDisplayCase;
- constexpr int initialOrientation = 180;
+ constexpr ui::Rotation initialOrientation = ui::ROTATION_180;
const Rect initialFrame = {1, 2, 3, 4};
const Rect initialViewport = {5, 6, 7, 8};
@@ -2458,8 +2458,8 @@
TEST_F(DisplayTransactionTest, setDisplayStateLockedRequestsUpdateIfOrientationChanged) {
using Case = SimplePrimaryDisplayCase;
- constexpr int initialOrientation = 90;
- constexpr int desiredOrientation = 180;
+ constexpr ui::Rotation initialOrientation = ui::ROTATION_90;
+ constexpr ui::Rotation desiredOrientation = ui::ROTATION_180;
// --------------------------------------------------------------------
// Preconditions
@@ -2721,7 +2721,7 @@
// The layer stack state should be set to zero
EXPECT_EQ(0u, primaryDisplayState.layerStack);
// The orientation state should be set to zero
- EXPECT_EQ(0, primaryDisplayState.orientation);
+ EXPECT_EQ(ui::ROTATION_0, primaryDisplayState.orientation);
// The frame state should be set to INVALID
EXPECT_EQ(Rect::INVALID_RECT, primaryDisplayState.frame);
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index b5245e2..9728c80 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -371,7 +371,6 @@
*/
auto& mutableHasWideColorDisplay() { return SurfaceFlinger::hasWideColorDisplay; }
- auto& mutablePrimaryDisplayOrientation() { return SurfaceFlinger::primaryDisplayOrientation; }
auto& mutableUseColorManagement() { return SurfaceFlinger::useColorManagement; }
auto& mutableCurrentState() { return mFlinger->mCurrentState; }