From a2acfa2219bda99e384b16df365274f9ab4aa471 Mon Sep 17 00:00:00 2001 From: Peiyong Lin Date: Wed, 28 Mar 2018 12:09:42 -0700 Subject: [PATCH] [Graphics] Update CommandWriter APIs to common::V1_1::* enum. Previously we introduced Dataspace V1.1 and PixelFormat V1.1, thus APIs accepting Dataspace should also be updated to accept V1_1::Dataspace and V1_1::PixelFormat. BUG: 77156734 Test: adb shell /data/nativetest/VtsHalGraphicsComposerV2_2TargetTest/VtsHalGraphicsComposerV2_2TargetTest Change-Id: I00d00749f2895b727a18a28903256128a33e8b97 --- current.txt | 2 +- .../2.1/ComposerCommandBuffer.h | 47 ++++++++------ .../include/composer-vts/2.1/ComposerVts.h | 7 +- graphics/composer/2.2/IComposerClient.hal | 64 ++++++++++++++++++- .../2.2/ComposerCommandBuffer.h | 12 +++- .../include/composer-hal/2.2/ComposerClient.h | 19 ++++++ .../include/composer-hal/2.2/ComposerHal.h | 20 +++++- .../include/composer-passthrough/2.2/HwcHal.h | 19 +++++- .../composer/2.2/utils/vts/ComposerVts.cpp | 27 ++++++++ .../include/composer-vts/2.2/ComposerVts.h | 8 ++- .../composer/2.2/vts/functional/Android.bp | 2 + .../VtsHalGraphicsComposerV2_2TargetTest.cpp | 59 +++++++++++++++-- graphics/mapper/2.1/utils/vts/MapperVts.cpp | 7 ++ .../vts/include/mapper-vts/2.1/MapperVts.h | 1 + 14 files changed, 257 insertions(+), 37 deletions(-) diff --git a/current.txt b/current.txt index 655fb13087..f94be833bf 100644 --- a/current.txt +++ b/current.txt @@ -325,7 +325,7 @@ b054af24fbb70d54cde1fb5cba126809e7c4e863e8f9115dc492321dfbcbc993 android.hardwar 83e7a10ff3702147bd7ffa04567b20d407a3b16bbb7705644af44d919afe9103 android.hardware.gnss@1.1::IGnssMeasurementCallback 0b96e0254e2168cfecb30c1ed5fb42681652cc00faa68c6e07568fafe64d1d50 android.hardware.graphics.common@1.1::types d9b40a5b09962a5a0780b10fe33a4e607e69e2e088fc83de88a584115b7cb1c0 android.hardware.graphics.composer@2.2::IComposer -da3979dd97093cdc4ffc2e2427e848f4ba07ddcd181f31f2cb494ad0d2fa58ad android.hardware.graphics.composer@2.2::IComposerClient +c3cd2a3e245ffefae859c9a3d31382a9421be95cfa6bc1231571eb3533049b54 android.hardware.graphics.composer@2.2::IComposerClient dd83be076b6b3f10ed62ab34d8c8b95f2415961fb785200eb842e7bfb2b0ee92 android.hardware.graphics.mapper@2.1::IMapper 675682dd3007805c985eaaec91612abc88f4c25b3431fb84070b7584a1a741fb android.hardware.health@2.0::IHealth 434c4c32c00b0e54bb05e40c79503208b40f786a318029a2a4f66e34f10f2a76 android.hardware.health@2.0::IHealthInfoCallback diff --git a/graphics/composer/2.1/utils/command-buffer/include/composer-command-buffer/2.1/ComposerCommandBuffer.h b/graphics/composer/2.1/utils/command-buffer/include/composer-command-buffer/2.1/ComposerCommandBuffer.h index df529ec615..2742207132 100644 --- a/graphics/composer/2.1/utils/command-buffer/include/composer-command-buffer/2.1/ComposerCommandBuffer.h +++ b/graphics/composer/2.1/utils/command-buffer/include/composer-command-buffer/2.1/ComposerCommandBuffer.h @@ -247,21 +247,8 @@ class CommandWriterBase { void setClientTarget(uint32_t slot, const native_handle_t* target, int acquireFence, Dataspace dataspace, const std::vector& damage) { - bool doWrite = (damage.size() <= (kMaxLength - 4) / 4); - size_t length = 4 + ((doWrite) ? damage.size() * 4 : 0); - - beginCommand(IComposerClient::Command::SET_CLIENT_TARGET, length); - write(slot); - writeHandle(target, true); - writeFence(acquireFence); - writeSigned(static_cast(dataspace)); - // When there are too many rectangles in the damage region and doWrite - // is false, we write no rectangle at all which means the entire - // client target is damaged. - if (doWrite) { - writeRegion(damage); - } - endCommand(); + setClientTargetInternal(slot, target, acquireFence, static_cast(dataspace), + damage); } static constexpr uint16_t kSetOutputBufferLength = 3; @@ -354,9 +341,7 @@ class CommandWriterBase { static constexpr uint16_t kSetLayerDataspaceLength = 1; void setLayerDataspace(Dataspace dataspace) { - beginCommand(IComposerClient::Command::SET_LAYER_DATASPACE, kSetLayerDataspaceLength); - writeSigned(static_cast(dataspace)); - endCommand(); + setLayerDataspaceInternal(static_cast(dataspace)); } static constexpr uint16_t kSetLayerDisplayFrameLength = 4; @@ -418,6 +403,32 @@ class CommandWriterBase { } protected: + void setClientTargetInternal(uint32_t slot, const native_handle_t* target, int acquireFence, + int32_t dataspace, + const std::vector& damage) { + bool doWrite = (damage.size() <= (kMaxLength - 4) / 4); + size_t length = 4 + ((doWrite) ? damage.size() * 4 : 0); + + beginCommand(IComposerClient::Command::SET_CLIENT_TARGET, length); + write(slot); + writeHandle(target, true); + writeFence(acquireFence); + writeSigned(dataspace); + // When there are too many rectangles in the damage region and doWrite + // is false, we write no rectangle at all which means the entire + // client target is damaged. + if (doWrite) { + writeRegion(damage); + } + endCommand(); + } + + void setLayerDataspaceInternal(int32_t dataspace) { + beginCommand(IComposerClient::Command::SET_LAYER_DATASPACE, kSetLayerDataspaceLength); + writeSigned(dataspace); + endCommand(); + } + void beginCommand(IComposerClient::Command command, uint16_t length) { if (mCommandEnd) { LOG_FATAL("endCommand was not called before command 0x%x", command); diff --git a/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/ComposerVts.h b/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/ComposerVts.h index 0d883e4f84..8d5493e8a5 100644 --- a/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/ComposerVts.h +++ b/graphics/composer/2.1/utils/vts/include/composer-vts/2.1/ComposerVts.h @@ -104,9 +104,7 @@ class ComposerClient { void execute(TestCommandReader* reader, CommandWriterBase* writer); - private: - sp mClient; - + protected: // Keep track of all virtual displays and layers. When a test fails with // ASSERT_*, the destructor will clean up the resources for the test. struct DisplayResource { @@ -116,6 +114,9 @@ class ComposerClient { std::unordered_set layers; }; std::unordered_map mDisplayResources; + + private: + sp mClient; }; } // namespace vts diff --git a/graphics/composer/2.2/IComposerClient.hal b/graphics/composer/2.2/IComposerClient.hal index 657bcac8e0..b7ba6a60e4 100644 --- a/graphics/composer/2.2/IComposerClient.hal +++ b/graphics/composer/2.2/IComposerClient.hal @@ -16,13 +16,14 @@ package android.hardware.graphics.composer@2.2; -import android.hardware.graphics.common@1.0::Dataspace; -import android.hardware.graphics.common@1.0::PixelFormat; import android.hardware.graphics.common@1.1::ColorMode; +import android.hardware.graphics.common@1.1::Dataspace; +import android.hardware.graphics.common@1.1::PixelFormat; import android.hardware.graphics.common@1.1::RenderIntent; import @2.1::IComposerClient; import @2.1::Display; import @2.1::Error; +import @2.1::IComposerClient; interface IComposerClient extends @2.1::IComposerClient { @@ -247,6 +248,65 @@ interface IComposerClient extends @2.1::IComposerClient { */ setReadbackBuffer(Display display, handle buffer, handle releaseFence) generates (Error error); + /** + * createVirtualDisplay_2_2 + * Creates a new virtual display with the given width and height. The + * format passed into this function is the default format requested by the + * consumer of the virtual display output buffers. + * + * The display must be assumed to be on from the time the first frame is + * presented until the display is destroyed. + * + * @param width is the width in pixels. + * @param height is the height in pixels. + * @param formatHint is the default output buffer format selected by + * the consumer. + * @param outputBufferSlotCount is the number of output buffer slots to be + * reserved. + * @return error is NONE upon success. Otherwise, + * UNSUPPORTED when the width or height is too large for the + * device to be able to create a virtual display. + * NO_RESOURCES when the device is unable to create a new virtual + * display at this time. + * @return display is the newly-created virtual display. + * @return format is the format of the buffer the device will produce. + */ + @callflow(next="*") + createVirtualDisplay_2_2(uint32_t width, + uint32_t height, + PixelFormat formatHint, + uint32_t outputBufferSlotCount) + generates (Error error, + Display display, + PixelFormat format); + + /** + * getClientTargetSupport_2_2 + * Returns whether a client target with the given properties can be + * handled by the device. + * + * This function must return true for a client target with width and + * height equal to the active display configuration dimensions, + * PixelFormat::RGBA_8888, and Dataspace::UNKNOWN. It is not required to + * return true for any other configuration. + * + * @param display is the display to query. + * @param width is the client target width in pixels. + * @param height is the client target height in pixels. + * @param format is the client target format. + * @param dataspace is the client target dataspace, as described in + * setLayerDataspace. + * @return error is NONE upon success. Otherwise, + * BAD_DISPLAY when an invalid display handle was passed in. + * UNSUPPORTED when the given configuration is not supported. + */ + @callflow(next="*") + getClientTargetSupport_2_2(Display display, + uint32_t width, + uint32_t height, + PixelFormat format, + Dataspace dataspace) + generates (Error error); /** * setPowerMode_2_2 * Sets the power mode of the given display. The transition must be 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 b499ca9754..138d70005e 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 @@ -47,8 +47,8 @@ namespace V2_2 { using android::hardware::MessageQueue; using android::hardware::graphics::common::V1_0::ColorTransform; -using android::hardware::graphics::common::V1_0::Dataspace; using android::hardware::graphics::common::V1_0::Transform; +using android::hardware::graphics::common::V1_1::Dataspace; using android::hardware::graphics::composer::V2_1::Config; using android::hardware::graphics::composer::V2_1::Display; using android::hardware::graphics::composer::V2_1::Error; @@ -64,6 +64,16 @@ class CommandWriterBase : public V2_1::CommandWriterBase { public: CommandWriterBase(uint32_t initialMaxSize) : V2_1::CommandWriterBase(initialMaxSize) {} + void setClientTarget(uint32_t slot, const native_handle_t* target, int acquireFence, + Dataspace dataspace, const std::vector& damage) { + setClientTargetInternal(slot, target, acquireFence, static_cast(dataspace), + damage); + } + + void setLayerDataspace(Dataspace dataspace) { + setLayerDataspaceInternal(static_cast(dataspace)); + } + static constexpr uint16_t kSetLayerFloatColorLength = 4; void setLayerFloatColor(IComposerClient::FloatColor color) { beginCommand_2_2(IComposerClient::Command::SET_LAYER_FLOAT_COLOR, diff --git a/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerClient.h b/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerClient.h index ba6723de52..a6871fb494 100644 --- a/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerClient.h +++ b/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerClient.h @@ -99,6 +99,25 @@ class ComposerClientImpl : public V2_1::hal::detail::ComposerClientImplsetReadbackBuffer(display, readbackBuffer, std::move(fenceFd)); } + Return createVirtualDisplay_2_2( + uint32_t width, uint32_t height, PixelFormat formatHint, uint32_t outputBufferSlotCount, + IComposerClient::createVirtualDisplay_2_2_cb hidl_cb) override { + Display display = 0; + Error err = mHal->createVirtualDisplay_2_2(width, height, &formatHint, &display); + if (err == Error::NONE) { + mResources->addVirtualDisplay(display, outputBufferSlotCount); + } + + hidl_cb(err, display, formatHint); + return Void(); + } + + Return getClientTargetSupport_2_2(Display display, uint32_t width, uint32_t height, + PixelFormat format, Dataspace dataspace) override { + Error err = mHal->getClientTargetSupport_2_2(display, width, height, format, dataspace); + return err; + } + Return setPowerMode_2_2(Display display, IComposerClient::PowerMode mode) override { return mHal->setPowerMode_2_2(display, mode); } diff --git a/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerHal.h b/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerHal.h index 12191bee57..335dc240d9 100644 --- a/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerHal.h +++ b/graphics/composer/2.2/utils/hal/include/composer-hal/2.2/ComposerHal.h @@ -28,9 +28,9 @@ namespace composer { namespace V2_2 { namespace hal { -using common::V1_0::Dataspace; -using common::V1_0::PixelFormat; using common::V1_1::ColorMode; +using common::V1_1::Dataspace; +using common::V1_1::PixelFormat; using common::V1_1::RenderIntent; using V2_1::Display; using V2_1::Error; @@ -38,6 +38,17 @@ using V2_1::Layer; class ComposerHal : public V2_1::hal::ComposerHal { public: + Error createVirtualDisplay(uint32_t width, uint32_t height, common::V1_0::PixelFormat* format, + Display* outDisplay) override { + return createVirtualDisplay_2_2(width, height, reinterpret_cast(format), + outDisplay); + } + Error getClientTargetSupport(Display display, uint32_t width, uint32_t height, + common::V1_0::PixelFormat format, + common::V1_0::Dataspace dataspace) override { + return getClientTargetSupport_2_2(display, width, height, static_cast(format), + static_cast(dataspace)); + } // superceded by setPowerMode_2_2 Error setPowerMode(Display display, V2_1::IComposerClient::PowerMode mode) override { return setPowerMode_2_2(display, static_cast(mode)); @@ -64,7 +75,10 @@ class ComposerHal : public V2_1::hal::ComposerHal { virtual Error setReadbackBuffer(Display display, const native_handle_t* bufferHandle, base::unique_fd fenceFd) = 0; virtual Error getReadbackBufferFence(Display display, base::unique_fd* outFenceFd) = 0; - + virtual Error createVirtualDisplay_2_2(uint32_t width, uint32_t height, PixelFormat* format, + Display* outDisplay) = 0; + virtual Error getClientTargetSupport_2_2(Display display, uint32_t width, uint32_t height, + PixelFormat format, Dataspace dataspace) = 0; virtual Error setPowerMode_2_2(Display display, IComposerClient::PowerMode mode) = 0; virtual Error setLayerFloatColor(Display display, Layer layer, diff --git a/graphics/composer/2.2/utils/passthrough/include/composer-passthrough/2.2/HwcHal.h b/graphics/composer/2.2/utils/passthrough/include/composer-passthrough/2.2/HwcHal.h index 7e38a7973e..93da0a5d94 100644 --- a/graphics/composer/2.2/utils/passthrough/include/composer-passthrough/2.2/HwcHal.h +++ b/graphics/composer/2.2/utils/passthrough/include/composer-passthrough/2.2/HwcHal.h @@ -34,9 +34,9 @@ namespace passthrough { namespace detail { -using common::V1_0::Dataspace; -using common::V1_0::PixelFormat; using common::V1_1::ColorMode; +using common::V1_1::Dataspace; +using common::V1_1::PixelFormat; using common::V1_1::RenderIntent; using V2_1::Display; using V2_1::Error; @@ -134,6 +134,19 @@ class HwcHalImpl : public V2_1::passthrough::detail::HwcHalImpl { return static_cast(error); } + Error createVirtualDisplay_2_2(uint32_t width, uint32_t height, PixelFormat* format, + Display* outDisplay) override { + return createVirtualDisplay( + width, height, reinterpret_cast(format), outDisplay); + } + + Error getClientTargetSupport_2_2(Display display, uint32_t width, uint32_t height, + PixelFormat format, Dataspace dataspace) override { + return getClientTargetSupport(display, width, height, + static_cast(format), + static_cast(dataspace)); + } + Error setPowerMode_2_2(Display display, IComposerClient::PowerMode mode) override { if (mode == IComposerClient::PowerMode::ON_SUSPEND) { return Error::UNSUPPORTED; @@ -271,6 +284,8 @@ class HwcHalImpl : public V2_1::passthrough::detail::HwcHalImpl { using BaseType2_1::getColorModes; using BaseType2_1::mDevice; using BaseType2_1::setColorMode; + using BaseType2_1::createVirtualDisplay; + using BaseType2_1::getClientTargetSupport; using BaseType2_1::setPowerMode; }; diff --git a/graphics/composer/2.2/utils/vts/ComposerVts.cpp b/graphics/composer/2.2/utils/vts/ComposerVts.cpp index 9a035f6539..357c7725af 100644 --- a/graphics/composer/2.2/utils/vts/ComposerVts.cpp +++ b/graphics/composer/2.2/utils/vts/ComposerVts.cpp @@ -87,6 +87,33 @@ void ComposerClient_v2_2::execute_v2_2(V2_1::vts::TestCommandReader* reader, }); } +Display ComposerClient_v2_2::createVirtualDisplay_2_2(uint32_t width, uint32_t height, + PixelFormat formatHint, + uint32_t outputBufferSlotCount, + PixelFormat* outFormat) { + Display display = 0; + mClient_v2_2->createVirtualDisplay_2_2( + width, height, formatHint, outputBufferSlotCount, + [&](const auto& tmpError, const auto& tmpDisplay, const auto& tmpFormat) { + ASSERT_EQ(Error::NONE, tmpError) << "failed to create virtual display"; + display = tmpDisplay; + *outFormat = tmpFormat; + + ASSERT_TRUE(mDisplayResources.insert({display, DisplayResource(true)}).second) + << "duplicated virtual display id " << display; + }); + + return display; +} + +bool ComposerClient_v2_2::getClientTargetSupport_2_2(Display display, uint32_t width, + uint32_t height, PixelFormat format, + Dataspace dataspace) { + Error error = + mClient_v2_2->getClientTargetSupport_2_2(display, width, height, format, dataspace); + return error == Error::NONE; +} + void ComposerClient_v2_2::setPowerMode_2_2(Display display, V2_2::IComposerClient::PowerMode mode) { Error error = mClient_v2_2->setPowerMode_2_2(display, mode); ASSERT_TRUE(error == Error::NONE || error == Error::UNSUPPORTED) << "failed to set power mode"; diff --git a/graphics/composer/2.2/utils/vts/include/composer-vts/2.2/ComposerVts.h b/graphics/composer/2.2/utils/vts/include/composer-vts/2.2/ComposerVts.h index 5467011e45..62ab83f3f2 100644 --- a/graphics/composer/2.2/utils/vts/include/composer-vts/2.2/ComposerVts.h +++ b/graphics/composer/2.2/utils/vts/include/composer-vts/2.2/ComposerVts.h @@ -36,10 +36,10 @@ namespace composer { namespace V2_2 { namespace vts { -using android::hardware::graphics::common::V1_0::Dataspace; using android::hardware::graphics::common::V1_0::Hdr; -using android::hardware::graphics::common::V1_0::PixelFormat; using android::hardware::graphics::common::V1_1::ColorMode; +using android::hardware::graphics::common::V1_1::Dataspace; +using android::hardware::graphics::common::V1_1::PixelFormat; using android::hardware::graphics::common::V1_1::RenderIntent; using android::hardware::graphics::composer::V2_2::IComposer; using android::hardware::graphics::composer::V2_2::IComposerClient; @@ -67,6 +67,10 @@ class ComposerClient_v2_2 std::vector getPerFrameMetadataKeys(Display display); + Display createVirtualDisplay_2_2(uint32_t width, uint32_t height, PixelFormat formatHint, + uint32_t outputBufferSlotCount, PixelFormat* outFormat); + bool getClientTargetSupport_2_2(Display display, uint32_t width, uint32_t height, + PixelFormat format, Dataspace dataspace); void setPowerMode_2_2(Display display, V2_2::IComposerClient::PowerMode mode); void setReadbackBuffer(Display display, const native_handle_t* buffer, int32_t releaseFence); void getReadbackBufferAttributes(Display display, PixelFormat* outPixelFormat, diff --git a/graphics/composer/2.2/vts/functional/Android.bp b/graphics/composer/2.2/vts/functional/Android.bp index 774790098e..669fbaea35 100644 --- a/graphics/composer/2.2/vts/functional/Android.bp +++ b/graphics/composer/2.2/vts/functional/Android.bp @@ -27,6 +27,7 @@ cc_test { ], static_libs: [ "android.hardware.graphics.allocator@2.0", + "android.hardware.graphics.common@1.1", "android.hardware.graphics.composer@2.1", "android.hardware.graphics.composer@2.1-vts", "android.hardware.graphics.composer@2.2", @@ -34,6 +35,7 @@ cc_test { "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@2.0-vts", "android.hardware.graphics.mapper@2.1", + "android.hardware.graphics.mapper@2.1-vts", ], header_libs: [ "android.hardware.graphics.composer@2.1-command-buffer", diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp index 3103d10fc2..4e41333e58 100644 --- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp +++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace android { namespace hardware { @@ -34,14 +34,14 @@ namespace { using android::hardware::graphics::common::V1_0::BufferUsage; using android::hardware::graphics::common::V1_0::ColorTransform; -using android::hardware::graphics::common::V1_0::Dataspace; -using android::hardware::graphics::common::V1_0::PixelFormat; using android::hardware::graphics::common::V1_0::Transform; using android::hardware::graphics::common::V1_1::ColorMode; +using android::hardware::graphics::common::V1_1::Dataspace; +using android::hardware::graphics::common::V1_1::PixelFormat; using android::hardware::graphics::common::V1_1::RenderIntent; using android::hardware::graphics::composer::V2_2::IComposerClient; -using android::hardware::graphics::mapper::V2_0::IMapper; -using android::hardware::graphics::mapper::V2_0::vts::Gralloc; +using android::hardware::graphics::mapper::V2_1::IMapper; +using android::hardware::graphics::mapper::V2_1::vts::Gralloc; using GrallocError = android::hardware::graphics::mapper::V2_0::Error; // Test environment for graphics.composer @@ -193,6 +193,55 @@ TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_PER_FRAME_METADATA) { TEST_F(GraphicsComposerHidlTest, GetPerFrameMetadataKeys) { mComposerClient->getPerFrameMetadataKeys(mPrimaryDisplay); } + +/** + * Test IComposerClient::createVirtualDisplay_2_2 and + * IComposerClient::destroyVirtualDisplay. + * + * Test that virtual displays can be created and has the correct display type. + */ +TEST_F(GraphicsComposerHidlTest, CreateVirtualDisplay_2_2) { + if (mComposerClient->getMaxVirtualDisplayCount() == 0) { + GTEST_SUCCEED() << "no virtual display support"; + return; + } + + Display display; + PixelFormat format; + ASSERT_NO_FATAL_FAILURE( + display = mComposerClient->createVirtualDisplay_2_2( + 64, 64, PixelFormat::IMPLEMENTATION_DEFINED, kBufferSlotCount, &format)); + + // test display type + IComposerClient::DisplayType type = mComposerClient->getDisplayType(display); + EXPECT_EQ(IComposerClient::DisplayType::VIRTUAL, type); + + mComposerClient->destroyVirtualDisplay(display); +} + +/** + * Test IComposerClient::getClientTargetSupport_2_2. + * + * Test that IComposerClient::getClientTargetSupport returns true for the + * required client targets. + */ +TEST_F(GraphicsComposerHidlTest, GetClientTargetSupport_2_2) { + std::vector configs = mComposerClient->getDisplayConfigs(mPrimaryDisplay); + for (auto config : configs) { + int32_t width = mComposerClient->getDisplayAttribute(mPrimaryDisplay, config, + IComposerClient::Attribute::WIDTH); + int32_t height = mComposerClient->getDisplayAttribute(mPrimaryDisplay, config, + IComposerClient::Attribute::HEIGHT); + ASSERT_LT(0, width); + ASSERT_LT(0, height); + + mComposerClient->setActiveConfig(mPrimaryDisplay, config); + + ASSERT_TRUE(mComposerClient->getClientTargetSupport_2_2( + mPrimaryDisplay, width, height, PixelFormat::RGBA_8888, Dataspace::UNKNOWN)); + } +} + /** * Test IComposerClient::setPowerMode_2_2. */ diff --git a/graphics/mapper/2.1/utils/vts/MapperVts.cpp b/graphics/mapper/2.1/utils/vts/MapperVts.cpp index 0aaa926018..078068e306 100644 --- a/graphics/mapper/2.1/utils/vts/MapperVts.cpp +++ b/graphics/mapper/2.1/utils/vts/MapperVts.cpp @@ -43,6 +43,13 @@ static_assert(sizeof(OldBufferDescriptorInfo) == sizeof(IMapper::BufferDescripto offsetof(IMapper::BufferDescriptorInfo, usage), ""); +Gralloc::Gralloc() : V2_0::vts::Gralloc() { + if (::testing::Test::HasFatalFailure()) { + return; + } + init(); +} + Gralloc::Gralloc(const std::string& allocatorServiceName, const std::string& mapperServiceName) : V2_0::vts::Gralloc(allocatorServiceName, mapperServiceName) { if (::testing::Test::HasFatalFailure()) { diff --git a/graphics/mapper/2.1/utils/vts/include/mapper-vts/2.1/MapperVts.h b/graphics/mapper/2.1/utils/vts/include/mapper-vts/2.1/MapperVts.h index b7fa751936..423d4b3c0d 100644 --- a/graphics/mapper/2.1/utils/vts/include/mapper-vts/2.1/MapperVts.h +++ b/graphics/mapper/2.1/utils/vts/include/mapper-vts/2.1/MapperVts.h @@ -32,6 +32,7 @@ using V2_0::BufferDescriptor; // A wrapper to IAllocator and IMapper. class Gralloc : public V2_0::vts::Gralloc { public: + Gralloc(); Gralloc(const std::string& allocatorServiceName, const std::string& mapperServiceName); sp getMapper() const;