1 /****************************************************************************
3 * Copyright (C) 2005 - 2013 by Vivante Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the license, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *****************************************************************************/
21 #ifndef __gc_hal_eglplatform_h_
22 #define __gc_hal_eglplatform_h_
24 /* Include VDK types. */
25 #include "gc_hal_types.h"
26 #include "gc_hal_base.h"
27 #include "gc_hal_eglplatform_type.h"
33 #if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
34 /* Win32 and Windows CE platforms. */
36 typedef HDC HALNativeDisplayType;
37 typedef HWND HALNativeWindowType;
38 typedef HBITMAP HALNativePixmapType;
40 typedef struct __BITFIELDINFO{
45 #elif defined(LINUX) && defined(EGL_API_DFB) && !defined(__APPLE__)
47 typedef struct _DFBDisplay * HALNativeDisplayType;
48 typedef struct _DFBWindow * HALNativeWindowType;
49 typedef struct _DFBPixmap * HALNativePixmapType;
51 #elif defined(LINUX) && defined(EGL_API_FB) && !defined(__APPLE__)
53 #if defined(EGL_API_WL)
54 /* Wayland platform. */
55 #include "wayland-server.h"
56 #include <wayland-egl.h>
58 #define WL_EGL_NUM_BACKBUFFERS 2
60 typedef struct _gcsWL_VIV_BUFFER
62 struct wl_buffer wl_buffer;
66 typedef struct _gcsWL_EGL_DISPLAY
68 struct wl_display* wl_display;
69 struct wl_viv* wl_viv;
72 typedef struct _gcsWL_EGL_BUFFER_INFO
77 gceSURF_FORMAT format;
78 gcuVIDMEM_NODE_PTR node;
82 } gcsWL_EGL_BUFFER_INFO;
84 typedef struct _gcsWL_EGL_BUFFER
86 struct wl_buffer* wl_buffer;
87 gcsWL_EGL_BUFFER_INFO info;
90 typedef struct _gcsWL_EGL_WINDOW_INFO
94 gceSURF_FORMAT format;
96 } gcsWL_EGL_WINDOW_INFO;
100 gcsWL_EGL_BUFFER backbuffers[WL_EGL_NUM_BACKBUFFERS];
101 gcsWL_EGL_WINDOW_INFO info;
103 struct wl_surface* surface;
104 struct wl_callback* pending;
107 typedef void* HALNativeDisplayType;
108 typedef void* HALNativeWindowType;
109 typedef void* HALNativePixmapType;
111 /* Linux platform for FBDEV. */
112 typedef struct _FBDisplay * HALNativeDisplayType;
113 typedef struct _FBWindow * HALNativeWindowType;
114 typedef struct _FBPixmap * HALNativePixmapType;
116 #elif defined(__ANDROID__) || defined(ANDROID)
118 struct egl_native_pixmap_t;
120 #if ANDROID_SDK_VERSION >= 9
121 #include <android/native_window.h>
123 typedef struct ANativeWindow* HALNativeWindowType;
124 typedef struct egl_native_pixmap_t* HALNativePixmapType;
125 typedef void* HALNativeDisplayType;
127 struct android_native_window_t;
128 typedef struct android_native_window_t* HALNativeWindowType;
129 typedef struct egl_native_pixmap_t * HALNativePixmapType;
130 typedef void* HALNativeDisplayType;
133 #elif defined(LINUX) || defined(__APPLE__)
135 #include <X11/Xlib.h>
136 #include <X11/Xutil.h>
138 typedef Display * HALNativeDisplayType;
139 typedef Window HALNativeWindowType;
142 typedef void * HALNativePixmapType;
144 typedef Pixmap HALNativePixmapType;
145 #endif /* CUSTOM_PIXMAP */
147 /* Rename some badly named X defines. */
158 # define XCurrentTime 0
161 #elif defined(__QNXNTO__)
162 #include <screen/screen.h>
165 typedef int HALNativeDisplayType;
166 typedef screen_window_t HALNativeWindowType;
167 typedef screen_pixmap_t HALNativePixmapType;
171 #error "Platform not recognized"
174 typedef void * HALNativeDisplayType;
175 typedef void * HALNativeWindowType;
176 typedef void * HALNativePixmapType;
180 /* define DUMMY according to the system */
181 #if defined(EGL_API_WL)
182 # define WL_DUMMY (31415926)
183 # define EGL_DUMMY WL_DUMMY
184 #elif defined(__ANDROID__) || defined(ANDROID)
185 # define ANDROID_DUMMY (31415926)
186 # define EGL_DUMMY ANDROID_DUMMY
188 # define EGL_DUMMY (31415926)
191 /*******************************************************************************
192 ** Display. ********************************************************************
197 OUT HALNativeDisplayType * Display,
198 IN gctPOINTER Context
202 gcoOS_GetDisplayByIndex(
203 IN gctINT DisplayIndex,
204 OUT HALNativeDisplayType * Display,
205 IN gctPOINTER Context
209 gcoOS_GetDisplayInfo(
210 IN HALNativeDisplayType Display,
213 OUT gctSIZE_T * Physical,
215 OUT gctINT * BitsPerPixel
221 gcoOS_GetDisplayInfoEx(
222 IN HALNativeDisplayType Display,
223 IN HALNativeWindowType Window,
224 IN gctUINT DisplayInfoSize,
225 OUT halDISPLAY_INFO * DisplayInfo
229 gcoOS_GetNextDisplayInfoExByIndex(
231 IN HALNativeDisplayType Display,
232 IN HALNativeWindowType Window,
233 IN gctUINT DisplayInfoSize,
234 OUT halDISPLAY_INFO * DisplayInfo
238 gcoOS_GetDisplayVirtual(
239 IN HALNativeDisplayType Display,
245 gcoOS_GetDisplayBackbuffer(
246 IN HALNativeDisplayType Display,
247 IN HALNativeWindowType Window,
248 OUT gctPOINTER * context,
249 OUT gcoSURF * surface,
250 OUT gctUINT * Offset,
256 gcoOS_SetDisplayVirtual(
257 IN HALNativeDisplayType Display,
258 IN HALNativeWindowType Window,
265 gcoOS_SetDisplayVirtualEx(
266 IN HALNativeDisplayType Display,
267 IN HALNativeWindowType Window,
268 IN gctPOINTER Context,
276 gcoOS_SetSwapInterval(
277 IN HALNativeDisplayType Display,
282 gcoOS_GetSwapInterval(
283 IN HALNativeDisplayType Display,
289 gcoOS_DisplayBufferRegions(
290 IN HALNativeDisplayType Display,
291 IN HALNativeWindowType Window,
297 gcoOS_DestroyDisplay(
298 IN HALNativeDisplayType Display
302 gcoOS_InitLocalDisplayInfo(
303 IN HALNativeDisplayType Display,
304 IN OUT gctPOINTER * localDisplay
308 gcoOS_DeinitLocalDisplayInfo(
309 IN HALNativeDisplayType Display,
310 IN OUT gctPOINTER * localDisplay
314 gcoOS_GetDisplayInfoEx2(
315 IN HALNativeDisplayType Display,
316 IN HALNativeWindowType Window,
317 IN gctPOINTER localDisplay,
318 IN gctUINT DisplayInfoSize,
319 OUT halDISPLAY_INFO * DisplayInfo
323 gcoOS_GetDisplayBackbufferEx(
324 IN HALNativeDisplayType Display,
325 IN HALNativeWindowType Window,
326 IN gctPOINTER localDisplay,
327 OUT gctPOINTER * context,
328 OUT gcoSURF * surface,
329 OUT gctUINT * Offset,
335 gcoOS_IsValidDisplay(
336 IN HALNativeDisplayType Display
340 gcoOS_GetNativeVisualId(
341 IN HALNativeDisplayType Display,
342 OUT gctINT* nativeVisualId
346 gcoOS_SynchronousFlip(
347 IN HALNativeDisplayType Display
350 /*******************************************************************************
351 ** Windows. ********************************************************************
356 IN HALNativeDisplayType Display,
361 OUT HALNativeWindowType * Window
366 IN HALNativeDisplayType Display,
367 IN HALNativeWindowType Window,
372 OUT gctINT * BitsPerPixel,
378 IN HALNativeDisplayType Display,
379 IN HALNativeWindowType Window
384 IN HALNativeDisplayType Display,
385 IN HALNativeWindowType Window,
392 IN gctINT BitsPerPixel,
398 IN HALNativeWindowType Window,
403 OUT gctINT * BitsPerPixel,
404 OUT gctPOINTER * Bits
408 gcoOS_GetWindowInfoEx(
409 IN HALNativeDisplayType Display,
410 IN HALNativeWindowType Window,
415 OUT gctINT * BitsPerPixel,
416 OUT gctUINT * Offset,
417 OUT gceSURF_FORMAT * Format
422 IN HALNativeDisplayType Display,
423 IN HALNativeWindowType Window,
430 IN gctINT BitsPerPixel,
432 IN gceSURF_FORMAT Format
435 /*******************************************************************************
436 ** Pixmaps. ********************************************************************
441 IN HALNativeDisplayType Display,
444 IN gctINT BitsPerPixel,
445 OUT HALNativePixmapType * Pixmap
450 IN HALNativeDisplayType Display,
451 IN HALNativePixmapType Pixmap,
454 OUT gctINT * BitsPerPixel,
456 OUT gctPOINTER * Bits
461 IN HALNativeDisplayType Display,
462 IN HALNativePixmapType Pixmap,
469 IN gctINT BitsPerPixel,
475 IN HALNativeDisplayType Display,
476 IN HALNativePixmapType Pixmap
480 gcoOS_GetPixmapInfoEx(
481 IN HALNativeDisplayType Display,
482 IN HALNativePixmapType Pixmap,
485 OUT gctINT * BitsPerPixel,
487 OUT gctPOINTER * Bits,
488 OUT gceSURF_FORMAT * Format
492 gcoOS_CopyPixmapBits(
493 IN HALNativeDisplayType Display,
494 IN HALNativePixmapType Pixmap,
496 IN gctUINT DstHeight,
498 IN gceSURF_FORMAT DstFormat,
499 OUT gctPOINTER DstBits
502 /*******************************************************************************
503 ** OS relative. ****************************************************************
506 gcoOS_LoadEGLLibrary(
507 OUT gctHANDLE * Handle
511 gcoOS_FreeEGLLibrary(
517 IN HALNativeDisplayType Display,
518 IN HALNativeWindowType Window
523 IN HALNativeDisplayType Display,
524 IN HALNativeWindowType Window
528 gcoOS_SetWindowTitle(
529 IN HALNativeDisplayType Display,
530 IN HALNativeWindowType Window,
531 IN gctCONST_STRING Title
535 gcoOS_CapturePointer(
536 IN HALNativeDisplayType Display,
537 IN HALNativeWindowType Window
542 IN HALNativeDisplayType Display,
543 IN HALNativeWindowType Window,
548 gcoOS_CreateClientBuffer(
553 OUT gctPOINTER * ClientBuffer
557 gcoOS_GetClientBufferInfo(
558 IN gctPOINTER ClientBuffer,
562 OUT gctPOINTER * Bits
566 gcoOS_DestroyClientBuffer(
567 IN gctPOINTER ClientBuffer
571 gcoOS_DestroyContext(
572 IN gctPOINTER Display,
573 IN gctPOINTER Context
578 IN gctPOINTER LocalDisplay,
579 IN gctPOINTER Context
584 IN gctPOINTER LocalDisplay,
585 IN HALNativeWindowType DrawDrawable,
586 IN HALNativeWindowType ReadDrawable,
587 IN gctPOINTER Context,
588 IN gcoSURF ResolveTarget
592 gcoOS_CreateDrawable(
593 IN gctPOINTER LocalDisplay,
594 IN HALNativeWindowType Drawable
598 gcoOS_DestroyDrawable(
599 IN gctPOINTER LocalDisplay,
600 IN HALNativeWindowType Drawable
604 IN gctPOINTER LocalDisplay,
605 IN HALNativeWindowType Drawable,
606 IN gcoSURF RenderTarget,
607 IN gcoSURF ResolveTarget,
608 IN gctPOINTER ResolveBits,
616 #endif /* __gc_hal_eglplatform_h_ */