xref: /aosp_15_r20/external/mesa3d/include/android_stub/system/graphics.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /*
2*61046927SAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*61046927SAndroid Build Coastguard Worker  *
4*61046927SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*61046927SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*61046927SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*61046927SAndroid Build Coastguard Worker  *
8*61046927SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*61046927SAndroid Build Coastguard Worker  *
10*61046927SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*61046927SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*61046927SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*61046927SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*61046927SAndroid Build Coastguard Worker  * limitations under the License.
15*61046927SAndroid Build Coastguard Worker  */
16*61046927SAndroid Build Coastguard Worker 
17*61046927SAndroid Build Coastguard Worker #ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
18*61046927SAndroid Build Coastguard Worker #define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
19*61046927SAndroid Build Coastguard Worker 
20*61046927SAndroid Build Coastguard Worker #include <stddef.h>
21*61046927SAndroid Build Coastguard Worker #include <stdint.h>
22*61046927SAndroid Build Coastguard Worker 
23*61046927SAndroid Build Coastguard Worker /*
24*61046927SAndroid Build Coastguard Worker  * Some of the enums are now defined in HIDL in hardware/interfaces and are
25*61046927SAndroid Build Coastguard Worker  * generated.
26*61046927SAndroid Build Coastguard Worker  */
27*61046927SAndroid Build Coastguard Worker #include "graphics-base.h"
28*61046927SAndroid Build Coastguard Worker #include "graphics-sw.h"
29*61046927SAndroid Build Coastguard Worker 
30*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
31*61046927SAndroid Build Coastguard Worker extern "C" {
32*61046927SAndroid Build Coastguard Worker #endif
33*61046927SAndroid Build Coastguard Worker 
34*61046927SAndroid Build Coastguard Worker /* for compatibility */
35*61046927SAndroid Build Coastguard Worker #define HAL_PIXEL_FORMAT_YCbCr_420_888 HAL_PIXEL_FORMAT_YCBCR_420_888
36*61046927SAndroid Build Coastguard Worker #define HAL_PIXEL_FORMAT_YCbCr_422_SP HAL_PIXEL_FORMAT_YCBCR_422_SP
37*61046927SAndroid Build Coastguard Worker #define HAL_PIXEL_FORMAT_YCrCb_420_SP HAL_PIXEL_FORMAT_YCRCB_420_SP
38*61046927SAndroid Build Coastguard Worker #define HAL_PIXEL_FORMAT_YCbCr_422_I HAL_PIXEL_FORMAT_YCBCR_422_I
39*61046927SAndroid Build Coastguard Worker typedef android_pixel_format_t android_pixel_format;
40*61046927SAndroid Build Coastguard Worker typedef android_transform_t android_transform;
41*61046927SAndroid Build Coastguard Worker typedef android_dataspace_t android_dataspace;
42*61046927SAndroid Build Coastguard Worker typedef android_color_mode_t android_color_mode;
43*61046927SAndroid Build Coastguard Worker typedef android_color_transform_t android_color_transform;
44*61046927SAndroid Build Coastguard Worker typedef android_hdr_t android_hdr;
45*61046927SAndroid Build Coastguard Worker 
46*61046927SAndroid Build Coastguard Worker /*
47*61046927SAndroid Build Coastguard Worker  * If the HAL needs to create service threads to handle graphics related
48*61046927SAndroid Build Coastguard Worker  * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority
49*61046927SAndroid Build Coastguard Worker  * if they can block the main rendering thread in any way.
50*61046927SAndroid Build Coastguard Worker  *
51*61046927SAndroid Build Coastguard Worker  * the priority of the current thread can be set with:
52*61046927SAndroid Build Coastguard Worker  *
53*61046927SAndroid Build Coastguard Worker  *      #include <sys/resource.h>
54*61046927SAndroid Build Coastguard Worker  *      setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
55*61046927SAndroid Build Coastguard Worker  *
56*61046927SAndroid Build Coastguard Worker  */
57*61046927SAndroid Build Coastguard Worker 
58*61046927SAndroid Build Coastguard Worker #define HAL_PRIORITY_URGENT_DISPLAY     (-8)
59*61046927SAndroid Build Coastguard Worker 
60*61046927SAndroid Build Coastguard Worker /*
61*61046927SAndroid Build Coastguard Worker  * Structure for describing YCbCr formats for consumption by applications.
62*61046927SAndroid Build Coastguard Worker  * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888.
63*61046927SAndroid Build Coastguard Worker  *
64*61046927SAndroid Build Coastguard Worker  * Buffer chroma subsampling is defined in the format.
65*61046927SAndroid Build Coastguard Worker  * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0.
66*61046927SAndroid Build Coastguard Worker  *
67*61046927SAndroid Build Coastguard Worker  * Buffers must have a 8 bit depth.
68*61046927SAndroid Build Coastguard Worker  *
69*61046927SAndroid Build Coastguard Worker  * y, cb, and cr point to the first byte of their respective planes.
70*61046927SAndroid Build Coastguard Worker  *
71*61046927SAndroid Build Coastguard Worker  * Stride describes the distance in bytes from the first value of one row of
72*61046927SAndroid Build Coastguard Worker  * the image to the first value of the next row.  It includes the width of the
73*61046927SAndroid Build Coastguard Worker  * image plus padding.
74*61046927SAndroid Build Coastguard Worker  * ystride is the stride of the luma plane.
75*61046927SAndroid Build Coastguard Worker  * cstride is the stride of the chroma planes.
76*61046927SAndroid Build Coastguard Worker  *
77*61046927SAndroid Build Coastguard Worker  * chroma_step is the distance in bytes from one chroma pixel value to the
78*61046927SAndroid Build Coastguard Worker  * next.  This is 2 bytes for semiplanar (because chroma values are interleaved
79*61046927SAndroid Build Coastguard Worker  * and each chroma value is one byte) and 1 for planar.
80*61046927SAndroid Build Coastguard Worker  */
81*61046927SAndroid Build Coastguard Worker 
82*61046927SAndroid Build Coastguard Worker struct android_ycbcr {
83*61046927SAndroid Build Coastguard Worker     void *y;
84*61046927SAndroid Build Coastguard Worker     void *cb;
85*61046927SAndroid Build Coastguard Worker     void *cr;
86*61046927SAndroid Build Coastguard Worker     size_t ystride;
87*61046927SAndroid Build Coastguard Worker     size_t cstride;
88*61046927SAndroid Build Coastguard Worker     size_t chroma_step;
89*61046927SAndroid Build Coastguard Worker 
90*61046927SAndroid Build Coastguard Worker     /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */
91*61046927SAndroid Build Coastguard Worker     uint32_t reserved[8];
92*61046927SAndroid Build Coastguard Worker };
93*61046927SAndroid Build Coastguard Worker 
94*61046927SAndroid Build Coastguard Worker /*
95*61046927SAndroid Build Coastguard Worker  * Structures for describing flexible YUVA/RGBA formats for consumption by
96*61046927SAndroid Build Coastguard Worker  * applications. Such flexible formats contain a plane for each component (e.g.
97*61046927SAndroid Build Coastguard Worker  * red, green, blue), where each plane is laid out in a grid-like pattern
98*61046927SAndroid Build Coastguard Worker  * occupying unique byte addresses and with consistent byte offsets between
99*61046927SAndroid Build Coastguard Worker  * neighboring pixels.
100*61046927SAndroid Build Coastguard Worker  *
101*61046927SAndroid Build Coastguard Worker  * The android_flex_layout structure is used with any pixel format that can be
102*61046927SAndroid Build Coastguard Worker  * represented by it, such as:
103*61046927SAndroid Build Coastguard Worker  *  - HAL_PIXEL_FORMAT_YCbCr_*_888
104*61046927SAndroid Build Coastguard Worker  *  - HAL_PIXEL_FORMAT_FLEX_RGB*_888
105*61046927SAndroid Build Coastguard Worker  *  - HAL_PIXEL_FORMAT_RGB[AX]_888[8],BGRA_8888,RGB_888
106*61046927SAndroid Build Coastguard Worker  *  - HAL_PIXEL_FORMAT_YV12,Y8,Y16,YCbCr_422_SP/I,YCrCb_420_SP
107*61046927SAndroid Build Coastguard Worker  *  - even implementation defined formats that can be represented by
108*61046927SAndroid Build Coastguard Worker  *    the structures
109*61046927SAndroid Build Coastguard Worker  *
110*61046927SAndroid Build Coastguard Worker  * Vertical increment (aka. row increment or stride) describes the distance in
111*61046927SAndroid Build Coastguard Worker  * bytes from the first pixel of one row to the first pixel of the next row
112*61046927SAndroid Build Coastguard Worker  * (below) for the component plane. This can be negative.
113*61046927SAndroid Build Coastguard Worker  *
114*61046927SAndroid Build Coastguard Worker  * Horizontal increment (aka. column or pixel increment) describes the distance
115*61046927SAndroid Build Coastguard Worker  * in bytes from one pixel to the next pixel (to the right) on the same row for
116*61046927SAndroid Build Coastguard Worker  * the component plane. This can be negative.
117*61046927SAndroid Build Coastguard Worker  *
118*61046927SAndroid Build Coastguard Worker  * Each plane can be subsampled either vertically or horizontally by
119*61046927SAndroid Build Coastguard Worker  * a power-of-two factor.
120*61046927SAndroid Build Coastguard Worker  *
121*61046927SAndroid Build Coastguard Worker  * The bit-depth of each component can be arbitrary, as long as the pixels are
122*61046927SAndroid Build Coastguard Worker  * laid out on whole bytes, in native byte-order, using the most significant
123*61046927SAndroid Build Coastguard Worker  * bits of each unit.
124*61046927SAndroid Build Coastguard Worker  */
125*61046927SAndroid Build Coastguard Worker 
126*61046927SAndroid Build Coastguard Worker typedef enum android_flex_component {
127*61046927SAndroid Build Coastguard Worker     /* luma */
128*61046927SAndroid Build Coastguard Worker     FLEX_COMPONENT_Y = 1 << 0,
129*61046927SAndroid Build Coastguard Worker     /* chroma blue */
130*61046927SAndroid Build Coastguard Worker     FLEX_COMPONENT_Cb = 1 << 1,
131*61046927SAndroid Build Coastguard Worker     /* chroma red */
132*61046927SAndroid Build Coastguard Worker     FLEX_COMPONENT_Cr = 1 << 2,
133*61046927SAndroid Build Coastguard Worker 
134*61046927SAndroid Build Coastguard Worker     /* red */
135*61046927SAndroid Build Coastguard Worker     FLEX_COMPONENT_R = 1 << 10,
136*61046927SAndroid Build Coastguard Worker     /* green */
137*61046927SAndroid Build Coastguard Worker     FLEX_COMPONENT_G = 1 << 11,
138*61046927SAndroid Build Coastguard Worker     /* blue */
139*61046927SAndroid Build Coastguard Worker     FLEX_COMPONENT_B = 1 << 12,
140*61046927SAndroid Build Coastguard Worker 
141*61046927SAndroid Build Coastguard Worker     /* alpha */
142*61046927SAndroid Build Coastguard Worker     FLEX_COMPONENT_A = 1 << 30,
143*61046927SAndroid Build Coastguard Worker } android_flex_component_t;
144*61046927SAndroid Build Coastguard Worker 
145*61046927SAndroid Build Coastguard Worker typedef struct android_flex_plane {
146*61046927SAndroid Build Coastguard Worker     /* pointer to the first byte of the top-left pixel of the plane. */
147*61046927SAndroid Build Coastguard Worker     uint8_t *top_left;
148*61046927SAndroid Build Coastguard Worker 
149*61046927SAndroid Build Coastguard Worker     android_flex_component_t component;
150*61046927SAndroid Build Coastguard Worker 
151*61046927SAndroid Build Coastguard Worker     /* bits allocated for the component in each pixel. Must be a positive
152*61046927SAndroid Build Coastguard Worker        multiple of 8. */
153*61046927SAndroid Build Coastguard Worker     int32_t bits_per_component;
154*61046927SAndroid Build Coastguard Worker     /* number of the most significant bits used in the format for this
155*61046927SAndroid Build Coastguard Worker        component. Must be between 1 and bits_per_component, inclusive. */
156*61046927SAndroid Build Coastguard Worker     int32_t bits_used;
157*61046927SAndroid Build Coastguard Worker 
158*61046927SAndroid Build Coastguard Worker     /* horizontal increment */
159*61046927SAndroid Build Coastguard Worker     int32_t h_increment;
160*61046927SAndroid Build Coastguard Worker     /* vertical increment */
161*61046927SAndroid Build Coastguard Worker     int32_t v_increment;
162*61046927SAndroid Build Coastguard Worker     /* horizontal subsampling. Must be a positive power of 2. */
163*61046927SAndroid Build Coastguard Worker     int32_t h_subsampling;
164*61046927SAndroid Build Coastguard Worker     /* vertical subsampling. Must be a positive power of 2. */
165*61046927SAndroid Build Coastguard Worker     int32_t v_subsampling;
166*61046927SAndroid Build Coastguard Worker } android_flex_plane_t;
167*61046927SAndroid Build Coastguard Worker 
168*61046927SAndroid Build Coastguard Worker typedef enum android_flex_format {
169*61046927SAndroid Build Coastguard Worker     /* not a flexible format */
170*61046927SAndroid Build Coastguard Worker     FLEX_FORMAT_INVALID = 0x0,
171*61046927SAndroid Build Coastguard Worker     FLEX_FORMAT_Y = FLEX_COMPONENT_Y,
172*61046927SAndroid Build Coastguard Worker     FLEX_FORMAT_YCbCr = FLEX_COMPONENT_Y | FLEX_COMPONENT_Cb | FLEX_COMPONENT_Cr,
173*61046927SAndroid Build Coastguard Worker     FLEX_FORMAT_YCbCrA = FLEX_FORMAT_YCbCr | FLEX_COMPONENT_A,
174*61046927SAndroid Build Coastguard Worker     FLEX_FORMAT_RGB = FLEX_COMPONENT_R | FLEX_COMPONENT_G | FLEX_COMPONENT_B,
175*61046927SAndroid Build Coastguard Worker     FLEX_FORMAT_RGBA = FLEX_FORMAT_RGB | FLEX_COMPONENT_A,
176*61046927SAndroid Build Coastguard Worker } android_flex_format_t;
177*61046927SAndroid Build Coastguard Worker 
178*61046927SAndroid Build Coastguard Worker typedef struct android_flex_layout {
179*61046927SAndroid Build Coastguard Worker     /* the kind of flexible format */
180*61046927SAndroid Build Coastguard Worker     android_flex_format_t format;
181*61046927SAndroid Build Coastguard Worker 
182*61046927SAndroid Build Coastguard Worker     /* number of planes; 0 for FLEX_FORMAT_INVALID */
183*61046927SAndroid Build Coastguard Worker     uint32_t num_planes;
184*61046927SAndroid Build Coastguard Worker     /* a plane for each component; ordered in increasing component value order.
185*61046927SAndroid Build Coastguard Worker        E.g. FLEX_FORMAT_RGBA maps 0 -> R, 1 -> G, etc.
186*61046927SAndroid Build Coastguard Worker        Can be NULL for FLEX_FORMAT_INVALID */
187*61046927SAndroid Build Coastguard Worker     android_flex_plane_t *planes;
188*61046927SAndroid Build Coastguard Worker } android_flex_layout_t;
189*61046927SAndroid Build Coastguard Worker 
190*61046927SAndroid Build Coastguard Worker /**
191*61046927SAndroid Build Coastguard Worker  * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB
192*61046927SAndroid Build Coastguard Worker  * with dataSpace value of HAL_DATASPACE_DEPTH.
193*61046927SAndroid Build Coastguard Worker  * When locking a native buffer of the above format and dataSpace value,
194*61046927SAndroid Build Coastguard Worker  * the vaddr pointer can be cast to this structure.
195*61046927SAndroid Build Coastguard Worker  *
196*61046927SAndroid Build Coastguard Worker  * A variable-length list of (x,y,z, confidence) 3D points, as floats.  (x, y,
197*61046927SAndroid Build Coastguard Worker  * z) represents a measured point's position, with the coordinate system defined
198*61046927SAndroid Build Coastguard Worker  * by the data source.  Confidence represents the estimated likelihood that this
199*61046927SAndroid Build Coastguard Worker  * measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f ==
200*61046927SAndroid Build Coastguard Worker  * 100% confidence.
201*61046927SAndroid Build Coastguard Worker  *
202*61046927SAndroid Build Coastguard Worker  * num_points is the number of points in the list
203*61046927SAndroid Build Coastguard Worker  *
204*61046927SAndroid Build Coastguard Worker  * xyz_points is the flexible array of floating-point values.
205*61046927SAndroid Build Coastguard Worker  *   It contains (num_points) * 4 floats.
206*61046927SAndroid Build Coastguard Worker  *
207*61046927SAndroid Build Coastguard Worker  *   For example:
208*61046927SAndroid Build Coastguard Worker  *     android_depth_points d = get_depth_buffer();
209*61046927SAndroid Build Coastguard Worker  *     struct {
210*61046927SAndroid Build Coastguard Worker  *       float x; float y; float z; float confidence;
211*61046927SAndroid Build Coastguard Worker  *     } firstPoint, lastPoint;
212*61046927SAndroid Build Coastguard Worker  *
213*61046927SAndroid Build Coastguard Worker  *     firstPoint.x = d.xyzc_points[0];
214*61046927SAndroid Build Coastguard Worker  *     firstPoint.y = d.xyzc_points[1];
215*61046927SAndroid Build Coastguard Worker  *     firstPoint.z = d.xyzc_points[2];
216*61046927SAndroid Build Coastguard Worker  *     firstPoint.confidence = d.xyzc_points[3];
217*61046927SAndroid Build Coastguard Worker  *     lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0];
218*61046927SAndroid Build Coastguard Worker  *     lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1];
219*61046927SAndroid Build Coastguard Worker  *     lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2];
220*61046927SAndroid Build Coastguard Worker  *     lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3];
221*61046927SAndroid Build Coastguard Worker  */
222*61046927SAndroid Build Coastguard Worker 
223*61046927SAndroid Build Coastguard Worker struct android_depth_points {
224*61046927SAndroid Build Coastguard Worker     uint32_t num_points;
225*61046927SAndroid Build Coastguard Worker 
226*61046927SAndroid Build Coastguard Worker     /** reserved for future use, set to 0 by gralloc's (*lock)() */
227*61046927SAndroid Build Coastguard Worker     uint32_t reserved[8];
228*61046927SAndroid Build Coastguard Worker 
229*61046927SAndroid Build Coastguard Worker #if defined(__clang__)
230*61046927SAndroid Build Coastguard Worker #pragma clang diagnostic push
231*61046927SAndroid Build Coastguard Worker #pragma clang diagnostic ignored "-Wc99-extensions"
232*61046927SAndroid Build Coastguard Worker #endif
233*61046927SAndroid Build Coastguard Worker     float xyzc_points[];
234*61046927SAndroid Build Coastguard Worker #if defined(__clang__)
235*61046927SAndroid Build Coastguard Worker #pragma clang diagnostic pop
236*61046927SAndroid Build Coastguard Worker #endif
237*61046927SAndroid Build Coastguard Worker };
238*61046927SAndroid Build Coastguard Worker 
239*61046927SAndroid Build Coastguard Worker /**
240*61046927SAndroid Build Coastguard Worker   * These structures are used to define the reference display's
241*61046927SAndroid Build Coastguard Worker   * capabilities for HDR content. Display engine can use this
242*61046927SAndroid Build Coastguard Worker   * to better tone map content to user's display.
243*61046927SAndroid Build Coastguard Worker   * Color is defined in CIE XYZ coordinates
244*61046927SAndroid Build Coastguard Worker   */
245*61046927SAndroid Build Coastguard Worker struct android_xy_color {
246*61046927SAndroid Build Coastguard Worker     float x;
247*61046927SAndroid Build Coastguard Worker     float y;
248*61046927SAndroid Build Coastguard Worker };
249*61046927SAndroid Build Coastguard Worker 
250*61046927SAndroid Build Coastguard Worker struct android_smpte2086_metadata {
251*61046927SAndroid Build Coastguard Worker     struct android_xy_color displayPrimaryRed;
252*61046927SAndroid Build Coastguard Worker     struct android_xy_color displayPrimaryGreen;
253*61046927SAndroid Build Coastguard Worker     struct android_xy_color displayPrimaryBlue;
254*61046927SAndroid Build Coastguard Worker     struct android_xy_color whitePoint;
255*61046927SAndroid Build Coastguard Worker     float maxLuminance;
256*61046927SAndroid Build Coastguard Worker     float minLuminance;
257*61046927SAndroid Build Coastguard Worker };
258*61046927SAndroid Build Coastguard Worker 
259*61046927SAndroid Build Coastguard Worker struct android_cta861_3_metadata {
260*61046927SAndroid Build Coastguard Worker     float maxContentLightLevel;
261*61046927SAndroid Build Coastguard Worker     float maxFrameAverageLightLevel;
262*61046927SAndroid Build Coastguard Worker };
263*61046927SAndroid Build Coastguard Worker 
264*61046927SAndroid Build Coastguard Worker #ifdef __cplusplus
265*61046927SAndroid Build Coastguard Worker }
266*61046927SAndroid Build Coastguard Worker #endif
267*61046927SAndroid Build Coastguard Worker 
268*61046927SAndroid Build Coastguard Worker #endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */
269