blob: 8d12754d79943131b048fabf862c36704b33eb1d [file] [log] [blame]
Marissa Wall48586522019-11-19 14:01:36 -08001/*
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 Wallef785e12019-12-12 14:26:59 -080020#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 Wall48586522019-11-19 14:01:36 -080023#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 Murphy048552f2019-12-17 19:58:45 +000027#include <aidl/android/hardware/graphics/common/PlaneLayoutComponentType.h>
Jeongik Chadb26a6b2020-04-08 21:46:00 +090028#include <aidl/android/hardware/graphics/common/Rect.h>
Marissa Wallef785e12019-12-12 14:26:59 -080029#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 Wall48586522019-11-19 14:01:36 -080032#include <android/hardware/graphics/mapper/4.0/IMapper.h>
33
Steven Morelanda694b462020-01-16 16:38:44 -080034namespace android {
35
Marissa Wall85d423a2019-12-15 13:42:02 -080036/**
37 * Define equality operators for Stable AIDL types.
38 */
39inline 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
44inline 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
49inline 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
66inline 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
71inline 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
88inline 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 Wall019a7ee2020-02-10 11:43:19 -080093inline 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
106inline 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 Wall85d423a2019-12-15 13:42:02 -0800111inline 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 Wall85d423a2019-12-15 13:42:02 -0800137 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
148inline 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
153inline 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
166inline 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
171inline 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
182inline 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
187inline 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
210inline 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
215inline 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
226inline 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 Wall48586522019-11-19 14:01:36 -0800231namespace gralloc4 {
232
Marissa Wall48586522019-11-19 14:01:36 -0800233#define GRALLOC4_STANDARD_METADATA_TYPE "android.hardware.graphics.common.StandardMetadataType"
Marissa Wall22b2de12019-12-02 18:11:43 -0800234#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 Wall48586522019-11-19 14:01:36 -0800239
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 */
245static 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
249static 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
253static 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
257static 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
261static 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
265static 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
269static 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
273static 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
277static 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
281static 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
285static 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
289static 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
293static 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
297static 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
301static 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 Wall019a7ee2020-02-10 11:43:19 -0800305static 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 Wall48586522019-11-19 14:01:36 -0800309static 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
313static 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 Wallef785e12019-12-12 14:26:59 -0800317static 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
322static 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
327static 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 Wall48586522019-11-19 14:01:36 -0800333/*---------------------------------------------------------------------------------------------*/
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 Wall22b2de12019-12-02 18:11:43 -0800339static 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 Wall48586522019-11-19 14:01:36 -0800342
Marissa Wall22b2de12019-12-02 18:11:43 -0800343static 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 Wall48586522019-11-19 14:01:36 -0800348
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 Wall22b2de12019-12-02 18:11:43 -0800355static 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 Wall48586522019-11-19 14:01:36 -0800358
Marissa Wall22b2de12019-12-02 18:11:43 -0800359static 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 Wall48586522019-11-19 14:01:36 -0800362
Marissa Wall22b2de12019-12-02 18:11:43 -0800363static 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 Wall48586522019-11-19 14:01:36 -0800366
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 Wall22b2de12019-12-02 18:11:43 -0800373static 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 Wall48586522019-11-19 14:01:36 -0800376
Marissa Wall22b2de12019-12-02 18:11:43 -0800377static 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 Wall48586522019-11-19 14:01:36 -0800380
Marissa Wall22b2de12019-12-02 18:11:43 -0800381static 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 Wall48586522019-11-19 14:01:36 -0800386
Marissa Wall22b2de12019-12-02 18:11:43 -0800387static 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 Wall48586522019-11-19 14:01:36 -0800392
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 Wall22b2de12019-12-02 18:11:43 -0800399static 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 Wall48586522019-11-19 14:01:36 -0800403
Marissa Wall22b2de12019-12-02 18:11:43 -0800404static 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 Wall48586522019-11-19 14:01:36 -0800408
Marissa Wall22b2de12019-12-02 18:11:43 -0800409static 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 Wall48586522019-11-19 14:01:36 -0800413
Marissa Wall22b2de12019-12-02 18:11:43 -0800414static 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 Wall48586522019-11-19 14:01:36 -0800418
Marissa Wall22b2de12019-12-02 18:11:43 -0800419static 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 Wall48586522019-11-19 14:01:36 -0800423
Marissa Wall22b2de12019-12-02 18:11:43 -0800424static 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 Wall48586522019-11-19 14:01:36 -0800428
Marissa Wall22b2de12019-12-02 18:11:43 -0800429static 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 Wall48586522019-11-19 14:01:36 -0800433
434/*---------------------------------------------------------------------------------------------*/
435
436/**
Marissa Walld5e9a612020-01-13 13:57:42 -0800437 * The functions below encode and decode BufferDescriptorInfo into a byte stream.
438 */
439status_t encodeBufferDescriptorInfo(const android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo& bufferDescriptorInfo, android::hardware::hidl_vec<uint8_t>* outBufferDescriptorInfo);
440status_t decodeBufferDescriptorInfo(const android::hardware::hidl_vec<uint8_t>& bufferDescriptorInfo, android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo* outBufferDescriptorInfo);
441
442/**
Marissa Wall48586522019-11-19 14:01:36 -0800443 * 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 */
447status_t encodeBufferId(uint64_t bufferId, android::hardware::hidl_vec<uint8_t>* outBufferId);
448status_t decodeBufferId(const android::hardware::hidl_vec<uint8_t>& bufferId, uint64_t* outBufferId);
449
450status_t encodeName(const std::string& name, android::hardware::hidl_vec<uint8_t>* outName);
451status_t decodeName(const android::hardware::hidl_vec<uint8_t>& name, std::string* outName);
452
453status_t encodeWidth(uint64_t width, android::hardware::hidl_vec<uint8_t>* outWidth);
454status_t decodeWidth(const android::hardware::hidl_vec<uint8_t>& width, uint64_t* outWidth);
455
456status_t encodeHeight(uint64_t height, android::hardware::hidl_vec<uint8_t>* outHeight);
457status_t decodeHeight(const android::hardware::hidl_vec<uint8_t>& height, uint64_t* outHeight);
458
459status_t encodeLayerCount(uint64_t layerCount, android::hardware::hidl_vec<uint8_t>* outLayerCount);
460status_t decodeLayerCount(const android::hardware::hidl_vec<uint8_t>& layerCount, uint64_t* outLayerCount);
461
462status_t encodePixelFormatRequested(const hardware::graphics::common::V1_2::PixelFormat& pixelFormatRequested, android::hardware::hidl_vec<uint8_t>* outPixelFormatRequested);
463status_t decodePixelFormatRequested(const android::hardware::hidl_vec<uint8_t>& pixelFormatRequested, hardware::graphics::common::V1_2::PixelFormat* outPixelFormatRequested);
464
465status_t encodePixelFormatFourCC(uint32_t pixelFormatFourCC, android::hardware::hidl_vec<uint8_t>* outPixelFormatFourCC);
466status_t decodePixelFormatFourCC(const android::hardware::hidl_vec<uint8_t>& pixelFormatFourCC, uint32_t* outPixelFormatFourCC);
467
468status_t encodePixelFormatModifier(uint64_t pixelFormatModifier, android::hardware::hidl_vec<uint8_t>* outPixelFormatModifier);
469status_t decodePixelFormatModifier(const android::hardware::hidl_vec<uint8_t>& pixelFormatModifier, uint64_t* outPixelFormatModifier);
470
471status_t encodeUsage(uint64_t usage, android::hardware::hidl_vec<uint8_t>* outUsage);
472status_t decodeUsage(const android::hardware::hidl_vec<uint8_t>& usage, uint64_t* outUsage);
473
474status_t encodeAllocationSize(uint64_t allocationSize, android::hardware::hidl_vec<uint8_t>* outAllocationSize);
475status_t decodeAllocationSize(const android::hardware::hidl_vec<uint8_t>& allocationSize, uint64_t* outAllocationSize);
476
477status_t encodeProtectedContent(uint64_t protectedContent, android::hardware::hidl_vec<uint8_t>* outProtectedContent);
478status_t decodeProtectedContent(const android::hardware::hidl_vec<uint8_t>& protectedContent, uint64_t* outProtectedContent);
479
480status_t encodeCompression(const aidl::android::hardware::graphics::common::ExtendableType& compression, android::hardware::hidl_vec<uint8_t>* outCompression);
481status_t decodeCompression(const android::hardware::hidl_vec<uint8_t>& compression, aidl::android::hardware::graphics::common::ExtendableType* outCompression);
482
483status_t encodeInterlaced(const aidl::android::hardware::graphics::common::ExtendableType& interlaced, android::hardware::hidl_vec<uint8_t>* outInterlaced);
484status_t decodeInterlaced(const android::hardware::hidl_vec<uint8_t>& interlaced, aidl::android::hardware::graphics::common::ExtendableType* outInterlaced);
485
486status_t encodeChromaSiting(const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting, android::hardware::hidl_vec<uint8_t>* outChromaSiting);
487status_t decodeChromaSiting(const android::hardware::hidl_vec<uint8_t>& chromaSiting, aidl::android::hardware::graphics::common::ExtendableType* outChromaSiting);
488
489status_t encodePlaneLayouts(const std::vector<aidl::android::hardware::graphics::common::PlaneLayout>& planeLayouts, android::hardware::hidl_vec<uint8_t>* outPlaneLayouts);
490status_t decodePlaneLayouts(const android::hardware::hidl_vec<uint8_t>& planeLayouts, std::vector<aidl::android::hardware::graphics::common::PlaneLayout>* outPlaneLayouts);
491
Marissa Wall019a7ee2020-02-10 11:43:19 -0800492status_t encodeCrop(const std::vector<aidl::android::hardware::graphics::common::Rect>& crop, android::hardware::hidl_vec<uint8_t>* outCrop);
493status_t decodeCrop(const android::hardware::hidl_vec<uint8_t>& crop, std::vector<aidl::android::hardware::graphics::common::Rect>* outCrop);
494
Marissa Wall48586522019-11-19 14:01:36 -0800495status_t encodeDataspace(const aidl::android::hardware::graphics::common::Dataspace& dataspace, android::hardware::hidl_vec<uint8_t>* outDataspace);
496status_t decodeDataspace(const android::hardware::hidl_vec<uint8_t>& dataspace, aidl::android::hardware::graphics::common::Dataspace* outDataspace);
497
498status_t encodeBlendMode(const aidl::android::hardware::graphics::common::BlendMode& blendMode, android::hardware::hidl_vec<uint8_t>* outBlendMode);
499status_t decodeBlendMode(const android::hardware::hidl_vec<uint8_t>& blendMode, aidl::android::hardware::graphics::common::BlendMode* outBlendMode);
500
Marissa Wallef785e12019-12-12 14:26:59 -0800501status_t encodeSmpte2086(
502 const std::optional<aidl::android::hardware::graphics::common::Smpte2086>& smpte2086,
503 android::hardware::hidl_vec<uint8_t>* outSmpte2086);
504status_t decodeSmpte2086(
505 const android::hardware::hidl_vec<uint8_t>& smpte2086,
506 std::optional<aidl::android::hardware::graphics::common::Smpte2086>* outSmpte2086);
507
508status_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);
511status_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
515status_t encodeSmpte2094_40(const std::optional<std::vector<uint8_t>>& smpte2094_40,
516 android::hardware::hidl_vec<uint8_t>* outSmpte2094_40);
517status_t decodeSmpte2094_40(const android::hardware::hidl_vec<uint8_t>& smpte2094_40,
518 std::optional<std::vector<uint8_t>>* outSmpte2094_40);
519
Marissa Wall22b2de12019-12-02 18:11:43 -0800520/**
Marissa Wallb95c1ef2019-12-18 14:57:31 -0800521 * The functions below can be used to encode and decode vendor metadata types.
522 */
523status_t encodeUint32(
524 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType,
525 uint32_t input, android::hardware::hidl_vec<uint8_t>* output);
526status_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
530status_t encodeInt32(
531 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType,
532 int32_t input, android::hardware::hidl_vec<uint8_t>* output);
533status_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
537status_t encodeUint64(
538 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType,
539 uint64_t input, android::hardware::hidl_vec<uint8_t>* output);
540status_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
544status_t encodeInt64(
545 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType,
546 int64_t input, android::hardware::hidl_vec<uint8_t>* output);
547status_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
551status_t encodeFloat(
552 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType,
553 float input, android::hardware::hidl_vec<uint8_t>* output);
554status_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
558status_t encodeDouble(
559 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType,
560 double input, android::hardware::hidl_vec<uint8_t>* output);
561status_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
565status_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);
568status_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 Wall22b2de12019-12-02 18:11:43 -0800573 * The functions below can be used to parse extendable types.
574 */
575bool isStandardMetadataType(
576 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType);
577bool isStandardCompression(
578 const aidl::android::hardware::graphics::common::ExtendableType& compression);
579bool isStandardInterlaced(
580 const aidl::android::hardware::graphics::common::ExtendableType& interlaced);
581bool isStandardChromaSiting(
582 const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting);
583bool isStandardPlaneLayoutComponentType(
584 const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType);
585
586aidl::android::hardware::graphics::common::StandardMetadataType getStandardMetadataTypeValue(
587 const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType& metadataType);
588aidl::android::hardware::graphics::common::Compression getStandardCompressionValue(
589 const aidl::android::hardware::graphics::common::ExtendableType& compression);
590aidl::android::hardware::graphics::common::Interlaced getStandardInterlacedValue(
591 const aidl::android::hardware::graphics::common::ExtendableType& interlaced);
592aidl::android::hardware::graphics::common::ChromaSiting getStandardChromaSitingValue(
593 const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting);
594aidl::android::hardware::graphics::common::PlaneLayoutComponentType
595getStandardPlaneLayoutComponentTypeValue(
596 const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType);
597
598/**
599 * The functions below return string representations of ExtendableTypes
600 */
601std::string getCompressionName(
602 const aidl::android::hardware::graphics::common::ExtendableType& compression);
603std::string getInterlacedName(
604 const aidl::android::hardware::graphics::common::ExtendableType& interlaced);
605std::string getChromaSitingName(
606 const aidl::android::hardware::graphics::common::ExtendableType& chromaSiting);
607std::string getPlaneLayoutComponentTypeName(
608 const aidl::android::hardware::graphics::common::ExtendableType& planeLayoutComponentType);
609
Marissa Wall48586522019-11-19 14:01:36 -0800610} // namespace gralloc4
611
612} // namespace android