[HWC] Add setLayerFloatColor API into HAL.
This patch:
1. Adds setLayerFloatColor API into HAL to enable setting more bits of color on
ColorLayer;
2. Adds VTS tests for setLayerFloatColor.
BUG: 69970838
Test: adb shell /data/nativetest/VtsHalGraphicsComposerV2_2TargetTest/VtsHalGraphicsComposerV2_2TargetTest
Change-Id: I439e35cb2505ee47b8e9a8dd1c19a3f3f2cf9c2f
diff --git a/graphics/composer/2.2/IComposerClient.hal b/graphics/composer/2.2/IComposerClient.hal
index 4a884bc..dcd9c8d 100644
--- a/graphics/composer/2.2/IComposerClient.hal
+++ b/graphics/composer/2.2/IComposerClient.hal
@@ -81,18 +81,38 @@
float value;
};
- /**
- * setPerFrameMetadata(Display display, vec<PerFrameMetadata> data)
- * Sets the PerFrameMetadata for the display. This metadata must be used
- * by the implementation to better tone map content to that display.
- *
- * This is a method that may be called every frame. Thus it's
- * implemented using buffered transport.
- * SET_PER_FRAME_METADATA is the command used by the buffered transport
- * mechanism.
- */
+ struct FloatColor {
+ float r;
+ float g;
+ float b;
+ float a;
+ };
+
enum Command : @2.1::IComposerClient.Command {
+ /**
+ * setPerFrameMetadata(Display display, vec<PerFrameMetadata> data)
+ * Sets the PerFrameMetadata for the display. This metadata must be used
+ * by the implementation to better tone map content to that display.
+ *
+ * This is a method that may be called every frame. Thus it's
+ * implemented using buffered transport.
+ * SET_PER_FRAME_METADATA is the command used by the buffered transport
+ * mechanism.
+ */
SET_PER_FRAME_METADATA = 0x207 << @2.1::IComposerClient.Command:OPCODE_SHIFT,
+
+ /**
+ * SET_LAYER_COLOR has this pseudo prototype
+ *
+ * setLayerColor(FloatColor 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.
+ *
+ * @param color is the new color using float type.
+ */
+ SET_LAYER_FLOAT_COLOR = 0x40c << @2.1::IComposerClient.Command:OPCODE_SHIFT,
};
/**
diff --git a/graphics/composer/2.2/utils/command-buffer/include/composer-command-buffer/2.2/ComposerCommandBuffer.h b/graphics/composer/2.2/utils/command-buffer/include/composer-command-buffer/2.2/ComposerCommandBuffer.h
index f953b96..c803d3c 100644
--- a/graphics/composer/2.2/utils/command-buffer/include/composer-command-buffer/2.2/ComposerCommandBuffer.h
+++ b/graphics/composer/2.2/utils/command-buffer/include/composer-command-buffer/2.2/ComposerCommandBuffer.h
@@ -64,8 +64,16 @@
public:
CommandWriterBase(uint32_t initialMaxSize) : V2_1::CommandWriterBase(initialMaxSize) {}
+ static constexpr uint16_t kSetLayerFloatColorLength = 4;
+ void setLayerFloatColor(IComposerClient::FloatColor color) {
+ beginCommand_2_2(IComposerClient::Command::SET_LAYER_FLOAT_COLOR,
+ kSetLayerFloatColorLength);
+ writeFloatColor(color);
+ endCommand();
+ }
+
void setPerFrameMetadata(const hidl_vec<IComposerClient::PerFrameMetadata>& metadataVec) {
- beginCommand2_2(IComposerClient::Command::SET_PER_FRAME_METADATA, metadataVec.size() * 2);
+ beginCommand_2_2(IComposerClient::Command::SET_PER_FRAME_METADATA, metadataVec.size() * 2);
for (const auto& metadata : metadataVec) {
writeSigned(static_cast<int32_t>(metadata.key));
writeFloat(metadata.value);
@@ -74,10 +82,17 @@
}
protected:
- void beginCommand2_2(IComposerClient::Command command, uint16_t length) {
+ void beginCommand_2_2(IComposerClient::Command command, uint16_t length) {
V2_1::CommandWriterBase::beginCommand(
static_cast<V2_1::IComposerClient::Command>(static_cast<int32_t>(command)), length);
}
+
+ void writeFloatColor(const IComposerClient::FloatColor& color) {
+ writeFloat(color.r);
+ writeFloat(color.g);
+ writeFloat(color.b);
+ writeFloat(color.a);
+ }
};
// This class helps parse a command queue. Note that all sizes/lengths are in
@@ -85,6 +100,15 @@
class CommandReaderBase : public V2_1::CommandReaderBase {
public:
CommandReaderBase() : V2_1::CommandReaderBase(){};
+
+ protected:
+ IComposerClient::FloatColor readFloatColor() {
+ float r = readFloat();
+ float g = readFloat();
+ float b = readFloat();
+ float a = readFloat();
+ return IComposerClient::FloatColor{r, g, b, a};
+ }
};
} // namespace V2_2
diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
index d7826bf..8b44d61 100644
--- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
+++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp
@@ -224,6 +224,20 @@
mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &pixelFormat, &dataspace);
}
+/**
+ * Test IComposerClient::Command::SET_LAYER_FLOAT_COLOR.
+ */
+TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_FLOAT_COLOR) {
+ V2_1::Layer layer;
+ ASSERT_NO_FATAL_FAILURE(layer =
+ mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount));
+
+ mWriter->selectDisplay(mPrimaryDisplay);
+ mWriter->selectLayer(layer);
+ mWriter->setLayerFloatColor(IComposerClient::FloatColor{1.0, 1.0, 1.0, 1.0});
+ mWriter->setLayerFloatColor(IComposerClient::FloatColor{0.0, 0.0, 0.0, 0.0});
+}
+
} // namespace
} // namespace tests
} // namespace V2_2