graphics.h revision 5c9be402a4d934b678fe6609b6cc4d488d6ddaa4
1/* 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 20__BEGIN_DECLS 21 22/* 23 * If the HAL needs to create service threads to handle graphics related 24 * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority 25 * if they can block the main rendering thread in any way. 26 * 27 * the priority of the current thread can be set with: 28 * 29 * #include <sys/resource.h> 30 * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); 31 * 32 */ 33 34#define HAL_PRIORITY_URGENT_DISPLAY (-8) 35 36/** 37 * pixel format definitions 38 */ 39 40enum { 41 HAL_PIXEL_FORMAT_RGBA_8888 = 1, 42 HAL_PIXEL_FORMAT_RGBX_8888 = 2, 43 HAL_PIXEL_FORMAT_RGB_888 = 3, 44 HAL_PIXEL_FORMAT_RGB_565 = 4, 45 HAL_PIXEL_FORMAT_BGRA_8888 = 5, 46 HAL_PIXEL_FORMAT_RGBA_5551 = 6, 47 HAL_PIXEL_FORMAT_RGBA_4444 = 7, 48 49 /* 0x8 - 0xFF range unavailable */ 50 51 /* 52 * 0x100 - 0x1FF 53 * 54 * This range is reserved for pixel formats that are specific to the HAL 55 * implementation. Implementations can use any value in this range to 56 * communicate video pixel formats between their HAL modules. These formats 57 * must not have an alpha channel. Additionally, an EGLimage created from a 58 * gralloc buffer of one of these formats must be supported for use with the 59 * GL_OES_EGL_image_external OpenGL ES extension. 60 */ 61 62 /* 63 * Android YUV format: 64 * 65 * This format is exposed outside of the HAL to software decoders and 66 * applications. EGLImageKHR must support it in conjunction with the 67 * OES_EGL_image_external extension. 68 * 69 * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed 70 * by (W/2) x (H/2) Cr and Cb planes. 71 * 72 * This format assumes 73 * - an even width 74 * - an even height 75 * - a horizontal stride multiple of 16 pixels 76 * - a vertical stride equal to the height 77 * 78 * y_size = stride * height 79 * c_size = ALIGN(stride/2, 16) * height/2 80 * size = y_size + c_size * 2 81 * cr_offset = y_size 82 * cb_offset = y_size + c_size 83 * 84 */ 85 HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar 86 87 88 89 /* Legacy formats (deprecated), used by ImageFormat.java */ 90 HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 91 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 92 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 93}; 94 95 96/** 97 * Transformation definitions 98 * 99 * IMPORTANT NOTE: 100 * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. 101 * 102 */ 103 104enum { 105 /* flip source image horizontally (around the vertical axis) */ 106 HAL_TRANSFORM_FLIP_H = 0x01, 107 /* flip source image vertically (around the horizontal axis)*/ 108 HAL_TRANSFORM_FLIP_V = 0x02, 109 /* rotate source image 90 degrees clockwise */ 110 HAL_TRANSFORM_ROT_90 = 0x04, 111 /* rotate source image 180 degrees */ 112 HAL_TRANSFORM_ROT_180 = 0x03, 113 /* rotate source image 270 degrees clockwise */ 114 HAL_TRANSFORM_ROT_270 = 0x07, 115}; 116 117__END_DECLS 118 119#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ 120