1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <aidl/android/hardware/graphics/common/BlendMode.h> 20 #include <aidl/android/hardware/graphics/common/ChromaSiting.h> 21 #include <aidl/android/hardware/graphics/common/Compression.h> 22 #include <aidl/android/hardware/graphics/common/Cta861_3.h> 23 #include <aidl/android/hardware/graphics/common/Dataspace.h> 24 #include <aidl/android/hardware/graphics/common/ExtendableType.h> 25 #include <aidl/android/hardware/graphics/common/Interlaced.h> 26 #include <aidl/android/hardware/graphics/common/PlaneLayout.h> 27 #include <aidl/android/hardware/graphics/common/PlaneLayoutComponentType.h> 28 #include <aidl/android/hardware/graphics/common/Rect.h> 29 #include <aidl/android/hardware/graphics/common/Smpte2086.h> 30 #include <aidl/android/hardware/graphics/common/StandardMetadataType.h> 31 #include <aidl/android/hardware/graphics/common/XyColor.h> 32 #include <android/hardware/graphics/mapper/4.0/IMapper.h> 33 34 namespace android { 35 36 /** 37 * Define equality operators for Stable AIDL types. 38 */ 39 inline bool operator==(const aidl::android::hardware::graphics::common::ExtendableType& lhs, 40 const aidl::android::hardware::graphics::common::ExtendableType& rhs) { 41 return !std::strcmp(lhs.name.c_str(), rhs.name.c_str()) && lhs.value == rhs.value; 42 } 43 44 inline bool operator!=(const aidl::android::hardware::graphics::common::ExtendableType& lhs, 45 const aidl::android::hardware::graphics::common::ExtendableType& rhs) { 46 return !(lhs == rhs); 47 } 48 49 inline bool operator==(const aidl::android::hardware::graphics::common::PlaneLayoutComponent& lhs, 50 const aidl::android::hardware::graphics::common::PlaneLayoutComponent& rhs) { 51 if (lhs.type.name != rhs.type.name) { 52 return false; 53 } 54 if (lhs.type.value != rhs.type.value) { 55 return false; 56 } 57 if (lhs.sizeInBits != rhs.sizeInBits) { 58 return false; 59 } 60 if (lhs.offsetInBits != rhs.offsetInBits) { 61 return false; 62 } 63 return true; 64 } 65 66 inline bool operator!=(const aidl::android::hardware::graphics::common::PlaneLayoutComponent& lhs, 67 const aidl::android::hardware::graphics::common::PlaneLayoutComponent& rhs) { 68 return !(lhs == rhs); 69 } 70 71 inline bool operator==(const aidl::android::hardware::graphics::common::Rect& lhs, 72 const aidl::android::hardware::graphics::common::Rect& rhs) { 73 if (lhs.left != rhs.left) { 74 return false; 75 } 76 if (lhs.top != rhs.top) { 77 return false; 78 } 79 if (lhs.right != rhs.right) { 80 return false; 81 } 82 if (lhs.bottom != rhs.bottom) { 83 return false; 84 } 85 return true; 86 } 87 88 inline bool operator!=(const aidl::android::hardware::graphics::common::Rect& lhs, 89 const aidl::android::hardware::graphics::common::Rect& rhs) { 90 return !(lhs == rhs); 91 } 92 93 inline bool operator==(const std::vector<aidl::android::hardware::graphics::common::Rect>& lhs, 94 const std::vector<aidl::android::hardware::graphics::common::Rect>& rhs) { 95 if (lhs.size() != rhs.size()) { 96 return false; 97 } 98 for (size_t i = 0; i < lhs.size(); i++) { 99 if (lhs[i] != rhs[i]) { 100 return false; 101 } 102 } 103 return true; 104 } 105 106 inline bool operator!=(const std::vector<aidl::android::hardware::graphics::common::Rect>& lhs, 107 const std::vector<aidl::android::hardware::graphics::common::Rect>& rhs) { 108 return !(lhs == rhs); 109 } 110 111 inline bool operator==(const aidl::android::hardware::graphics::common::PlaneLayout& lhs, 112 const aidl::android::hardware::graphics::common::PlaneLayout& rhs) { 113 if (lhs.offsetInBytes != rhs.offsetInBytes) { 114 return false; 115 } 116 if (lhs.sampleIncrementInBits != rhs.sampleIncrementInBits) { 117 return false; 118 } 119 if (lhs.strideInBytes != rhs.strideInBytes) { 120 return false; 121 } 122 if (lhs.widthInSamples != rhs.widthInSamples) { 123 return false; 124 } 125 if (lhs.heightInSamples != rhs.heightInSamples) { 126 return false; 127 } 128 if (lhs.totalSizeInBytes != rhs.totalSizeInBytes) { 129 return false; 130 } 131 if (lhs.horizontalSubsampling != rhs.horizontalSubsampling) { 132 return false; 133 } 134 if (lhs.verticalSubsampling != rhs.verticalSubsampling) { 135 return false; 136 } 137 if (lhs.components.size() != rhs.components.size()) { 138 return false; 139 } 140 for (size_t i = 0; i < lhs.components.size(); i++) { 141 if (lhs.components[i] != rhs.components[i]) { 142 return false; 143 } 144 } 145 return true; 146 } 147 148 inline bool operator!=(const aidl::android::hardware::graphics::common::PlaneLayout& lhs, 149 const aidl::android::hardware::graphics::common::PlaneLayout& rhs) { 150 return !(lhs == rhs); 151 } 152 153 inline bool operator==(const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& lhs, 154 const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& rhs) { 155 if (lhs.size() != rhs.size()) { 156 return false; 157 } 158 for (size_t i = 0; i < lhs.size(); i++) { 159 if (lhs[i] != rhs[i]) { 160 return false; 161 } 162 } 163 return true; 164 } 165 166 inline bool operator!=(const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& lhs, 167 const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& rhs) { 168 return !(lhs == rhs); 169 } 170 171 inline bool operator==(const aidl::android::hardware::graphics::common::XyColor& lhs, 172 const aidl::android::hardware::graphics::common::XyColor& rhs) { 173 if (lhs.x != rhs.x) { 174 return false; 175 } 176 if (lhs.y != rhs.y) { 177 return false; 178 } 179 return true; 180 } 181 182 inline bool operator!=(const aidl::android::hardware::graphics::common::XyColor& lhs, 183 const aidl::android::hardware::graphics::common::XyColor& rhs) { 184 return !(lhs == rhs); 185 } 186 187 inline bool operator==(const aidl::android::hardware::graphics::common::Smpte2086& lhs, 188 const aidl::android::hardware::graphics::common::Smpte2086& rhs) { 189 if (lhs.primaryRed != rhs.primaryRed) { 190 return false; 191 } 192 if (lhs.primaryGreen != rhs.primaryGreen) { 193 return false; 194 } 195 if (lhs.primaryBlue != rhs.primaryBlue) { 196 return false; 197 } 198 if (lhs.whitePoint != rhs.whitePoint) { 199 return false; 200 } 201 if (lhs.maxLuminance != rhs.maxLuminance) { 202 return false; 203 } 204 if (lhs.minLuminance != rhs.minLuminance) { 205 return false; 206 } 207 return true; 208 } 209 210 inline bool operator!=(const aidl::android::hardware::graphics::common::Smpte2086& lhs, 211 const aidl::android::hardware::graphics::common::Smpte2086& rhs) { 212 return !(lhs == rhs); 213 } 214 215 inline bool operator==(const aidl::android::hardware::graphics::common::Cta861_3& lhs, 216 const aidl::android::hardware::graphics::common::Cta861_3& rhs) { 217 if (lhs.maxContentLightLevel != rhs.maxContentLightLevel) { 218 return false; 219 } 220 if (lhs.maxFrameAverageLightLevel != rhs.maxFrameAverageLightLevel) { 221 return false; 222 } 223 return true; 224 } 225 226 inline bool operator!=(const aidl::android::hardware::graphics::common::Cta861_3& lhs, 227 const aidl::android::hardware::graphics::common::Cta861_3& rhs) { 228 return !(lhs == rhs); 229 } 230 231 namespace gralloc4 { 232 233 #define GRALLOC4_STANDARD_METADATA_TYPE "android.hardware.graphics.common.StandardMetadataType" 234 #define GRALLOC4_STANDARD_CHROMA_SITING "android.hardware.graphics.common.ChromaSiting" 235 #define GRALLOC4_STANDARD_COMPRESSION "android.hardware.graphics.common.Compression" 236 #define GRALLOC4_STANDARD_INTERLACED "android.hardware.graphics.common.Interlaced" 237 #define GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE \ 238 "android.hardware.graphics.common.PlaneLayoutComponentType" 239 240 /*---------------------------------------------------------------------------------------------*/ 241 /** 242 * Definitions of the standard buffer metadata types. It is recommended that everyone uses 243 * these definitions directly for standard buffer metadata types. 244 */ 245 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_BufferId = { 246 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::BUFFER_ID) 247 }; 248 249 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Name = { 250 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::NAME) 251 }; 252 253 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Width = { 254 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::WIDTH) 255 }; 256 257 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Height = { 258 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::HEIGHT) 259 }; 260 261 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_LayerCount = { 262 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::LAYER_COUNT) 263 }; 264 265 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_PixelFormatRequested = { 266 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::PIXEL_FORMAT_REQUESTED) 267 }; 268 269 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_PixelFormatFourCC = { 270 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::PIXEL_FORMAT_FOURCC) 271 }; 272 273 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_PixelFormatModifier = { 274 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::PIXEL_FORMAT_MODIFIER) 275 }; 276 277 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Usage = { 278 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::USAGE) 279 }; 280 281 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_AllocationSize = { 282 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::ALLOCATION_SIZE) 283 }; 284 285 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_ProtectedContent = { 286 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::PROTECTED_CONTENT) 287 }; 288 289 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Compression = { 290 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::COMPRESSION) 291 }; 292 293 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Interlaced = { 294 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::INTERLACED) 295 }; 296 297 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_ChromaSiting = { 298 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::CHROMA_SITING) 299 }; 300 301 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_PlaneLayouts = { 302 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::PLANE_LAYOUTS) 303 }; 304 305 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Crop = { 306 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::CROP) 307 }; 308 309 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_Dataspace = { 310 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::DATASPACE) 311 }; 312 313 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType MetadataType_BlendMode = { 314 GRALLOC4_STANDARD_METADATA_TYPE, static_cast<int64_t>(aidl::android::hardware::graphics::common::StandardMetadataType::BLEND_MODE) 315 }; 316 317 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType 318 MetadataType_Smpte2086 = {GRALLOC4_STANDARD_METADATA_TYPE, 319 static_cast<int64_t>(aidl::android::hardware::graphics::common:: 320 StandardMetadataType::SMPTE2086)}; 321 322 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType 323 MetadataType_Cta861_3 = {GRALLOC4_STANDARD_METADATA_TYPE, 324 static_cast<int64_t>(aidl::android::hardware::graphics::common:: 325 StandardMetadataType::CTA861_3)}; 326 327 static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType 328 MetadataType_Smpte2094_40 = {GRALLOC4_STANDARD_METADATA_TYPE, 329 static_cast<int64_t>( 330 aidl::android::hardware::graphics::common:: 331 StandardMetadataType::SMPTE2094_40)}; 332 333 /*---------------------------------------------------------------------------------------------*/ 334 335 /** 336 * Definitions of the standard compression strategies. It is recommended that everyone uses 337 * these definitions directly for standard compression strategies. 338 */ 339 static const aidl::android::hardware::graphics::common::ExtendableType Compression_None = 340 {GRALLOC4_STANDARD_COMPRESSION, 341 static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression::NONE)}; 342 343 static const aidl::android::hardware::graphics::common::ExtendableType 344 Compression_DisplayStreamCompression = 345 {GRALLOC4_STANDARD_COMPRESSION, 346 static_cast<int64_t>(aidl::android::hardware::graphics::common::Compression:: 347 DISPLAY_STREAM_COMPRESSION)}; 348 349 /*---------------------------------------------------------------------------------------------*/ 350 351 /** 352 * Definitions of the standard interlaced strategies. It is recommended that everyone uses 353 * these definitions directly for standard interlaced strategies. 354 */ 355 static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_None = 356 {GRALLOC4_STANDARD_INTERLACED, 357 static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::NONE)}; 358 359 static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_TopBottom = 360 {GRALLOC4_STANDARD_INTERLACED, 361 static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::TOP_BOTTOM)}; 362 363 static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_RightLeft = 364 {GRALLOC4_STANDARD_INTERLACED, 365 static_cast<int64_t>(aidl::android::hardware::graphics::common::Interlaced::RIGHT_LEFT)}; 366 367 /*---------------------------------------------------------------------------------------------*/ 368 369 /** 370 * Definitions of the standard chroma siting. It is recommended that everyone uses 371 * these definitions directly for standard chroma siting. 372 */ 373 static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_None = 374 {GRALLOC4_STANDARD_CHROMA_SITING, 375 static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::NONE)}; 376 377 static const aidl::android::hardware::graphics::common::ExtendableType ChromaSiting_Unknown = 378 {GRALLOC4_STANDARD_CHROMA_SITING, 379 static_cast<int64_t>(aidl::android::hardware::graphics::common::ChromaSiting::UNKNOWN)}; 380 381 static const aidl::android::hardware::graphics::common::ExtendableType 382 ChromaSiting_SitedInterstitial = {GRALLOC4_STANDARD_CHROMA_SITING, 383 static_cast<int64_t>( 384 aidl::android::hardware::graphics::common:: 385 ChromaSiting::SITED_INTERSTITIAL)}; 386 387 static const aidl::android::hardware::graphics::common::ExtendableType 388 ChromaSiting_CositedHorizontal = {GRALLOC4_STANDARD_CHROMA_SITING, 389 static_cast<int64_t>( 390 aidl::android::hardware::graphics::common:: 391 ChromaSiting::COSITED_HORIZONTAL)}; 392 393 /*---------------------------------------------------------------------------------------------*/ 394 395 /** 396 * Definitions of the standard plane layout component types. It is recommended that everyone uses 397 * these definitions directly for standard plane layout component types 398 */ 399 static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_Y = 400 {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, 401 static_cast<int64_t>( 402 aidl::android::hardware::graphics::common::PlaneLayoutComponentType::Y)}; 403 404 static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CB = 405 {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, 406 static_cast<int64_t>( 407 aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CB)}; 408 409 static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_CR = 410 {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, 411 static_cast<int64_t>( 412 aidl::android::hardware::graphics::common::PlaneLayoutComponentType::CR)}; 413 414 static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_R = 415 {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, 416 static_cast<int64_t>( 417 aidl::android::hardware::graphics::common::PlaneLayoutComponentType::R)}; 418 419 static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_G = 420 {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, 421 static_cast<int64_t>( 422 aidl::android::hardware::graphics::common::PlaneLayoutComponentType::G)}; 423 424 static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_B = 425 {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, 426 static_cast<int64_t>( 427 aidl::android::hardware::graphics::common::PlaneLayoutComponentType::B)}; 428 429 static const aidl::android::hardware::graphics::common::ExtendableType PlaneLayoutComponentType_A = 430 {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, 431 static_cast<int64_t>( 432 aidl::android::hardware::graphics::common::PlaneLayoutComponentType::A)}; 433 434 static const aidl::android::hardware::graphics::common::ExtendableType 435 PlaneLayoutComponentType_RAW = 436 {GRALLOC4_STANDARD_PLANE_LAYOUT_COMPONENT_TYPE, 437 static_cast<int64_t>( 438 aidl::android::hardware::graphics::common::PlaneLayoutComponentType::RAW)}; 439 440 /*---------------------------------------------------------------------------------------------*/ 441 442 /** 443 * The functions below encode and decode BufferDescriptorInfo into a byte stream. 444 */ 445 status_t encodeBufferDescriptorInfo(const android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo& bufferDescriptorInfo, android::hardware::hidl_vec<uint8_t>* outBufferDescriptorInfo); 446 status_t decodeBufferDescriptorInfo(const android::hardware::hidl_vec<uint8_t>& bufferDescriptorInfo, android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo* outBufferDescriptorInfo); 447 448 /** 449 * The functions below encode and decode standard metadata into a byte stream. It is STRONGLY 450 * recommended that both the vendor and system partitions use these functions when getting 451 * and setting metadata through gralloc 4 (IMapper 4.0). 452 */ 453 status_t encodeBufferId(uint64_t bufferId, android::hardware::hidl_vec<uint8_t>* outBufferId); 454 status_t decodeBufferId(const android::hardware::hidl_vec<uint8_t>& bufferId, uint64_t* outBufferId); 455 456 status_t encodeName(const std::string& name, android::hardware::hidl_vec<uint8_t>* outName); 457 status_t decodeName(const android::hardware::hidl_vec<uint8_t>& name, std::string* outName); 458 459 status_t encodeWidth(uint64_t width, android::hardware::hidl_vec<uint8_t>* outWidth); 460 status_t decodeWidth(const android::hardware::hidl_vec<uint8_t>& width, uint64_t* outWidth); 461 462 status_t encodeHeight(uint64_t height, android::hardware::hidl_vec<uint8_t>* outHeight); 463 status_t decodeHeight(const android::hardware::hidl_vec<uint8_t>& height, uint64_t* outHeight); 464 465 status_t encodeLayerCount(uint64_t layerCount, android::hardware::hidl_vec<uint8_t>* outLayerCount); 466 status_t decodeLayerCount(const android::hardware::hidl_vec<uint8_t>& layerCount, uint64_t* outLayerCount); 467 468 status_t encodePixelFormatRequested(const hardware::graphics::common::V1_2::PixelFormat& pixelFormatRequested, android::hardware::hidl_vec<uint8_t>* outPixelFormatRequested); 469 status_t decodePixelFormatRequested(const android::hardware::hidl_vec<uint8_t>& pixelFormatRequested, hardware::graphics::common::V1_2::PixelFormat* outPixelFormatRequested); 470 471 status_t encodePixelFormatFourCC(uint32_t pixelFormatFourCC, android::hardware::hidl_vec<uint8_t>* outPixelFormatFourCC); 472 status_t decodePixelFormatFourCC(const android::hardware::hidl_vec<uint8_t>& pixelFormatFourCC, uint32_t* outPixelFormatFourCC); 473 474 status_t encodePixelFormatModifier(uint64_t pixelFormatModifier, android::hardware::hidl_vec<uint8_t>* outPixelFormatModifier); 475 status_t decodePixelFormatModifier(const android::hardware::hidl_vec<uint8_t>& pixelFormatModifier, uint64_t* outPixelFormatModifier); 476 477 status_t encodeUsage(uint64_t usage, android::hardware::hidl_vec<uint8_t>* outUsage); 478 status_t decodeUsage(const android::hardware::hidl_vec<uint8_t>& usage, uint64_t* outUsage); 479 480 status_t encodeAllocationSize(uint64_t allocationSize, android::hardware::hidl_vec<uint8_t>* outAllocationSize); 481 status_t decodeAllocationSize(const android::hardware::hidl_vec<uint8_t>& allocationSize, uint64_t* outAllocationSize); 482 483 status_t encodeProtectedContent(uint64_t protectedContent, android::hardware::hidl_vec<uint8_t>* outProtectedContent); 484 status_t decodeProtectedContent(const android::hardware::hidl_vec<uint8_t>& protectedContent, uint64_t* outProtectedContent); 485 486 status_t encodeCompression(const aidl::android::hardware::graphics::common::ExtendableType& compression, android::hardware::hidl_vec<uint8_t>* outCompression); 487 status_t decodeCompression(const android::hardware::hidl_vec<uint8_t>& compression, aidl::android::hardware::graphics::common::ExtendableType* outCompression); 488 489 status_t encodeInterlaced(const aidl::android::hardware::graphics::common::ExtendableType& interlaced, android::hardware::hidl_vec<uint8_t>* outInterlaced); 490 status_t decodeInterlaced(const android::hardware::hidl_vec<uint8_t>& interlaced, aidl::android::hardware::graphics::common::ExtendableType* outInterlaced); 491 492 status_t encodeChromaSiting(const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting, android::hardware::hidl_vec<uint8_t>* outChromaSiting); 493 status_t decodeChromaSiting(const android::hardware::hidl_vec<uint8_t>& chromaSiting, aidl::android::hardware::graphics::common::ExtendableType* outChromaSiting); 494 495 status_t encodePlaneLayouts(const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& planeLayouts, android::hardware::hidl_vec<uint8_t>* outPlaneLayouts); 496 status_t decodePlaneLayouts(const android::hardware::hidl_vec<uint8_t>& planeLayouts, std::vector<aidl::android::hardware::graphics::common::PlaneLayout>* outPlaneLayouts); 497 498 status_t encodeCrop(const std::vector<aidl::android::hardware::graphics::common::Rect>& crop, android::hardware::hidl_vec<uint8_t>* outCrop); 499 status_t decodeCrop(const android::hardware::hidl_vec<uint8_t>& crop, std::vector<aidl::android::hardware::graphics::common::Rect>* outCrop); 500 501 status_t encodeDataspace(const aidl::android::hardware::graphics::common::Dataspace& dataspace, android::hardware::hidl_vec<uint8_t>* outDataspace); 502 status_t decodeDataspace(const android::hardware::hidl_vec<uint8_t>& dataspace, aidl::android::hardware::graphics::common::Dataspace* outDataspace); 503 504 status_t encodeBlendMode(const aidl::android::hardware::graphics::common::BlendMode& blendMode, android::hardware::hidl_vec<uint8_t>* outBlendMode); 505 status_t decodeBlendMode(const android::hardware::hidl_vec<uint8_t>& blendMode, aidl::android::hardware::graphics::common::BlendMode* outBlendMode); 506 507 status_t encodeSmpte2086( 508 const std::optional<aidl::android::hardware::graphics::common::Smpte2086>& smpte2086, 509 android::hardware::hidl_vec<uint8_t>* outSmpte2086); 510 status_t decodeSmpte2086( 511 const android::hardware::hidl_vec<uint8_t>& smpte2086, 512 std::optional<aidl::android::hardware::graphics::common::Smpte2086>* outSmpte2086); 513 514 status_t encodeCta861_3( 515 const std::optional<aidl::android::hardware::graphics::common::Cta861_3>& cta861_3, 516 android::hardware::hidl_vec<uint8_t>* outCta861_3); 517 status_t decodeCta861_3( 518 const android::hardware::hidl_vec<uint8_t>& cta861_3, 519 std::optional<aidl::android::hardware::graphics::common::Cta861_3>* outCta861_3); 520 521 status_t encodeSmpte2094_40(const std::optional<std::vector<uint8_t>>& smpte2094_40, 522 android::hardware::hidl_vec<uint8_t>* outSmpte2094_40); 523 status_t decodeSmpte2094_40(const android::hardware::hidl_vec<uint8_t>& smpte2094_40, 524 std::optional<std::vector<uint8_t>>* outSmpte2094_40); 525 526 /** 527 * The functions below can be used to encode and decode vendor metadata types. 528 */ 529 status_t encodeUint32( 530 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 531 uint32_t input, android::hardware::hidl_vec<uint8_t>* output); 532 status_t decodeUint32( 533 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 534 const android::hardware::hidl_vec<uint8_t>& input, uint32_t* output); 535 536 status_t encodeInt32( 537 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 538 int32_t input, android::hardware::hidl_vec<uint8_t>* output); 539 status_t decodeInt32( 540 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 541 const android::hardware::hidl_vec<uint8_t>& input, int32_t* output); 542 543 status_t encodeUint64( 544 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 545 uint64_t input, android::hardware::hidl_vec<uint8_t>* output); 546 status_t decodeUint64( 547 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 548 const android::hardware::hidl_vec<uint8_t>& input, uint64_t* output); 549 550 status_t encodeInt64( 551 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 552 int64_t input, android::hardware::hidl_vec<uint8_t>* output); 553 status_t decodeInt64( 554 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 555 const android::hardware::hidl_vec<uint8_t>& input, int64_t* output); 556 557 status_t encodeFloat( 558 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 559 float input, android::hardware::hidl_vec<uint8_t>* output); 560 status_t decodeFloat( 561 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 562 const android::hardware::hidl_vec<uint8_t>& input, float* output); 563 564 status_t encodeDouble( 565 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 566 double input, android::hardware::hidl_vec<uint8_t>* output); 567 status_t decodeDouble( 568 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 569 const android::hardware::hidl_vec<uint8_t>& input, double* output); 570 571 status_t encodeString( 572 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 573 const std::string& input, android::hardware::hidl_vec<uint8_t>* output); 574 status_t decodeString( 575 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, 576 const android::hardware::hidl_vec<uint8_t>& input, std::string* output); 577 578 /** 579 * The functions below can be used to parse extendable types. 580 */ 581 bool isStandardMetadataType( 582 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); 583 bool isStandardCompression( 584 const aidl::android::hardware::graphics::common::ExtendableType& compression); 585 bool isStandardInterlaced( 586 const aidl::android::hardware::graphics::common::ExtendableType& interlaced); 587 bool isStandardChromaSiting( 588 const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); 589 bool isStandardPlaneLayoutComponentType( 590 const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); 591 592 aidl::android::hardware::graphics::common::StandardMetadataType getStandardMetadataTypeValue( 593 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); 594 aidl::android::hardware::graphics::common::Compression getStandardCompressionValue( 595 const aidl::android::hardware::graphics::common::ExtendableType& compression); 596 aidl::android::hardware::graphics::common::Interlaced getStandardInterlacedValue( 597 const aidl::android::hardware::graphics::common::ExtendableType& interlaced); 598 aidl::android::hardware::graphics::common::ChromaSiting getStandardChromaSitingValue( 599 const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); 600 aidl::android::hardware::graphics::common::PlaneLayoutComponentType 601 getStandardPlaneLayoutComponentTypeValue( 602 const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); 603 604 /** 605 * The functions below return string representations of ExtendableTypes 606 */ 607 std::string getCompressionName( 608 const aidl::android::hardware::graphics::common::ExtendableType& compression); 609 std::string getInterlacedName( 610 const aidl::android::hardware::graphics::common::ExtendableType& interlaced); 611 std::string getChromaSitingName( 612 const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); 613 std::string getPlaneLayoutComponentTypeName( 614 const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); 615 616 } // namespace gralloc4 617 618 } // namespace android 619