The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2008 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 ANDROID_BLIT_HARDWARE_H |
| 18 | #define ANDROID_BLIT_HARDWARE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #if __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| 27 | /******************************************************************************/ |
| 28 | |
| 29 | /* supported pixel-formats. these must be compatible with |
| 30 | * graphics/PixelFormat.java, ui/PixelFormat.h, pixelflinger/format.h |
| 31 | */ |
| 32 | |
| 33 | enum |
| 34 | { |
| 35 | COPYBIT_RGBA_8888 = 1, |
| 36 | COPYBIT_RGB_565 = 4, |
| 37 | COPYBIT_RGBA_5551 = 6, |
| 38 | COPYBIT_RGBA_4444 = 7, |
| 39 | COPYBIT_YCbCr_422_SP = 0x10, |
| 40 | COPYBIT_YCbCr_420_SP = 0x11 |
| 41 | }; |
| 42 | |
| 43 | /* name for copybit_set_parameter */ |
| 44 | enum |
| 45 | { |
| 46 | /* rotation of the source image in degrees (0 to 359) */ |
| 47 | COPYBIT_ROTATION_DEG = 1, |
| 48 | /* plane alpha value */ |
| 49 | COPYBIT_PLANE_ALPHA = 2, |
| 50 | /* enable or disable dithering */ |
| 51 | COPYBIT_DITHER = 3, |
| 52 | /* transformation applied (this is a superset of COPYBIT_ROTATION_DEG) */ |
| 53 | COPYBIT_TRANSFORM = 4, |
| 54 | }; |
| 55 | |
| 56 | /* values for copybit_set_parameter(COPYBIT_TRANSFORM) */ |
| 57 | enum { |
| 58 | /* flip source image horizontally */ |
| 59 | COPYBIT_TRANSFORM_FLIP_H = 0x01, |
| 60 | /* flip source image vertically */ |
| 61 | COPYBIT_TRANSFORM_FLIP_V = 0x02, |
| 62 | /* rotate source image 90 degres */ |
| 63 | COPYBIT_TRANSFORM_ROT_90 = 0x04, |
| 64 | /* rotate source image 180 degres */ |
| 65 | COPYBIT_TRANSFORM_ROT_180 = 0x03, |
| 66 | /* rotate source image 270 degres */ |
| 67 | COPYBIT_TRANSFORM_ROT_270 = 0x07, |
| 68 | }; |
| 69 | |
| 70 | /* enable/disable value copybit_set_parameter */ |
| 71 | enum { |
| 72 | COPYBIT_DISABLE = 0, |
| 73 | COPYBIT_ENABLE = 1 |
| 74 | }; |
| 75 | |
| 76 | /* use get() to query static informations about the hardware */ |
| 77 | enum { |
| 78 | /* Maximum amount of minification supported by the hardware*/ |
| 79 | COPYBIT_MINIFICATION_LIMIT = 1, |
| 80 | /* Maximum amount of magnification supported by the hardware */ |
| 81 | COPYBIT_MAGNIFICATION_LIMIT = 2, |
| 82 | /* Number of fractional bits support by the scaling engine */ |
| 83 | COPYBIT_SCALING_FRAC_BITS = 3, |
| 84 | /* Supported rotation step in degres. */ |
| 85 | COPYBIT_ROTATION_STEP_DEG = 4, |
| 86 | }; |
| 87 | |
| 88 | struct copybit_image_t { |
| 89 | uint32_t w; |
| 90 | uint32_t h; |
| 91 | int32_t format; |
| 92 | uint32_t offset; |
| 93 | void* base; |
| 94 | int fd; |
| 95 | }; |
| 96 | |
| 97 | |
| 98 | struct copybit_rect_t { |
| 99 | int l; |
| 100 | int t; |
| 101 | int r; |
| 102 | int b; |
| 103 | }; |
| 104 | |
| 105 | struct copybit_region_t { |
| 106 | int (*next)(copybit_region_t const*, copybit_rect_t* rect); |
| 107 | }; |
| 108 | |
| 109 | struct copybit_t |
| 110 | { |
| 111 | int (*set_parameter)(struct copybit_t* handle, int name, int value); |
| 112 | |
| 113 | int (*get)(struct copybit_t* handle, int name); |
| 114 | |
| 115 | int (*blit)( |
| 116 | struct copybit_t* handle, |
| 117 | struct copybit_image_t const* dst, |
| 118 | struct copybit_image_t const* src, |
| 119 | struct copybit_region_t const* region); |
| 120 | |
| 121 | int (*stretch)( |
| 122 | struct copybit_t* handle, |
| 123 | struct copybit_image_t const* dst, |
| 124 | struct copybit_image_t const* src, |
| 125 | struct copybit_rect_t const* dst_rect, |
| 126 | struct copybit_rect_t const* src_rect, |
| 127 | struct copybit_region_t const* region); |
| 128 | }; |
| 129 | |
| 130 | /******************************************************************************/ |
| 131 | |
| 132 | struct copybit_t* copybit_init(); |
| 133 | |
| 134 | int copybit_term(struct copybit_t* handle); |
| 135 | |
| 136 | |
| 137 | /******************************************************************************/ |
| 138 | |
| 139 | #if __cplusplus |
| 140 | } // extern "C" |
| 141 | #endif |
| 142 | |
| 143 | #endif // ANDROID_BLIT_HARDWARE_H |