xref: /aosp_15_r20/frameworks/native/include/android/display_luts.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker  * Copyright (C) 2024 The Android Open Source Project
3*38e8c45fSAndroid Build Coastguard Worker  *
4*38e8c45fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*38e8c45fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*38e8c45fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*38e8c45fSAndroid Build Coastguard Worker  *
8*38e8c45fSAndroid Build Coastguard Worker  *     http://www.apache.org/licenses/LICENSE-2.0
9*38e8c45fSAndroid Build Coastguard Worker  *
10*38e8c45fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*38e8c45fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*38e8c45fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38e8c45fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*38e8c45fSAndroid Build Coastguard Worker  * limitations under the License.
15*38e8c45fSAndroid Build Coastguard Worker  */
16*38e8c45fSAndroid Build Coastguard Worker 
17*38e8c45fSAndroid Build Coastguard Worker /**
18*38e8c45fSAndroid Build Coastguard Worker  * @addtogroup NativeActivity Native Activity
19*38e8c45fSAndroid Build Coastguard Worker  * @{
20*38e8c45fSAndroid Build Coastguard Worker  */
21*38e8c45fSAndroid Build Coastguard Worker 
22*38e8c45fSAndroid Build Coastguard Worker /**
23*38e8c45fSAndroid Build Coastguard Worker  * @file display_luts.h
24*38e8c45fSAndroid Build Coastguard Worker  */
25*38e8c45fSAndroid Build Coastguard Worker #pragma once
26*38e8c45fSAndroid Build Coastguard Worker 
27*38e8c45fSAndroid Build Coastguard Worker #include <inttypes.h>
28*38e8c45fSAndroid Build Coastguard Worker 
29*38e8c45fSAndroid Build Coastguard Worker __BEGIN_DECLS
30*38e8c45fSAndroid Build Coastguard Worker 
31*38e8c45fSAndroid Build Coastguard Worker /**
32*38e8c45fSAndroid Build Coastguard Worker  * The dimension of the lut
33*38e8c45fSAndroid Build Coastguard Worker  */
34*38e8c45fSAndroid Build Coastguard Worker enum ADisplayLuts_Dimension : int32_t {
35*38e8c45fSAndroid Build Coastguard Worker     ADISPLAYLUTS_ONE_DIMENSION = 1,
36*38e8c45fSAndroid Build Coastguard Worker     ADISPLAYLUTS_THREE_DIMENSION = 3,
37*38e8c45fSAndroid Build Coastguard Worker };
38*38e8c45fSAndroid Build Coastguard Worker typedef enum ADisplayLuts_Dimension ADisplayLuts_Dimension;
39*38e8c45fSAndroid Build Coastguard Worker 
40*38e8c45fSAndroid Build Coastguard Worker /**
41*38e8c45fSAndroid Build Coastguard Worker  * The sampling key used by the lut
42*38e8c45fSAndroid Build Coastguard Worker  */
43*38e8c45fSAndroid Build Coastguard Worker enum ADisplayLuts_SamplingKey : int32_t {
44*38e8c45fSAndroid Build Coastguard Worker     ADISPLAYLUTS_SAMPLINGKEY_RGB = 0,
45*38e8c45fSAndroid Build Coastguard Worker     ADISPLAYLUTS_SAMPLINGKEY_MAX_RGB = 1,
46*38e8c45fSAndroid Build Coastguard Worker     ADISPLAYLUTS_SAMPLINGKEY_CIE_Y = 2,
47*38e8c45fSAndroid Build Coastguard Worker };
48*38e8c45fSAndroid Build Coastguard Worker typedef enum ADisplayLuts_SamplingKey ADisplayLuts_SamplingKey;
49*38e8c45fSAndroid Build Coastguard Worker 
50*38e8c45fSAndroid Build Coastguard Worker /**
51*38e8c45fSAndroid Build Coastguard Worker  * Used to get and set display luts entry
52*38e8c45fSAndroid Build Coastguard Worker  */
53*38e8c45fSAndroid Build Coastguard Worker typedef struct ADisplayLutsEntry ADisplayLutsEntry;
54*38e8c45fSAndroid Build Coastguard Worker 
55*38e8c45fSAndroid Build Coastguard Worker /**
56*38e8c45fSAndroid Build Coastguard Worker  * Used to get and set display luts
57*38e8c45fSAndroid Build Coastguard Worker  */
58*38e8c45fSAndroid Build Coastguard Worker typedef struct ADisplayLuts ADisplayLuts;
59*38e8c45fSAndroid Build Coastguard Worker 
60*38e8c45fSAndroid Build Coastguard Worker /**
61*38e8c45fSAndroid Build Coastguard Worker  * Creates a \a ADisplayLutsEntry entry.
62*38e8c45fSAndroid Build Coastguard Worker  *
63*38e8c45fSAndroid Build Coastguard Worker  * You are responsible for mamanging the memory of the returned object.
64*38e8c45fSAndroid Build Coastguard Worker  * Always call \a ADisplayLutsEntry_destroy to release it after use.
65*38e8c45fSAndroid Build Coastguard Worker  *
66*38e8c45fSAndroid Build Coastguard Worker  * Functions like \a ADisplayLuts_set create their own copies of entries,
67*38e8c45fSAndroid Build Coastguard Worker  * therefore they don't take the ownership of the instance created by
68*38e8c45fSAndroid Build Coastguard Worker  * \a ADisplayLutsEntry_create.
69*38e8c45fSAndroid Build Coastguard Worker  *
70*38e8c45fSAndroid Build Coastguard Worker  * @param buffer The lut raw buffer. The function creates a copy of it and does not need to
71*38e8c45fSAndroid Build Coastguard Worker  * outlive the life of the ADisplayLutsEntry.
72*38e8c45fSAndroid Build Coastguard Worker  * @param length The length of lut raw buffer
73*38e8c45fSAndroid Build Coastguard Worker  * @param dimension The dimension of the lut. see \a ADisplayLuts_Dimension
74*38e8c45fSAndroid Build Coastguard Worker  * @param key The sampling key used by the lut. see \a ADisplayLuts_SamplingKey
75*38e8c45fSAndroid Build Coastguard Worker  * @return a new \a ADisplayLutsEntry instance.
76*38e8c45fSAndroid Build Coastguard Worker  */
77*38e8c45fSAndroid Build Coastguard Worker ADisplayLutsEntry* _Nonnull ADisplayLutsEntry_createEntry(float* _Nonnull buffer,
78*38e8c45fSAndroid Build Coastguard Worker     int32_t length, ADisplayLuts_Dimension dimension, ADisplayLuts_SamplingKey key)
79*38e8c45fSAndroid Build Coastguard Worker     __INTRODUCED_IN(36);
80*38e8c45fSAndroid Build Coastguard Worker 
81*38e8c45fSAndroid Build Coastguard Worker /**
82*38e8c45fSAndroid Build Coastguard Worker  * Destroy the \a ADisplayLutsEntry instance.
83*38e8c45fSAndroid Build Coastguard Worker  *
84*38e8c45fSAndroid Build Coastguard Worker  * @param entry The entry to be destroyed
85*38e8c45fSAndroid Build Coastguard Worker  */
86*38e8c45fSAndroid Build Coastguard Worker void ADisplayLutsEntry_destroy(ADisplayLutsEntry* _Nullable entry) __INTRODUCED_IN(36);
87*38e8c45fSAndroid Build Coastguard Worker 
88*38e8c45fSAndroid Build Coastguard Worker /**
89*38e8c45fSAndroid Build Coastguard Worker  * Gets the dimension of the entry.
90*38e8c45fSAndroid Build Coastguard Worker  *
91*38e8c45fSAndroid Build Coastguard Worker  * The function is only valid for the lifetime of the `entry`.
92*38e8c45fSAndroid Build Coastguard Worker  *
93*38e8c45fSAndroid Build Coastguard Worker  * @param entry The entry to query
94*38e8c45fSAndroid Build Coastguard Worker  * @return the dimension of the lut
95*38e8c45fSAndroid Build Coastguard Worker  */
96*38e8c45fSAndroid Build Coastguard Worker ADisplayLuts_Dimension ADisplayLutsEntry_getDimension(const ADisplayLutsEntry* _Nonnull entry)
97*38e8c45fSAndroid Build Coastguard Worker         __INTRODUCED_IN(36);
98*38e8c45fSAndroid Build Coastguard Worker 
99*38e8c45fSAndroid Build Coastguard Worker /**
100*38e8c45fSAndroid Build Coastguard Worker  * Gets the size for each dimension of the entry.
101*38e8c45fSAndroid Build Coastguard Worker  *
102*38e8c45fSAndroid Build Coastguard Worker  * The function is only valid for the lifetime of the `entry`.
103*38e8c45fSAndroid Build Coastguard Worker  *
104*38e8c45fSAndroid Build Coastguard Worker  * @param entry The entry to query
105*38e8c45fSAndroid Build Coastguard Worker  * @return the size of each dimension of the lut
106*38e8c45fSAndroid Build Coastguard Worker  */
107*38e8c45fSAndroid Build Coastguard Worker int32_t ADisplayLutsEntry_getSize(const ADisplayLutsEntry* _Nonnull entry)
108*38e8c45fSAndroid Build Coastguard Worker         __INTRODUCED_IN(36);
109*38e8c45fSAndroid Build Coastguard Worker 
110*38e8c45fSAndroid Build Coastguard Worker /**
111*38e8c45fSAndroid Build Coastguard Worker  * Gets the sampling key used by the entry.
112*38e8c45fSAndroid Build Coastguard Worker  *
113*38e8c45fSAndroid Build Coastguard Worker  * The function is only valid for the lifetime of the `entry`.
114*38e8c45fSAndroid Build Coastguard Worker  *
115*38e8c45fSAndroid Build Coastguard Worker  * @param entry The entry to query
116*38e8c45fSAndroid Build Coastguard Worker  * @return the sampling key used by the lut
117*38e8c45fSAndroid Build Coastguard Worker  */
118*38e8c45fSAndroid Build Coastguard Worker ADisplayLuts_SamplingKey ADisplayLutsEntry_getSamplingKey(const ADisplayLutsEntry* _Nonnull entry)
119*38e8c45fSAndroid Build Coastguard Worker         __INTRODUCED_IN(36);
120*38e8c45fSAndroid Build Coastguard Worker 
121*38e8c45fSAndroid Build Coastguard Worker /**
122*38e8c45fSAndroid Build Coastguard Worker  * Gets the lut buffer of the entry.
123*38e8c45fSAndroid Build Coastguard Worker  *
124*38e8c45fSAndroid Build Coastguard Worker  * The function is only valid for the lifetime of the `entry`.
125*38e8c45fSAndroid Build Coastguard Worker  *
126*38e8c45fSAndroid Build Coastguard Worker  * @param entry The entry to query
127*38e8c45fSAndroid Build Coastguard Worker  * @return a pointer to the raw lut buffer
128*38e8c45fSAndroid Build Coastguard Worker  */
129*38e8c45fSAndroid Build Coastguard Worker const float* _Nonnull ADisplayLutsEntry_getBuffer(const ADisplayLutsEntry* _Nonnull entry)
130*38e8c45fSAndroid Build Coastguard Worker         __INTRODUCED_IN(36);
131*38e8c45fSAndroid Build Coastguard Worker 
132*38e8c45fSAndroid Build Coastguard Worker /**
133*38e8c45fSAndroid Build Coastguard Worker  * Creates a \a ADisplayLuts instance.
134*38e8c45fSAndroid Build Coastguard Worker  *
135*38e8c45fSAndroid Build Coastguard Worker  * You are responsible for mamanging the memory of the returned object.
136*38e8c45fSAndroid Build Coastguard Worker  * Always call \a ADisplayLuts_destroy to release it after use. E.g., after calling
137*38e8c45fSAndroid Build Coastguard Worker  * the function \a ASurfaceTransaction_setLuts.
138*38e8c45fSAndroid Build Coastguard Worker  *
139*38e8c45fSAndroid Build Coastguard Worker  * @return a new \a ADisplayLuts instance
140*38e8c45fSAndroid Build Coastguard Worker  */
141*38e8c45fSAndroid Build Coastguard Worker ADisplayLuts* _Nonnull ADisplayLuts_create() __INTRODUCED_IN(36);
142*38e8c45fSAndroid Build Coastguard Worker 
143*38e8c45fSAndroid Build Coastguard Worker /**
144*38e8c45fSAndroid Build Coastguard Worker  * Sets Luts in order to be applied.
145*38e8c45fSAndroid Build Coastguard Worker  *
146*38e8c45fSAndroid Build Coastguard Worker  * The function accepts a single 1D Lut, or a single 3D Lut or both 1D and 3D Lut in order.
147*38e8c45fSAndroid Build Coastguard Worker  * And the function will replace any previously set lut(s).
148*38e8c45fSAndroid Build Coastguard Worker  * If you want to clear the previously set lut(s), set `entries` to be nullptr,
149*38e8c45fSAndroid Build Coastguard Worker  * and `numEntries` will be internally ignored.
150*38e8c45fSAndroid Build Coastguard Worker  *
151*38e8c45fSAndroid Build Coastguard Worker  * @param luts the pointer of the \a ADisplayLuts instance
152*38e8c45fSAndroid Build Coastguard Worker  * @param entries the pointer of the array of lut entries to be applied
153*38e8c45fSAndroid Build Coastguard Worker  * @param numEntries the number of lut entries. The value should be either 1 or 2.
154*38e8c45fSAndroid Build Coastguard Worker  */
155*38e8c45fSAndroid Build Coastguard Worker void ADisplayLuts_setEntries(ADisplayLuts* _Nonnull luts,
156*38e8c45fSAndroid Build Coastguard Worker         ADisplayLutsEntry* _Nullable *_Nullable entries, int32_t numEntries) __INTRODUCED_IN(36);
157*38e8c45fSAndroid Build Coastguard Worker 
158*38e8c45fSAndroid Build Coastguard Worker /**
159*38e8c45fSAndroid Build Coastguard Worker  * Deletes the \a ADisplayLuts instance.
160*38e8c45fSAndroid Build Coastguard Worker  *
161*38e8c45fSAndroid Build Coastguard Worker  * @param luts The luts to be destroyed
162*38e8c45fSAndroid Build Coastguard Worker  */
163*38e8c45fSAndroid Build Coastguard Worker void ADisplayLuts_destroy(ADisplayLuts* _Nullable luts) __INTRODUCED_IN(36);
164*38e8c45fSAndroid Build Coastguard Worker 
165*38e8c45fSAndroid Build Coastguard Worker __END_DECLS
166*38e8c45fSAndroid Build Coastguard Worker 
167*38e8c45fSAndroid Build Coastguard Worker /** @} */