1+ /*
2+ * Copyright (C) 2024 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+ /**
18+ * @addtogroup NativeActivity Native Activity
19+ * @{
20+ */
21+
22+ /**
23+ * @file display_luts.h
24+ */
25+ #pragma once
26+
27+ #include <inttypes.h>
28+
29+ __BEGIN_DECLS
30+
31+ /**
32+ * The dimension of the lut
33+ */
34+ enum ADisplayLuts_Dimension : int32_t {
35+ ADISPLAYLUTS_ONE_DIMENSION = 1 ,
36+ ADISPLAYLUTS_THREE_DIMENSION = 3 ,
37+ };
38+
39+ /**
40+ * The sampling key used by the lut
41+ */
42+ enum ADisplayLuts_SamplingKey : int32_t {
43+ ADISPLAYLUTS_SAMPLINGKEY_RGB = 0 ,
44+ ADISPLAYLUTS_SAMPLINGKEY_MAX_RGB = 1 ,
45+ };
46+
47+ /**
48+ * Used to get and set display luts entry
49+ */
50+ typedef struct ADisplayLutsEntry ADisplayLutsEntry ;
51+
52+ /**
53+ * Used to get and set display luts
54+ */
55+ typedef struct ADisplayLuts ADisplayLuts ;
56+
57+ /**
58+ * Creates a \a ADisplayLutsEntry entry.
59+ *
60+ * You are responsible for mamanging the memory of the returned object.
61+ * Always call \a ADisplayLutsEntry_destroy to release it after use.
62+ *
63+ * Functions like \a ADisplayLuts_set create their own copies of entries,
64+ * therefore they don't take the ownership of the instance created by
65+ * \a ADisplayLutsEntry_create.
66+ *
67+ * @param buffer The lut raw buffer. The function creates a copy of it and does not need to
68+ * outlive the life of the ADisplayLutsEntry.
69+ * @param length The length of lut raw buffer
70+ * @param dimension The dimension of the lut. see \a ADisplayLuts_Dimension
71+ * @param key The sampling key used by the lut. see \a ADisplayLuts_SamplingKey
72+ * @return a new \a ADisplayLutsEntry instance.
73+ */
74+ ADisplayLutsEntry * _Nonnull ADisplayLutsEntry_createEntry (float * _Nonnull buffer ,
75+ int32_t length , int32_t dimension , int32_t key ) __INTRODUCED_IN (36 );
76+
77+ /**
78+ * Destroy the \a ADisplayLutsEntry instance.
79+ *
80+ * @param entry The entry to be destroyed
81+ */
82+ void ADisplayLutsEntry_destroy (ADisplayLutsEntry * _Nullable entry ) __INTRODUCED_IN (36 );
83+
84+ /**
85+ * Gets the dimension of the entry.
86+ *
87+ * The function is only valid for the lifetime of the `entry`.
88+ *
89+ * @param entry The entry to query
90+ * @return the dimension of the lut
91+ */
92+ ADisplayLuts_Dimension ADisplayLutsEntry_getDimension (const ADisplayLutsEntry * _Nonnull entry )
93+ __INTRODUCED_IN (36 );
94+
95+ /**
96+ * Gets the size for each dimension of the entry.
97+ *
98+ * The function is only valid for the lifetime of the `entry`.
99+ *
100+ * @param entry The entry to query
101+ * @return the size of each dimension of the lut
102+ */
103+ int32_t ADisplayLutsEntry_getSize (const ADisplayLutsEntry * _Nonnull entry )
104+ __INTRODUCED_IN (36 );
105+
106+ /**
107+ * Gets the sampling key used by the entry.
108+ *
109+ * The function is only valid for the lifetime of the `entry`.
110+ *
111+ * @param entry The entry to query
112+ * @return the sampling key used by the lut
113+ */
114+ ADisplayLuts_SamplingKey ADisplayLutsEntry_getSamplingKey (const ADisplayLutsEntry * _Nonnull entry )
115+ __INTRODUCED_IN (36 );
116+
117+ /**
118+ * Gets the lut buffer of the entry.
119+ *
120+ * The function is only valid for the lifetime of the `entry`.
121+ *
122+ * @param entry The entry to query
123+ * @return a pointer to the raw lut buffer
124+ */
125+ const float * _Nonnull ADisplayLutsEntry_getBuffer (const ADisplayLutsEntry * _Nonnull entry )
126+ __INTRODUCED_IN (36 );
127+
128+ /**
129+ * Creates a \a ADisplayLuts instance.
130+ *
131+ * You are responsible for mamanging the memory of the returned object.
132+ * Always call \a ADisplayLuts_destroy to release it after use. E.g., after calling
133+ * the function \a ASurfaceTransaction_setLuts.
134+ *
135+ * @return a new \a ADisplayLuts instance
136+ */
137+ ADisplayLuts * _Nonnull ADisplayLuts_create () __INTRODUCED_IN (36 );
138+
139+ /**
140+ * Sets Luts in order to be applied.
141+ *
142+ * The function accepts a single 1D Lut, or a single 3D Lut or both 1D and 3D Lut in order.
143+ * And the function will replace any previously set lut(s).
144+ * If you want to clear the previously set lut(s), set `entries` to be nullptr,
145+ * and `numEntries` will be internally ignored.
146+ *
147+ * @param luts the pointer of the \a ADisplayLuts instance
148+ * @param entries the pointer of the array of lut entries to be applied
149+ * @param numEntries the number of lut entries. The value should be either 1 or 2.
150+ */
151+ void ADisplayLuts_setEntries (ADisplayLuts * _Nonnull luts ,
152+ ADisplayLutsEntry * _Nullable * _Nullable entries , int32_t numEntries ) __INTRODUCED_IN (36 );
153+
154+ /**
155+ * Deletes the \a ADisplayLuts instance.
156+ *
157+ * @param luts The luts to be destroyed
158+ */
159+ void ADisplayLuts_destroy (ADisplayLuts * _Nullable luts ) __INTRODUCED_IN (36 );
160+
161+ __END_DECLS
162+
163+ /** @} */
0 commit comments