Path: blob/21.2-virgl/include/android_stub/system/graphics.h
4547 views
/*1* Copyright (C) 2011 The Android Open Source Project2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/1516#ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H17#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H1819#include <stddef.h>20#include <stdint.h>2122/*23* Some of the enums are now defined in HIDL in hardware/interfaces and are24* generated.25*/26#include "graphics-base.h"27#include "graphics-sw.h"2829#ifdef __cplusplus30extern "C" {31#endif3233/* for compatibility */34#define HAL_PIXEL_FORMAT_YCbCr_420_888 HAL_PIXEL_FORMAT_YCBCR_420_88835#define HAL_PIXEL_FORMAT_YCbCr_422_SP HAL_PIXEL_FORMAT_YCBCR_422_SP36#define HAL_PIXEL_FORMAT_YCrCb_420_SP HAL_PIXEL_FORMAT_YCRCB_420_SP37#define HAL_PIXEL_FORMAT_YCbCr_422_I HAL_PIXEL_FORMAT_YCBCR_422_I38typedef android_pixel_format_t android_pixel_format;39typedef android_transform_t android_transform;40typedef android_dataspace_t android_dataspace;41typedef android_color_mode_t android_color_mode;42typedef android_color_transform_t android_color_transform;43typedef android_hdr_t android_hdr;4445/*46* If the HAL needs to create service threads to handle graphics related47* tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority48* if they can block the main rendering thread in any way.49*50* the priority of the current thread can be set with:51*52* #include <sys/resource.h>53* setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);54*55*/5657#define HAL_PRIORITY_URGENT_DISPLAY (-8)5859/*60* Structure for describing YCbCr formats for consumption by applications.61* This is used with HAL_PIXEL_FORMAT_YCbCr_*_888.62*63* Buffer chroma subsampling is defined in the format.64* e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0.65*66* Buffers must have a 8 bit depth.67*68* y, cb, and cr point to the first byte of their respective planes.69*70* Stride describes the distance in bytes from the first value of one row of71* the image to the first value of the next row. It includes the width of the72* image plus padding.73* ystride is the stride of the luma plane.74* cstride is the stride of the chroma planes.75*76* chroma_step is the distance in bytes from one chroma pixel value to the77* next. This is 2 bytes for semiplanar (because chroma values are interleaved78* and each chroma value is one byte) and 1 for planar.79*/8081struct android_ycbcr {82void *y;83void *cb;84void *cr;85size_t ystride;86size_t cstride;87size_t chroma_step;8889/** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */90uint32_t reserved[8];91};9293/*94* Structures for describing flexible YUVA/RGBA formats for consumption by95* applications. Such flexible formats contain a plane for each component (e.g.96* red, green, blue), where each plane is laid out in a grid-like pattern97* occupying unique byte addresses and with consistent byte offsets between98* neighboring pixels.99*100* The android_flex_layout structure is used with any pixel format that can be101* represented by it, such as:102* - HAL_PIXEL_FORMAT_YCbCr_*_888103* - HAL_PIXEL_FORMAT_FLEX_RGB*_888104* - HAL_PIXEL_FORMAT_RGB[AX]_888[8],BGRA_8888,RGB_888105* - HAL_PIXEL_FORMAT_YV12,Y8,Y16,YCbCr_422_SP/I,YCrCb_420_SP106* - even implementation defined formats that can be represented by107* the structures108*109* Vertical increment (aka. row increment or stride) describes the distance in110* bytes from the first pixel of one row to the first pixel of the next row111* (below) for the component plane. This can be negative.112*113* Horizontal increment (aka. column or pixel increment) describes the distance114* in bytes from one pixel to the next pixel (to the right) on the same row for115* the component plane. This can be negative.116*117* Each plane can be subsampled either vertically or horizontally by118* a power-of-two factor.119*120* The bit-depth of each component can be arbitrary, as long as the pixels are121* laid out on whole bytes, in native byte-order, using the most significant122* bits of each unit.123*/124125typedef enum android_flex_component {126/* luma */127FLEX_COMPONENT_Y = 1 << 0,128/* chroma blue */129FLEX_COMPONENT_Cb = 1 << 1,130/* chroma red */131FLEX_COMPONENT_Cr = 1 << 2,132133/* red */134FLEX_COMPONENT_R = 1 << 10,135/* green */136FLEX_COMPONENT_G = 1 << 11,137/* blue */138FLEX_COMPONENT_B = 1 << 12,139140/* alpha */141FLEX_COMPONENT_A = 1 << 30,142} android_flex_component_t;143144typedef struct android_flex_plane {145/* pointer to the first byte of the top-left pixel of the plane. */146uint8_t *top_left;147148android_flex_component_t component;149150/* bits allocated for the component in each pixel. Must be a positive151multiple of 8. */152int32_t bits_per_component;153/* number of the most significant bits used in the format for this154component. Must be between 1 and bits_per_component, inclusive. */155int32_t bits_used;156157/* horizontal increment */158int32_t h_increment;159/* vertical increment */160int32_t v_increment;161/* horizontal subsampling. Must be a positive power of 2. */162int32_t h_subsampling;163/* vertical subsampling. Must be a positive power of 2. */164int32_t v_subsampling;165} android_flex_plane_t;166167typedef enum android_flex_format {168/* not a flexible format */169FLEX_FORMAT_INVALID = 0x0,170FLEX_FORMAT_Y = FLEX_COMPONENT_Y,171FLEX_FORMAT_YCbCr = FLEX_COMPONENT_Y | FLEX_COMPONENT_Cb | FLEX_COMPONENT_Cr,172FLEX_FORMAT_YCbCrA = FLEX_FORMAT_YCbCr | FLEX_COMPONENT_A,173FLEX_FORMAT_RGB = FLEX_COMPONENT_R | FLEX_COMPONENT_G | FLEX_COMPONENT_B,174FLEX_FORMAT_RGBA = FLEX_FORMAT_RGB | FLEX_COMPONENT_A,175} android_flex_format_t;176177typedef struct android_flex_layout {178/* the kind of flexible format */179android_flex_format_t format;180181/* number of planes; 0 for FLEX_FORMAT_INVALID */182uint32_t num_planes;183/* a plane for each component; ordered in increasing component value order.184E.g. FLEX_FORMAT_RGBA maps 0 -> R, 1 -> G, etc.185Can be NULL for FLEX_FORMAT_INVALID */186android_flex_plane_t *planes;187} android_flex_layout_t;188189/**190* Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB191* with dataSpace value of HAL_DATASPACE_DEPTH.192* When locking a native buffer of the above format and dataSpace value,193* the vaddr pointer can be cast to this structure.194*195* A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y,196* z) represents a measured point's position, with the coordinate system defined197* by the data source. Confidence represents the estimated likelihood that this198* measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f ==199* 100% confidence.200*201* num_points is the number of points in the list202*203* xyz_points is the flexible array of floating-point values.204* It contains (num_points) * 4 floats.205*206* For example:207* android_depth_points d = get_depth_buffer();208* struct {209* float x; float y; float z; float confidence;210* } firstPoint, lastPoint;211*212* firstPoint.x = d.xyzc_points[0];213* firstPoint.y = d.xyzc_points[1];214* firstPoint.z = d.xyzc_points[2];215* firstPoint.confidence = d.xyzc_points[3];216* lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0];217* lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1];218* lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2];219* lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3];220*/221222struct android_depth_points {223uint32_t num_points;224225/** reserved for future use, set to 0 by gralloc's (*lock)() */226uint32_t reserved[8];227228#if defined(__clang__)229#pragma clang diagnostic push230#pragma clang diagnostic ignored "-Wc99-extensions"231#endif232float xyzc_points[];233#if defined(__clang__)234#pragma clang diagnostic pop235#endif236};237238/**239* These structures are used to define the reference display's240* capabilities for HDR content. Display engine can use this241* to better tone map content to user's display.242* Color is defined in CIE XYZ coordinates243*/244struct android_xy_color {245float x;246float y;247};248249struct android_smpte2086_metadata {250struct android_xy_color displayPrimaryRed;251struct android_xy_color displayPrimaryGreen;252struct android_xy_color displayPrimaryBlue;253struct android_xy_color whitePoint;254float maxLuminance;255float minLuminance;256};257258struct android_cta861_3_metadata {259float maxContentLightLevel;260float maxFrameAverageLightLevel;261};262263#ifdef __cplusplus264}265#endif266267#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */268269270