Added (partially implemented) android video backend and associated files needed to build
authorPaul Hunkin <paul@bieh.net>
Thu, 10 Jun 2010 18:54:23 +1200
changeset 4701d40bb3165d2b
parent 4700 cf23d9b8e606
child 4702 44798016d513
Added (partially implemented) android video backend and associated files needed to build
Makefile.android
build-scripts/acc.sh
build-scripts/ald.sh
build-scripts/android_libs/libEGL.so
build-scripts/android_libs/libcutils.so
build-scripts/android_libs/libutils.so
include/SDL_config_android.h
src/SDL_compat.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/android/SDL_androidevents.c
src/video/android/SDL_androidevents_c.h
src/video/android/SDL_androidgl.c
src/video/android/SDL_androidrender.c
src/video/android/SDL_androidrender_c.h
src/video/android/SDL_androidvideo.c
src/video/android/SDL_androidvideo.h
src/video/android/egl.h
src/video/android/eglext.h
src/video/android/eglplatform.h
     1.1 --- a/Makefile.android	Sun May 23 15:18:16 2010 +1200
     1.2 +++ b/Makefile.android	Thu Jun 10 18:54:23 2010 +1200
     1.3 @@ -5,7 +5,7 @@
     1.4  ANDROID_INCLUDES = 	-I$(ANDROID_NDK)/build/platforms/android-4/common/include \
     1.5  					-I$(ANDROID_NDK)/build/platforms/android-4/arch-arm/usr/include 
     1.6  INCLUDE = -I./include
     1.7 -CFLAGS  = -g -O2 $(INCLUDE) $(ANDROID_INCLUDES) -DANDROID -static
     1.8 +CFLAGS  = -g -O2 $(INCLUDE) $(ANDROID_INCLUDES) -DANDROID -DANDROID_NDK -static
     1.9  
    1.10  AR	= $(TOOLS_PATH)/arm-eabi-ar
    1.11  RANLIB	= $(TOOLS_PATH)/arm-eabi-ranlib
    1.12 @@ -28,7 +28,7 @@
    1.13  	src/video/*.c \
    1.14  	src/power/*.c \
    1.15  	src/audio/dummy/*.c \
    1.16 -	src/video/dummy/*.c \
    1.17 +	src/video/android/*.c \
    1.18  	src/joystick/dummy/*.c \
    1.19  	src/haptic/dummy/*.c \
    1.20  	src/atomic/dummy/*.c \
     2.1 --- a/build-scripts/acc.sh	Sun May 23 15:18:16 2010 +1200
     2.2 +++ b/build-scripts/acc.sh	Thu Jun 10 18:54:23 2010 +1200
     2.3 @@ -7,9 +7,9 @@
     2.4  CC="arm-eabi-gcc"
     2.5  
     2.6  #cflags
     2.7 -ACC_C="	-I$ANDROID_NDK/build/platforms/android-4/common/include \
     2.8 -		-I$ANDROID_NDK/build/platforms/android-4/arch-arm/usr/include \
     2.9 -		-DANDROID -c"
    2.10 +ACC_C="	-I$ANDROID_NDK/build/platforms/android-8/common/include \
    2.11 +		-I$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/include \
    2.12 +		-DANDROID -DANDROID_NDK -c"
    2.13  		
    2.14  		
    2.15  $CC $CFLAGS $ACC_C $@
     3.1 --- a/build-scripts/ald.sh	Sun May 23 15:18:16 2010 +1200
     3.2 +++ b/build-scripts/ald.sh	Thu Jun 10 18:54:23 2010 +1200
     3.3 @@ -1,18 +1,20 @@
     3.4  #!/bin/bash
     3.5  ANDROID_NDK="/home/paul/Projects/gsoc/sdk/android-ndk-r4"
     3.6  TOOLS_PATH="$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin"
     3.7 +ADDITIONAL_LIBS=`dirname "$0"`/android_libs/
     3.8  
     3.9  export PATH=$TOOLS_PATH:$PATH
    3.10  
    3.11  LD="arm-eabi-ld"
    3.12  
    3.13  #ldflags
    3.14 -ACC_L="	-rpath-link=$ANDROID_NDK/build/platforms/android-4/arch-arm/usr/lib/ \
    3.15 +ACC_L="	-rpath-link=$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/ \
    3.16  		-dynamic-linker=/system/bin/linker \
    3.17 -		-L$ANDROID_NDK/build/platforms/android-3/arch-arm/usr/lib/ -lc -nostdlib \
    3.18 - 		$ANDROID_NDK/build/platforms/android-4/arch-arm/usr/lib/crtbegin_static.o \
    3.19 - 		-L$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1 "
    3.20 +		-lc -nostdlib \
    3.21 + 		$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/crtbegin_static.o \
    3.22 + 		-L$ANDROID_NDK/build/platforms/android-8/arch-arm/usr/lib/ \
    3.23 + 		-L$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1 \
    3.24 + 		-L$ADDITIONAL_LIBS "
    3.25  		
    3.26  $LD $ACC_L $LDFLAGS $@ -lgcc
    3.27  
    3.28 -
     4.1 Binary file build-scripts/android_libs/libEGL.so has changed
     5.1 Binary file build-scripts/android_libs/libcutils.so has changed
     6.1 Binary file build-scripts/android_libs/libutils.so has changed
     7.1 --- a/include/SDL_config_android.h	Sun May 23 15:18:16 2010 +1200
     7.2 +++ b/include/SDL_config_android.h	Thu Jun 10 18:54:23 2010 +1200
     7.3 @@ -63,10 +63,14 @@
     7.4  
     7.5  #define SDL_TIMER_UNIX 1
     7.6  
     7.7 -#define SDL_VIDEO_DRIVER_DUMMY 1
     7.8 +#define SDL_VIDEO_DRIVER_ANDROID 1
     7.9  
    7.10  #define HAVE_STDIO_H 1
    7.11  #define HAVE_SYS_TYPES_H 1
    7.12  
    7.13 +#define HAVE_M_PI 1
    7.14 +
    7.15 +#define SDL_VIDEO_RENDER_OGL_ES 1
    7.16 +
    7.17  #endif /* _SDL_config_minimal_h */
    7.18  
     8.1 --- a/src/SDL_compat.c	Sun May 23 15:18:16 2010 +1200
     8.2 +++ b/src/SDL_compat.c	Thu Jun 10 18:54:23 2010 +1200
     8.3 @@ -643,18 +643,29 @@
     8.4  
     8.5      /* If we're in OpenGL mode, just create a stub surface and we're done! */
     8.6      if (flags & SDL_OPENGL) {
     8.7 +        
     8.8 +       printf("1\n");
     8.9 +    
    8.10          SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow);
    8.11          if (!SDL_VideoContext) {
    8.12              return NULL;
    8.13          }
    8.14 +
    8.15 +        
    8.16 +    printf("2\n");
    8.17 +    
    8.18          if (SDL_GL_MakeCurrent(SDL_VideoWindow, SDL_VideoContext) < 0) {
    8.19              return NULL;
    8.20          }
    8.21 +        
    8.22 +    printf("3\n");
    8.23          SDL_VideoSurface =
    8.24              SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0);
    8.25          if (!SDL_VideoSurface) {
    8.26              return NULL;
    8.27          }
    8.28 +        
    8.29 +    printf("4\n");
    8.30          SDL_VideoSurface->flags |= surface_flags;
    8.31          SDL_PublicSurface = SDL_VideoSurface;
    8.32          return SDL_PublicSurface;
     9.1 --- a/src/video/SDL_sysvideo.h	Sun May 23 15:18:16 2010 +1200
     9.2 +++ b/src/video/SDL_sysvideo.h	Thu Jun 10 18:54:23 2010 +1200
     9.3 @@ -414,6 +414,9 @@
     9.4  #if SDL_VIDEO_DRIVER_PANDORA
     9.5  extern VideoBootStrap PND_bootstrap;
     9.6  #endif
     9.7 +#if SDL_VIDEO_DRIVER_ANDROID
     9.8 +extern VideoBootStrap Android_bootstrap;
     9.9 +#endif
    9.10  
    9.11  #define SDL_CurrentDisplay	(&_this->displays[_this->current_display])
    9.12  #define SDL_CurrentRenderer	(SDL_CurrentDisplay->current_renderer)
    10.1 --- a/src/video/SDL_video.c	Sun May 23 15:18:16 2010 +1200
    10.2 +++ b/src/video/SDL_video.c	Thu Jun 10 18:54:23 2010 +1200
    10.3 @@ -100,6 +100,9 @@
    10.4  #if SDL_VIDEO_DRIVER_PANDORA
    10.5      &PND_bootstrap,
    10.6  #endif
    10.7 +#if SDL_VIDEO_DRIVER_ANDROID
    10.8 +    &Android_bootstrap,
    10.9 +#endif
   10.10      NULL
   10.11  };
   10.12  
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/video/android/SDL_androidevents.c	Thu Jun 10 18:54:23 2010 +1200
    11.3 @@ -0,0 +1,52 @@
    11.4 +/*
    11.5 +    SDL - Simple DirectMedia Layer
    11.6 +    Copyright (C) 1997-2010 Sam Lantinga
    11.7 +
    11.8 +    This library is free software; you can redistribute it and/or
    11.9 +    modify it under the terms of the GNU Lesser General Public
   11.10 +    License as published by the Free Software Foundation; either
   11.11 +    version 2.1 of the License, or (at your option) any later version.
   11.12 +
   11.13 +    This library is distributed in the hope that it will be useful,
   11.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.16 +    Lesser General Public License for more details.
   11.17 +
   11.18 +    You should have received a copy of the GNU Lesser General Public
   11.19 +    License along with this library; if not, write to the Free Software
   11.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.21 +
   11.22 +    Sam Lantinga
   11.23 +    slouken@libsdl.org
   11.24 +*/
   11.25 +#include "SDL_config.h"
   11.26 +
   11.27 +/* Being a null driver, there's no event stream. We just define stubs for
   11.28 +   most of the API. */
   11.29 +
   11.30 +#include <stdio.h>
   11.31 +#include <stdlib.h>
   11.32 +
   11.33 +#include "../../events/SDL_sysevents.h"
   11.34 +#include "../../events/SDL_events_c.h"
   11.35 +
   11.36 +void
   11.37 +Android_PumpEvents(_THIS)
   11.38 +{
   11.39 +
   11.40 +    //scanKeys();
   11.41 +    /* TODO: defer click-age */
   11.42 +    /*
   11.43 +    if (keysDown() & KEY_TOUCH) {
   11.44 +        SDL_SendMouseButton(0, SDL_PRESSED, 0);
   11.45 +    } else if (keysUp() & KEY_TOUCH) {
   11.46 +        SDL_SendMouseButton(0, SDL_RELEASED, 0);
   11.47 +    }
   11.48 +    if (keysHeld() & KEY_TOUCH) {
   11.49 +        touchPosition t = touchReadXY();
   11.50 +        SDL_SendMouseMotion(0, 0, t.px, t.py, 1);       
   11.51 +    }
   11.52 +    */
   11.53 +}
   11.54 +
   11.55 +/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/video/android/SDL_androidevents_c.h	Thu Jun 10 18:54:23 2010 +1200
    12.3 @@ -0,0 +1,28 @@
    12.4 +/*
    12.5 +    SDL - Simple DirectMedia Layer
    12.6 +    Copyright (C) 1997-2010 Sam Lantinga
    12.7 +
    12.8 +    This library is free software; you can redistribute it and/or
    12.9 +    modify it under the terms of the GNU Lesser General Public
   12.10 +    License as published by the Free Software Foundation; either
   12.11 +    version 2.1 of the License, or (at your option) any later version.
   12.12 +
   12.13 +    This library is distributed in the hope that it will be useful,
   12.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 +    Lesser General Public License for more details.
   12.17 +
   12.18 +    You should have received a copy of the GNU Lesser General Public
   12.19 +    License along with this library; if not, write to the Free Software
   12.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 +
   12.22 +    Sam Lantinga
   12.23 +    slouken@libsdl.org
   12.24 +*/
   12.25 +#include "SDL_config.h"
   12.26 +
   12.27 +#include "SDL_androidvideo.h"
   12.28 +
   12.29 +extern void Android_PumpEvents(_THIS);
   12.30 +
   12.31 +/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/video/android/SDL_androidgl.c	Thu Jun 10 18:54:23 2010 +1200
    13.3 @@ -0,0 +1,158 @@
    13.4 +/*
    13.5 +    SDL - Simple DirectMedia Layer
    13.6 +    Copyright (C) 1997-2010 Sam Lantinga
    13.7 +
    13.8 +    This library is free software; you can redistribute it and/or
    13.9 +    modify it under the terms of the GNU Lesser General Public
   13.10 +    License as published by the Free Software Foundation; either
   13.11 +    version 2.1 of the License, or (at your option) any later version.
   13.12 +
   13.13 +    This library is distributed in the hope that it will be useful,
   13.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.16 +    Lesser General Public License for more details.
   13.17 +
   13.18 +    You should have received a copy of the GNU Lesser General Public
   13.19 +    License along with this library; if not, write to the Free Software
   13.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.21 +
   13.22 +    Sam Lantinga
   13.23 +    slouken@libsdl.org
   13.24 +*/
   13.25 +#include "SDL_config.h"
   13.26 +
   13.27 +/* Android SDL video driver implementation
   13.28 +*/
   13.29 +
   13.30 +#include "SDL_video.h"
   13.31 +#include "SDL_mouse.h"
   13.32 +#include "../SDL_sysvideo.h"
   13.33 +#include "../SDL_pixels_c.h"
   13.34 +#include "../../events/SDL_events_c.h"
   13.35 +
   13.36 +#include "SDL_androidvideo.h"
   13.37 +#include "SDL_androidevents_c.h"
   13.38 +#include "SDL_androidrender_c.h"
   13.39 +
   13.40 +/* Android header */
   13.41 +#include "egl.h"
   13.42 +
   13.43 +
   13.44 +//EGL globals
   13.45 +static EGLDisplay iEglDisplay; 	
   13.46 +static EGLConfig  iEglConfig;   	
   13.47 +static EGLContext iEglContext; 	
   13.48 +static EGLSurface iEglSurface;	
   13.49 +
   13.50 +EGLint attribList [] = 
   13.51 +{ 
   13.52 +	EGL_BUFFER_SIZE, 16, //16 bit color
   13.53 +	EGL_DEPTH_SIZE, 15,
   13.54 +	EGL_NONE 
   13.55 +};	
   13.56 +
   13.57 +
   13.58 +
   13.59 +
   13.60 +/* GL functions */
   13.61 +int Android_GL_LoadLibrary(_THIS, const char *path){
   13.62 +	printf("[STUB] GL_LoadLibrary\n");
   13.63 +	return 0;
   13.64 +}
   13.65 +
   13.66 +void *Android_GL_GetProcAddress(_THIS, const char *proc){
   13.67 +	printf("[STUB] GL_GetProcAddress\n");
   13.68 +	return 0;
   13.69 +}
   13.70 +
   13.71 +void Android_GL_UnloadLibrary(_THIS){
   13.72 +	printf("[STUB] GL_UnloadLibrary\n");
   13.73 +}
   13.74 +
   13.75 +/*
   13.76 +int *Android_GL_GetVisual(_THIS, Display * display, int screen){
   13.77 +	printf("[STUB] GL_GetVisual\n");
   13.78 +	return 0;
   13.79 +}
   13.80 +*/
   13.81 +
   13.82 +SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window){
   13.83 +	printf("[STUB] GL_CreateContext\n");
   13.84 +
   13.85 +	//Start up the display
   13.86 +	iEglDisplay = eglGetDisplay (EGL_DEFAULT_DISPLAY);
   13.87 +	if(iEglDisplay == EGL_NO_DISPLAY){
   13.88 +		printf("Unable to find a  suitable EGLDisplay\n");
   13.89 +		return NULL;
   13.90 +	}
   13.91 +
   13.92 +	printf("1\n");
   13.93 +		
   13.94 +	if(!eglInitialize(iEglDisplay, 0, 0)){
   13.95 +		printf("Couldn't init display\n");
   13.96 +		return NULL;
   13.97 +	}
   13.98 +
   13.99 +	printf("2\n");
  13.100 +	
  13.101 +	EGLint numConfigs;
  13.102 +	
  13.103 +	if(!eglChooseConfig(iEglDisplay, attribList, &iEglConfig, 1, &numConfigs)){
  13.104 +		printf("Couldn't choose config\n");
  13.105 +		return NULL;
  13.106 +	}
  13.107 +
  13.108 +	printf("3\n");
  13.109 +	 
  13.110 +	iEglContext = eglCreateContext(iEglDisplay, iEglConfig, EGL_NO_CONTEXT, 0);
  13.111 +		
  13.112 +	if(iEglContext == 0){
  13.113 +		printf("Couldn't create context\n");
  13.114 +		return NULL;
  13.115 +	}
  13.116 +
  13.117 +	printf("4\n");
  13.118 +		
  13.119 +	NativeWindowType iWindow = 1; //android_createDisplaySurface();
  13.120 +	
  13.121 +	iEglSurface = eglCreateWindowSurface(iEglDisplay, iEglConfig, iWindow, 0);	
  13.122 +
  13.123 +	printf("5\n");
  13.124 +	
  13.125 +	if(iEglSurface == NULL){
  13.126 +		printf("Couldn't create surface\n");
  13.127 +		return NULL;
  13.128 +	}
  13.129 +
  13.130 +	printf("6\n");
  13.131 +	
  13.132 +	eglMakeCurrent(iEglDisplay, iEglSurface, iEglSurface, iEglContext);
  13.133 +
  13.134 +	printf("fininshed making context\n");
  13.135 +	
  13.136 +	return iEglSurface;
  13.137 +}
  13.138 +
  13.139 +int Android_GL_MakeCurrent(_THIS, SDL_Window * window,
  13.140 +                              SDL_GLContext context){
  13.141 +	printf("[STUB] GL_MakeCurrent\n");
  13.142 +	return 0;
  13.143 +}
  13.144 +
  13.145 +int Android_GL_SetSwapInterval(_THIS, int interval){
  13.146 +	printf("[STUB] GL_SetSwapInterval\n");
  13.147 +	return 0;
  13.148 +}
  13.149 +
  13.150 +int Android_GL_GetSwapInterval(_THIS){
  13.151 +	printf("[STUB] GL_GetSwapInterval\n");
  13.152 +	return 0;
  13.153 +}
  13.154 +
  13.155 +void Android_GL_SwapWindow(_THIS, SDL_Window * window){
  13.156 +	printf("[STUB] GL_SwapWindow\n");
  13.157 +}
  13.158 +
  13.159 +void Android_GL_DeleteContext(_THIS, SDL_GLContext context){
  13.160 +	printf("[STUB] GL_DeleteContext\n");
  13.161 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/video/android/SDL_androidrender.c	Thu Jun 10 18:54:23 2010 +1200
    14.3 @@ -0,0 +1,344 @@
    14.4 +/*
    14.5 +    SDL - Simple DirectMedia Layer
    14.6 +    Copyright (C) 1997-2010 Sam Lantinga
    14.7 +
    14.8 +    This library is free software; you can redistribute it and/or
    14.9 +    modify it under the terms of the GNU Lesser General Public
   14.10 +    License as published by the Free Software Foundation; either
   14.11 +    version 2.1 of the License, or (at your option) any later version.
   14.12 +
   14.13 +    This library is distributed in the hope that it will be useful,
   14.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14.16 +    Lesser General Public License for more details.
   14.17 +
   14.18 +    You should have received a copy of the GNU Lesser General Public
   14.19 +    License along with this library; if not, write to the Free Software
   14.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   14.21 +
   14.22 +    Sam Lantinga
   14.23 +    slouken@libsdl.org
   14.24 +*/
   14.25 +#include "SDL_config.h"
   14.26 +
   14.27 +#include "SDL_video.h"
   14.28 +#include "../SDL_sysvideo.h"
   14.29 +#include "../SDL_yuv_sw_c.h"
   14.30 +#include "../SDL_renderer_sw.h"
   14.31 +
   14.32 +
   14.33 +/* SDL surface based renderer implementation */
   14.34 +
   14.35 +static SDL_Renderer *Android_CreateRenderer(SDL_Window * window,
   14.36 +                                              Uint32 flags);
   14.37 +static int Android_RenderDrawPoints(SDL_Renderer * renderer,
   14.38 +                                      const SDL_Point * points, int count);
   14.39 +static int Android_RenderDrawLines(SDL_Renderer * renderer,
   14.40 +                                     const SDL_Point * points, int count);
   14.41 +static int Android_RenderDrawRects(SDL_Renderer * renderer,
   14.42 +                                     const SDL_Rect ** rects, int count);
   14.43 +static int Android_RenderFillRects(SDL_Renderer * renderer,
   14.44 +                                     const SDL_Rect ** rects, int count);
   14.45 +static int Android_RenderCopy(SDL_Renderer * renderer,
   14.46 +                                SDL_Texture * texture,
   14.47 +                                const SDL_Rect * srcrect,
   14.48 +                                const SDL_Rect * dstrect);
   14.49 +static int Android_RenderReadPixels(SDL_Renderer * renderer,
   14.50 +                                      const SDL_Rect * rect,
   14.51 +                                      Uint32 format,
   14.52 +                                      void * pixels, int pitch);
   14.53 +static int Android_RenderWritePixels(SDL_Renderer * renderer,
   14.54 +                                       const SDL_Rect * rect,
   14.55 +                                       Uint32 format,
   14.56 +                                       const void * pixels, int pitch);
   14.57 +static void Android_RenderPresent(SDL_Renderer * renderer);
   14.58 +static void Android_DestroyRenderer(SDL_Renderer * renderer);
   14.59 +
   14.60 +
   14.61 +SDL_RenderDriver Android_RenderDriver = {
   14.62 +    Android_CreateRenderer,
   14.63 +    {
   14.64 +     "dummy",
   14.65 +     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
   14.66 +      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
   14.67 +      SDL_RENDERER_PRESENTDISCARD),
   14.68 +     }
   14.69 +};
   14.70 +
   14.71 +typedef struct
   14.72 +{
   14.73 +    int current_screen;
   14.74 +    SDL_Surface *screens[3];
   14.75 +} Android_RenderData;
   14.76 +
   14.77 +SDL_Renderer *
   14.78 +Android_CreateRenderer(SDL_Window * window, Uint32 flags)
   14.79 +{
   14.80 +    SDL_VideoDisplay *display = window->display;
   14.81 +    SDL_DisplayMode *displayMode = &display->current_mode;
   14.82 +    SDL_Renderer *renderer;
   14.83 +    Android_RenderData *data;
   14.84 +    int i, n;
   14.85 +    int bpp;
   14.86 +    Uint32 Rmask, Gmask, Bmask, Amask;
   14.87 +
   14.88 +    if (!SDL_PixelFormatEnumToMasks
   14.89 +        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
   14.90 +        SDL_SetError("Unknown display format");
   14.91 +        return NULL;
   14.92 +    }
   14.93 +
   14.94 +    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
   14.95 +    if (!renderer) {
   14.96 +        SDL_OutOfMemory();
   14.97 +        return NULL;
   14.98 +    }
   14.99 +
  14.100 +    data = (Android_RenderData *) SDL_malloc(sizeof(*data));
  14.101 +    if (!data) {
  14.102 +        Android_DestroyRenderer(renderer);
  14.103 +        SDL_OutOfMemory();
  14.104 +        return NULL;
  14.105 +    }
  14.106 +    SDL_zerop(data);
  14.107 +
  14.108 +    renderer->RenderDrawPoints = Android_RenderDrawPoints;
  14.109 +    renderer->RenderDrawLines = Android_RenderDrawLines;
  14.110 +    renderer->RenderDrawRects = Android_RenderDrawRects;
  14.111 +    renderer->RenderFillRects = Android_RenderFillRects;
  14.112 +    renderer->RenderCopy = Android_RenderCopy;
  14.113 +    renderer->RenderReadPixels = Android_RenderReadPixels;
  14.114 +    renderer->RenderWritePixels = Android_RenderWritePixels;
  14.115 +    renderer->RenderPresent = Android_RenderPresent;
  14.116 +    renderer->DestroyRenderer = Android_DestroyRenderer;
  14.117 +    renderer->info.name = Android_RenderDriver.info.name;
  14.118 +    renderer->info.flags = 0;
  14.119 +    renderer->window = window;
  14.120 +    renderer->driverdata = data;
  14.121 +    Setup_SoftwareRenderer(renderer);
  14.122 +
  14.123 +    if (flags & SDL_RENDERER_PRESENTFLIP2) {
  14.124 +        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
  14.125 +        n = 2;
  14.126 +    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
  14.127 +        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
  14.128 +        n = 3;
  14.129 +    } else {
  14.130 +        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
  14.131 +        n = 1;
  14.132 +    }
  14.133 +    for (i = 0; i < n; ++i) {
  14.134 +        data->screens[i] =
  14.135 +            SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
  14.136 +                                 Bmask, Amask);
  14.137 +        if (!data->screens[i]) {
  14.138 +            Android_DestroyRenderer(renderer);
  14.139 +            return NULL;
  14.140 +        }
  14.141 +        SDL_SetSurfacePalette(data->screens[i], display->palette);
  14.142 +    }
  14.143 +    data->current_screen = 0;
  14.144 +
  14.145 +    return renderer;
  14.146 +}
  14.147 +
  14.148 +static int
  14.149 +Android_RenderDrawPoints(SDL_Renderer * renderer,
  14.150 +                           const SDL_Point * points, int count)
  14.151 +{
  14.152 +    Android_RenderData *data =
  14.153 +        (Android_RenderData *) renderer->driverdata;
  14.154 +    SDL_Surface *target = data->screens[data->current_screen];
  14.155 +
  14.156 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
  14.157 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
  14.158 +        Uint32 color = SDL_MapRGBA(target->format,
  14.159 +                                   renderer->r, renderer->g, renderer->b,
  14.160 +                                   renderer->a);
  14.161 +
  14.162 +        return SDL_DrawPoints(target, points, count, color);
  14.163 +    } else {
  14.164 +        return SDL_BlendPoints(target, points, count, renderer->blendMode,
  14.165 +                               renderer->r, renderer->g, renderer->b,
  14.166 +                               renderer->a);
  14.167 +    }
  14.168 +}
  14.169 +
  14.170 +static int
  14.171 +Android_RenderDrawLines(SDL_Renderer * renderer,
  14.172 +                          const SDL_Point * points, int count)
  14.173 +{
  14.174 +    Android_RenderData *data =
  14.175 +        (Android_RenderData *) renderer->driverdata;
  14.176 +    SDL_Surface *target = data->screens[data->current_screen];
  14.177 +
  14.178 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
  14.179 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
  14.180 +        Uint32 color = SDL_MapRGBA(target->format,
  14.181 +                                   renderer->r, renderer->g, renderer->b,
  14.182 +                                   renderer->a);
  14.183 +
  14.184 +        return SDL_DrawLines(target, points, count, color);
  14.185 +    } else {
  14.186 +        return SDL_BlendLines(target, points, count, renderer->blendMode,
  14.187 +                              renderer->r, renderer->g, renderer->b,
  14.188 +                              renderer->a);
  14.189 +    }
  14.190 +}
  14.191 +
  14.192 +static int
  14.193 +Android_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
  14.194 +                          int count)
  14.195 +{
  14.196 +    Android_RenderData *data =
  14.197 +        (Android_RenderData *) renderer->driverdata;
  14.198 +    SDL_Surface *target = data->screens[data->current_screen];
  14.199 +
  14.200 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
  14.201 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
  14.202 +        Uint32 color = SDL_MapRGBA(target->format,
  14.203 +                                   renderer->r, renderer->g, renderer->b,
  14.204 +                                   renderer->a);
  14.205 +
  14.206 +        return SDL_DrawRects(target, rects, count, color);
  14.207 +    } else {
  14.208 +        return SDL_BlendRects(target, rects, count,
  14.209 +                              renderer->blendMode,
  14.210 +                              renderer->r, renderer->g, renderer->b,
  14.211 +                              renderer->a);
  14.212 +    }
  14.213 +}
  14.214 +
  14.215 +static int
  14.216 +Android_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
  14.217 +                          int count)
  14.218 +{
  14.219 +    Android_RenderData *data =
  14.220 +        (Android_RenderData *) renderer->driverdata;
  14.221 +    SDL_Surface *target = data->screens[data->current_screen];
  14.222 +
  14.223 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
  14.224 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
  14.225 +        Uint32 color = SDL_MapRGBA(target->format,
  14.226 +                                   renderer->r, renderer->g, renderer->b,
  14.227 +                                   renderer->a);
  14.228 +
  14.229 +        return SDL_FillRects(target, rects, count, color);
  14.230 +    } else {
  14.231 +        return SDL_BlendFillRects(target, rects, count,
  14.232 +                                  renderer->blendMode,
  14.233 +                                  renderer->r, renderer->g, renderer->b,
  14.234 +                                  renderer->a);
  14.235 +    }
  14.236 +}
  14.237 +
  14.238 +static int
  14.239 +Android_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
  14.240 +                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
  14.241 +{
  14.242 +    Android_RenderData *data =
  14.243 +        (Android_RenderData *) renderer->driverdata;
  14.244 +    SDL_Window *window = renderer->window;
  14.245 +    SDL_VideoDisplay *display = window->display;
  14.246 +
  14.247 +    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
  14.248 +        SDL_Surface *target = data->screens[data->current_screen];
  14.249 +        void *pixels =
  14.250 +            (Uint8 *) target->pixels + dstrect->y * target->pitch +
  14.251 +            dstrect->x * target->format->BytesPerPixel;
  14.252 +        return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
  14.253 +                                   srcrect, display->current_mode.format,
  14.254 +                                   dstrect->w, dstrect->h, pixels,
  14.255 +                                   target->pitch);
  14.256 +    } else {
  14.257 +        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
  14.258 +        SDL_Surface *target = data->screens[data->current_screen];
  14.259 +        SDL_Rect real_srcrect = *srcrect;
  14.260 +        SDL_Rect real_dstrect = *dstrect;
  14.261 +
  14.262 +        return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
  14.263 +    }
  14.264 +}
  14.265 +
  14.266 +static int
  14.267 +Android_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
  14.268 +                           Uint32 format, void * pixels, int pitch)
  14.269 +{
  14.270 +    Android_RenderData *data =
  14.271 +        (Android_RenderData *) renderer->driverdata;
  14.272 +    SDL_Window *window = renderer->window;
  14.273 +    SDL_VideoDisplay *display = window->display;
  14.274 +    SDL_Surface *screen = data->screens[data->current_screen];
  14.275 +    Uint32 screen_format = display->current_mode.format;
  14.276 +    Uint8 *screen_pixels = (Uint8 *) screen->pixels +
  14.277 +                            rect->y * screen->pitch +
  14.278 +                            rect->x * screen->format->BytesPerPixel;
  14.279 +    int screen_pitch = screen->pitch;
  14.280 +
  14.281 +    return SDL_ConvertPixels(rect->w, rect->h,
  14.282 +                             screen_format, screen_pixels, screen_pitch,
  14.283 +                             format, pixels, pitch);
  14.284 +}
  14.285 +
  14.286 +static int
  14.287 +Android_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
  14.288 +                            Uint32 format, const void * pixels, int pitch)
  14.289 +{
  14.290 +    Android_RenderData *data =
  14.291 +        (Android_RenderData *) renderer->driverdata;
  14.292 +    SDL_Window *window = renderer->window;
  14.293 +    SDL_VideoDisplay *display = window->display;
  14.294 +    SDL_Surface *screen = data->screens[data->current_screen];
  14.295 +    Uint32 screen_format = display->current_mode.format;
  14.296 +    Uint8 *screen_pixels = (Uint8 *) screen->pixels +
  14.297 +                            rect->y * screen->pitch +
  14.298 +                            rect->x * screen->format->BytesPerPixel;
  14.299 +    int screen_pitch = screen->pitch;
  14.300 +
  14.301 +    return SDL_ConvertPixels(rect->w, rect->h,
  14.302 +                             format, pixels, pitch,
  14.303 +                             screen_format, screen_pixels, screen_pitch);
  14.304 +}
  14.305 +
  14.306 +static void
  14.307 +Android_RenderPresent(SDL_Renderer * renderer)
  14.308 +{
  14.309 +    static int frame_number;
  14.310 +    Android_RenderData *data =
  14.311 +        (Android_RenderData *) renderer->driverdata;
  14.312 +
  14.313 +    /* Send the data to the display */
  14.314 +    if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
  14.315 +        char file[128];
  14.316 +        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
  14.317 +                     renderer->window->id, ++frame_number);
  14.318 +        SDL_SaveBMP(data->screens[data->current_screen], file);
  14.319 +    }
  14.320 +
  14.321 +    /* Update the flipping chain, if any */
  14.322 +    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
  14.323 +        data->current_screen = (data->current_screen + 1) % 2;
  14.324 +    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
  14.325 +        data->current_screen = (data->current_screen + 1) % 3;
  14.326 +    }
  14.327 +}
  14.328 +
  14.329 +static void
  14.330 +Android_DestroyRenderer(SDL_Renderer * renderer)
  14.331 +{
  14.332 +    Android_RenderData *data =
  14.333 +        (Android_RenderData *) renderer->driverdata;
  14.334 +    int i;
  14.335 +
  14.336 +    if (data) {
  14.337 +        for (i = 0; i < SDL_arraysize(data->screens); ++i) {
  14.338 +            if (data->screens[i]) {
  14.339 +                SDL_FreeSurface(data->screens[i]);
  14.340 +            }
  14.341 +        }
  14.342 +        SDL_free(data);
  14.343 +    }
  14.344 +    SDL_free(renderer);
  14.345 +}
  14.346 +
  14.347 +/* vi: set ts=4 sw=4 expandtab: */
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/video/android/SDL_androidrender_c.h	Thu Jun 10 18:54:23 2010 +1200
    15.3 @@ -0,0 +1,28 @@
    15.4 +/*
    15.5 +    SDL - Simple DirectMedia Layer
    15.6 +    Copyright (C) 1997-2010 Sam Lantinga
    15.7 +
    15.8 +    This library is free software; you can redistribute it and/or
    15.9 +    modify it under the terms of the GNU Lesser General Public
   15.10 +    License as published by the Free Software Foundation; either
   15.11 +    version 2.1 of the License, or (at your option) any later version.
   15.12 +
   15.13 +    This library is distributed in the hope that it will be useful,
   15.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15.16 +    Lesser General Public License for more details.
   15.17 +
   15.18 +    You should have received a copy of the GNU Lesser General Public
   15.19 +    License along with this library; if not, write to the Free Software
   15.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   15.21 +
   15.22 +    Sam Lantinga
   15.23 +    slouken@libsdl.org
   15.24 +*/
   15.25 +#include "SDL_config.h"
   15.26 +
   15.27 +/* SDL surface based renderer implementation */
   15.28 +
   15.29 +extern SDL_RenderDriver Android_RenderDriver;
   15.30 +
   15.31 +/* vi: set ts=4 sw=4 expandtab: */
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/src/video/android/SDL_androidvideo.c	Thu Jun 10 18:54:23 2010 +1200
    16.3 @@ -0,0 +1,152 @@
    16.4 +/*
    16.5 +    SDL - Simple DirectMedia Layer
    16.6 +    Copyright (C) 1997-2010 Sam Lantinga
    16.7 +
    16.8 +    This library is free software; you can redistribute it and/or
    16.9 +    modify it under the terms of the GNU Lesser General Public
   16.10 +    License as published by the Free Software Foundation; either
   16.11 +    version 2.1 of the License, or (at your option) any later version.
   16.12 +
   16.13 +    This library is distributed in the hope that it will be useful,
   16.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.16 +    Lesser General Public License for more details.
   16.17 +
   16.18 +    You should have received a copy of the GNU Lesser General Public
   16.19 +    License along with this library; if not, write to the Free Software
   16.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   16.21 +
   16.22 +    Sam Lantinga
   16.23 +    slouken@libsdl.org
   16.24 +*/
   16.25 +#include "SDL_config.h"
   16.26 +
   16.27 +/* Android SDL video driver implementation
   16.28 +*/
   16.29 +
   16.30 +#include "SDL_video.h"
   16.31 +#include "SDL_mouse.h"
   16.32 +#include "../SDL_sysvideo.h"
   16.33 +#include "../SDL_pixels_c.h"
   16.34 +#include "../../events/SDL_events_c.h"
   16.35 +
   16.36 +#include "SDL_androidvideo.h"
   16.37 +#include "SDL_androidevents_c.h"
   16.38 +#include "SDL_androidrender_c.h"
   16.39 +
   16.40 +#define ANDROID_VID_DRIVER_NAME "Android"
   16.41 +
   16.42 +/* Initialization/Query functions */
   16.43 +static int Android_VideoInit(_THIS);
   16.44 +static int Android_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   16.45 +static void Android_VideoQuit(_THIS);
   16.46 +
   16.47 +/* GL functions (SDL_androidgl.c) */
   16.48 +extern int Android_GL_LoadLibrary(_THIS, const char *path);
   16.49 +extern void *Android_GL_GetProcAddress(_THIS, const char *proc);
   16.50 +extern void Android_GL_UnloadLibrary(_THIS);
   16.51 +//extern int *Android_GL_GetVisual(_THIS, Display * display, int screen);
   16.52 +extern SDL_GLContext Android_GL_CreateContext(_THIS, SDL_Window * window);
   16.53 +extern int Android_GL_MakeCurrent(_THIS, SDL_Window * window,
   16.54 +                              SDL_GLContext context);
   16.55 +extern int Android_GL_SetSwapInterval(_THIS, int interval);
   16.56 +extern int Android_GL_GetSwapInterval(_THIS);
   16.57 +extern void Android_GL_SwapWindow(_THIS, SDL_Window * window);
   16.58 +extern void Android_GL_DeleteContext(_THIS, SDL_GLContext context);
   16.59 +
   16.60 +/* Android driver bootstrap functions */
   16.61 +
   16.62 +
   16.63 +static int
   16.64 +Android_Available(void)
   16.65 +{
   16.66 +    return 1;
   16.67 +}
   16.68 +
   16.69 +static void
   16.70 +Android_DeleteDevice(SDL_VideoDevice * device)
   16.71 +{
   16.72 +    SDL_free(device);
   16.73 +}
   16.74 +
   16.75 +static SDL_VideoDevice *
   16.76 +Android_CreateDevice(int devindex)
   16.77 +{
   16.78 +    printf("Creating video device\n");
   16.79 +    SDL_VideoDevice *device;
   16.80 +
   16.81 +    /* Initialize all variables that we clean on shutdown */
   16.82 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   16.83 +    if (!device) {
   16.84 +        SDL_OutOfMemory();
   16.85 +        if (device) {
   16.86 +            SDL_free(device);
   16.87 +        }
   16.88 +        return (0);
   16.89 +    }
   16.90 +
   16.91 +    /* Set the function pointers */
   16.92 +    device->VideoInit = Android_VideoInit;
   16.93 +    device->VideoQuit = Android_VideoQuit;
   16.94 +    device->SetDisplayMode = Android_SetDisplayMode;
   16.95 +    device->PumpEvents = Android_PumpEvents;
   16.96 +   
   16.97 +    device->free = Android_DeleteDevice;
   16.98 +
   16.99 +    /* GL pointers */
  16.100 +    device->GL_LoadLibrary = Android_GL_LoadLibrary;
  16.101 +    device->GL_GetProcAddress = Android_GL_GetProcAddress;
  16.102 +    device->GL_UnloadLibrary = Android_GL_UnloadLibrary;
  16.103 +    device->GL_CreateContext = Android_GL_CreateContext;
  16.104 +    device->GL_MakeCurrent = Android_GL_MakeCurrent;
  16.105 +    device->GL_SetSwapInterval = Android_GL_SetSwapInterval;
  16.106 +    device->GL_GetSwapInterval = Android_GL_GetSwapInterval;
  16.107 +    device->GL_SwapWindow = Android_GL_SwapWindow;
  16.108 +    device->GL_DeleteContext = Android_GL_DeleteContext;
  16.109 +
  16.110 +    return device;
  16.111 +}
  16.112 +
  16.113 +VideoBootStrap Android_bootstrap = {
  16.114 +    ANDROID_VID_DRIVER_NAME, "SDL Android video driver",
  16.115 +    Android_Available, Android_CreateDevice
  16.116 +};
  16.117 +
  16.118 +
  16.119 +int
  16.120 +Android_VideoInit(_THIS)
  16.121 +{
  16.122 +    SDL_DisplayMode mode;
  16.123 +
  16.124 +    /* Use a fake 32-bpp desktop mode */
  16.125 +    mode.format = SDL_PIXELFORMAT_RGB888;
  16.126 +    mode.w = 1024;
  16.127 +    mode.h = 768;
  16.128 +    mode.refresh_rate = 0;
  16.129 +    mode.driverdata = NULL;
  16.130 +    if (SDL_AddBasicVideoDisplay(&mode) < 0) {
  16.131 +        return -1;
  16.132 +    }
  16.133 +    SDL_AddRenderDriver(&_this->displays[0], &Android_RenderDriver);
  16.134 +
  16.135 +    SDL_zero(mode);
  16.136 +    SDL_AddDisplayMode(&_this->displays[0], &mode);
  16.137 +
  16.138 +    /* We're done! */
  16.139 +    return 0;
  16.140 +}
  16.141 +
  16.142 +static int
  16.143 +Android_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  16.144 +{
  16.145 +    return 0;
  16.146 +}
  16.147 +
  16.148 +void
  16.149 +Android_VideoQuit(_THIS)
  16.150 +{
  16.151 +}
  16.152 +
  16.153 +
  16.154 +
  16.155 +/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/video/android/SDL_androidvideo.h	Thu Jun 10 18:54:23 2010 +1200
    17.3 @@ -0,0 +1,31 @@
    17.4 +/*
    17.5 +    SDL - Simple DirectMedia Layer
    17.6 +    Copyright (C) 1997-2010 Sam Lantinga
    17.7 +
    17.8 +    This library is free software; you can redistribute it and/or
    17.9 +    modify it under the terms of the GNU Lesser General Public
   17.10 +    License as published by the Free Software Foundation; either
   17.11 +    version 2.1 of the License, or (at your option) any later version.
   17.12 +
   17.13 +    This library is distributed in the hope that it will be useful,
   17.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.16 +    Lesser General Public License for more details.
   17.17 +
   17.18 +    You should have received a copy of the GNU Lesser General Public
   17.19 +    License along with this library; if not, write to the Free Software
   17.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   17.21 +
   17.22 +    Sam Lantinga
   17.23 +    slouken@libsdl.org
   17.24 +*/
   17.25 +#include "SDL_config.h"
   17.26 +
   17.27 +#ifndef _SDL_androidvideo_h
   17.28 +#define _SDL_androidvideo_h
   17.29 +
   17.30 +#include "../SDL_sysvideo.h"
   17.31 +
   17.32 +#endif /* _SDL_ndsvideo_h */
   17.33 +
   17.34 +/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/video/android/egl.h	Thu Jun 10 18:54:23 2010 +1200
    18.3 @@ -0,0 +1,330 @@
    18.4 +/* -*- mode: c; tab-width: 8; -*- */
    18.5 +/* vi: set sw=4 ts=8: */
    18.6 +/* Reference version of egl.h for EGL 1.4.
    18.7 + * $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $
    18.8 + */
    18.9 +
   18.10 +/*
   18.11 +** Copyright (c) 2007-2009 The Khronos Group Inc.
   18.12 +**
   18.13 +** Permission is hereby granted, free of charge, to any person obtaining a
   18.14 +** copy of this software and/or associated documentation files (the
   18.15 +** "Materials"), to deal in the Materials without restriction, including
   18.16 +** without limitation the rights to use, copy, modify, merge, publish,
   18.17 +** distribute, sublicense, and/or sell copies of the Materials, and to
   18.18 +** permit persons to whom the Materials are furnished to do so, subject to
   18.19 +** the following conditions:
   18.20 +**
   18.21 +** The above copyright notice and this permission notice shall be included
   18.22 +** in all copies or substantial portions of the Materials.
   18.23 +**
   18.24 +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   18.25 +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   18.26 +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   18.27 +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   18.28 +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   18.29 +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   18.30 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
   18.31 +*/
   18.32 +
   18.33 +#ifndef __egl_h_
   18.34 +#define __egl_h_
   18.35 +
   18.36 +/* All platform-dependent types and macro boilerplate (such as EGLAPI
   18.37 + * and EGLAPIENTRY) should go in eglplatform.h.
   18.38 + */
   18.39 +#include "eglplatform.h"
   18.40 +
   18.41 +#ifdef __cplusplus
   18.42 +extern "C" {
   18.43 +#endif
   18.44 +
   18.45 +/* EGL Types */
   18.46 +/* EGLint is defined in eglplatform.h */
   18.47 +typedef unsigned int EGLBoolean;
   18.48 +typedef unsigned int EGLenum;
   18.49 +typedef void *EGLConfig;
   18.50 +typedef void *EGLContext;
   18.51 +typedef void *EGLDisplay;
   18.52 +typedef void *EGLSurface;
   18.53 +typedef void *EGLClientBuffer;
   18.54 +
   18.55 +/* EGL Versioning */
   18.56 +#define EGL_VERSION_1_0			1
   18.57 +#define EGL_VERSION_1_1			1
   18.58 +#define EGL_VERSION_1_2			1
   18.59 +#define EGL_VERSION_1_3			1
   18.60 +#define EGL_VERSION_1_4			1
   18.61 +
   18.62 +/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
   18.63 + * enums are assigned unique values starting at 0x3000.
   18.64 + */
   18.65 +
   18.66 +/* EGL aliases */
   18.67 +#define EGL_FALSE			0
   18.68 +#define EGL_TRUE			1
   18.69 +
   18.70 +/* Out-of-band handle values */
   18.71 +#define EGL_DEFAULT_DISPLAY		((EGLNativeDisplayType)0)
   18.72 +#define EGL_NO_CONTEXT			((EGLContext)0)
   18.73 +#define EGL_NO_DISPLAY			((EGLDisplay)0)
   18.74 +#define EGL_NO_SURFACE			((EGLSurface)0)
   18.75 +
   18.76 +/* Out-of-band attribute value */
   18.77 +#define EGL_DONT_CARE			((EGLint)-1)
   18.78 +
   18.79 +/* Errors / GetError return values */
   18.80 +#define EGL_SUCCESS			0x3000
   18.81 +#define EGL_NOT_INITIALIZED		0x3001
   18.82 +#define EGL_BAD_ACCESS			0x3002
   18.83 +#define EGL_BAD_ALLOC			0x3003
   18.84 +#define EGL_BAD_ATTRIBUTE		0x3004
   18.85 +#define EGL_BAD_CONFIG			0x3005
   18.86 +#define EGL_BAD_CONTEXT			0x3006
   18.87 +#define EGL_BAD_CURRENT_SURFACE		0x3007
   18.88 +#define EGL_BAD_DISPLAY			0x3008
   18.89 +#define EGL_BAD_MATCH			0x3009
   18.90 +#define EGL_BAD_NATIVE_PIXMAP		0x300A
   18.91 +#define EGL_BAD_NATIVE_WINDOW		0x300B
   18.92 +#define EGL_BAD_PARAMETER		0x300C
   18.93 +#define EGL_BAD_SURFACE			0x300D
   18.94 +#define EGL_CONTEXT_LOST		0x300E	/* EGL 1.1 - IMG_power_management */
   18.95 +
   18.96 +/* Reserved 0x300F-0x301F for additional errors */
   18.97 +
   18.98 +/* Config attributes */
   18.99 +#define EGL_BUFFER_SIZE			0x3020
  18.100 +#define EGL_ALPHA_SIZE			0x3021
  18.101 +#define EGL_BLUE_SIZE			0x3022
  18.102 +#define EGL_GREEN_SIZE			0x3023
  18.103 +#define EGL_RED_SIZE			0x3024
  18.104 +#define EGL_DEPTH_SIZE			0x3025
  18.105 +#define EGL_STENCIL_SIZE		0x3026
  18.106 +#define EGL_CONFIG_CAVEAT		0x3027
  18.107 +#define EGL_CONFIG_ID			0x3028
  18.108 +#define EGL_LEVEL			0x3029
  18.109 +#define EGL_MAX_PBUFFER_HEIGHT		0x302A
  18.110 +#define EGL_MAX_PBUFFER_PIXELS		0x302B
  18.111 +#define EGL_MAX_PBUFFER_WIDTH		0x302C
  18.112 +#define EGL_NATIVE_RENDERABLE		0x302D
  18.113 +#define EGL_NATIVE_VISUAL_ID		0x302E
  18.114 +#define EGL_NATIVE_VISUAL_TYPE		0x302F
  18.115 +#define EGL_PRESERVED_RESOURCES		0x3030
  18.116 +#define EGL_SAMPLES			0x3031
  18.117 +#define EGL_SAMPLE_BUFFERS		0x3032
  18.118 +#define EGL_SURFACE_TYPE		0x3033
  18.119 +#define EGL_TRANSPARENT_TYPE		0x3034
  18.120 +#define EGL_TRANSPARENT_BLUE_VALUE	0x3035
  18.121 +#define EGL_TRANSPARENT_GREEN_VALUE	0x3036
  18.122 +#define EGL_TRANSPARENT_RED_VALUE	0x3037
  18.123 +#define EGL_NONE			0x3038	/* Attrib list terminator */
  18.124 +#define EGL_BIND_TO_TEXTURE_RGB		0x3039
  18.125 +#define EGL_BIND_TO_TEXTURE_RGBA	0x303A
  18.126 +#define EGL_MIN_SWAP_INTERVAL		0x303B
  18.127 +#define EGL_MAX_SWAP_INTERVAL		0x303C
  18.128 +#define EGL_LUMINANCE_SIZE		0x303D
  18.129 +#define EGL_ALPHA_MASK_SIZE		0x303E
  18.130 +#define EGL_COLOR_BUFFER_TYPE		0x303F
  18.131 +#define EGL_RENDERABLE_TYPE		0x3040
  18.132 +#define EGL_MATCH_NATIVE_PIXMAP		0x3041	/* Pseudo-attribute (not queryable) */
  18.133 +#define EGL_CONFORMANT			0x3042
  18.134 +
  18.135 +/* Reserved 0x3041-0x304F for additional config attributes */
  18.136 +
  18.137 +/* Config attribute values */
  18.138 +#define EGL_SLOW_CONFIG			0x3050	/* EGL_CONFIG_CAVEAT value */
  18.139 +#define EGL_NON_CONFORMANT_CONFIG	0x3051	/* EGL_CONFIG_CAVEAT value */
  18.140 +#define EGL_TRANSPARENT_RGB		0x3052	/* EGL_TRANSPARENT_TYPE value */
  18.141 +#define EGL_RGB_BUFFER			0x308E	/* EGL_COLOR_BUFFER_TYPE value */
  18.142 +#define EGL_LUMINANCE_BUFFER		0x308F	/* EGL_COLOR_BUFFER_TYPE value */
  18.143 +
  18.144 +/* More config attribute values, for EGL_TEXTURE_FORMAT */
  18.145 +#define EGL_NO_TEXTURE			0x305C
  18.146 +#define EGL_TEXTURE_RGB			0x305D
  18.147 +#define EGL_TEXTURE_RGBA		0x305E
  18.148 +#define EGL_TEXTURE_2D			0x305F
  18.149 +
  18.150 +/* Config attribute mask bits */
  18.151 +#define EGL_PBUFFER_BIT			0x0001	/* EGL_SURFACE_TYPE mask bits */
  18.152 +#define EGL_PIXMAP_BIT			0x0002	/* EGL_SURFACE_TYPE mask bits */
  18.153 +#define EGL_WINDOW_BIT			0x0004	/* EGL_SURFACE_TYPE mask bits */
  18.154 +#define EGL_VG_COLORSPACE_LINEAR_BIT	0x0020	/* EGL_SURFACE_TYPE mask bits */
  18.155 +#define EGL_VG_ALPHA_FORMAT_PRE_BIT	0x0040	/* EGL_SURFACE_TYPE mask bits */
  18.156 +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200	/* EGL_SURFACE_TYPE mask bits */
  18.157 +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400	/* EGL_SURFACE_TYPE mask bits */
  18.158 +
  18.159 +#define EGL_OPENGL_ES_BIT		0x0001	/* EGL_RENDERABLE_TYPE mask bits */
  18.160 +#define EGL_OPENVG_BIT			0x0002	/* EGL_RENDERABLE_TYPE mask bits */
  18.161 +#define EGL_OPENGL_ES2_BIT		0x0004	/* EGL_RENDERABLE_TYPE mask bits */
  18.162 +#define EGL_OPENGL_BIT			0x0008	/* EGL_RENDERABLE_TYPE mask bits */
  18.163 +
  18.164 +/* QueryString targets */
  18.165 +#define EGL_VENDOR			0x3053
  18.166 +#define EGL_VERSION			0x3054
  18.167 +#define EGL_EXTENSIONS			0x3055
  18.168 +#define EGL_CLIENT_APIS			0x308D
  18.169 +
  18.170 +/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
  18.171 +#define EGL_HEIGHT			0x3056
  18.172 +#define EGL_WIDTH			0x3057
  18.173 +#define EGL_LARGEST_PBUFFER		0x3058
  18.174 +#define EGL_TEXTURE_FORMAT		0x3080
  18.175 +#define EGL_TEXTURE_TARGET		0x3081
  18.176 +#define EGL_MIPMAP_TEXTURE		0x3082
  18.177 +#define EGL_MIPMAP_LEVEL		0x3083
  18.178 +#define EGL_RENDER_BUFFER		0x3086
  18.179 +#define EGL_VG_COLORSPACE		0x3087
  18.180 +#define EGL_VG_ALPHA_FORMAT		0x3088
  18.181 +#define EGL_HORIZONTAL_RESOLUTION	0x3090
  18.182 +#define EGL_VERTICAL_RESOLUTION		0x3091
  18.183 +#define EGL_PIXEL_ASPECT_RATIO		0x3092
  18.184 +#define EGL_SWAP_BEHAVIOR		0x3093
  18.185 +#define EGL_MULTISAMPLE_RESOLVE		0x3099
  18.186 +
  18.187 +/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
  18.188 +#define EGL_BACK_BUFFER			0x3084
  18.189 +#define EGL_SINGLE_BUFFER		0x3085
  18.190 +
  18.191 +/* OpenVG color spaces */
  18.192 +#define EGL_VG_COLORSPACE_sRGB		0x3089	/* EGL_VG_COLORSPACE value */
  18.193 +#define EGL_VG_COLORSPACE_LINEAR	0x308A	/* EGL_VG_COLORSPACE value */
  18.194 +
  18.195 +/* OpenVG alpha formats */
  18.196 +#define EGL_VG_ALPHA_FORMAT_NONPRE	0x308B	/* EGL_ALPHA_FORMAT value */
  18.197 +#define EGL_VG_ALPHA_FORMAT_PRE		0x308C	/* EGL_ALPHA_FORMAT value */
  18.198 +
  18.199 +/* Constant scale factor by which fractional display resolutions &
  18.200 + * aspect ratio are scaled when queried as integer values.
  18.201 + */
  18.202 +#define EGL_DISPLAY_SCALING		10000
  18.203 +
  18.204 +/* Unknown display resolution/aspect ratio */
  18.205 +#define EGL_UNKNOWN			((EGLint)-1)
  18.206 +
  18.207 +/* Back buffer swap behaviors */
  18.208 +#define EGL_BUFFER_PRESERVED		0x3094	/* EGL_SWAP_BEHAVIOR value */
  18.209 +#define EGL_BUFFER_DESTROYED		0x3095	/* EGL_SWAP_BEHAVIOR value */
  18.210 +
  18.211 +/* CreatePbufferFromClientBuffer buffer types */
  18.212 +#define EGL_OPENVG_IMAGE		0x3096
  18.213 +
  18.214 +/* QueryContext targets */
  18.215 +#define EGL_CONTEXT_CLIENT_TYPE		0x3097
  18.216 +
  18.217 +/* CreateContext attributes */
  18.218 +#define EGL_CONTEXT_CLIENT_VERSION	0x3098
  18.219 +
  18.220 +/* Multisample resolution behaviors */
  18.221 +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A	/* EGL_MULTISAMPLE_RESOLVE value */
  18.222 +#define EGL_MULTISAMPLE_RESOLVE_BOX	0x309B	/* EGL_MULTISAMPLE_RESOLVE value */
  18.223 +
  18.224 +/* BindAPI/QueryAPI targets */
  18.225 +#define EGL_OPENGL_ES_API		0x30A0
  18.226 +#define EGL_OPENVG_API			0x30A1
  18.227 +#define EGL_OPENGL_API			0x30A2
  18.228 +
  18.229 +/* GetCurrentSurface targets */
  18.230 +#define EGL_DRAW			0x3059
  18.231 +#define EGL_READ			0x305A
  18.232 +
  18.233 +/* WaitNative engines */
  18.234 +#define EGL_CORE_NATIVE_ENGINE		0x305B
  18.235 +
  18.236 +/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
  18.237 +#define EGL_COLORSPACE			EGL_VG_COLORSPACE
  18.238 +#define EGL_ALPHA_FORMAT		EGL_VG_ALPHA_FORMAT
  18.239 +#define EGL_COLORSPACE_sRGB		EGL_VG_COLORSPACE_sRGB
  18.240 +#define EGL_COLORSPACE_LINEAR		EGL_VG_COLORSPACE_LINEAR
  18.241 +#define EGL_ALPHA_FORMAT_NONPRE		EGL_VG_ALPHA_FORMAT_NONPRE
  18.242 +#define EGL_ALPHA_FORMAT_PRE		EGL_VG_ALPHA_FORMAT_PRE
  18.243 +
  18.244 +/* EGL extensions must request enum blocks from the Khronos
  18.245 + * API Registrar, who maintains the enumerant registry. Submit
  18.246 + * a bug in Khronos Bugzilla against task "Registry".
  18.247 + */
  18.248 +
  18.249 +
  18.250 +
  18.251 +/* EGL Functions */
  18.252 +
  18.253 +EGLAPI EGLint EGLAPIENTRY eglGetError(void);
  18.254 +
  18.255 +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
  18.256 +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
  18.257 +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
  18.258 +
  18.259 +EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
  18.260 +
  18.261 +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
  18.262 +			 EGLint config_size, EGLint *num_config);
  18.263 +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
  18.264 +			   EGLConfig *configs, EGLint config_size,
  18.265 +			   EGLint *num_config);
  18.266 +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
  18.267 +			      EGLint attribute, EGLint *value);
  18.268 +
  18.269 +EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
  18.270 +				  EGLNativeWindowType win,
  18.271 +				  const EGLint *attrib_list);
  18.272 +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
  18.273 +				   const EGLint *attrib_list);
  18.274 +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
  18.275 +				  EGLNativePixmapType pixmap,
  18.276 +				  const EGLint *attrib_list);
  18.277 +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
  18.278 +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
  18.279 +			   EGLint attribute, EGLint *value);
  18.280 +
  18.281 +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
  18.282 +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
  18.283 +
  18.284 +EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
  18.285 +
  18.286 +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
  18.287 +
  18.288 +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
  18.289 +	      EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
  18.290 +	      EGLConfig config, const EGLint *attrib_list);
  18.291 +
  18.292 +EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
  18.293 +			    EGLint attribute, EGLint value);
  18.294 +EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
  18.295 +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
  18.296 +
  18.297 +
  18.298 +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
  18.299 +
  18.300 +
  18.301 +EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
  18.302 +			    EGLContext share_context,
  18.303 +			    const EGLint *attrib_list);
  18.304 +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
  18.305 +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
  18.306 +			  EGLSurface read, EGLContext ctx);
  18.307 +
  18.308 +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
  18.309 +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
  18.310 +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
  18.311 +EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
  18.312 +			   EGLint attribute, EGLint *value);
  18.313 +
  18.314 +EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
  18.315 +EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
  18.316 +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
  18.317 +EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
  18.318 +			  EGLNativePixmapType target);
  18.319 +
  18.320 +/* This is a generic function pointer type, whose name indicates it must
  18.321 + * be cast to the proper type *and calling convention* before use.
  18.322 + */
  18.323 +typedef void (*__eglMustCastToProperFunctionPointerType)(void);
  18.324 +
  18.325 +/* Now, define eglGetProcAddress using the generic function ptr. type */
  18.326 +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
  18.327 +       eglGetProcAddress(const char *procname);
  18.328 +
  18.329 +#ifdef __cplusplus
  18.330 +}
  18.331 +#endif
  18.332 +
  18.333 +#endif /* __egl_h_ */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/video/android/eglext.h	Thu Jun 10 18:54:23 2010 +1200
    19.3 @@ -0,0 +1,162 @@
    19.4 +#ifndef __eglext_h_
    19.5 +#define __eglext_h_
    19.6 +
    19.7 +#ifdef __cplusplus
    19.8 +extern "C" {
    19.9 +#endif
   19.10 +
   19.11 +/*
   19.12 +** Copyright (c) 2007-2009 The Khronos Group Inc.
   19.13 +**
   19.14 +** Permission is hereby granted, free of charge, to any person obtaining a
   19.15 +** copy of this software and/or associated documentation files (the
   19.16 +** "Materials"), to deal in the Materials without restriction, including
   19.17 +** without limitation the rights to use, copy, modify, merge, publish,
   19.18 +** distribute, sublicense, and/or sell copies of the Materials, and to
   19.19 +** permit persons to whom the Materials are furnished to do so, subject to
   19.20 +** the following conditions:
   19.21 +**
   19.22 +** The above copyright notice and this permission notice shall be included
   19.23 +** in all copies or substantial portions of the Materials.
   19.24 +**
   19.25 +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   19.26 +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   19.27 +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   19.28 +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   19.29 +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   19.30 +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   19.31 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
   19.32 +*/
   19.33 +
   19.34 +#include <EGL/eglplatform.h>
   19.35 +
   19.36 +/*************************************************************/
   19.37 +
   19.38 +/* Header file version number */
   19.39 +/* Current version at http://www.khronos.org/registry/egl/ */
   19.40 +/* $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $ */
   19.41 +#define EGL_EGLEXT_VERSION 3
   19.42 +
   19.43 +#ifndef EGL_KHR_config_attribs
   19.44 +#define EGL_KHR_config_attribs 1
   19.45 +#define EGL_CONFORMANT_KHR			0x3042	/* EGLConfig attribute */
   19.46 +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR	0x0020	/* EGL_SURFACE_TYPE bitfield */
   19.47 +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR		0x0040	/* EGL_SURFACE_TYPE bitfield */
   19.48 +#endif
   19.49 +
   19.50 +#ifndef EGL_KHR_lock_surface
   19.51 +#define EGL_KHR_lock_surface 1
   19.52 +#define EGL_READ_SURFACE_BIT_KHR		0x0001	/* EGL_LOCK_USAGE_HINT_KHR bitfield */
   19.53 +#define EGL_WRITE_SURFACE_BIT_KHR		0x0002	/* EGL_LOCK_USAGE_HINT_KHR bitfield */
   19.54 +#define EGL_LOCK_SURFACE_BIT_KHR		0x0080	/* EGL_SURFACE_TYPE bitfield */
   19.55 +#define EGL_OPTIMAL_FORMAT_BIT_KHR		0x0100	/* EGL_SURFACE_TYPE bitfield */
   19.56 +#define EGL_MATCH_FORMAT_KHR			0x3043	/* EGLConfig attribute */
   19.57 +#define EGL_FORMAT_RGB_565_EXACT_KHR		0x30C0	/* EGL_MATCH_FORMAT_KHR value */
   19.58 +#define EGL_FORMAT_RGB_565_KHR			0x30C1	/* EGL_MATCH_FORMAT_KHR value */
   19.59 +#define EGL_FORMAT_RGBA_8888_EXACT_KHR		0x30C2	/* EGL_MATCH_FORMAT_KHR value */
   19.60 +#define EGL_FORMAT_RGBA_8888_KHR		0x30C3	/* EGL_MATCH_FORMAT_KHR value */
   19.61 +#define EGL_MAP_PRESERVE_PIXELS_KHR		0x30C4	/* eglLockSurfaceKHR attribute */
   19.62 +#define EGL_LOCK_USAGE_HINT_KHR			0x30C5	/* eglLockSurfaceKHR attribute */
   19.63 +#define EGL_BITMAP_POINTER_KHR			0x30C6	/* eglQuerySurface attribute */
   19.64 +#define EGL_BITMAP_PITCH_KHR			0x30C7	/* eglQuerySurface attribute */
   19.65 +#define EGL_BITMAP_ORIGIN_KHR			0x30C8	/* eglQuerySurface attribute */
   19.66 +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR		0x30C9	/* eglQuerySurface attribute */
   19.67 +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR	0x30CA	/* eglQuerySurface attribute */
   19.68 +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR	0x30CB	/* eglQuerySurface attribute */
   19.69 +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR	0x30CC	/* eglQuerySurface attribute */
   19.70 +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR	0x30CD	/* eglQuerySurface attribute */
   19.71 +#define EGL_LOWER_LEFT_KHR			0x30CE	/* EGL_BITMAP_ORIGIN_KHR value */
   19.72 +#define EGL_UPPER_LEFT_KHR			0x30CF	/* EGL_BITMAP_ORIGIN_KHR value */
   19.73 +#ifdef EGL_EGLEXT_PROTOTYPES
   19.74 +EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
   19.75 +EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
   19.76 +#endif /* EGL_EGLEXT_PROTOTYPES */
   19.77 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
   19.78 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
   19.79 +#endif
   19.80 +
   19.81 +#ifndef EGL_KHR_image
   19.82 +#define EGL_KHR_image 1
   19.83 +#define EGL_NATIVE_PIXMAP_KHR			0x30B0	/* eglCreateImageKHR target */
   19.84 +typedef void *EGLImageKHR;
   19.85 +#define EGL_NO_IMAGE_KHR			((EGLImageKHR)0)
   19.86 +#ifdef EGL_EGLEXT_PROTOTYPES
   19.87 +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
   19.88 +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
   19.89 +#endif /* EGL_EGLEXT_PROTOTYPES */
   19.90 +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
   19.91 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
   19.92 +#endif
   19.93 +
   19.94 +#ifndef EGL_KHR_vg_parent_image
   19.95 +#define EGL_KHR_vg_parent_image 1
   19.96 +#define EGL_VG_PARENT_IMAGE_KHR			0x30BA	/* eglCreateImageKHR target */
   19.97 +#endif
   19.98 +
   19.99 +#ifndef EGL_KHR_gl_texture_2D_image
  19.100 +#define EGL_KHR_gl_texture_2D_image 1
  19.101 +#define EGL_GL_TEXTURE_2D_KHR			0x30B1	/* eglCreateImageKHR target */
  19.102 +#define EGL_GL_TEXTURE_LEVEL_KHR		0x30BC	/* eglCreateImageKHR attribute */
  19.103 +#endif
  19.104 +
  19.105 +#ifndef EGL_KHR_gl_texture_cubemap_image
  19.106 +#define EGL_KHR_gl_texture_cubemap_image 1
  19.107 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR	0x30B3	/* eglCreateImageKHR target */
  19.108 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR	0x30B4	/* eglCreateImageKHR target */
  19.109 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR	0x30B5	/* eglCreateImageKHR target */
  19.110 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR	0x30B6	/* eglCreateImageKHR target */
  19.111 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR	0x30B7	/* eglCreateImageKHR target */
  19.112 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR	0x30B8	/* eglCreateImageKHR target */
  19.113 +#endif
  19.114 +
  19.115 +#ifndef EGL_KHR_gl_texture_3D_image
  19.116 +#define EGL_KHR_gl_texture_3D_image 1
  19.117 +#define EGL_GL_TEXTURE_3D_KHR			0x30B2	/* eglCreateImageKHR target */
  19.118 +#define EGL_GL_TEXTURE_ZOFFSET_KHR		0x30BD	/* eglCreateImageKHR attribute */
  19.119 +#endif
  19.120 +
  19.121 +#ifndef EGL_KHR_gl_renderbuffer_image
  19.122 +#define EGL_KHR_gl_renderbuffer_image 1
  19.123 +#define EGL_GL_RENDERBUFFER_KHR			0x30B9	/* eglCreateImageKHR target */
  19.124 +#endif
  19.125 +
  19.126 +#ifndef EGL_KHR_image_base
  19.127 +#define EGL_KHR_image_base 1
  19.128 +/* Most interfaces defined by EGL_KHR_image_pixmap above */
  19.129 +#define EGL_IMAGE_PRESERVED_KHR			0x30D2	/* eglCreateImageKHR attribute */
  19.130 +#endif
  19.131 +
  19.132 +#ifndef EGL_KHR_image_pixmap
  19.133 +#define EGL_KHR_image_pixmap 1
  19.134 +/* Interfaces defined by EGL_KHR_image above */
  19.135 +#endif
  19.136 +
  19.137 +
  19.138 +#ifndef EGL_ANDROID_image_native_buffer
  19.139 +#define EGL_ANDROID_image_native_buffer 1
  19.140 +struct android_native_buffer_t;
  19.141 +#define EGL_NATIVE_BUFFER_ANDROID       0x3140  /* eglCreateImageKHR target */
  19.142 +#endif
  19.143 +
  19.144 +#ifndef EGL_ANDROID_get_render_buffer
  19.145 +#define EGL_ANDROID_get_render_buffer 1
  19.146 +#ifdef EGL_EGLEXT_PROTOTYPES
  19.147 +EGLAPI EGLClientBuffer EGLAPIENTRY eglGetRenderBufferANDROID(EGLDisplay dpy, EGLSurface draw);
  19.148 +#endif
  19.149 +typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETRENDERBUFFERANDROIDPROC) (EGLDisplay dpy, EGLSurface draw);
  19.150 +#endif
  19.151 +
  19.152 +#ifndef EGL_ANDROID_swap_rectangle
  19.153 +#define EGL_ANDROID_swap_rectangle 1
  19.154 +#ifdef EGL_EGLEXT_PROTOTYPES
  19.155 +EGLAPI EGLBoolean EGLAPIENTRY eglSetSwapRectangleANDROID (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
  19.156 +#endif /* EGL_EGLEXT_PROTOTYPES */
  19.157 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSWAPRECTANGLEANDROIDPROC) (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
  19.158 +#endif
  19.159 +
  19.160 +
  19.161 +#ifdef __cplusplus
  19.162 +}
  19.163 +#endif
  19.164 +
  19.165 +#endif
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/video/android/eglplatform.h	Thu Jun 10 18:54:23 2010 +1200
    20.3 @@ -0,0 +1,118 @@
    20.4 +#ifndef __eglplatform_h_
    20.5 +#define __eglplatform_h_
    20.6 +
    20.7 +/*
    20.8 +** Copyright (c) 2007-2009 The Khronos Group Inc.
    20.9 +**
   20.10 +** Permission is hereby granted, free of charge, to any person obtaining a
   20.11 +** copy of this software and/or associated documentation files (the
   20.12 +** "Materials"), to deal in the Materials without restriction, including
   20.13 +** without limitation the rights to use, copy, modify, merge, publish,
   20.14 +** distribute, sublicense, and/or sell copies of the Materials, and to
   20.15 +** permit persons to whom the Materials are furnished to do so, subject to
   20.16 +** the following conditions:
   20.17 +**
   20.18 +** The above copyright notice and this permission notice shall be included
   20.19 +** in all copies or substantial portions of the Materials.
   20.20 +**
   20.21 +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   20.22 +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   20.23 +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   20.24 +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   20.25 +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   20.26 +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   20.27 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
   20.28 +*/
   20.29 +
   20.30 +/* Platform-specific types and definitions for egl.h
   20.31 + * $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $
   20.32 + *
   20.33 + * Adopters may modify khrplatform.h and this file to suit their platform.
   20.34 + * You are encouraged to submit all modifications to the Khronos group so that
   20.35 + * they can be included in future versions of this file.  Please submit changes
   20.36 + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
   20.37 + * by filing a bug against product "EGL" component "Registry".
   20.38 + */
   20.39 +
   20.40 +#include <KHR/khrplatform.h>
   20.41 +
   20.42 +/* Macros used in EGL function prototype declarations.
   20.43 + *
   20.44 + * EGL functions should be prototyped as:
   20.45 + *
   20.46 + * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
   20.47 + * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
   20.48 + *
   20.49 + * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
   20.50 + */
   20.51 +
   20.52 +#ifndef EGLAPI
   20.53 +#define EGLAPI KHRONOS_APICALL
   20.54 +#endif
   20.55 +
   20.56 +#define EGLAPIENTRY  KHRONOS_APIENTRY
   20.57 +#define EGLAPIENTRYP KHRONOS_APIENTRY*
   20.58 +
   20.59 +/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
   20.60 + * are aliases of window-system-dependent types, such as X Display * or
   20.61 + * Windows Device Context. They must be defined in platform-specific
   20.62 + * code below. The EGL-prefixed versions of Native*Type are the same
   20.63 + * types, renamed in EGL 1.3 so all types in the API start with "EGL".
   20.64 + */
   20.65 +
   20.66 +#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
   20.67 +#ifndef WIN32_LEAN_AND_MEAN
   20.68 +#define WIN32_LEAN_AND_MEAN 1
   20.69 +#endif
   20.70 +#include <windows.h>
   20.71 +
   20.72 +typedef HDC     EGLNativeDisplayType;
   20.73 +typedef HBITMAP EGLNativePixmapType;
   20.74 +typedef HWND    EGLNativeWindowType;
   20.75 +
   20.76 +#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
   20.77 +
   20.78 +typedef int   EGLNativeDisplayType;
   20.79 +typedef void *EGLNativeWindowType;
   20.80 +typedef void *EGLNativePixmapType;
   20.81 +
   20.82 +#elif defined(__unix__) && !defined(ANDROID)
   20.83 +
   20.84 +/* X11 (tentative)  */
   20.85 +#include <X11/Xlib.h>
   20.86 +#include <X11/Xutil.h>
   20.87 +
   20.88 +typedef Display *EGLNativeDisplayType;
   20.89 +typedef Pixmap   EGLNativePixmapType;
   20.90 +typedef Window   EGLNativeWindowType;
   20.91 +
   20.92 +
   20.93 +#elif defined(ANDROID)
   20.94 +
   20.95 +struct android_native_window_t;
   20.96 +struct egl_native_pixmap_t;
   20.97 +
   20.98 +typedef struct android_native_window_t* EGLNativeWindowType;
   20.99 +typedef struct egl_native_pixmap_t*     EGLNativePixmapType;
  20.100 +typedef void*                           EGLNativeDisplayType;
  20.101 +
  20.102 +#else
  20.103 +#error "Platform not recognized"
  20.104 +#endif
  20.105 +
  20.106 +/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
  20.107 +typedef EGLNativeDisplayType NativeDisplayType;
  20.108 +typedef EGLNativePixmapType  NativePixmapType;
  20.109 +typedef EGLNativeWindowType  NativeWindowType;
  20.110 +
  20.111 +
  20.112 +/* Define EGLint. This must be a signed integral type large enough to contain
  20.113 + * all legal attribute names and values passed into and out of EGL, whether
  20.114 + * their type is boolean, bitmask, enumerant (symbolic constant), integer,
  20.115 + * handle, or other.  While in general a 32-bit integer will suffice, if
  20.116 + * handles are 64 bit types, then EGLint should be defined as a signed 64-bit
  20.117 + * integer type.
  20.118 + */
  20.119 +typedef khronos_int32_t EGLint;
  20.120 +
  20.121 +#endif /* __eglplatform_h */