Loading libs/gralloc/types/Gralloc4.cpp +129 −15 Original line number Diff line number Diff line Loading @@ -25,15 +25,19 @@ using android::hardware::hidl_vec; using ::aidl::android::hardware::graphics::common::BlendMode; using ::aidl::android::hardware::graphics::common::Dataspace; using ::aidl::android::hardware::graphics::common::PlaneLayout; using ::aidl::android::hardware::graphics::common::PlaneLayoutComponent; using ::aidl::android::hardware::graphics::common::ExtendableType; using ::aidl::android::hardware::graphics::common::Rect; using ::aidl::android::hardware::graphics::common::StandardMetadataType; using MetadataType = ::android::hardware::graphics::mapper::V4_0::IMapper::MetadataType; using aidl::android::hardware::graphics::common::BlendMode; using aidl::android::hardware::graphics::common::ChromaSiting; using aidl::android::hardware::graphics::common::Compression; using aidl::android::hardware::graphics::common::Dataspace; using aidl::android::hardware::graphics::common::ExtendableType; using aidl::android::hardware::graphics::common::Interlaced; using aidl::android::hardware::graphics::common::PlaneLayout; using aidl::android::hardware::graphics::common::PlaneLayoutComponent; using aidl::android::hardware::graphics::common::PlaneLayoutComponentType; using aidl::android::hardware::graphics::common::Rect; using aidl::android::hardware::graphics::common::StandardMetadataType; using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType; namespace android { Loading Loading @@ -545,12 +549,9 @@ void clearPlaneLayouts(std::vector<PlaneLayout>* output) { /** * Public API functions */ bool isStandardMetadataType(const MetadataType& metadataType) { return !std::strncmp(metadataType.name.c_str(), GRALLOC4_STANDARD_METADATA_TYPE, metadataType.name.size()); } StandardMetadataType getStandardMetadataTypeValue(const MetadataType& metadataType) { return static_cast<StandardMetadataType>(metadataType.value); PlaneLayoutComponentType getStandardPlaneLayoutComponentTypeValue( const ExtendableType& planeLayoutComponentType) { return static_cast<PlaneLayoutComponentType>(planeLayoutComponentType.value); } status_t encodeBufferId(uint64_t bufferId, hidl_vec<uint8_t>* outBufferId) { Loading Loading @@ -691,6 +692,119 @@ status_t decodeBlendMode(const hidl_vec<uint8_t>& blendMode, BlendMode* outBlend return decode(blendMode, reinterpret_cast<int32_t*>(outBlendMode), decodeInteger); } bool isStandardMetadataType(const MetadataType& metadataType) { return !std::strncmp(metadataType.name.c_str(), GRALLOC4_STANDARD_METADATA_TYPE, metadataType.name.size()); } bool isStandardCompression(const ExtendableType& compression) { return !std::strncmp(compression.name.c_str(), GRALLOC4_STANDARD_COMPRESSION, compression.name.size()); } bool isStandardInterlaced(const ExtendableType& interlaced) { return !std::strncmp(interlaced.name.c_str(), GRALLOC4_STANDARD_INTERLACED, interlaced.name.size()); } bool isStandardChromaSiting(const ExtendableType& chromaSiting) { return !std::strncmp(chromaSiting.name.c_str(), GRALLOC4_STANDARD_CHROMA_SITING, chromaSiting.name.size()); } bool isStandardPlaneLayoutComponentType(const ExtendableType& planeLayoutComponentType) { return !std::strncmp(planeLayoutComponentType.name.c_str(), GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, planeLayoutComponentType.name.size()); } StandardMetadataType getStandardMetadataTypeValue(const MetadataType& metadataType) { return static_cast<StandardMetadataType>(metadataType.value); } Compression getStandardCompressionValue(const ExtendableType& compression) { return static_cast<Compression>(compression.value); } Interlaced getStandardInterlacedValue(const ExtendableType& interlaced) { return static_cast<Interlaced>(interlaced.value); } ChromaSiting getStandardChromaSitingValue(const ExtendableType& chromaSiting) { return static_cast<ChromaSiting>(chromaSiting.value); } std::string getCompressionName(const ExtendableType& compression) { if (!isStandardCompression(compression)) { std::ostringstream stream; stream << compression.name << "#" << compression.value; return stream.str(); } switch (getStandardCompressionValue(compression)) { case Compression::NONE: return "None"; case Compression::DISPLAY_STREAM_COMPRESSION: return "DisplayStreamCompression"; } } std::string getInterlacedName(const ExtendableType& interlaced) { if (!isStandardInterlaced(interlaced)) { std::ostringstream stream; stream << interlaced.name << "#" << interlaced.value; return stream.str(); } switch (getStandardInterlacedValue(interlaced)) { case Interlaced::NONE: return "None"; case Interlaced::TOP_BOTTOM: return "TopBottom"; case Interlaced::RIGHT_LEFT: return "RightLeft"; } } std::string getChromaSitingName(const ExtendableType& chromaSiting) { if (!isStandardChromaSiting(chromaSiting)) { std::ostringstream stream; stream << chromaSiting.name << "#" << chromaSiting.value; return stream.str(); } switch (getStandardChromaSitingValue(chromaSiting)) { case ChromaSiting::NONE: return "None"; case ChromaSiting::UNKNOWN: return "Unknown"; case ChromaSiting::SITED_INTERSTITIAL: return "SitedInterstitial"; case ChromaSiting::COSITED_HORIZONTAL: return "CositedHorizontal"; } } std::string getPlaneLayoutComponentTypeName(const ExtendableType& planeLayoutComponentType) { if (!isStandardPlaneLayoutComponentType(planeLayoutComponentType)) { std::ostringstream stream; stream << planeLayoutComponentType.name << "#" << planeLayoutComponentType.value; return stream.str(); } switch (getStandardPlaneLayoutComponentTypeValue(planeLayoutComponentType)) { case PlaneLayoutComponentType::Y: return "Y"; case PlaneLayoutComponentType::CB: return "Cb"; case PlaneLayoutComponentType::CR: return "Cr"; case PlaneLayoutComponentType::R: return "R"; case PlaneLayoutComponentType::G: return "G"; case PlaneLayoutComponentType::B: return "B"; case PlaneLayoutComponentType::A: return "A"; } } } // namespace gralloc4 } // namespace android libs/gralloc/types/include/gralloctypes/Gralloc4.h +113 −68 Original line number Diff line number Diff line Loading @@ -34,10 +34,11 @@ namespace android { namespace gralloc4 { #define GRALLOC4_STANDARD_METADATA_TYPE "android.hardware.graphics.common.StandardMetadataType" #define GRALLOC4_CHROMA_SITING "android.hardware.graphics.common.ChromaSiting" #define GRALLOC4_COMPRESSION "android.hardware.graphics.common.Compression" #define GRALLOC4_INTERLACED "android.hardware.graphics.common.Interlaced" #define GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE "android.hardware.graphics.common.PlaneLayoutComponentType" #define GRALLOC4_STANDARD_CHROMA_SITING "android.hardware.graphics.common.ChromaSiting" #define GRALLOC4_STANDARD_COMPRESSION "android.hardware.graphics.common.Compression" #define GRALLOC4_STANDARD_INTERLACED "android.hardware.graphics.common.Interlaced" #define GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE \ "android.hardware.graphics.common.PlaneLayoutComponentType" /*---------------------------------------------------------------------------------------------*/ /** Loading Loading @@ -118,13 +119,15 @@ static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType Me * Definitions of the standard compression strategies. It is recommended that everyone uses * these definitions directly for standard compression strategies. */ static const aidl::android::hardware::graphics::common::ExtendableType Compression_None = { GRALLOC4_COMPRESSION, static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression::NONE) }; static const aidl::android::hardware::graphics::common::ExtendableType Compression_None = {GRALLOC4_STANDARD_COMPRESSION, static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression::NONE)}; static const aidl::android::hardware::graphics::common::ExtendableType Compression_DisplayStreamCompression = { GRALLOC4_COMPRESSION, static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression::DISPLAY_STREAM_COMPRESSION) }; static const aidl::android::hardware::graphics::common::ExtendableType Compression_DisplayStreamCompression = {GRALLOC4_STANDARD_COMPRESSION, static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression:: DISPLAY_STREAM_COMPRESSION)}; /*---------------------------------------------------------------------------------------------*/ Loading @@ -132,17 +135,17 @@ static const aidl::android::hardware::graphics::common::ExtendableType Compressi * Definitions of the standard interlaced strategies. It is recommended that everyone uses * these definitions directly for standard interlaced strategies. */ static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_None = { GRALLOC4_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::NONE) }; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_None = {GRALLOC4_STANDARD_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::NONE)}; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_TopBottom = { GRALLOC4_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::TOP_BOTTOM) }; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_TopBottom = {GRALLOC4_STANDARD_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::TOP_BOTTOM)}; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_RightLeft = { GRALLOC4_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::RIGHT_LEFT) }; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_RightLeft = {GRALLOC4_STANDARD_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::RIGHT_LEFT)}; /*---------------------------------------------------------------------------------------------*/ Loading @@ -150,21 +153,25 @@ static const aidl::android::hardware::graphics::common::ExtendableType Interlace * Definitions of the standard chroma siting. It is recommended that everyone uses * these definitions directly for standard chroma siting. */ static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_None = { GRALLOC4_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::NONE) }; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_Unknown = { GRALLOC4_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::UNKNOWN) }; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_SitedInterstitial = { GRALLOC4_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::SITED_INTERSTITIAL) }; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_CositedHorizontal = { GRALLOC4_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::COSITED_HORIZONTAL) }; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_None = {GRALLOC4_STANDARD_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::NONE)}; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_Unknown = {GRALLOC4_STANDARD_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::UNKNOWN)}; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_SitedInterstitial = {GRALLOC4_STANDARD_CHROMA_SITING, static_cast<int64_t>( aidl::android::hardware::graphics::common:: ChromaSiting::SITED_INTERSTITIAL)}; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_CositedHorizontal = {GRALLOC4_STANDARD_CHROMA_SITING, static_cast<int64_t>( aidl::android::hardware::graphics::common:: ChromaSiting::COSITED_HORIZONTAL)}; /*---------------------------------------------------------------------------------------------*/ Loading @@ -172,43 +179,43 @@ static const aidl::android::hardware::graphics::common::ExtendableType ChromaSit * Definitions of the standard plane layout component types. It is recommended that everyone uses * these definitions directly for standard plane layout component types */ static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_Y = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::Y) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CB = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CB) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CR = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CR) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_R = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::R) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_G = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::G) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_B = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::B) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_A = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::A) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_Y = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::Y)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CB = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CB)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CR = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CR)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_R = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::R)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_G = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::G)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_B = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::B)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_A = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::A)}; /*---------------------------------------------------------------------------------------------*/ /** * The functions below can be used to parse a StandardMetadataType. */ bool isStandardMetadataType(const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); aidl::android::hardware::graphics::common::StandardMetadataType getStandardMetadataTypeValue(const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); /** * The functions below encode and decode standard metadata into a byte stream. It is STRONGLY * recommended that both the vendor and system partitions use these functions when getting Loading Loading @@ -265,6 +272,44 @@ status_t decodeDataspace(const android::hardware::hidl_vec<uint8_t>& dataspace, status_t encodeBlendMode(const aidl::android::hardware::graphics::common::BlendMode& blendMode, android::hardware::hidl_vec<uint8_t>* outBlendMode); status_t decodeBlendMode(const android::hardware::hidl_vec<uint8_t>& blendMode, aidl::android::hardware::graphics::common::BlendMode* outBlendMode); /** * The functions below can be used to parse extendable types. */ bool isStandardMetadataType( const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); bool isStandardCompression( const aidl::android::hardware::graphics::common::ExtendableType& compression); bool isStandardInterlaced( const aidl::android::hardware::graphics::common::ExtendableType& interlaced); bool isStandardChromaSiting( const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); bool isStandardPlaneLayoutComponentType( const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); aidl::android::hardware::graphics::common::StandardMetadataType getStandardMetadataTypeValue( const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); aidl::android::hardware::graphics::common::Compression getStandardCompressionValue( const aidl::android::hardware::graphics::common::ExtendableType& compression); aidl::android::hardware::graphics::common::Interlaced getStandardInterlacedValue( const aidl::android::hardware::graphics::common::ExtendableType& interlaced); aidl::android::hardware::graphics::common::ChromaSiting getStandardChromaSitingValue( const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); aidl::android::hardware::graphics::common::PlaneLayoutComponentType getStandardPlaneLayoutComponentTypeValue( const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); /** * The functions below return string representations of ExtendableTypes */ std::string getCompressionName( const aidl::android::hardware::graphics::common::ExtendableType& compression); std::string getInterlacedName( const aidl::android::hardware::graphics::common::ExtendableType& interlaced); std::string getChromaSitingName( const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); std::string getPlaneLayoutComponentTypeName( const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); } // namespace gralloc4 } // namespace android libs/ui/Android.bp +5 −0 Original line number Diff line number Diff line Loading @@ -89,14 +89,19 @@ cc_library_shared { "android.hardware.graphics.mapper@4.0", "libbase", "libcutils", "libgralloctypes", "libhidlbase", "libsync", "libutils", "liblog", "vintf-graphics-common-ndk_platform", ], export_shared_lib_headers: [ "android.hardware.graphics.common@1.2", "android.hardware.graphics.mapper@4.0", "libgralloctypes", "vintf-graphics-common-ndk_platform", ], static_libs: [ Loading libs/ui/Gralloc2.cpp +5 −11 Original line number Diff line number Diff line Loading @@ -351,12 +351,6 @@ int Gralloc2Mapper::unlock(buffer_handle_t bufferHandle) const { return releaseFence; } status_t Gralloc2Mapper::isSupported(uint32_t /*width*/, uint32_t /*height*/, android::PixelFormat /*format*/, uint32_t /*layerCount*/, uint64_t /*usage*/, bool* /*outSupported*/) const { return INVALID_OPERATION; } Gralloc2Allocator::Gralloc2Allocator(const Gralloc2Mapper& mapper) : mMapper(mapper) { mAllocator = IAllocator::getService(); if (mAllocator == nullptr) { Loading @@ -369,7 +363,7 @@ bool Gralloc2Allocator::isLoaded() const { return mAllocator != nullptr; } std::string Gralloc2Allocator::dumpDebugInfo() const { std::string Gralloc2Allocator::dumpDebugInfo(bool /*less*/) const { std::string debugInfo; mAllocator->dumpDebugInfo([&](const auto& tmpDebugInfo) { Loading @@ -379,10 +373,10 @@ std::string Gralloc2Allocator::dumpDebugInfo() const { return debugInfo; } status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { status_t Gralloc2Allocator::allocate(std::string /*requestorName*/, uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo = {}; descriptorInfo.width = width; descriptorInfo.height = height; Loading libs/ui/Gralloc3.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ bool Gralloc3Allocator::isLoaded() const { return mAllocator != nullptr; } std::string Gralloc3Allocator::dumpDebugInfo() const { std::string Gralloc3Allocator::dumpDebugInfo(bool /*less*/) const { std::string debugInfo; mAllocator->dumpDebugInfo([&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); }); Loading @@ -360,10 +360,10 @@ std::string Gralloc3Allocator::dumpDebugInfo() const { return debugInfo; } status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { status_t Gralloc3Allocator::allocate(std::string /*requestorName*/, uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); Loading Loading
libs/gralloc/types/Gralloc4.cpp +129 −15 Original line number Diff line number Diff line Loading @@ -25,15 +25,19 @@ using android::hardware::hidl_vec; using ::aidl::android::hardware::graphics::common::BlendMode; using ::aidl::android::hardware::graphics::common::Dataspace; using ::aidl::android::hardware::graphics::common::PlaneLayout; using ::aidl::android::hardware::graphics::common::PlaneLayoutComponent; using ::aidl::android::hardware::graphics::common::ExtendableType; using ::aidl::android::hardware::graphics::common::Rect; using ::aidl::android::hardware::graphics::common::StandardMetadataType; using MetadataType = ::android::hardware::graphics::mapper::V4_0::IMapper::MetadataType; using aidl::android::hardware::graphics::common::BlendMode; using aidl::android::hardware::graphics::common::ChromaSiting; using aidl::android::hardware::graphics::common::Compression; using aidl::android::hardware::graphics::common::Dataspace; using aidl::android::hardware::graphics::common::ExtendableType; using aidl::android::hardware::graphics::common::Interlaced; using aidl::android::hardware::graphics::common::PlaneLayout; using aidl::android::hardware::graphics::common::PlaneLayoutComponent; using aidl::android::hardware::graphics::common::PlaneLayoutComponentType; using aidl::android::hardware::graphics::common::Rect; using aidl::android::hardware::graphics::common::StandardMetadataType; using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType; namespace android { Loading Loading @@ -545,12 +549,9 @@ void clearPlaneLayouts(std::vector<PlaneLayout>* output) { /** * Public API functions */ bool isStandardMetadataType(const MetadataType& metadataType) { return !std::strncmp(metadataType.name.c_str(), GRALLOC4_STANDARD_METADATA_TYPE, metadataType.name.size()); } StandardMetadataType getStandardMetadataTypeValue(const MetadataType& metadataType) { return static_cast<StandardMetadataType>(metadataType.value); PlaneLayoutComponentType getStandardPlaneLayoutComponentTypeValue( const ExtendableType& planeLayoutComponentType) { return static_cast<PlaneLayoutComponentType>(planeLayoutComponentType.value); } status_t encodeBufferId(uint64_t bufferId, hidl_vec<uint8_t>* outBufferId) { Loading Loading @@ -691,6 +692,119 @@ status_t decodeBlendMode(const hidl_vec<uint8_t>& blendMode, BlendMode* outBlend return decode(blendMode, reinterpret_cast<int32_t*>(outBlendMode), decodeInteger); } bool isStandardMetadataType(const MetadataType& metadataType) { return !std::strncmp(metadataType.name.c_str(), GRALLOC4_STANDARD_METADATA_TYPE, metadataType.name.size()); } bool isStandardCompression(const ExtendableType& compression) { return !std::strncmp(compression.name.c_str(), GRALLOC4_STANDARD_COMPRESSION, compression.name.size()); } bool isStandardInterlaced(const ExtendableType& interlaced) { return !std::strncmp(interlaced.name.c_str(), GRALLOC4_STANDARD_INTERLACED, interlaced.name.size()); } bool isStandardChromaSiting(const ExtendableType& chromaSiting) { return !std::strncmp(chromaSiting.name.c_str(), GRALLOC4_STANDARD_CHROMA_SITING, chromaSiting.name.size()); } bool isStandardPlaneLayoutComponentType(const ExtendableType& planeLayoutComponentType) { return !std::strncmp(planeLayoutComponentType.name.c_str(), GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, planeLayoutComponentType.name.size()); } StandardMetadataType getStandardMetadataTypeValue(const MetadataType& metadataType) { return static_cast<StandardMetadataType>(metadataType.value); } Compression getStandardCompressionValue(const ExtendableType& compression) { return static_cast<Compression>(compression.value); } Interlaced getStandardInterlacedValue(const ExtendableType& interlaced) { return static_cast<Interlaced>(interlaced.value); } ChromaSiting getStandardChromaSitingValue(const ExtendableType& chromaSiting) { return static_cast<ChromaSiting>(chromaSiting.value); } std::string getCompressionName(const ExtendableType& compression) { if (!isStandardCompression(compression)) { std::ostringstream stream; stream << compression.name << "#" << compression.value; return stream.str(); } switch (getStandardCompressionValue(compression)) { case Compression::NONE: return "None"; case Compression::DISPLAY_STREAM_COMPRESSION: return "DisplayStreamCompression"; } } std::string getInterlacedName(const ExtendableType& interlaced) { if (!isStandardInterlaced(interlaced)) { std::ostringstream stream; stream << interlaced.name << "#" << interlaced.value; return stream.str(); } switch (getStandardInterlacedValue(interlaced)) { case Interlaced::NONE: return "None"; case Interlaced::TOP_BOTTOM: return "TopBottom"; case Interlaced::RIGHT_LEFT: return "RightLeft"; } } std::string getChromaSitingName(const ExtendableType& chromaSiting) { if (!isStandardChromaSiting(chromaSiting)) { std::ostringstream stream; stream << chromaSiting.name << "#" << chromaSiting.value; return stream.str(); } switch (getStandardChromaSitingValue(chromaSiting)) { case ChromaSiting::NONE: return "None"; case ChromaSiting::UNKNOWN: return "Unknown"; case ChromaSiting::SITED_INTERSTITIAL: return "SitedInterstitial"; case ChromaSiting::COSITED_HORIZONTAL: return "CositedHorizontal"; } } std::string getPlaneLayoutComponentTypeName(const ExtendableType& planeLayoutComponentType) { if (!isStandardPlaneLayoutComponentType(planeLayoutComponentType)) { std::ostringstream stream; stream << planeLayoutComponentType.name << "#" << planeLayoutComponentType.value; return stream.str(); } switch (getStandardPlaneLayoutComponentTypeValue(planeLayoutComponentType)) { case PlaneLayoutComponentType::Y: return "Y"; case PlaneLayoutComponentType::CB: return "Cb"; case PlaneLayoutComponentType::CR: return "Cr"; case PlaneLayoutComponentType::R: return "R"; case PlaneLayoutComponentType::G: return "G"; case PlaneLayoutComponentType::B: return "B"; case PlaneLayoutComponentType::A: return "A"; } } } // namespace gralloc4 } // namespace android
libs/gralloc/types/include/gralloctypes/Gralloc4.h +113 −68 Original line number Diff line number Diff line Loading @@ -34,10 +34,11 @@ namespace android { namespace gralloc4 { #define GRALLOC4_STANDARD_METADATA_TYPE "android.hardware.graphics.common.StandardMetadataType" #define GRALLOC4_CHROMA_SITING "android.hardware.graphics.common.ChromaSiting" #define GRALLOC4_COMPRESSION "android.hardware.graphics.common.Compression" #define GRALLOC4_INTERLACED "android.hardware.graphics.common.Interlaced" #define GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE "android.hardware.graphics.common.PlaneLayoutComponentType" #define GRALLOC4_STANDARD_CHROMA_SITING "android.hardware.graphics.common.ChromaSiting" #define GRALLOC4_STANDARD_COMPRESSION "android.hardware.graphics.common.Compression" #define GRALLOC4_STANDARD_INTERLACED "android.hardware.graphics.common.Interlaced" #define GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE \ "android.hardware.graphics.common.PlaneLayoutComponentType" /*---------------------------------------------------------------------------------------------*/ /** Loading Loading @@ -118,13 +119,15 @@ static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType Me * Definitions of the standard compression strategies. It is recommended that everyone uses * these definitions directly for standard compression strategies. */ static const aidl::android::hardware::graphics::common::ExtendableType Compression_None = { GRALLOC4_COMPRESSION, static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression::NONE) }; static const aidl::android::hardware::graphics::common::ExtendableType Compression_None = {GRALLOC4_STANDARD_COMPRESSION, static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression::NONE)}; static const aidl::android::hardware::graphics::common::ExtendableType Compression_DisplayStreamCompression = { GRALLOC4_COMPRESSION, static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression::DISPLAY_STREAM_COMPRESSION) }; static const aidl::android::hardware::graphics::common::ExtendableType Compression_DisplayStreamCompression = {GRALLOC4_STANDARD_COMPRESSION, static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression:: DISPLAY_STREAM_COMPRESSION)}; /*---------------------------------------------------------------------------------------------*/ Loading @@ -132,17 +135,17 @@ static const aidl::android::hardware::graphics::common::ExtendableType Compressi * Definitions of the standard interlaced strategies. It is recommended that everyone uses * these definitions directly for standard interlaced strategies. */ static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_None = { GRALLOC4_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::NONE) }; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_None = {GRALLOC4_STANDARD_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::NONE)}; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_TopBottom = { GRALLOC4_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::TOP_BOTTOM) }; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_TopBottom = {GRALLOC4_STANDARD_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::TOP_BOTTOM)}; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_RightLeft = { GRALLOC4_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::RIGHT_LEFT) }; static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_RightLeft = {GRALLOC4_STANDARD_INTERLACED, static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::RIGHT_LEFT)}; /*---------------------------------------------------------------------------------------------*/ Loading @@ -150,21 +153,25 @@ static const aidl::android::hardware::graphics::common::ExtendableType Interlace * Definitions of the standard chroma siting. It is recommended that everyone uses * these definitions directly for standard chroma siting. */ static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_None = { GRALLOC4_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::NONE) }; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_Unknown = { GRALLOC4_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::UNKNOWN) }; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_SitedInterstitial = { GRALLOC4_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::SITED_INTERSTITIAL) }; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_CositedHorizontal = { GRALLOC4_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::COSITED_HORIZONTAL) }; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_None = {GRALLOC4_STANDARD_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::NONE)}; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_Unknown = {GRALLOC4_STANDARD_CHROMA_SITING, static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::UNKNOWN)}; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_SitedInterstitial = {GRALLOC4_STANDARD_CHROMA_SITING, static_cast<int64_t>( aidl::android::hardware::graphics::common:: ChromaSiting::SITED_INTERSTITIAL)}; static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_CositedHorizontal = {GRALLOC4_STANDARD_CHROMA_SITING, static_cast<int64_t>( aidl::android::hardware::graphics::common:: ChromaSiting::COSITED_HORIZONTAL)}; /*---------------------------------------------------------------------------------------------*/ Loading @@ -172,43 +179,43 @@ static const aidl::android::hardware::graphics::common::ExtendableType ChromaSit * Definitions of the standard plane layout component types. It is recommended that everyone uses * these definitions directly for standard plane layout component types */ static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_Y = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::Y) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CB = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CB) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CR = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CR) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_R = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::R) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_G = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::G) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_B = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::B) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_A = { GRALLOC4_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::PlaneLayoutComponentType::A) }; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_Y = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::Y)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CB = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CB)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CR = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CR)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_R = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::R)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_G = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::G)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_B = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::B)}; static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_A = {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, static_cast<int64_t>( aidl::android::hardware::graphics::common::PlaneLayoutComponentType::A)}; /*---------------------------------------------------------------------------------------------*/ /** * The functions below can be used to parse a StandardMetadataType. */ bool isStandardMetadataType(const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); aidl::android::hardware::graphics::common::StandardMetadataType getStandardMetadataTypeValue(const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); /** * The functions below encode and decode standard metadata into a byte stream. It is STRONGLY * recommended that both the vendor and system partitions use these functions when getting Loading Loading @@ -265,6 +272,44 @@ status_t decodeDataspace(const android::hardware::hidl_vec<uint8_t>& dataspace, status_t encodeBlendMode(const aidl::android::hardware::graphics::common::BlendMode& blendMode, android::hardware::hidl_vec<uint8_t>* outBlendMode); status_t decodeBlendMode(const android::hardware::hidl_vec<uint8_t>& blendMode, aidl::android::hardware::graphics::common::BlendMode* outBlendMode); /** * The functions below can be used to parse extendable types. */ bool isStandardMetadataType( const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); bool isStandardCompression( const aidl::android::hardware::graphics::common::ExtendableType& compression); bool isStandardInterlaced( const aidl::android::hardware::graphics::common::ExtendableType& interlaced); bool isStandardChromaSiting( const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); bool isStandardPlaneLayoutComponentType( const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); aidl::android::hardware::graphics::common::StandardMetadataType getStandardMetadataTypeValue( const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); aidl::android::hardware::graphics::common::Compression getStandardCompressionValue( const aidl::android::hardware::graphics::common::ExtendableType& compression); aidl::android::hardware::graphics::common::Interlaced getStandardInterlacedValue( const aidl::android::hardware::graphics::common::ExtendableType& interlaced); aidl::android::hardware::graphics::common::ChromaSiting getStandardChromaSitingValue( const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); aidl::android::hardware::graphics::common::PlaneLayoutComponentType getStandardPlaneLayoutComponentTypeValue( const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); /** * The functions below return string representations of ExtendableTypes */ std::string getCompressionName( const aidl::android::hardware::graphics::common::ExtendableType& compression); std::string getInterlacedName( const aidl::android::hardware::graphics::common::ExtendableType& interlaced); std::string getChromaSitingName( const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); std::string getPlaneLayoutComponentTypeName( const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); } // namespace gralloc4 } // namespace android
libs/ui/Android.bp +5 −0 Original line number Diff line number Diff line Loading @@ -89,14 +89,19 @@ cc_library_shared { "android.hardware.graphics.mapper@4.0", "libbase", "libcutils", "libgralloctypes", "libhidlbase", "libsync", "libutils", "liblog", "vintf-graphics-common-ndk_platform", ], export_shared_lib_headers: [ "android.hardware.graphics.common@1.2", "android.hardware.graphics.mapper@4.0", "libgralloctypes", "vintf-graphics-common-ndk_platform", ], static_libs: [ Loading
libs/ui/Gralloc2.cpp +5 −11 Original line number Diff line number Diff line Loading @@ -351,12 +351,6 @@ int Gralloc2Mapper::unlock(buffer_handle_t bufferHandle) const { return releaseFence; } status_t Gralloc2Mapper::isSupported(uint32_t /*width*/, uint32_t /*height*/, android::PixelFormat /*format*/, uint32_t /*layerCount*/, uint64_t /*usage*/, bool* /*outSupported*/) const { return INVALID_OPERATION; } Gralloc2Allocator::Gralloc2Allocator(const Gralloc2Mapper& mapper) : mMapper(mapper) { mAllocator = IAllocator::getService(); if (mAllocator == nullptr) { Loading @@ -369,7 +363,7 @@ bool Gralloc2Allocator::isLoaded() const { return mAllocator != nullptr; } std::string Gralloc2Allocator::dumpDebugInfo() const { std::string Gralloc2Allocator::dumpDebugInfo(bool /*less*/) const { std::string debugInfo; mAllocator->dumpDebugInfo([&](const auto& tmpDebugInfo) { Loading @@ -379,10 +373,10 @@ std::string Gralloc2Allocator::dumpDebugInfo() const { return debugInfo; } status_t Gralloc2Allocator::allocate(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { status_t Gralloc2Allocator::allocate(std::string /*requestorName*/, uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo = {}; descriptorInfo.width = width; descriptorInfo.height = height; Loading
libs/ui/Gralloc3.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ bool Gralloc3Allocator::isLoaded() const { return mAllocator != nullptr; } std::string Gralloc3Allocator::dumpDebugInfo() const { std::string Gralloc3Allocator::dumpDebugInfo(bool /*less*/) const { std::string debugInfo; mAllocator->dumpDebugInfo([&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); }); Loading @@ -360,10 +360,10 @@ std::string Gralloc3Allocator::dumpDebugInfo() const { return debugInfo; } status_t Gralloc3Allocator::allocate(uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { status_t Gralloc3Allocator::allocate(std::string /*requestorName*/, uint32_t width, uint32_t height, android::PixelFormat format, uint32_t layerCount, uint64_t usage, uint32_t bufferCount, uint32_t* outStride, buffer_handle_t* outBufferHandles, bool importBuffers) const { IMapper::BufferDescriptorInfo descriptorInfo; sBufferDescriptorInfo(width, height, format, layerCount, usage, &descriptorInfo); Loading