gralloc: hide AIDL metadata for gralloc0-only build if requested
This is needed for ARC-R container targets using arc-cros-gralloc. Meanwhile, bump -std=c++14 to -std=c++17 for std::optional and others. Bug: b/433317686 Test: chromium CI + android CI Change-Id: Id9ed5f27f6788ca63d0bdb9566c54b3cd4030e16
This commit is contained in:
parent
6f6b9e3c6f
commit
854a9186df
7 changed files with 28 additions and 2 deletions
|
|
@ -17,7 +17,7 @@ LIBDRM_CFLAGS := $(shell $(PKG_CONFIG) --cflags libdrm)
|
|||
LIBDRM_LIBS := $(shell $(PKG_CONFIG) --libs libdrm)
|
||||
|
||||
CPPFLAGS += -Wall -fPIC -Werror -flto $(LIBDRM_CFLAGS) -D_GNU_SOURCE=1
|
||||
CXXFLAGS += -std=c++14
|
||||
CXXFLAGS += -std=c++17 -DHAS_NO_AIDL_METADATA
|
||||
CFLAGS += -std=c99 -D_GNU_SOURCE=1
|
||||
LIBS += -shared -lcutils -lhardware -lsync $(LIBDRM_LIBS)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@
|
|||
|
||||
#include "cros_gralloc_buffer_metadata.h"
|
||||
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
using aidl::android::hardware::graphics::common::BlendMode;
|
||||
using aidl::android::hardware::graphics::common::Cta861_3;
|
||||
using aidl::android::hardware::graphics::common::Dataspace;
|
||||
using aidl::android::hardware::graphics::common::Smpte2086;
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
|
||||
/*static*/
|
||||
std::unique_ptr<cros_gralloc_buffer>
|
||||
|
|
@ -62,8 +64,10 @@ cros_gralloc_buffer::initialize_metadata(const struct cros_gralloc_buffer_descri
|
|||
|
||||
snprintf(metadata->name, CROS_GRALLOC_BUFFER_METADATA_MAX_NAME_SIZE, "%s",
|
||||
descriptor->name.c_str());
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
metadata->dataspace = descriptor->dataspace;
|
||||
metadata->blend_mode = descriptor->blend;
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -174,6 +178,7 @@ int32_t cros_gralloc_buffer::get_name(std::optional<std::string> *name) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
int32_t cros_gralloc_buffer::get_blend_mode(std::optional<BlendMode> *blend_mode) const
|
||||
{
|
||||
const struct cros_gralloc_buffer_metadata *metadata;
|
||||
|
|
@ -285,6 +290,7 @@ int32_t cros_gralloc_buffer::set_smpte2086(std::optional<Smpte2086> smpte)
|
|||
metadata->smpte2086 = smpte;
|
||||
return 0;
|
||||
}
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
|
||||
int32_t cros_gralloc_buffer::increase_refcount()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
#include <aidl/android/hardware/graphics/common/BlendMode.h>
|
||||
#include <aidl/android/hardware/graphics/common/Cta861_3.h>
|
||||
#include <aidl/android/hardware/graphics/common/Dataspace.h>
|
||||
#include <aidl/android/hardware/graphics/common/Smpte2086.h>
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
|
||||
#include "cros_gralloc_helpers.h"
|
||||
|
||||
|
|
@ -44,6 +46,7 @@ class cros_gralloc_buffer
|
|||
|
||||
int32_t get_name(std::optional<std::string> *name) const;
|
||||
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
int32_t get_blend_mode(
|
||||
std::optional<aidl::android::hardware::graphics::common::BlendMode> *blend_mode) const;
|
||||
int32_t set_blend_mode(aidl::android::hardware::graphics::common::BlendMode blend_mode);
|
||||
|
|
@ -61,6 +64,7 @@ class cros_gralloc_buffer
|
|||
std::optional<aidl::android::hardware::graphics::common::Smpte2086> *smpte) const;
|
||||
int32_t
|
||||
set_smpte2086(std::optional<aidl::android::hardware::graphics::common::Smpte2086> smpte);
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
|
||||
/* The new reference count is returned by both these functions. */
|
||||
int32_t increase_refcount();
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
#include <optional>
|
||||
#include <type_traits>
|
||||
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
#include <aidl/android/hardware/graphics/common/BlendMode.h>
|
||||
#include <aidl/android/hardware/graphics/common/Cta861_3.h>
|
||||
#include <aidl/android/hardware/graphics/common/Dataspace.h>
|
||||
#include <aidl/android/hardware/graphics/common/Smpte2086.h>
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
|
||||
#include "cros_gralloc_helpers.h"
|
||||
|
||||
|
|
@ -55,10 +57,12 @@ struct cros_gralloc_buffer_metadata {
|
|||
* handles.
|
||||
*/
|
||||
char name[CROS_GRALLOC_BUFFER_METADATA_MAX_NAME_SIZE];
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
aidl::android::hardware::graphics::common::BlendMode blend_mode;
|
||||
aidl::android::hardware::graphics::common::Dataspace dataspace;
|
||||
cros_buffer_optional<aidl::android::hardware::graphics::common::Cta861_3> cta861_3;
|
||||
cros_buffer_optional<aidl::android::hardware::graphics::common::Smpte2086> smpte2086;
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
};
|
||||
|
||||
static_assert(std::is_standard_layout_v<cros_gralloc_buffer_metadata>);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@
|
|||
#include "../drv.h"
|
||||
#include "cros_gralloc_handle.h"
|
||||
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
#include <aidl/android/hardware/graphics/common/BlendMode.h>
|
||||
#include <aidl/android/hardware/graphics/common/Dataspace.h>
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
#include <log/log.h>
|
||||
#include <system/graphics.h>
|
||||
#include <system/window.h>
|
||||
|
|
@ -44,10 +46,12 @@ struct cros_gralloc_buffer_descriptor {
|
|||
// additional amount of space reserved for client use.
|
||||
uint64_t client_metadata_size = 0;
|
||||
std::string name;
|
||||
#ifndef HAS_NO_AIDL_METADATA
|
||||
aidl::android::hardware::graphics::common::Dataspace dataspace =
|
||||
aidl::android::hardware::graphics::common::Dataspace::UNKNOWN;
|
||||
aidl::android::hardware::graphics::common::BlendMode blend =
|
||||
aidl::android::hardware::graphics::common::BlendMode::INVALID;
|
||||
#endif // HAS_NO_AIDL_METADATA
|
||||
};
|
||||
|
||||
constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ const static IMapper::MetadataType kArmMetadataTypePlaneFds{
|
|||
const static IMapper::MetadataType kArmMetadataTypeFormatDataType{
|
||||
GRALLOC_ARM_METADATA_TYPE_NAME, static_cast<int64_t>(ArmMetadataType::FORMAT_DATA_TYPE)};
|
||||
|
||||
#ifdef HAS_NO_AIDL_METADATA
|
||||
static_assert(false, "Must not define HAS_NO_AIDL_METADATA when gralloc4 is enabled");
|
||||
#endif
|
||||
|
||||
Return<void> CrosGralloc4Mapper::createDescriptor(const BufferDescriptorInfo& description,
|
||||
createDescriptor_cb hidlCb) {
|
||||
hidl_vec<uint8_t> descriptor;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ using ::android::base::unique_fd;
|
|||
REQUIRE_DRIVER() \
|
||||
VALIDATE_BUFFER_HANDLE(bufferHandle)
|
||||
|
||||
#ifdef HAS_NO_AIDL_METADATA
|
||||
static_assert(false, "Must not define HAS_NO_AIDL_METADATA when gralloc5 is enabled");
|
||||
#endif
|
||||
|
||||
static_assert(CROS_GRALLOC_BUFFER_METADATA_MAX_NAME_SIZE >=
|
||||
decltype(std::declval<BufferDescriptorInfo>().name){}.size(),
|
||||
"Metadata name storage too small to fit a BufferDescriptorInfo::name");
|
||||
|
|
@ -760,4 +764,4 @@ extern "C" uint32_t ANDROID_HAL_MAPPER_VERSION = AIMAPPER_VERSION_5;
|
|||
extern "C" AIMapper_Error AIMapper_loadIMapper(AIMapper* _Nullable* _Nonnull outImplementation) {
|
||||
static vendor::mapper::IMapperProvider<CrosGrallocMapperV5> provider;
|
||||
return provider.load(outImplementation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue