mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 15:58:43 +00:00
Merge "Add ExtendableType to allocate" am: 0a9430add2 am: efa98b101f
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2364519 Change-Id: Ibc0e7bffa8badc604b3c4cc4a6ee560016a9206d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -21,6 +21,9 @@ cc_defaults {
|
||||
static_libs: [
|
||||
"android.hardware.graphics.allocator-V2-ndk",
|
||||
],
|
||||
defaults: [
|
||||
"android.hardware.graphics.common-ndk_static",
|
||||
],
|
||||
}
|
||||
|
||||
cc_defaults {
|
||||
@@ -28,6 +31,9 @@ cc_defaults {
|
||||
shared_libs: [
|
||||
"android.hardware.graphics.allocator-V2-ndk",
|
||||
],
|
||||
defaults: [
|
||||
"android.hardware.graphics.common-ndk_shared",
|
||||
],
|
||||
}
|
||||
|
||||
cc_defaults {
|
||||
|
||||
@@ -41,4 +41,5 @@ parcelable BufferDescriptorInfo {
|
||||
android.hardware.graphics.common.PixelFormat format = android.hardware.graphics.common.PixelFormat.UNSPECIFIED;
|
||||
android.hardware.graphics.common.BufferUsage usage = android.hardware.graphics.common.BufferUsage.CPU_READ_NEVER;
|
||||
long reservedSize;
|
||||
android.hardware.graphics.common.ExtendableType[] additionalOptions;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.hardware.graphics.allocator;
|
||||
|
||||
import android.hardware.graphics.common.BufferUsage;
|
||||
import android.hardware.graphics.common.ExtendableType;
|
||||
import android.hardware.graphics.common.PixelFormat;
|
||||
|
||||
@VintfStability
|
||||
@@ -54,6 +55,9 @@ parcelable BufferDescriptorInfo {
|
||||
/**
|
||||
* Buffer usage mask; valid flags can be found in the definition of
|
||||
* BufferUsage.aidl in graphics/common
|
||||
*
|
||||
* The allocator must report isSupported() == false and reject any allocations
|
||||
* with unrecognized buffer usages.
|
||||
*/
|
||||
BufferUsage usage = BufferUsage.CPU_READ_NEVER;
|
||||
|
||||
@@ -62,4 +66,16 @@ parcelable BufferDescriptorInfo {
|
||||
* See getReservedRegion for more information.
|
||||
*/
|
||||
long reservedSize;
|
||||
|
||||
/**
|
||||
* Extensible additional options that can be set.
|
||||
*
|
||||
* This is intended for options that do not change the overall usage, but which do impact
|
||||
* how a buffer is allocated. An example of this is compression level, such as for
|
||||
* the EGL_EXT_surface_compression extension.
|
||||
*
|
||||
* The allocator must report isSupported() == false and reject any allocations
|
||||
* with unrecognized options.
|
||||
*/
|
||||
ExtendableType[] additionalOptions;
|
||||
}
|
||||
|
||||
@@ -217,6 +217,8 @@ class GraphicsTestsBase {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t allocatorVersion() const { return mIAllocatorVersion; }
|
||||
};
|
||||
|
||||
BufferHandle::~BufferHandle() {
|
||||
@@ -309,6 +311,62 @@ TEST_P(GraphicsAllocatorAidlTests, CanAllocate) {
|
||||
EXPECT_GE(buffer->stride(), 64);
|
||||
}
|
||||
|
||||
TEST_P(GraphicsAllocatorAidlTests, RejectsUnknownUsages) {
|
||||
if (allocatorVersion() < 2) {
|
||||
GTEST_SKIP() << "Must be version 2+";
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr auto FirstInvalidV2Usage = static_cast<BufferUsage>(1LL << 33);
|
||||
|
||||
BufferUsage invalidUsage;
|
||||
if (allocatorVersion() == 2) {
|
||||
invalidUsage = FirstInvalidV2Usage;
|
||||
} else {
|
||||
GTEST_FAIL() << "Unknown version " << allocatorVersion();
|
||||
}
|
||||
|
||||
BufferDescriptorInfo info{
|
||||
.name = {"CPU_8888"},
|
||||
.width = 64,
|
||||
.height = 64,
|
||||
.layerCount = 1,
|
||||
.format = PixelFormat::RGBA_8888,
|
||||
.usage = BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN,
|
||||
.reservedSize = 0,
|
||||
};
|
||||
|
||||
// First make sure we can allocate a known usage buffer as expected
|
||||
EXPECT_TRUE(isSupported(info));
|
||||
EXPECT_TRUE(allocate(info));
|
||||
|
||||
// Now add the unknown bit and verify it's rejected
|
||||
info.usage |= invalidUsage;
|
||||
EXPECT_FALSE(isSupported(info)) << "isSupported() returned true for unknown-to-HAL usage";
|
||||
EXPECT_FALSE(allocate(info)) << "allocate succeeded for unknown-to-HAL usage";
|
||||
}
|
||||
|
||||
TEST_P(GraphicsAllocatorAidlTests, RejectsUnknownOptions) {
|
||||
if (allocatorVersion() < 2) {
|
||||
GTEST_SKIP() << "Must be version 2+";
|
||||
return;
|
||||
}
|
||||
|
||||
BufferDescriptorInfo info{
|
||||
.name = {"CPU_8888"},
|
||||
.width = 64,
|
||||
.height = 64,
|
||||
.layerCount = 1,
|
||||
.format = PixelFormat::RGBA_8888,
|
||||
.usage = BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN,
|
||||
.reservedSize = 0,
|
||||
};
|
||||
info.additionalOptions.push_back({"android.hardware.graphics.common.NotARealOption", 1});
|
||||
|
||||
EXPECT_FALSE(isSupported(info)) << "isSupported() returned true for unknown-to-HAL option";
|
||||
EXPECT_FALSE(allocate(info)) << "allocate succeeded for unknown-to-HAL option";
|
||||
}
|
||||
|
||||
TEST_P(GraphicsFrontBufferTests, FrontBufferGpuToCpu) {
|
||||
BufferDescriptorInfo info{
|
||||
.name = {"CPU_8888"},
|
||||
|
||||
Reference in New Issue
Block a user