1 /* 2 __ 3 / _| 4 __ _ _ _ _ __ ___ _ __ __ _ | |_ ___ ___ ___ 5 / _` | | | | '__/ _ \| '__/ _` | | _/ _ \/ __/ __| 6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \ 7 \__,_|\__,_|_| \___/|_| \__,_| |_| \___/|___/___/ 8 9 Copyright (C) 2010 The Android Open Source Project. 10 Copyright (C) 2018-2019 Aurora Free Open Source Software. 11 12 This file is part of the Aurora Free Open Source Software. This 13 organization promote free and open source software that you can 14 redistribute and/or modify under the terms of the GNU Lesser General 15 Public License Version 3 as published by the Free Software Foundation or 16 (at your option) any later version approved by the Aurora Free Open Source 17 Software Organization. The license is available in the package root path 18 as 'LICENSE' file. Please review the following information to ensure the 19 GNU Lesser General Public License version 3 requirements will be met: 20 https://www.gnu.org/licenses/lgpl.html . 21 22 Alternatively, this file may be used under the terms of the GNU General 23 Public License version 3 or later as published by the Free Software 24 Foundation. Please review the following information to ensure the GNU 25 General Public License requirements will be met: 26 https://www.gnu.org/licenses/gpl-3.0.html. 27 28 NOTE: All products, services or anything associated to trademarks and 29 service marks used or referenced on this file are the property of their 30 respective companies/owners or its subsidiaries. Other names and brands 31 may be claimed as the property of others. 32 33 For more info about intellectual property visit: aurorafoss.org or 34 directly send an email to: contact (at) aurorafoss.org . 35 36 This file has bindings for an existing code, part of The Android Open Source 37 Project implementation. Check it out at android.googlesource.com . 38 */ 39 40 module aurorafw.android.platform.native_window; 41 42 /** 43 * @addtogroup NativeActivity Native Activity 44 * @{ 45 */ 46 47 /** 48 * @file aurorafw/android/platform/native_window.d 49 * @brief API for accessing a native window. 50 */ 51 52 version (Android): 53 extern (C): 54 @system: 55 nothrow: 56 @nogc: 57 58 /** 59 * Legacy window pixel format names, kept for backwards compatibility. 60 * New code and APIs should use AHARDWAREBUFFER_FORMAT_*. 61 */ 62 enum 63 { 64 // NOTE: these values must match the values from graphics/common/x.x/types.hal 65 66 /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/ 67 WINDOW_FORMAT_RGBA_8888 = 1, 68 /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits. **/ 69 WINDOW_FORMAT_RGBX_8888 = 2, 70 /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/ 71 WINDOW_FORMAT_RGB_565 = 4 72 } 73 74 /** 75 * Transforms that can be applied to buffers as they are displayed to a window. 76 * 77 * Supported transforms are any combination of horizontal mirror, vertical 78 * mirror, and clockwise 90 degree rotation, in that order. Rotations of 180 79 * and 270 degrees are made up of those basic transforms. 80 */ 81 enum ANativeWindowTransform 82 { 83 ANATIVEWINDOW_TRANSFORM_IDENTITY = 0, 84 ANATIVEWINDOW_TRANSFORM_MIRROR_HORIZONTAL = 1, 85 ANATIVEWINDOW_TRANSFORM_MIRROR_VERTICAL = 2, 86 ANATIVEWINDOW_TRANSFORM_ROTATE_90 = 4, 87 88 ANATIVEWINDOW_TRANSFORM_ROTATE_180 = 3, 89 ANATIVEWINDOW_TRANSFORM_ROTATE_270 = 7 90 } 91 92 struct ANativeWindow; 93 /** 94 * Opaque type that provides access to a native window. 95 * 96 * A pointer can be obtained using {@link ANativeWindow_fromSurface()}. 97 */ 98 99 /** 100 * Struct that represents a windows buffer. 101 * 102 * A pointer can be obtained using {@link ANativeWindow_lock()}. 103 */ 104 struct ANativeWindow_Buffer 105 { 106 /// The number of pixels that are shown horizontally. 107 int width; 108 109 /// The number of pixels that are shown vertically. 110 int height; 111 112 /// The number of *pixels* that a line in the buffer takes in 113 /// memory. This may be >= width. 114 int stride; 115 116 /// The format of the buffer. One of AHARDWAREBUFFER_FORMAT_* 117 int format; 118 119 /// The actual bits. 120 void* bits; 121 122 /// Do not touch. 123 uint[6] reserved; 124 } 125 126 /** 127 * Acquire a reference on the given {@link ANativeWindow} object. This prevents the object 128 * from being deleted until the reference is removed. 129 */ 130 void ANativeWindow_acquire (ANativeWindow* window); 131 132 /** 133 * Remove a reference that was previously acquired with {@link ANativeWindow_acquire()}. 134 */ 135 void ANativeWindow_release (ANativeWindow* window); 136 137 /** 138 * Return the current width in pixels of the window surface. 139 * 140 * \return negative value on error. 141 */ 142 int ANativeWindow_getWidth (ANativeWindow* window); 143 144 /** 145 * Return the current height in pixels of the window surface. 146 * 147 * \return a negative value on error. 148 */ 149 int ANativeWindow_getHeight (ANativeWindow* window); 150 151 /** 152 * Return the current pixel format (AHARDWAREBUFFER_FORMAT_*) of the window surface. 153 * 154 * \return a negative value on error. 155 */ 156 int ANativeWindow_getFormat (ANativeWindow* window); 157 158 /** 159 * Change the format and size of the window buffers. 160 * 161 * The width and height control the number of pixels in the buffers, not the 162 * dimensions of the window on screen. If these are different than the 163 * window's physical size, then its buffer will be scaled to match that size 164 * when compositing it to the screen. The width and height must be either both zero 165 * or both non-zero. 166 * 167 * For all of these parameters, if 0 is supplied then the window's base 168 * value will come back in force. 169 * 170 * \param width width of the buffers in pixels. 171 * \param height height of the buffers in pixels. 172 * \param format one of AHARDWAREBUFFER_FORMAT_* constants. 173 * \return 0 for success, or a negative value on error. 174 */ 175 int ANativeWindow_setBuffersGeometry ( 176 ANativeWindow* window, 177 int width, 178 int height, 179 int format); 180 181 /** 182 * Lock the window's next drawing surface for writing. 183 * inOutDirtyBounds is used as an in/out parameter, upon entering the 184 * function, it contains the dirty region, that is, the region the caller 185 * intends to redraw. When the function returns, inOutDirtyBounds is updated 186 * with the actual area the caller needs to redraw -- this region is often 187 * extended by {@link ANativeWindow_lock}. 188 * 189 * \return 0 for success, or a negative value on error. 190 */ 191 int ANativeWindow_lock ( 192 ANativeWindow* window, 193 ANativeWindow_Buffer* outBuffer, 194 ARect* inOutDirtyBounds); 195 196 /** 197 * Unlock the window's drawing surface after previously locking it, 198 * posting the new buffer to the display. 199 * 200 * \return 0 for success, or a negative value on error. 201 */ 202 int ANativeWindow_unlockAndPost (ANativeWindow* window); 203 204 /** 205 * Set a transform that will be applied to future buffers posted to the window. 206 * 207 * \param transform combination of {@link ANativeWindowTransform} flags 208 * \return 0 for success, or -EINVAL if \p transform is invalid 209 */ 210 int ANativeWindow_setBuffersTransform (ANativeWindow* window, int transform); 211 212 // __ANDROID_API__ >= 26 213 214 /** 215 * All buffers queued after this call will be associated with the dataSpace 216 * parameter specified. 217 * 218 * dataSpace specifies additional information about the buffer. 219 * For example, it can be used to convey the color space of the image data in 220 * the buffer, or it can be used to indicate that the buffers contain depth 221 * measurement data instead of color images. The default dataSpace is 0, 222 * ADATASPACE_UNKNOWN, unless it has been overridden by the producer. 223 * 224 * \param dataSpace data space of all buffers queued after this call. 225 * \return 0 for success, -EINVAL if window is invalid or the dataspace is not 226 * supported. 227 */ 228 int ANativeWindow_setBuffersDataSpace (ANativeWindow* window, int dataSpace); 229 230 /** 231 * Get the dataspace of the buffers in window. 232 * \return the dataspace of buffers in window, ADATASPACE_UNKNOWN is returned if 233 * dataspace is unknown, or -EINVAL if window is invalid. 234 */ 235 int ANativeWindow_getBuffersDataSpace (ANativeWindow* window); 236 237 // __ANDROID_API__ >= 28 238 239 // ANDROID_NATIVE_WINDOW_H 240 241 /** @} */