Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 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> |
Marissa Wall | ef785e1 | 2019-12-12 14:26:59 -0800 | [diff] [blame] | 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> |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 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> |
Joseph Murphy | 048552f | 2019-12-17 19:58:45 +0000 | [diff] [blame] | 27 | #include <aidl/android/hardware/graphics/common/PlaneLayoutComponentType.h> |
Jeongik Cha | db26a6b | 2020-04-08 21:46:00 +0900 | [diff] [blame] | 28 | #include <aidl/android/hardware/graphics/common/Rect.h> |
Marissa Wall | ef785e1 | 2019-12-12 14:26:59 -0800 | [diff] [blame] | 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> |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 32 | #include <android/hardware/graphics/mapper/4.0/IMapper.h> |
| 33 | |
Steven Moreland | a694b46 | 2020-01-16 16:38:44 -0800 | [diff] [blame] | 34 | namespace android { |
| 35 | |
Marissa Wall | 85d423a | 2019-12-15 13:42:02 -0800 | [diff] [blame] | 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 | |
Marissa Wall | 019a7ee | 2020-02-10 11:43:19 -0800 | [diff] [blame] | 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 | |
Marissa Wall | 85d423a | 2019-12-15 13:42:02 -0800 | [diff] [blame] | 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 | } |
Marissa Wall | 85d423a | 2019-12-15 13:42:02 -0800 | [diff] [blame] | 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 | |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 231 | namespace gralloc4 { |
| 232 | |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 233 | #define GRALLOC4_STANDARD_METADATA_TYPE "android.hardware.graphics.common.StandardMetadataType" |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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" |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 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 | |
Marissa Wall | 019a7ee | 2020-02-10 11:43:19 -0800 | [diff] [blame] | 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 | |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 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 | |
Marissa Wall | ef785e1 | 2019-12-12 14:26:59 -0800 | [diff] [blame] | 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 | |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 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 | */ |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 342 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 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 | */ |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 358 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 362 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 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 | */ |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 376 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 380 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 386 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 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 | */ |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 403 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 408 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 413 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 418 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 423 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 428 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 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)}; |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 433 | |
| 434 | /*---------------------------------------------------------------------------------------------*/ |
| 435 | |
| 436 | /** |
Marissa Wall | d5e9a61 | 2020-01-13 13:57:42 -0800 | [diff] [blame] | 437 | * The functions below encode and decode BufferDescriptorInfo into a byte stream. |
| 438 | */ |
| 439 | status_t encodeBufferDescriptorInfo(const android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo& bufferDescriptorInfo, android::hardware::hidl_vec<uint8_t>* outBufferDescriptorInfo); |
| 440 | status_t decodeBufferDescriptorInfo(const android::hardware::hidl_vec<uint8_t>& bufferDescriptorInfo, android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo* outBufferDescriptorInfo); |
| 441 | |
| 442 | /** |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 443 | * The functions below encode and decode standard metadata into a byte stream. It is STRONGLY |
| 444 | * recommended that both the vendor and system partitions use these functions when getting |
| 445 | * and setting metadata through gralloc 4 (IMapper 4.0). |
| 446 | */ |
| 447 | status_t encodeBufferId(uint64_t bufferId, android::hardware::hidl_vec<uint8_t>* outBufferId); |
| 448 | status_t decodeBufferId(const android::hardware::hidl_vec<uint8_t>& bufferId, uint64_t* outBufferId); |
| 449 | |
| 450 | status_t encodeName(const std::string& name, android::hardware::hidl_vec<uint8_t>* outName); |
| 451 | status_t decodeName(const android::hardware::hidl_vec<uint8_t>& name, std::string* outName); |
| 452 | |
| 453 | status_t encodeWidth(uint64_t width, android::hardware::hidl_vec<uint8_t>* outWidth); |
| 454 | status_t decodeWidth(const android::hardware::hidl_vec<uint8_t>& width, uint64_t* outWidth); |
| 455 | |
| 456 | status_t encodeHeight(uint64_t height, android::hardware::hidl_vec<uint8_t>* outHeight); |
| 457 | status_t decodeHeight(const android::hardware::hidl_vec<uint8_t>& height, uint64_t* outHeight); |
| 458 | |
| 459 | status_t encodeLayerCount(uint64_t layerCount, android::hardware::hidl_vec<uint8_t>* outLayerCount); |
| 460 | status_t decodeLayerCount(const android::hardware::hidl_vec<uint8_t>& layerCount, uint64_t* outLayerCount); |
| 461 | |
| 462 | status_t encodePixelFormatRequested(const hardware::graphics::common::V1_2::PixelFormat& pixelFormatRequested, android::hardware::hidl_vec<uint8_t>* outPixelFormatRequested); |
| 463 | status_t decodePixelFormatRequested(const android::hardware::hidl_vec<uint8_t>& pixelFormatRequested, hardware::graphics::common::V1_2::PixelFormat* outPixelFormatRequested); |
| 464 | |
| 465 | status_t encodePixelFormatFourCC(uint32_t pixelFormatFourCC, android::hardware::hidl_vec<uint8_t>* outPixelFormatFourCC); |
| 466 | status_t decodePixelFormatFourCC(const android::hardware::hidl_vec<uint8_t>& pixelFormatFourCC, uint32_t* outPixelFormatFourCC); |
| 467 | |
| 468 | status_t encodePixelFormatModifier(uint64_t pixelFormatModifier, android::hardware::hidl_vec<uint8_t>* outPixelFormatModifier); |
| 469 | status_t decodePixelFormatModifier(const android::hardware::hidl_vec<uint8_t>& pixelFormatModifier, uint64_t* outPixelFormatModifier); |
| 470 | |
| 471 | status_t encodeUsage(uint64_t usage, android::hardware::hidl_vec<uint8_t>* outUsage); |
| 472 | status_t decodeUsage(const android::hardware::hidl_vec<uint8_t>& usage, uint64_t* outUsage); |
| 473 | |
| 474 | status_t encodeAllocationSize(uint64_t allocationSize, android::hardware::hidl_vec<uint8_t>* outAllocationSize); |
| 475 | status_t decodeAllocationSize(const android::hardware::hidl_vec<uint8_t>& allocationSize, uint64_t* outAllocationSize); |
| 476 | |
| 477 | status_t encodeProtectedContent(uint64_t protectedContent, android::hardware::hidl_vec<uint8_t>* outProtectedContent); |
| 478 | status_t decodeProtectedContent(const android::hardware::hidl_vec<uint8_t>& protectedContent, uint64_t* outProtectedContent); |
| 479 | |
| 480 | status_t encodeCompression(const aidl::android::hardware::graphics::common::ExtendableType& compression, android::hardware::hidl_vec<uint8_t>* outCompression); |
| 481 | status_t decodeCompression(const android::hardware::hidl_vec<uint8_t>& compression, aidl::android::hardware::graphics::common::ExtendableType* outCompression); |
| 482 | |
| 483 | status_t encodeInterlaced(const aidl::android::hardware::graphics::common::ExtendableType& interlaced, android::hardware::hidl_vec<uint8_t>* outInterlaced); |
| 484 | status_t decodeInterlaced(const android::hardware::hidl_vec<uint8_t>& interlaced, aidl::android::hardware::graphics::common::ExtendableType* outInterlaced); |
| 485 | |
| 486 | status_t encodeChromaSiting(const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting, android::hardware::hidl_vec<uint8_t>* outChromaSiting); |
| 487 | status_t decodeChromaSiting(const android::hardware::hidl_vec<uint8_t>& chromaSiting, aidl::android::hardware::graphics::common::ExtendableType* outChromaSiting); |
| 488 | |
| 489 | status_t encodePlaneLayouts(const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& planeLayouts, android::hardware::hidl_vec<uint8_t>* outPlaneLayouts); |
| 490 | status_t decodePlaneLayouts(const android::hardware::hidl_vec<uint8_t>& planeLayouts, std::vector<aidl::android::hardware::graphics::common::PlaneLayout>* outPlaneLayouts); |
| 491 | |
Marissa Wall | 019a7ee | 2020-02-10 11:43:19 -0800 | [diff] [blame] | 492 | status_t encodeCrop(const std::vector<aidl::android::hardware::graphics::common::Rect>& crop, android::hardware::hidl_vec<uint8_t>* outCrop); |
| 493 | status_t decodeCrop(const android::hardware::hidl_vec<uint8_t>& crop, std::vector<aidl::android::hardware::graphics::common::Rect>* outCrop); |
| 494 | |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 495 | status_t encodeDataspace(const aidl::android::hardware::graphics::common::Dataspace& dataspace, android::hardware::hidl_vec<uint8_t>* outDataspace); |
| 496 | status_t decodeDataspace(const android::hardware::hidl_vec<uint8_t>& dataspace, aidl::android::hardware::graphics::common::Dataspace* outDataspace); |
| 497 | |
| 498 | status_t encodeBlendMode(const aidl::android::hardware::graphics::common::BlendMode& blendMode, android::hardware::hidl_vec<uint8_t>* outBlendMode); |
| 499 | status_t decodeBlendMode(const android::hardware::hidl_vec<uint8_t>& blendMode, aidl::android::hardware::graphics::common::BlendMode* outBlendMode); |
| 500 | |
Marissa Wall | ef785e1 | 2019-12-12 14:26:59 -0800 | [diff] [blame] | 501 | status_t encodeSmpte2086( |
| 502 | const std::optional<aidl::android::hardware::graphics::common::Smpte2086>& smpte2086, |
| 503 | android::hardware::hidl_vec<uint8_t>* outSmpte2086); |
| 504 | status_t decodeSmpte2086( |
| 505 | const android::hardware::hidl_vec<uint8_t>& smpte2086, |
| 506 | std::optional<aidl::android::hardware::graphics::common::Smpte2086>* outSmpte2086); |
| 507 | |
| 508 | status_t encodeCta861_3( |
| 509 | const std::optional<aidl::android::hardware::graphics::common::Cta861_3>& cta861_3, |
| 510 | android::hardware::hidl_vec<uint8_t>* outCta861_3); |
| 511 | status_t decodeCta861_3( |
| 512 | const android::hardware::hidl_vec<uint8_t>& cta861_3, |
| 513 | std::optional<aidl::android::hardware::graphics::common::Cta861_3>* outCta861_3); |
| 514 | |
| 515 | status_t encodeSmpte2094_40(const std::optional<std::vector<uint8_t>>& smpte2094_40, |
| 516 | android::hardware::hidl_vec<uint8_t>* outSmpte2094_40); |
| 517 | status_t decodeSmpte2094_40(const android::hardware::hidl_vec<uint8_t>& smpte2094_40, |
| 518 | std::optional<std::vector<uint8_t>>* outSmpte2094_40); |
| 519 | |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 520 | /** |
Marissa Wall | b95c1ef | 2019-12-18 14:57:31 -0800 | [diff] [blame] | 521 | * The functions below can be used to encode and decode vendor metadata types. |
| 522 | */ |
| 523 | status_t encodeUint32( |
| 524 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 525 | uint32_t input, android::hardware::hidl_vec<uint8_t>* output); |
| 526 | status_t decodeUint32( |
| 527 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 528 | const android::hardware::hidl_vec<uint8_t>& input, uint32_t* output); |
| 529 | |
| 530 | status_t encodeInt32( |
| 531 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 532 | int32_t input, android::hardware::hidl_vec<uint8_t>* output); |
| 533 | status_t decodeInt32( |
| 534 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 535 | const android::hardware::hidl_vec<uint8_t>& input, int32_t* output); |
| 536 | |
| 537 | status_t encodeUint64( |
| 538 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 539 | uint64_t input, android::hardware::hidl_vec<uint8_t>* output); |
| 540 | status_t decodeUint64( |
| 541 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 542 | const android::hardware::hidl_vec<uint8_t>& input, uint64_t* output); |
| 543 | |
| 544 | status_t encodeInt64( |
| 545 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 546 | int64_t input, android::hardware::hidl_vec<uint8_t>* output); |
| 547 | status_t decodeInt64( |
| 548 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 549 | const android::hardware::hidl_vec<uint8_t>& input, int64_t* output); |
| 550 | |
| 551 | status_t encodeFloat( |
| 552 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 553 | float input, android::hardware::hidl_vec<uint8_t>* output); |
| 554 | status_t decodeFloat( |
| 555 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 556 | const android::hardware::hidl_vec<uint8_t>& input, float* output); |
| 557 | |
| 558 | status_t encodeDouble( |
| 559 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 560 | double input, android::hardware::hidl_vec<uint8_t>* output); |
| 561 | status_t decodeDouble( |
| 562 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 563 | const android::hardware::hidl_vec<uint8_t>& input, double* output); |
| 564 | |
| 565 | status_t encodeString( |
| 566 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 567 | const std::string& input, android::hardware::hidl_vec<uint8_t>* output); |
| 568 | status_t decodeString( |
| 569 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType, |
| 570 | const android::hardware::hidl_vec<uint8_t>& input, std::string* output); |
| 571 | |
| 572 | /** |
Marissa Wall | 22b2de1 | 2019-12-02 18:11:43 -0800 | [diff] [blame] | 573 | * The functions below can be used to parse extendable types. |
| 574 | */ |
| 575 | bool isStandardMetadataType( |
| 576 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); |
| 577 | bool isStandardCompression( |
| 578 | const aidl::android::hardware::graphics::common::ExtendableType& compression); |
| 579 | bool isStandardInterlaced( |
| 580 | const aidl::android::hardware::graphics::common::ExtendableType& interlaced); |
| 581 | bool isStandardChromaSiting( |
| 582 | const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); |
| 583 | bool isStandardPlaneLayoutComponentType( |
| 584 | const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); |
| 585 | |
| 586 | aidl::android::hardware::graphics::common::StandardMetadataType getStandardMetadataTypeValue( |
| 587 | const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType); |
| 588 | aidl::android::hardware::graphics::common::Compression getStandardCompressionValue( |
| 589 | const aidl::android::hardware::graphics::common::ExtendableType& compression); |
| 590 | aidl::android::hardware::graphics::common::Interlaced getStandardInterlacedValue( |
| 591 | const aidl::android::hardware::graphics::common::ExtendableType& interlaced); |
| 592 | aidl::android::hardware::graphics::common::ChromaSiting getStandardChromaSitingValue( |
| 593 | const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); |
| 594 | aidl::android::hardware::graphics::common::PlaneLayoutComponentType |
| 595 | getStandardPlaneLayoutComponentTypeValue( |
| 596 | const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); |
| 597 | |
| 598 | /** |
| 599 | * The functions below return string representations of ExtendableTypes |
| 600 | */ |
| 601 | std::string getCompressionName( |
| 602 | const aidl::android::hardware::graphics::common::ExtendableType& compression); |
| 603 | std::string getInterlacedName( |
| 604 | const aidl::android::hardware::graphics::common::ExtendableType& interlaced); |
| 605 | std::string getChromaSitingName( |
| 606 | const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting); |
| 607 | std::string getPlaneLayoutComponentTypeName( |
| 608 | const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType); |
| 609 | |
Marissa Wall | 4858652 | 2019-11-19 14:01:36 -0800 | [diff] [blame] | 610 | } // namespace gralloc4 |
| 611 | |
| 612 | } // namespace android |