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 *****************************************************************************/
22 #ifndef __gc_hal_eglplatform_h_
23 #define __gc_hal_eglplatform_h_
25 /* Include VDK types. */
26 #include "gc_hal_types.h"
27 #include "gc_hal_base.h"
28 #include "gc_hal_eglplatform_type.h"
34 #if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
35 /* Win32 and Windows CE platforms. */
37 typedef HDC HALNativeDisplayType;
38 typedef HWND HALNativeWindowType;
39 typedef HBITMAP HALNativePixmapType;
41 typedef struct __BITFIELDINFO{
46 #elif defined(LINUX) && defined(EGL_API_DFB) && !defined(__APPLE__)
48 typedef struct _DFBDisplay * HALNativeDisplayType;
49 typedef IDirectFBWindow * HALNativeWindowType;
50 typedef struct _DFBPixmap * HALNativePixmapType;
52 #elif defined(LINUX) && defined(EGL_API_FB) && !defined(__APPLE__)
54 #if defined(EGL_API_WL)
55 /* Wayland platform. */
56 #include "wayland-server.h"
57 #include <wayland-egl.h>
59 #define WL_EGL_NUM_BACKBUFFERS 2
61 typedef struct _gcsWL_VIV_BUFFER
63 struct wl_buffer wl_buffer;
67 typedef struct _gcsWL_EGL_DISPLAY
69 struct wl_display* wl_display;
70 struct wl_viv* wl_viv;
73 typedef struct _gcsWL_EGL_BUFFER_INFO
78 gceSURF_FORMAT format;
79 gcuVIDMEM_NODE_PTR node;
83 } gcsWL_EGL_BUFFER_INFO;
85 typedef struct _gcsWL_EGL_BUFFER
87 struct wl_buffer* wl_buffer;
88 gcsWL_EGL_BUFFER_INFO info;
91 typedef struct _gcsWL_EGL_WINDOW_INFO
95 gceSURF_FORMAT format;
97 } gcsWL_EGL_WINDOW_INFO;
101 gcsWL_EGL_BUFFER backbuffers[WL_EGL_NUM_BACKBUFFERS];
102 gcsWL_EGL_WINDOW_INFO info;
104 struct wl_surface* surface;
105 struct wl_callback* pending;
108 typedef void* HALNativeDisplayType;
109 typedef void* HALNativeWindowType;
110 typedef void* HALNativePixmapType;
112 /* Linux platform for FBDEV. */
113 typedef struct _FBDisplay * HALNativeDisplayType;
114 typedef struct _FBWindow * HALNativeWindowType;
115 typedef struct _FBPixmap * HALNativePixmapType;
117 #elif defined(__ANDROID__) || defined(ANDROID)
119 struct egl_native_pixmap_t;
121 #if ANDROID_SDK_VERSION >= 9
122 #include <android/native_window.h>
124 typedef struct ANativeWindow* HALNativeWindowType;
125 typedef struct egl_native_pixmap_t* HALNativePixmapType;
126 typedef void* HALNativeDisplayType;
128 struct android_native_window_t;
129 typedef struct android_native_window_t* HALNativeWindowType;
130 typedef struct egl_native_pixmap_t * HALNativePixmapType;
131 typedef void* HALNativeDisplayType;
134 #elif defined(LINUX) || defined(__APPLE__)
136 #include <X11/Xlib.h>
137 #include <X11/Xutil.h>
139 typedef Display * HALNativeDisplayType;
140 typedef Window HALNativeWindowType;
143 typedef void * HALNativePixmapType;
145 typedef Pixmap HALNativePixmapType;
146 #endif /* CUSTOM_PIXMAP */
148 /* Rename some badly named X defines. */
159 # define XCurrentTime 0
162 #elif defined(__QNXNTO__)
163 #include <screen/screen.h>
166 typedef int HALNativeDisplayType;
167 typedef screen_window_t HALNativeWindowType;
168 typedef screen_pixmap_t HALNativePixmapType;
172 #error "Platform not recognized"
175 typedef void * HALNativeDisplayType;
176 typedef void * HALNativeWindowType;
177 typedef void * HALNativePixmapType;
181 /* define DUMMY according to the system */
182 #if defined(EGL_API_WL)
183 # define WL_DUMMY (31415926)
184 # define EGL_DUMMY WL_DUMMY
185 #elif defined(__ANDROID__) || defined(ANDROID)
186 # define ANDROID_DUMMY (31415926)
187 # define EGL_DUMMY ANDROID_DUMMY
189 # define EGL_DUMMY (31415926)
192 /*******************************************************************************
193 ** Display. ********************************************************************
198 OUT HALNativeDisplayType * Display,
199 IN gctPOINTER Context
203 gcoOS_GetDisplayByIndex(
204 IN gctINT DisplayIndex,
205 OUT HALNativeDisplayType * Display,
206 IN gctPOINTER Context
210 gcoOS_GetDisplayInfo(
211 IN HALNativeDisplayType Display,
214 OUT gctSIZE_T * Physical,
216 OUT gctINT * BitsPerPixel
222 gcoOS_GetDisplayInfoEx(
223 IN HALNativeDisplayType Display,
224 IN HALNativeWindowType Window,
225 IN gctUINT DisplayInfoSize,
226 OUT halDISPLAY_INFO * DisplayInfo
230 gcoOS_GetNextDisplayInfoExByIndex(
232 IN HALNativeDisplayType Display,
233 IN HALNativeWindowType Window,
234 IN gctUINT DisplayInfoSize,
235 OUT halDISPLAY_INFO * DisplayInfo
239 gcoOS_GetDisplayVirtual(
240 IN HALNativeDisplayType Display,
246 gcoOS_GetDisplayBackbuffer(
247 IN HALNativeDisplayType Display,
248 IN HALNativeWindowType Window,
249 OUT gctPOINTER * context,
250 OUT gcoSURF * surface,
251 OUT gctUINT * Offset,
257 gcoOS_SetDisplayVirtual(
258 IN HALNativeDisplayType Display,
259 IN HALNativeWindowType Window,
266 gcoOS_SetDisplayVirtualEx(
267 IN HALNativeDisplayType Display,
268 IN HALNativeWindowType Window,
269 IN gctPOINTER Context,
277 gcoOS_SetSwapInterval(
278 IN HALNativeDisplayType Display,
283 gcoOS_GetSwapInterval(
284 IN HALNativeDisplayType Display,
290 gcoOS_DisplayBufferRegions(
291 IN HALNativeDisplayType Display,
292 IN HALNativeWindowType Window,
298 gcoOS_DestroyDisplay(
299 IN HALNativeDisplayType Display
303 gcoOS_InitLocalDisplayInfo(
304 IN HALNativeDisplayType Display,
305 IN OUT gctPOINTER * localDisplay
309 gcoOS_DeinitLocalDisplayInfo(
310 IN HALNativeDisplayType Display,
311 IN OUT gctPOINTER * localDisplay
315 gcoOS_GetDisplayInfoEx2(
316 IN HALNativeDisplayType Display,
317 IN HALNativeWindowType Window,
318 IN gctPOINTER localDisplay,
319 IN gctUINT DisplayInfoSize,
320 OUT halDISPLAY_INFO * DisplayInfo
324 gcoOS_GetDisplayBackbufferEx(
325 IN HALNativeDisplayType Display,
326 IN HALNativeWindowType Window,
327 IN gctPOINTER localDisplay,
328 OUT gctPOINTER * context,
329 OUT gcoSURF * surface,
330 OUT gctUINT * Offset,
336 gcoOS_IsValidDisplay(
337 IN HALNativeDisplayType Display
341 gcoOS_GetNativeVisualId(
342 IN HALNativeDisplayType Display,
343 OUT gctINT* nativeVisualId
347 gcoOS_SynchronousFlip(
348 IN HALNativeDisplayType Display
351 /*******************************************************************************
352 ** Windows. ********************************************************************
357 IN HALNativeDisplayType Display,
362 OUT HALNativeWindowType * Window
367 IN HALNativeDisplayType Display,
368 IN HALNativeWindowType Window,
373 OUT gctINT * BitsPerPixel,
379 IN HALNativeDisplayType Display,
380 IN HALNativeWindowType Window
385 IN HALNativeDisplayType Display,
386 IN HALNativeWindowType Window,
393 IN gctINT BitsPerPixel,
399 IN HALNativeWindowType Window,
404 OUT gctINT * BitsPerPixel,
405 OUT gctPOINTER * Bits
409 gcoOS_GetWindowInfoEx(
410 IN HALNativeDisplayType Display,
411 IN HALNativeWindowType Window,
416 OUT gctINT * BitsPerPixel,
417 OUT gctUINT * Offset,
418 OUT gceSURF_FORMAT * Format
423 IN HALNativeDisplayType Display,
424 IN HALNativeWindowType Window,
431 IN gctINT BitsPerPixel,
433 IN gceSURF_FORMAT Format
436 /*******************************************************************************
437 ** Pixmaps. ********************************************************************
442 IN HALNativeDisplayType Display,
445 IN gctINT BitsPerPixel,
446 OUT HALNativePixmapType * Pixmap
451 IN HALNativeDisplayType Display,
452 IN HALNativePixmapType Pixmap,
455 OUT gctINT * BitsPerPixel,
457 OUT gctPOINTER * Bits
462 IN HALNativeDisplayType Display,
463 IN HALNativePixmapType Pixmap,
470 IN gctINT BitsPerPixel,
476 IN HALNativeDisplayType Display,
477 IN HALNativePixmapType Pixmap
481 gcoOS_GetPixmapInfoEx(
482 IN HALNativeDisplayType Display,
483 IN HALNativePixmapType Pixmap,
486 OUT gctINT * BitsPerPixel,
488 OUT gctPOINTER * Bits,
489 OUT gceSURF_FORMAT * Format
493 gcoOS_CopyPixmapBits(
494 IN HALNativeDisplayType Display,
495 IN HALNativePixmapType Pixmap,
497 IN gctUINT DstHeight,
499 IN gceSURF_FORMAT DstFormat,
500 OUT gctPOINTER DstBits
503 /*******************************************************************************
504 ** OS relative. ****************************************************************
507 gcoOS_LoadEGLLibrary(
508 OUT gctHANDLE * Handle
512 gcoOS_FreeEGLLibrary(
518 IN HALNativeDisplayType Display,
519 IN HALNativeWindowType Window
524 IN HALNativeDisplayType Display,
525 IN HALNativeWindowType Window
529 gcoOS_SetWindowTitle(
530 IN HALNativeDisplayType Display,
531 IN HALNativeWindowType Window,
532 IN gctCONST_STRING Title
536 gcoOS_CapturePointer(
537 IN HALNativeDisplayType Display,
538 IN HALNativeWindowType Window
543 IN HALNativeDisplayType Display,
544 IN HALNativeWindowType Window,
549 gcoOS_CreateClientBuffer(
554 OUT gctPOINTER * ClientBuffer
558 gcoOS_GetClientBufferInfo(
559 IN gctPOINTER ClientBuffer,
563 OUT gctPOINTER * Bits
567 gcoOS_DestroyClientBuffer(
568 IN gctPOINTER ClientBuffer
572 gcoOS_DestroyContext(
573 IN gctPOINTER Display,
574 IN gctPOINTER Context
579 IN gctPOINTER LocalDisplay,
580 IN gctPOINTER Context
585 IN gctPOINTER LocalDisplay,
586 IN HALNativeWindowType DrawDrawable,
587 IN HALNativeWindowType ReadDrawable,
588 IN gctPOINTER Context,
589 IN gcoSURF ResolveTarget
593 gcoOS_CreateDrawable(
594 IN gctPOINTER LocalDisplay,
595 IN HALNativeWindowType Drawable
599 gcoOS_DestroyDrawable(
600 IN gctPOINTER LocalDisplay,
601 IN HALNativeWindowType Drawable
605 IN gctPOINTER LocalDisplay,
606 IN HALNativeWindowType Drawable,
607 IN gcoSURF RenderTarget,
608 IN gcoSURF ResolveTarget,
609 IN gctPOINTER ResolveBits,
617 #endif /* __gc_hal_eglplatform_h_ */