blob: 24e2bfb207243838a14336b7fb8af05ce8bd44ed [file] [log] [blame]
Iliyan Malchev66ea3572011-05-01 14:05:30 -07001/*
2 * Copyright (C) 2011 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#ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
18#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H
19
Mathias Agopianc9b06952011-08-11 22:35:31 -070020#ifdef __cplusplus
21extern "C" {
22#endif
Iliyan Malchev66ea3572011-05-01 14:05:30 -070023
Mathias Agopian5c9be402011-08-09 18:55:44 -070024/*
25 * If the HAL needs to create service threads to handle graphics related
26 * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority
27 * if they can block the main rendering thread in any way.
28 *
29 * the priority of the current thread can be set with:
30 *
31 * #include <sys/resource.h>
32 * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
33 *
34 */
35
36#define HAL_PRIORITY_URGENT_DISPLAY (-8)
37
Iliyan Malchev66ea3572011-05-01 14:05:30 -070038/**
39 * pixel format definitions
40 */
41
42enum {
43 HAL_PIXEL_FORMAT_RGBA_8888 = 1,
44 HAL_PIXEL_FORMAT_RGBX_8888 = 2,
45 HAL_PIXEL_FORMAT_RGB_888 = 3,
46 HAL_PIXEL_FORMAT_RGB_565 = 4,
47 HAL_PIXEL_FORMAT_BGRA_8888 = 5,
48 HAL_PIXEL_FORMAT_RGBA_5551 = 6,
49 HAL_PIXEL_FORMAT_RGBA_4444 = 7,
50
51 /* 0x8 - 0xFF range unavailable */
52
53 /*
54 * 0x100 - 0x1FF
55 *
56 * This range is reserved for pixel formats that are specific to the HAL
57 * implementation. Implementations can use any value in this range to
58 * communicate video pixel formats between their HAL modules. These formats
59 * must not have an alpha channel. Additionally, an EGLimage created from a
60 * gralloc buffer of one of these formats must be supported for use with the
61 * GL_OES_EGL_image_external OpenGL ES extension.
62 */
63
64 /*
65 * Android YUV format:
66 *
Jamie Gennisda1a1f62011-05-18 14:42:46 -070067 * This format is exposed outside of the HAL to software decoders and
68 * applications. EGLImageKHR must support it in conjunction with the
Iliyan Malchev66ea3572011-05-01 14:05:30 -070069 * OES_EGL_image_external extension.
70 *
Jamie Gennisda1a1f62011-05-18 14:42:46 -070071 * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
Iliyan Malchev66ea3572011-05-01 14:05:30 -070072 * by (W/2) x (H/2) Cr and Cb planes.
73 *
74 * This format assumes
75 * - an even width
76 * - an even height
77 * - a horizontal stride multiple of 16 pixels
78 * - a vertical stride equal to the height
79 *
80 * y_size = stride * height
Jamie Gennis185b3002012-04-30 12:50:38 -070081 * c_stride = ALIGN(stride/2, 16)
82 * c_size = c_stride * height/2
Iliyan Malchev66ea3572011-05-01 14:05:30 -070083 * size = y_size + c_size * 2
84 * cr_offset = y_size
85 * cb_offset = y_size + c_size
86 *
87 */
88 HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar
89
Eino-Ville Talvala0a851542012-04-10 15:10:50 -070090 /*
91 * Android RAW sensor format:
92 *
93 * This format is exposed outside of the HAL to applications.
94 *
95 * RAW_SENSOR is a single-channel 16-bit format, typically representing raw
96 * Bayer-pattern images from an image sensor, with minimal processing.
97 *
98 * The exact pixel layout of the data in the buffer is sensor-dependent, and
99 * needs to be queried from the camera device.
100 *
101 * Generally, not all 16 bits are used; more common values are 10 or 12
102 * bits. All parameters to interpret the raw data (black and white points,
103 * color space, etc) must be queried from the camera device.
104 *
105 * This format assumes
106 * - an even width
107 * - an even height
108 * - a horizontal stride multiple of 16 pixels (32 bytes).
109 */
110 HAL_PIXEL_FORMAT_RAW_SENSOR = 0x20,
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700111
112 /* Legacy formats (deprecated), used by ImageFormat.java */
113 HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16
114 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21
115 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2
116};
117
118
119/**
120 * Transformation definitions
121 *
122 * IMPORTANT NOTE:
123 * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}.
124 *
125 */
126
127enum {
128 /* flip source image horizontally (around the vertical axis) */
129 HAL_TRANSFORM_FLIP_H = 0x01,
130 /* flip source image vertically (around the horizontal axis)*/
131 HAL_TRANSFORM_FLIP_V = 0x02,
132 /* rotate source image 90 degrees clockwise */
133 HAL_TRANSFORM_ROT_90 = 0x04,
134 /* rotate source image 180 degrees */
135 HAL_TRANSFORM_ROT_180 = 0x03,
136 /* rotate source image 270 degrees clockwise */
137 HAL_TRANSFORM_ROT_270 = 0x07,
138};
139
Mathias Agopianc9b06952011-08-11 22:35:31 -0700140#ifdef __cplusplus
141}
142#endif
Iliyan Malchev66ea3572011-05-01 14:05:30 -0700143
144#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */