test-hwc2: set layer transform
Test: Add "#define HAVE_NO_SURFACE_FLINGER" to
frameworks/native/libs/gui/BufferQueueCore.cpp.
Recompile and flash.
Run "mm" in frameworks/native/services/surfaceflinger/tests/hwc2.
Push test-hwc2 to device.
Run "adb root && adb shell stop".
Run test case. Ex: "./test-hwc2"
Change-Id: I55e318cbddf957d1728435488c6283f8ce77a3d6
diff --git a/services/surfaceflinger/tests/hwc2/Hwc2Test.cpp b/services/surfaceflinger/tests/hwc2/Hwc2Test.cpp
index 4078411..dbce9d5 100644
--- a/services/surfaceflinger/tests/hwc2/Hwc2Test.cpp
+++ b/services/surfaceflinger/tests/hwc2/Hwc2Test.cpp
@@ -407,6 +407,23 @@
}
}
+ void setLayerTransform(hwc2_display_t display, hwc2_layer_t layer,
+ hwc_transform_t transform, hwc2_error_t* outErr = nullptr)
+ {
+ auto pfn = reinterpret_cast<HWC2_PFN_SET_LAYER_TRANSFORM>(
+ getFunction(HWC2_FUNCTION_SET_LAYER_TRANSFORM));
+ ASSERT_TRUE(pfn) << "failed to get function";
+
+ auto err = static_cast<hwc2_error_t>(pfn(mHwc2Device, display, layer,
+ transform));
+ if (outErr) {
+ *outErr = err;
+ } else {
+ ASSERT_EQ(err, HWC2_ERROR_NONE) << "failed to set layer transform "
+ << getTransformName(transform);
+ }
+ }
+
protected:
hwc2_function_pointer_t getFunction(hwc2_function_descriptor_t descriptor)
{
@@ -777,6 +794,13 @@
testLayer.getPlaneAlpha(), outErr));
}
+void setTransform(Hwc2Test* test, hwc2_display_t display, hwc2_layer_t layer,
+ const Hwc2TestLayer& testLayer, hwc2_error_t* outErr)
+{
+ EXPECT_NO_FATAL_FAILURE(test->setLayerTransform(display, layer,
+ testLayer.getTransform(), outErr));
+}
+
bool advanceBlendMode(Hwc2TestLayer* testLayer)
{
return testLayer->advanceBlendMode();
@@ -797,6 +821,11 @@
return testLayer->advancePlaneAlpha();
}
+bool advanceTransform(Hwc2TestLayer* testLayer)
+{
+ return testLayer->advanceTransform();
+}
+
static const std::array<hwc2_function_descriptor_t, 42> requiredFunctions = {{
HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
@@ -1726,3 +1755,24 @@
}
));
}
+
+/* TESTCASE: Tests that the HWC2 can set the transform value of a layer. */
+TEST_F(Hwc2Test, SET_LAYER_TRANSFORM)
+{
+ ASSERT_NO_FATAL_FAILURE(setLayerProperty(Hwc2TestCoverage::Complete,
+ setTransform, advanceTransform));
+}
+
+/* TESTCASE: Tests that the HWC2 can update the transform value of a layer. */
+TEST_F(Hwc2Test, SET_LAYER_TRANSFORM_update)
+{
+ ASSERT_NO_FATAL_FAILURE(setLayerPropertyUpdate(Hwc2TestCoverage::Complete,
+ setTransform, advanceTransform));
+}
+
+/* TESTCASE: Tests that the HWC2 cannot set the transform for a bad layer. */
+TEST_F(Hwc2Test, SET_LAYER_TRANSFORM_bad_layer)
+{
+ ASSERT_NO_FATAL_FAILURE(setLayerPropertyBadLayer(Hwc2TestCoverage::Default,
+ setTransform));
+}
diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestLayer.cpp b/services/surfaceflinger/tests/hwc2/Hwc2TestLayer.cpp
index 647f0ff..5445a77 100644
--- a/services/surfaceflinger/tests/hwc2/Hwc2TestLayer.cpp
+++ b/services/surfaceflinger/tests/hwc2/Hwc2TestLayer.cpp
@@ -22,7 +22,8 @@
: mBlendMode(coverage),
mComposition(coverage),
mDataspace(coverage),
- mPlaneAlpha(coverage) { }
+ mPlaneAlpha(coverage),
+ mTransform(coverage) { }
std::string Hwc2TestLayer::dump() const
{
@@ -64,6 +65,11 @@
return mPlaneAlpha.get();
}
+hwc_transform_t Hwc2TestLayer::getTransform() const
+{
+ return mTransform.get();
+}
+
bool Hwc2TestLayer::advanceBlendMode()
{
return mBlendMode.advance();
@@ -83,3 +89,8 @@
{
return mPlaneAlpha.advance();
}
+
+bool Hwc2TestLayer::advanceTransform()
+{
+ return mTransform.advance();
+}
diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestLayer.h b/services/surfaceflinger/tests/hwc2/Hwc2TestLayer.h
index 5ba2cfc..d259ad9 100644
--- a/services/surfaceflinger/tests/hwc2/Hwc2TestLayer.h
+++ b/services/surfaceflinger/tests/hwc2/Hwc2TestLayer.h
@@ -37,21 +37,24 @@
hwc2_composition_t getComposition() const;
android_dataspace_t getDataspace() const;
float getPlaneAlpha() const;
+ hwc_transform_t getTransform() const;
bool advanceBlendMode();
bool advanceComposition();
bool advanceDataspace();
bool advancePlaneAlpha();
+ bool advanceTransform();
private:
- std::array<Hwc2TestContainer*, 4> mProperties = {{
- &mBlendMode, &mComposition, &mDataspace, &mPlaneAlpha
+ std::array<Hwc2TestContainer*, 5> mProperties = {{
+ &mBlendMode, &mComposition, &mDataspace, &mPlaneAlpha, &mTransform
}};
Hwc2TestBlendMode mBlendMode;
Hwc2TestComposition mComposition;
Hwc2TestDataspace mDataspace;
Hwc2TestPlaneAlpha mPlaneAlpha;
+ Hwc2TestTransform mTransform;
};
#endif /* ifndef _HWC2_TEST_LAYER_H */
diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.cpp b/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.cpp
index 8477949..eb49d32 100644
--- a/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.cpp
+++ b/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.cpp
@@ -162,3 +162,37 @@
const std::vector<float> Hwc2TestPlaneAlpha::mCompletePlaneAlphas = {
1.0f, 0.75f, 0.5f, 0.25f, 0.0f,
};
+
+
+Hwc2TestTransform::Hwc2TestTransform(Hwc2TestCoverage coverage)
+ : Hwc2TestProperty(coverage, mCompleteTransforms, mBasicTransforms,
+ mDefaultTransforms) { }
+
+std::string Hwc2TestTransform::dump() const
+{
+ std::stringstream dmp;
+ dmp << "\ttransform: " << getTransformName(get()) << "\n";
+ return dmp.str();
+}
+
+const std::vector<hwc_transform_t> Hwc2TestTransform::mDefaultTransforms = {
+ static_cast<hwc_transform_t>(0),
+};
+
+const std::vector<hwc_transform_t> Hwc2TestTransform::mBasicTransforms = {
+ static_cast<hwc_transform_t>(0),
+ HWC_TRANSFORM_FLIP_H,
+ HWC_TRANSFORM_FLIP_V,
+ HWC_TRANSFORM_ROT_90,
+};
+
+const std::vector<hwc_transform_t> Hwc2TestTransform::mCompleteTransforms = {
+ static_cast<hwc_transform_t>(0),
+ HWC_TRANSFORM_FLIP_H,
+ HWC_TRANSFORM_FLIP_V,
+ HWC_TRANSFORM_ROT_90,
+ HWC_TRANSFORM_ROT_180,
+ HWC_TRANSFORM_ROT_270,
+ HWC_TRANSFORM_FLIP_H_ROT_90,
+ HWC_TRANSFORM_FLIP_V_ROT_90,
+};
diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.h b/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.h
index f54c8c8..a96b629 100644
--- a/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.h
+++ b/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.h
@@ -137,4 +137,17 @@
static const std::vector<float> mCompletePlaneAlphas;
};
+
+class Hwc2TestTransform : public Hwc2TestProperty<hwc_transform_t> {
+public:
+ Hwc2TestTransform(Hwc2TestCoverage coverage);
+
+ std::string dump() const override;
+
+protected:
+ static const std::vector<hwc_transform_t> mDefaultTransforms;
+ static const std::vector<hwc_transform_t> mBasicTransforms;
+ static const std::vector<hwc_transform_t> mCompleteTransforms;
+};
+
#endif /* ifndef _HWC2_TEST_PROPERTIES_H */