Roman Stratiienko | 1cbaaf9 | 2022-02-21 10:52:18 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 <cstdint> |
Roman Stratiienko | 7c8cc4e | 2025-01-25 22:41:53 +0200 | [diff] [blame] | 20 | #include <memory> |
Roman Stratiienko | 1cbaaf9 | 2022-02-21 10:52:18 +0200 | [diff] [blame] | 21 | |
| 22 | constexpr int kBufferMaxPlanes = 4; |
| 23 | |
Roman Stratiienko | 4b2cc48 | 2022-02-21 14:53:58 +0200 | [diff] [blame] | 24 | enum class BufferColorSpace : int32_t { |
| 25 | kUndefined, |
| 26 | kItuRec601, |
| 27 | kItuRec709, |
| 28 | kItuRec2020, |
| 29 | }; |
| 30 | |
| 31 | enum class BufferSampleRange : int32_t { |
| 32 | kUndefined, |
| 33 | kFullRange, |
| 34 | kLimitedRange, |
| 35 | }; |
| 36 | |
| 37 | enum class BufferBlendMode : int32_t { |
| 38 | kUndefined, |
| 39 | kNone, |
| 40 | kPreMult, |
| 41 | kCoverage, |
| 42 | }; |
| 43 | |
Roman Stratiienko | 7c8cc4e | 2025-01-25 22:41:53 +0200 | [diff] [blame] | 44 | class PrimeFdsSharedBase { |
| 45 | public: |
| 46 | virtual ~PrimeFdsSharedBase() = default; |
| 47 | }; |
| 48 | |
Roman Stratiienko | 1cbaaf9 | 2022-02-21 10:52:18 +0200 | [diff] [blame] | 49 | struct BufferInfo { |
| 50 | uint32_t width; |
| 51 | uint32_t height; |
| 52 | uint32_t format; /* DRM_FORMAT_* from drm_fourcc.h */ |
| 53 | uint32_t pitches[kBufferMaxPlanes]; |
| 54 | uint32_t offsets[kBufferMaxPlanes]; |
| 55 | /* sizes[] is used only by mapper@4 metadata getter for internal purposes */ |
| 56 | uint32_t sizes[kBufferMaxPlanes]; |
| 57 | int prime_fds[kBufferMaxPlanes]; |
| 58 | uint64_t modifiers[kBufferMaxPlanes]; |
Roman Stratiienko | 4b2cc48 | 2022-02-21 14:53:58 +0200 | [diff] [blame] | 59 | |
| 60 | BufferColorSpace color_space; |
| 61 | BufferSampleRange sample_range; |
| 62 | BufferBlendMode blend_mode; |
Roman Stratiienko | 7c8cc4e | 2025-01-25 22:41:53 +0200 | [diff] [blame] | 63 | |
| 64 | /* prime_fds field require valid file descriptors. While their lifecycle is |
| 65 | * managed elsewhere. The shared_ptr is used to ensure that the fds are not |
| 66 | * closed while the BufferInfo is still in use. */ |
| 67 | std::shared_ptr<PrimeFdsSharedBase> fds_shared; |
Roman Stratiienko | 1cbaaf9 | 2022-02-21 10:52:18 +0200 | [diff] [blame] | 68 | }; |