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