Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_NATIVE_WINDOW_H |
| 18 | #define ANDROID_NATIVE_WINDOW_H |
| 19 | |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 20 | #include <android/rect.h> |
| 21 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
Dianne Hackborn | 8ae5a8e | 2010-07-01 18:44:46 -0700 | [diff] [blame] | 26 | /* |
| 27 | * Pixel formats that a window can use. |
| 28 | */ |
| 29 | enum { |
| 30 | WINDOW_FORMAT_RGBA_8888 = 1, |
| 31 | WINDOW_FORMAT_RGBX_8888 = 2, |
| 32 | WINDOW_FORMAT_RGB_565 = 4, |
| 33 | }; |
| 34 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 35 | struct ANativeWindow; |
| 36 | typedef struct ANativeWindow ANativeWindow; |
| 37 | |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 38 | typedef struct ANativeWindow_Buffer { |
Dianne Hackborn | 08d5b8f | 2010-08-04 11:12:40 -0700 | [diff] [blame] | 39 | // The number of pixels that are show horizontally. |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 40 | int32_t width; |
Dianne Hackborn | 08d5b8f | 2010-08-04 11:12:40 -0700 | [diff] [blame] | 41 | |
| 42 | // The number of pixels that are shown vertically. |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 43 | int32_t height; |
Dianne Hackborn | 08d5b8f | 2010-08-04 11:12:40 -0700 | [diff] [blame] | 44 | |
| 45 | // The number of *pixels* that a line in the buffer takes in |
| 46 | // memory. This may be >= width. |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 47 | int32_t stride; |
Dianne Hackborn | 08d5b8f | 2010-08-04 11:12:40 -0700 | [diff] [blame] | 48 | |
| 49 | // The format of the buffer. One of WINDOW_FORMAT_* |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 50 | int32_t format; |
Dianne Hackborn | 08d5b8f | 2010-08-04 11:12:40 -0700 | [diff] [blame] | 51 | |
| 52 | // The actual bits. |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 53 | void* bits; |
| 54 | |
Dianne Hackborn | 08d5b8f | 2010-08-04 11:12:40 -0700 | [diff] [blame] | 55 | // Do not touch. |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 56 | uint32_t reserved[6]; |
| 57 | } ANativeWindow_Buffer; |
| 58 | |
| 59 | /** |
| 60 | * Acquire a reference on the given ANativeWindow object. This prevents the object |
| 61 | * from being deleted until the reference is removed. |
| 62 | */ |
| 63 | void ANativeWindow_acquire(ANativeWindow* window); |
| 64 | |
| 65 | /** |
| 66 | * Remove a reference that was previously acquired with ANativeWindow_acquire(). |
| 67 | */ |
| 68 | void ANativeWindow_release(ANativeWindow* window); |
| 69 | |
Dianne Hackborn | 54a181b | 2010-06-30 18:35:14 -0700 | [diff] [blame] | 70 | /* |
| 71 | * Return the current width in pixels of the window surface. Returns a |
| 72 | * negative value on error. |
| 73 | */ |
| 74 | int32_t ANativeWindow_getWidth(ANativeWindow* window); |
| 75 | |
| 76 | /* |
| 77 | * Return the current height in pixels of the window surface. Returns a |
| 78 | * negative value on error. |
| 79 | */ |
| 80 | int32_t ANativeWindow_getHeight(ANativeWindow* window); |
| 81 | |
| 82 | /* |
| 83 | * Return the current pixel format of the window surface. Returns a |
| 84 | * negative value on error. |
| 85 | */ |
| 86 | int32_t ANativeWindow_getFormat(ANativeWindow* window); |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 87 | |
Dianne Hackborn | 8ae5a8e | 2010-07-01 18:44:46 -0700 | [diff] [blame] | 88 | /* |
| 89 | * Change the format and size of the window buffers. |
| 90 | * |
| 91 | * The width and height control the number of pixels in the buffers, not the |
| 92 | * dimensions of the window on screen. If these are different than the |
| 93 | * window's physical size, then it buffer will be scaled to match that size |
| 94 | * when compositing it to the screen. |
| 95 | * |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 96 | * For all of these parameters, if 0 is supplied then the window's base |
Dianne Hackborn | 8ae5a8e | 2010-07-01 18:44:46 -0700 | [diff] [blame] | 97 | * value will come back in force. |
Mathias Agopian | da5a444 | 2011-03-31 20:59:58 -0700 | [diff] [blame] | 98 | * |
| 99 | * width and height must be either both zero or both non-zero. |
| 100 | * |
Dianne Hackborn | 8ae5a8e | 2010-07-01 18:44:46 -0700 | [diff] [blame] | 101 | */ |
Mathias Agopian | 949be32 | 2011-07-13 17:39:11 -0700 | [diff] [blame] | 102 | int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, |
| 103 | int32_t width, int32_t height, int32_t format); |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 104 | |
| 105 | /** |
| 106 | * Lock the window's next drawing surface for writing. |
Mathias Agopian | 949be32 | 2011-07-13 17:39:11 -0700 | [diff] [blame] | 107 | * inOutDirtyBounds is used as an in/out parameter, upon entering the |
| 108 | * function, it contains the dirty region, that is, the region the caller |
| 109 | * intends to redraw. When the function returns, inOutDirtyBounds is updated |
| 110 | * with the actual area the caller needs to redraw -- this region is often |
| 111 | * extended by ANativeWindow_lock. |
Dianne Hackborn | 289b9b6 | 2010-07-09 11:44:11 -0700 | [diff] [blame] | 112 | */ |
| 113 | int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, |
| 114 | ARect* inOutDirtyBounds); |
| 115 | |
| 116 | /** |
| 117 | * Unlock the window's drawing surface after previously locking it, |
| 118 | * posting the new buffer to the display. |
| 119 | */ |
| 120 | int32_t ANativeWindow_unlockAndPost(ANativeWindow* window); |
Dianne Hackborn | 8ae5a8e | 2010-07-01 18:44:46 -0700 | [diff] [blame] | 121 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 122 | #ifdef __cplusplus |
| 123 | }; |
| 124 | #endif |
| 125 | |
| 126 | #endif // ANDROID_NATIVE_WINDOW_H |