diff options
Diffstat (limited to 'gralloc4/src/hidl_common/SharedMetadata.cpp')
-rw-r--r-- | gralloc4/src/hidl_common/SharedMetadata.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/gralloc4/src/hidl_common/SharedMetadata.cpp b/gralloc4/src/hidl_common/SharedMetadata.cpp index b5964f7..6960b08 100644 --- a/gralloc4/src/hidl_common/SharedMetadata.cpp +++ b/gralloc4/src/hidl_common/SharedMetadata.cpp @@ -17,7 +17,9 @@ */ #include "SharedMetadata.h" +#include "core/mali_gralloc_reference.h" #include "mali_gralloc_log.h" +#include "mali_gralloc_usages.h" //#include <VendorVideoAPI.h> namespace arm @@ -39,19 +41,19 @@ size_t shared_metadata_size() void get_name(const private_handle_t *hnd, std::string *name) { - auto *metadata = reinterpret_cast<const shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); *name = metadata->get_name(); } void get_crop_rect(const private_handle_t *hnd, std::optional<Rect> *crop) { - auto *metadata = reinterpret_cast<const shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); *crop = metadata->crop.to_std_optional(); } android::status_t set_crop_rect(const private_handle_t *hnd, const Rect &crop) { - auto *metadata = reinterpret_cast<shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); if (crop.top < 0 || crop.left < 0 || crop.left > crop.right || crop.right > hnd->plane_info[0].alloc_width || @@ -69,31 +71,31 @@ android::status_t set_crop_rect(const private_handle_t *hnd, const Rect &crop) void get_dataspace(const private_handle_t *hnd, std::optional<Dataspace> *dataspace) { - auto *metadata = reinterpret_cast<const shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); *dataspace = metadata->dataspace.to_std_optional(); } void set_dataspace(const private_handle_t *hnd, const Dataspace &dataspace) { - auto *metadata = reinterpret_cast<shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); metadata->dataspace = aligned_optional(dataspace); } void get_blend_mode(const private_handle_t *hnd, std::optional<BlendMode> *blend_mode) { - auto *metadata = reinterpret_cast<const shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); *blend_mode = metadata->blend_mode.to_std_optional(); } void set_blend_mode(const private_handle_t *hnd, const BlendMode &blend_mode) { - auto *metadata = reinterpret_cast<shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); metadata->blend_mode = aligned_optional(blend_mode); } void get_smpte2086(const private_handle_t *hnd, std::optional<Smpte2086> *smpte2086) { - auto *metadata = reinterpret_cast<const shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); *smpte2086 = metadata->smpte2086.to_std_optional(); } @@ -104,7 +106,7 @@ android::status_t set_smpte2086(const private_handle_t *hnd, const std::optional return android::BAD_VALUE; } - auto *metadata = reinterpret_cast<shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); metadata->smpte2086 = aligned_optional(smpte2086); return android::OK; @@ -112,7 +114,7 @@ android::status_t set_smpte2086(const private_handle_t *hnd, const std::optional void get_cta861_3(const private_handle_t *hnd, std::optional<Cta861_3> *cta861_3) { - auto *metadata = reinterpret_cast<const shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); *cta861_3 = metadata->cta861_3.to_std_optional(); } @@ -123,7 +125,7 @@ android::status_t set_cta861_3(const private_handle_t *hnd, const std::optional< return android::BAD_VALUE; } - auto *metadata = reinterpret_cast<shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); metadata->cta861_3 = aligned_optional(cta861_3); return android::OK; @@ -131,7 +133,7 @@ android::status_t set_cta861_3(const private_handle_t *hnd, const std::optional< void get_smpte2094_40(const private_handle_t *hnd, std::optional<std::vector<uint8_t>> *smpte2094_40) { - auto *metadata = reinterpret_cast<const shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); if (metadata->smpte2094_40.size > 0) { const uint8_t *begin = metadata->smpte2094_40.data(); @@ -146,7 +148,7 @@ void get_smpte2094_40(const private_handle_t *hnd, std::optional<std::vector<uin android::status_t set_smpte2094_40(const private_handle_t *hnd, const std::optional<std::vector<uint8_t>> &smpte2094_40) { - auto *metadata = reinterpret_cast<shared_metadata *>(hnd->attr_base); + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); const size_t size = smpte2094_40.has_value() ? smpte2094_40->size() : 0; if (size > metadata->smpte2094_40.capacity()) { @@ -160,6 +162,18 @@ android::status_t set_smpte2094_40(const private_handle_t *hnd, const std::optio return android::OK; } +void* get_video_hdr(const private_handle_t *hnd) { + auto *metadata = reinterpret_cast<shared_metadata *>(mali_gralloc_reference_get_metadata_addr(hnd).value()); + return &(metadata->video_private_data); +} + +void* get_video_roiinfo(const private_handle_t *hnd) { + if (!(hnd->get_usage() & GRALLOC_USAGE_ROIINFO)) + return nullptr; + + auto *metadata = static_cast<char*>(mali_gralloc_reference_get_metadata_addr(hnd).value()); + return metadata + sizeof(shared_metadata) + hnd->reserved_region_size; +} } // namespace common } // namespace mapper } // namespace arm |