blob: db4c53e31c337abae00c90852b22a082d8d0f955 [file] [log] [blame]
Roman Stratiienko1cbaaf92022-02-21 10:52:18 +02001/*
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 Stratiienko7c8cc4e2025-01-25 22:41:53 +020020#include <memory>
Roman Stratiienko1cbaaf92022-02-21 10:52:18 +020021
22constexpr int kBufferMaxPlanes = 4;
23
Roman Stratiienko4b2cc482022-02-21 14:53:58 +020024enum class BufferColorSpace : int32_t {
25 kUndefined,
26 kItuRec601,
27 kItuRec709,
28 kItuRec2020,
29};
30
31enum class BufferSampleRange : int32_t {
32 kUndefined,
33 kFullRange,
34 kLimitedRange,
35};
36
37enum class BufferBlendMode : int32_t {
38 kUndefined,
39 kNone,
40 kPreMult,
41 kCoverage,
42};
43
Roman Stratiienko7c8cc4e2025-01-25 22:41:53 +020044class PrimeFdsSharedBase {
45 public:
46 virtual ~PrimeFdsSharedBase() = default;
47};
48
Roman Stratiienko1cbaaf92022-02-21 10:52:18 +020049struct 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 Stratiienko4b2cc482022-02-21 14:53:58 +020059
60 BufferColorSpace color_space;
61 BufferSampleRange sample_range;
62 BufferBlendMode blend_mode;
Roman Stratiienko7c8cc4e2025-01-25 22:41:53 +020063
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 Stratiienko1cbaaf92022-02-21 10:52:18 +020068};