| 1 | #ifndef __eglplatform_h_ |
| 2 | #define __eglplatform_h_ |
| 3 | |
| 4 | /* |
| 5 | ** Copyright (c) 2007-2009 The Khronos Group Inc. |
| 6 | ** |
| 7 | ** Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | ** copy of this software and/or associated documentation files (the |
| 9 | ** "Materials"), to deal in the Materials without restriction, including |
| 10 | ** without limitation the rights to use, copy, modify, merge, publish, |
| 11 | ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 12 | ** permit persons to whom the Materials are furnished to do so, subject to |
| 13 | ** the following conditions: |
| 14 | ** |
| 15 | ** The above copyright notice and this permission notice shall be included |
| 16 | ** in all copies or substantial portions of the Materials. |
| 17 | ** |
| 18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 21 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 22 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 23 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 24 | ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 25 | */ |
| 26 | |
| 27 | /* Platform-specific types and definitions for egl.h |
| 28 | * $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $ |
| 29 | * |
| 30 | * Adopters may modify khrplatform.h and this file to suit their platform. |
| 31 | * You are encouraged to submit all modifications to the Khronos group so that |
| 32 | * they can be included in future versions of this file. Please submit changes |
| 33 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) |
| 34 | * by filing a bug against product "EGL" component "Registry". |
| 35 | */ |
| 36 | |
| 37 | #include "../KHR/khrplatform.h" |
| 38 | |
| 39 | #ifdef ABSTRACT_PLATFORM |
| 40 | #include "begl_memplatform.h" |
| 41 | #include "begl_hwplatform.h" |
| 42 | #include "begl_dispplatform.h" |
| 43 | #endif /* ABSTRACT_PLATFORM */ |
| 44 | |
| 45 | /* Macros used in EGL function prototype declarations. |
| 46 | * |
| 47 | * EGL functions should be prototyped as: |
| 48 | * |
| 49 | * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); |
| 50 | * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); |
| 51 | * |
| 52 | * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h |
| 53 | */ |
| 54 | |
| 55 | #ifndef EGLAPI |
| 56 | #define EGLAPI KHRONOS_APICALL |
| 57 | #endif |
| 58 | |
| 59 | #ifndef EGLAPIENTRY |
| 60 | #define EGLAPIENTRY KHRONOS_APIENTRY |
| 61 | #endif |
| 62 | #ifndef EGLAPIENTRYP |
| 63 | #define EGLAPIENTRYP EGLAPIENTRY * |
| 64 | #endif |
| 65 | #ifndef EGLAPI |
| 66 | #ifdef KHAPI |
| 67 | #define EGLAPI KHAPI |
| 68 | #else |
| 69 | #define EGLAPI extern |
| 70 | #endif |
| 71 | #endif |
| 72 | |
| 73 | /* The types NativeDisplayType, NativeWindowType, and NativePixmapType |
| 74 | * are aliases of window-system-dependent types, such as X Display * or |
| 75 | * Windows Device Context. They must be defined in platform-specific |
| 76 | * code below. The EGL-prefixed versions of Native*Type are the same |
| 77 | * types, renamed in EGL 1.3 so all types in the API start with "EGL". |
| 78 | * |
| 79 | * Khronos STRONGLY RECOMMENDS that you use the default definitions |
| 80 | * provided below, since these changes affect both binary and source |
| 81 | * portability of applications using EGL running on different EGL |
| 82 | * implementations. |
| 83 | */ |
| 84 | |
| 85 | /* Unix (tentative) |
| 86 | #include <X headers> |
| 87 | typedef Display *NativeDisplayType; |
| 88 | - or maybe, if encoding "hostname:display.head" |
| 89 | typedef const char *NativeWindowType; |
| 90 | etc. |
| 91 | */ |
| 92 | #if (defined (__ANDROID__) || defined(ANDROID)) && defined(KHRN_BCG_ANDROID) |
| 93 | |
| 94 | struct android_native_window_t; |
| 95 | struct egl_native_pixmap_t; |
| 96 | |
| 97 | typedef struct android_native_window_t* EGLNativeWindowType; |
| 98 | typedef struct egl_native_pixmap_t* EGLNativePixmapType; |
| 99 | typedef void *EGLNativeDisplayType; |
| 100 | |
| 101 | #else |
| 102 | |
| 103 | typedef void *EGLNativeDisplayType; |
| 104 | typedef void *EGLNativePixmapType; |
| 105 | typedef void *EGLNativeWindowType; |
| 106 | #endif |
| 107 | |
| 108 | #ifndef EGL_SERVER_SMALLINT |
| 109 | |
| 110 | #include "interface/vmcs_host/vc_dispmanx.h" |
| 111 | /* TODO: EGLNativeWindowType is really one of these but I'm leaving it |
| 112 | * as void* for now, in case changing it would cause problems |
| 113 | */ |
| 114 | typedef struct { |
| 115 | DISPMANX_ELEMENT_HANDLE_T element; |
| 116 | int width; /* This is necessary because dispmanx elements are not queriable. */ |
| 117 | int height; |
| 118 | } EGL_DISPMANX_WINDOW_T; |
| 119 | #elif defined (ABSTRACT_PLATFORM) |
| 120 | |
| 121 | #else |
| 122 | |
| 123 | /* window I of a horizontal strip of N WxH windows */ |
| 124 | #define PACK_NATIVE_WINDOW(W, H, I, N) ((NativeWindowType)((W) | ((H) << 12) | ((I) << 24) | ((N) << 28))) |
| 125 | #define UNPACK_NATIVE_WINDOW_W(WIN) ((unsigned int)(WIN) & 0xfff) |
| 126 | #define UNPACK_NATIVE_WINDOW_H(WIN) (((unsigned int)(WIN) >> 12) & 0xfff) |
| 127 | #define UNPACK_NATIVE_WINDOW_I(WIN) (((unsigned int)(WIN) >> 24) & 0xf) |
| 128 | #define UNPACK_NATIVE_WINDOW_N(WIN) ((unsigned int)(WIN) >> 28) |
| 129 | |
| 130 | /* todo: can we change these to use PACK_NATIVE_WINDOW and get rid of platform_canonical_win from platform.h? */ |
| 131 | #define NATIVE_WINDOW_800_480 ((NativeWindowType)0) |
| 132 | #define NATIVE_WINDOW_640_480 ((NativeWindowType)1) |
| 133 | #define NATIVE_WINDOW_320_240 ((NativeWindowType)2) |
| 134 | #define NATIVE_WINDOW_240_320 ((NativeWindowType)3) |
| 135 | #define NATIVE_WINDOW_64_64 ((NativeWindowType)4) |
| 136 | #define NATIVE_WINDOW_400_480_A ((NativeWindowType)5) |
| 137 | #define NATIVE_WINDOW_400_480_B ((NativeWindowType)6) |
| 138 | #define NATIVE_WINDOW_512_512 ((NativeWindowType)7) |
| 139 | #define NATIVE_WINDOW_360_640 ((NativeWindowType)8) |
| 140 | #define NATIVE_WINDOW_640_360 ((NativeWindowType)9) |
| 141 | #define NATIVE_WINDOW_1280_720 ((NativeWindowType)10) |
| 142 | #define NATIVE_WINDOW_1920_1080 ((NativeWindowType)11) |
| 143 | #define NATIVE_WINDOW_480_320 ((NativeWindowType)12) |
| 144 | #define NATIVE_WINDOW_1680_1050 ((NativeWindowType)13) |
| 145 | #endif |
| 146 | |
| 147 | /* EGL 1.2 types, renamed for consistency in EGL 1.3 */ |
| 148 | typedef EGLNativeDisplayType NativeDisplayType; |
| 149 | typedef EGLNativePixmapType NativePixmapType; |
| 150 | typedef EGLNativeWindowType NativeWindowType; |
| 151 | |
| 152 | |
| 153 | /* Define EGLint. This must be a signed integral type large enough to contain |
| 154 | * all legal attribute names and values passed into and out of EGL, whether |
| 155 | * their type is boolean, bitmask, enumerant (symbolic constant), integer, |
| 156 | * handle, or other. While in general a 32-bit integer will suffice, if |
| 157 | * handles are 64 bit types, then EGLint should be defined as a signed 64-bit |
| 158 | * integer type. |
| 159 | */ |
| 160 | typedef khronos_int32_t EGLint; |
| 161 | |
| 162 | #ifdef ABSTRACT_PLATFORM |
| 163 | |
| 164 | #ifdef __cplusplus |
| 165 | extern "C" |
| 166 | { |
| 167 | #endif |
| 168 | |
| 169 | /* |
| 170 | The client application, or default platform library must register valid versions of each of these |
| 171 | interfaces before any EGL or GL functions are invoked, using the following functions provided by the 3D driver. |
| 172 | */ |
| 173 | typedef struct |
| 174 | { |
| 175 | BEGL_MemoryInterface *memInterface; /* Memory interface which will called by the 3d driver */ |
| 176 | BEGL_HWInterface *hwInterface; /* Hardware interface which will be called by the driver */ |
| 177 | BEGL_DisplayInterface *displayInterface; /* Display interface which will be called by the driver */ |
| 178 | |
| 179 | BEGL_DisplayCallbacks displayCallbacks; /* Callback pointers set by BEGL_GetDefaultDriverInterfaces, for client to call into driver */ |
| 180 | int hwInterfaceCloned; |
| 181 | int memInterfaceCloned; |
| 182 | void *memInterfaceFn; |
| 183 | void *hwInterfaceFn; |
| 184 | } BEGL_DriverInterfaces; |
| 185 | |
| 186 | /* Register application level overrides for any or all of the abstract API calls made by the 3D driver. */ |
| 187 | EGLAPI void EGLAPIENTRY BEGL_RegisterDriverInterfaces(BEGL_DriverInterfaces *iface); |
| 188 | |
| 189 | /* Get a pointer to the registered driver interfaces, can be used to override partial defaults - see android platform layer(s) for example */ |
| 190 | EGLAPI BEGL_DriverInterfaces * BEGL_GetDriverInterfaces(void); |
| 191 | |
| 192 | /* Initializes all interfaces in the structure to NULL, fills out Callbacks with appropriate function pointers */ |
| 193 | EGLAPI void EGLAPIENTRY BEGL_GetDefaultDriverInterfaces(BEGL_DriverInterfaces *iface); |
| 194 | |
| 195 | #ifdef __cplusplus |
| 196 | } |
| 197 | #endif |
| 198 | |
| 199 | #endif /* ABSTRACT_PLATFORM */ |
| 200 | |
| 201 | #if 0 |
| 202 | #include "interface/khronos/common/khrn_client_mangle.h" |
| 203 | #endif |
| 204 | |
| 205 | #endif /* __eglplatform_h */ |
| 206 | |